From: Joan Lledó <[email protected]> Add support for `ipi_spec_dst`. Due to the limited concept of routing lwip implements. This field will always hold the interface address as value. --- debian/patches/in_pktinfo | 73 +++++++++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 74 insertions(+) create mode 100644 debian/patches/in_pktinfo
diff --git a/debian/patches/in_pktinfo b/debian/patches/in_pktinfo new file mode 100644 index 0000000..79d11a9 --- /dev/null +++ b/debian/patches/in_pktinfo @@ -0,0 +1,73 @@ +Description: Add `ipi_spec_dst` field to `struct in_pktinfo` +Author: Joan Lledó <[email protected]> +Last-Update: 2025-12-26 + +Index: lwip-deb/src/api/sockets.c +=================================================================== +--- lwip-deb.orig/src/api/sockets.c 2026-01-04 19:06:46.000000000 +0100 ++++ lwip-deb/src/api/sockets.c 2026-01-04 19:16:14.000000000 +0100 +@@ -1272,6 +1272,9 @@ + chdr->cmsg_type = IP_PKTINFO; + chdr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); + pkti->ipi_ifindex = buf->p->if_idx; ++#if LWIP_SOCKET_HAVE_IPI_SPEC_DST ++ inet_addr_from_ip4addr(&pkti->ipi_spec_dst, ip_2_ip4(netbuf_ifaddr(buf))); ++#endif /* LWIP_SOCKET_HAVE_IPI_SPEC_DST */ + inet_addr_from_ip4addr(&pkti->ipi_addr, ip_2_ip4(netbuf_destaddr(buf))); + msg->msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); + wrote_msg = 1; +Index: lwip-deb/src/include/lwip/sockets.h +=================================================================== +--- lwip-deb.orig/src/include/lwip/sockets.h 2026-01-04 19:06:46.000000000 +0100 ++++ lwip-deb/src/include/lwip/sockets.h 2026-01-04 19:14:18.000000000 +0100 +@@ -62,6 +62,9 @@ + /* sockaddr and pals include length fields */ + #define LWIP_SOCKET_HAVE_SA_LEN 1 + ++/* in_pktinfo includes routing destination address */ ++#define LWIP_SOCKET_HAVE_IPI_SPEC_DST 1 ++ + /* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED + to prevent this code from redefining it. */ + #if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED) +@@ -334,6 +337,7 @@ + #if LWIP_IPV4 + struct in_pktinfo { + unsigned int ipi_ifindex; /* Interface index */ ++ struct in_addr ipi_spec_dst; /* Destination (from routing) address */ + struct in_addr ipi_addr; /* Destination (from header) address */ + }; + #endif /* LWIP_IPV4 */ +Index: lwip-deb/src/api/api_msg.c +=================================================================== +--- lwip-deb.orig/src/api/api_msg.c 2026-01-04 19:06:46.000000000 +0100 ++++ lwip-deb/src/api/api_msg.c 2026-01-04 19:06:46.000000000 +0100 +@@ -263,6 +263,7 @@ + /* get the UDP header - always in the first pbuf, ensured by udp_input */ + const struct udp_hdr *udphdr = (const struct udp_hdr *)ip_next_header_ptr(); + buf->flags = NETBUF_FLAG_DESTADDR; ++ ip_addr_set(&buf->ifaddr, netif_ip_addr4(ip_current_netif())); + ip_addr_set(&buf->toaddr, ip_current_dest_addr()); + buf->toport_chksum = udphdr->dest; + } +Index: lwip-deb/src/include/lwip/netbuf.h +=================================================================== +--- lwip-deb.orig/src/include/lwip/netbuf.h 2026-01-04 19:06:46.000000000 +0100 ++++ lwip-deb/src/include/lwip/netbuf.h 2026-01-04 19:06:46.000000000 +0100 +@@ -65,6 +65,7 @@ + u8_t flags; + u16_t toport_chksum; + #if LWIP_NETBUF_RECVINFO ++ ip_addr_t ifaddr; + ip_addr_t toaddr; + #endif /* LWIP_NETBUF_RECVINFO */ + #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ +@@ -96,6 +97,8 @@ + #if LWIP_NETBUF_RECVINFO + #define netbuf_destaddr(buf) (&((buf)->toaddr)) + #define netbuf_set_destaddr(buf, destaddr) ip_addr_set(&((buf)->toaddr), destaddr) ++#define netbuf_ifaddr(buf) (&((buf)->ifaddr)) ++#define netbuf_set_ifaddr(buf, ifaddr) ip_addr_set(&((buf)->ifaddr), ifaddr) + #if LWIP_CHECKSUM_ON_COPY + #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) + #else /* LWIP_CHECKSUM_ON_COPY */ diff --git a/debian/patches/series b/debian/patches/series index d3b8ef5..196d4b7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ empty_block_last max_sockets doxygen doxygen2 +in_pktinfo -- 2.50.1
