mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-17 13:46:56 +08:00
raw: core support for IP_HDRINCL socket option
This patch adds a new RAW_FLAGS_HDRINCL flag to the raw core implementation. When this flag is set on a RAW PCB, the raw send routines expect the caller to supply an IP header for the given packet, and will use that IP header instead of prepending one to the packet themselves. This feature allows the IP_HDRINCL socket option to be implemented in higher layers with no further effort. Even thoguh that option is traditionally supported for IPv4 sockets only (e.g., see RFC 3542 Sec. 3), the RAW_FLAGS_HDRINCL flag supports both IPv4 and IPv6, as much of the lower-level infrastructure was already in place anyway.
This commit is contained in:
committed by
Dirk Ziegelmeier
parent
162cc4d343
commit
b59472cf63
@@ -243,6 +243,11 @@ extern struct ip_globals ip_data;
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output_if_src(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
|
||||
ip4_output_if_src(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
|
||||
/** Output IP packet that already includes an IP header. */
|
||||
#define ip_output_if_hdrincl(p, src, dest, netif) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output_if(p, ip_2_ip6(src), LWIP_IP_HDRINCL, 0, 0, 0, netif) : \
|
||||
ip4_output_if(p, ip_2_ip4(src), LWIP_IP_HDRINCL, 0, 0, 0, netif))
|
||||
/** Output IP packet with addr_hint */
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
@@ -277,6 +282,8 @@ err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
ip4_output_if_src(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
ip4_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_output_if_hdrincl(p, src, dest, netif) \
|
||||
ip4_output_if(p, src, LWIP_IP_HDRINCL, 0, 0, 0, netif)
|
||||
#define ip_route(src, dest) \
|
||||
ip4_route_src(dest, src)
|
||||
#define ip_netif_get_local_ip(netif, dest) \
|
||||
@@ -295,6 +302,8 @@ err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
ip6_output_if_src(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
ip6_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_output_if_hdrincl(p, src, dest, netif) \
|
||||
ip6_output_if(p, src, LWIP_IP_HDRINCL, 0, 0, 0, netif)
|
||||
#define ip_route(src, dest) \
|
||||
ip6_route(src, dest)
|
||||
#define ip_netif_get_local_ip(netif, dest) \
|
||||
|
||||
@@ -53,6 +53,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define RAW_FLAGS_CONNECTED 0x01U
|
||||
#define RAW_FLAGS_HDRINCL 0x02U
|
||||
|
||||
struct raw_pcb;
|
||||
|
||||
@@ -106,6 +107,7 @@ err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
|
||||
void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
|
||||
|
||||
#define raw_flags(pcb) ((pcb)->flags)
|
||||
#define raw_setflags(pcb,f) ((pcb)->flags = (f))
|
||||
|
||||
/* The following functions are the lower layer interface to RAW. */
|
||||
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
||||
|
||||
Reference in New Issue
Block a user