mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 23:29:25 +00:00
sockets.c, ip.h, api.h, tcp.h: declare a "struct ip_pcb" which only contains IP_PCB. Add in the netconn's "pcb" union a "struct ip_pcb *ip;" (no size change). Use this new field to access to common pcb fields (ttl, tos, so_options, etc...). Enable to access to these fields with LWIP_TCP=0.
This commit is contained in:
parent
75d4c9b446
commit
8205737fdb
@ -19,6 +19,12 @@ HISTORY
|
||||
|
||||
++ New features:
|
||||
|
||||
2007-09-08 Frédéric Bernon
|
||||
* sockets.c, ip.h, api.h, tcp.h: declare a "struct ip_pcb" which only contains
|
||||
IP_PCB. Add in the netconn's "pcb" union a "struct ip_pcb *ip;" (no size change).
|
||||
Use this new field to access to common pcb fields (ttl, tos, so_options, etc...).
|
||||
Enable to access to these fields with LWIP_TCP=0.
|
||||
|
||||
2007-09-05 Frédéric Bernon
|
||||
* udp.c, ipv4/icmp.c, ipv4/ip.c, ipv6/icmp.c, ipv6/ip6.c, ipv4/icmp.h,
|
||||
ipv6/icmp.h, opt.h: Integrate "task #7272 : LWIP_ICMP option". The new option
|
||||
|
@ -1238,7 +1238,7 @@ static void lwip_getsockopt_internal(void *arg)
|
||||
case SO_REUSEPORT:
|
||||
#endif /* SO_REUSE */
|
||||
/*case SO_USELOOPBACK: UNIMPL */
|
||||
*(int*)optval = sock->conn->pcb.tcp->so_options & optname;
|
||||
*(int*)optval = sock->conn->pcb.ip->so_options & optname;
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n",
|
||||
s, optname, (*(int*)optval?"on":"off")));
|
||||
break;
|
||||
@ -1291,12 +1291,12 @@ static void lwip_getsockopt_internal(void *arg)
|
||||
case IPPROTO_IP:
|
||||
switch (optname) {
|
||||
case IP_TTL:
|
||||
*(int*)optval = sock->conn->pcb.tcp->ttl;
|
||||
*(int*)optval = sock->conn->pcb.ip->ttl;
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n",
|
||||
s, *(int *)optval));
|
||||
break;
|
||||
case IP_TOS:
|
||||
*(int*)optval = sock->conn->pcb.tcp->tos;
|
||||
*(int*)optval = sock->conn->pcb.ip->tos;
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n",
|
||||
s, *(int *)optval));
|
||||
break;
|
||||
@ -1583,9 +1583,9 @@ static void lwip_setsockopt_internal(void *arg)
|
||||
#endif /* SO_REUSE */
|
||||
/* UNIMPL case SO_USELOOPBACK: */
|
||||
if (*(int*)optval) {
|
||||
sock->conn->pcb.tcp->so_options |= optname;
|
||||
sock->conn->pcb.ip->so_options |= optname;
|
||||
} else {
|
||||
sock->conn->pcb.tcp->so_options &= ~optname;
|
||||
sock->conn->pcb.ip->so_options &= ~optname;
|
||||
}
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n",
|
||||
s, optname, (*(int*)optval?"on":"off")));
|
||||
@ -1611,14 +1611,14 @@ static void lwip_setsockopt_internal(void *arg)
|
||||
case IPPROTO_IP:
|
||||
switch (optname) {
|
||||
case IP_TTL:
|
||||
sock->conn->pcb.tcp->ttl = (u8_t)(*(int*)optval);
|
||||
sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %u\n",
|
||||
s, sock->conn->pcb.tcp->ttl));
|
||||
s, sock->conn->pcb.ip->ttl));
|
||||
break;
|
||||
case IP_TOS:
|
||||
sock->conn->pcb.tcp->tos = (u8_t)(*(int*)optval);
|
||||
sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %u\n",
|
||||
s, sock->conn->pcb.tcp->tos));
|
||||
s, sock->conn->pcb.ip->tos));
|
||||
break;
|
||||
#if LWIP_IGMP
|
||||
case IP_MULTICAST_TTL:
|
||||
|
@ -90,6 +90,10 @@ err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
/* link layer address resolution hint */ \
|
||||
IP_PCB_ADDRHINT
|
||||
|
||||
struct ip_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
};
|
||||
|
||||
/*
|
||||
* Option flags per-socket. These are the same like SO_XXX.
|
||||
|
@ -98,6 +98,7 @@ struct netconn {
|
||||
enum netconn_type type;
|
||||
enum netconn_state state;
|
||||
union {
|
||||
struct ip_pcb *ip;
|
||||
struct tcp_pcb *tcp;
|
||||
struct udp_pcb *udp;
|
||||
struct raw_pcb *raw;
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/*#if LWIP_TCP*/ /* don't build if not configured for use in lwipopts.h */
|
||||
#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/mem.h"
|
||||
@ -592,6 +592,6 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*#endif*/ /* LWIP_TCP */
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#endif /* __LWIP_TCP_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user