mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-19 14:46:58 +08:00
eliminate temporary storage when using netif addresses for ip_addr_t* now that they have the correct type (ATTENTION: ip6_select_source_address() and ip4_netif_get_local_ip() now return ip_addr_t*!)
This commit is contained in:
@@ -263,9 +263,9 @@ extern struct ip_globals ip_data;
|
||||
((isipv6) ? \
|
||||
ip6_route(ip_2_ip6_c(src), ip_2_ip6_c(dest)) : \
|
||||
ip4_route_src(ip_2_ip4_c(dest), ip_2_ip4_c(src)))
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest, storage) ((isipv6) ? \
|
||||
ip6_2_ip(ip6_netif_get_local_ip(netif, ip_2_ip6_c(dest)), storage) : \
|
||||
ip4_2_ip(ip4_netif_get_local_ip(netif), storage))
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest) ((isipv6) ? \
|
||||
ip6_netif_get_local_ip(netif, ip_2_ip6_c(dest)) : \
|
||||
ip4_netif_get_local_ip(netif))
|
||||
#define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p))
|
||||
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#define ip_output(isipv6, p, src, dest, ttl, tos, proto) \
|
||||
@@ -278,7 +278,7 @@ extern struct ip_globals ip_data;
|
||||
ip4_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_route(isipv6, src, dest) \
|
||||
ip4_route_src(dest, src)
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest, storage) \
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest) \
|
||||
ip4_netif_get_local_ip(netif)
|
||||
#define ip_debug_print(is_ipv6, p) ip4_debug_print(p)
|
||||
#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
@@ -292,14 +292,14 @@ extern struct ip_globals ip_data;
|
||||
ip6_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_route(isipv6, src, dest) \
|
||||
ip6_route(src, dest)
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest, storage) \
|
||||
#define ip_netif_get_local_ip(isipv6, netif, dest) \
|
||||
ip6_netif_get_local_ip(netif, dest)
|
||||
#define ip_debug_print(is_ipv6, p) ip6_debug_print(p)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#define ip_route_get_local_ip(isipv6, src, dest, netif, ipaddr, storage) do { \
|
||||
#define ip_route_get_local_ip(isipv6, src, dest, netif, ipaddr) do { \
|
||||
(netif) = ip_route(isipv6, src, dest); \
|
||||
(ipaddr) = ip_netif_get_local_ip(isipv6, netif, dest, storage); \
|
||||
(ipaddr) = ip_netif_get_local_ip(isipv6, netif, dest); \
|
||||
}while(0)
|
||||
|
||||
err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
@@ -143,7 +143,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
|
||||
void ip4_set_default_multicast_netif(struct netif* default_multicast_netif);
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
#define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? netif_ip4_addr(netif) : NULL)
|
||||
#define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? &((netif)->ip_addr) : NULL)
|
||||
|
||||
#if IP_DEBUG
|
||||
void ip4_debug_print(struct pbuf *p);
|
||||
|
||||
@@ -162,7 +162,7 @@ PACK_STRUCT_END
|
||||
|
||||
|
||||
struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest);
|
||||
const ip6_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest);
|
||||
const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest);
|
||||
err_t ip6_input(struct pbuf *p, struct netif *inp);
|
||||
err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
u8_t hl, u8_t tc, u8_t nexth);
|
||||
|
||||
@@ -68,10 +68,6 @@ typedef struct _ip_addr {
|
||||
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (PCB_ISIPV6(pcb) == IP_IS_V6(ipaddr))
|
||||
|
||||
/* Convert ipv4/ipv6 address to generic ip address.
|
||||
Since source types do not contain the type field, a target storage need to be supplied. */
|
||||
ip_addr_t* ip4_2_ip(const ip4_addr_t *ip4addr, ip_addr_t* storage);
|
||||
ip_addr_t* ip6_2_ip(const ip6_addr_t *ip6addr, ip_addr_t* storage);
|
||||
/* Convert generic ip address to specific protocol version */
|
||||
#define ip_2_ip6(ipaddr) (&((ipaddr)->u_addr.ip6))
|
||||
#define ip_2_ip6_c(ipaddr) ip_2_ip6(ipaddr)
|
||||
@@ -166,7 +162,6 @@ typedef ip4_addr_t ip_addr_t;
|
||||
#define IP_IS_V6(ipaddr) 0
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
#define ip4_2_ip(ipaddr, unused) (ipaddr)
|
||||
#define ip_2_ip4(ipaddr) (ipaddr)
|
||||
#define ip_2_ip4_c(ipaddr) (ipaddr)
|
||||
#define IP_ADDR4(ipaddr,a,b,c,d) IP4_ADDR(ipaddr,a,b,c,d)
|
||||
@@ -205,7 +200,6 @@ typedef ip6_addr_t ip_addr_t;
|
||||
#define IP_IS_V6(ipaddr) 1
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
#define ip6_2_ip(ipaddr, unused) (ipaddr)
|
||||
#define ip_2_ip6(ipaddr) (ipaddr)
|
||||
#define ip_2_ip6_c(ipaddr) (ipaddr)
|
||||
#define IP_ADDR6(ipaddr,i0,i1,i2,i3) IP6_ADDR(ipaddr,i0,i1,i2,i3)
|
||||
|
||||
@@ -398,6 +398,7 @@ void netif_poll_all(void);
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
||||
#define netif_ip6_addr(netif, i) (ip_2_ip6_c(&((netif)->ip6_addr[i])))
|
||||
#define netif_ip6_addr_set(netif, i, addr6) do { ip6_addr_set(ip_2_ip6(&((netif)->ip6_addr[i])), addr6); IP_SET_TYPE_VAL((netif)->ip6_addr[i], IPADDR_TYPE_V6); } while(0)
|
||||
#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i])
|
||||
|
||||
Reference in New Issue
Block a user