diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index f838c37a..1c7129c3 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -710,9 +710,7 @@ err_t ip_output_if_opt_src(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u32_t chk_sum = 0; #endif /* CHECKSUM_GEN_IP_INLINE */ - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); snmp_inc_ipoutrequests(); @@ -867,9 +865,7 @@ ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, { struct netif *netif; - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); if ((netif = ip_route(dest)) == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", @@ -907,9 +903,7 @@ ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif; err_t err; - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); if ((netif = ip_route(dest)) == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c index 1c3a95e7..854d746a 100644 --- a/src/core/ipv6/ip6.c +++ b/src/core/ipv6/ip6.c @@ -773,9 +773,7 @@ ip6_output_if_src(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, struct ip6_hdr *ip6hdr; ip6_addr_t dest_addr; - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); /* Should the IPv6 header be generated or is it already included in p? */ if (dest != IP_HDRINCL) { @@ -867,9 +865,7 @@ ip6_output(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, struct ip6_hdr *ip6hdr; ip6_addr_t src_addr, dest_addr; - /* pbufs passed to IPv6 must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); if (dest != IP_HDRINCL) { netif = ip6_route(src, dest); @@ -928,9 +924,7 @@ ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, ip6_addr_t src_addr, dest_addr; err_t err; - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); + LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); if (dest != IP_HDRINCL) { netif = ip6_route(src, dest); diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h index e3cfead5..522e98da 100644 --- a/src/include/lwip/ip.h +++ b/src/include/lwip/ip.h @@ -54,6 +54,12 @@ extern "C" { #endif /* IP_HDRINCL */ #define IP_HDRINCL NULL +/** pbufs passed to IP must have a ref-count of 1 as their payload pointer + gets altered as the packet is passed down the stack */ +#ifndef LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX +#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p) LWIP_ASSERT("p->ref == 1", (p)->ref == 1) +#endif + #if LWIP_NETIF_HWADDRHINT #define IP_PCB_ADDRHINT ;u8_t addr_hint #else