mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-30 12:32:37 +00:00
patch #6888: Patch for UDP Netbufs to support dest-addr and dest-port
This commit is contained in:
parent
9e5cf1cf8e
commit
a9cbdc141b
@ -19,6 +19,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2009-10-07 Simon Goldschmidt/Fabian Koch
|
||||||
|
* api_msg.c, netbuf.c/.h, opt.h: patch #6888: Patch for UDP Netbufs to
|
||||||
|
support dest-addr and dest-port (optional: LWIP_NETBUF_RECVINFO)
|
||||||
|
|
||||||
2009-08-26 Simon Goldschmidt/Simon Kallweit
|
2009-08-26 Simon Goldschmidt/Simon Kallweit
|
||||||
* slipif.c/.h: bug #26397: SLIP polling support
|
* slipif.c/.h: bug #26397: SLIP polling support
|
||||||
|
|
||||||
|
@ -168,6 +168,15 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
|||||||
buf->ptr = p;
|
buf->ptr = p;
|
||||||
buf->addr = addr;
|
buf->addr = addr;
|
||||||
buf->port = port;
|
buf->port = port;
|
||||||
|
#if LWIP_NETBUF_RECVINFO
|
||||||
|
{
|
||||||
|
const struct ip_hdr* iphdr = ip_current_header();
|
||||||
|
/* get the UDP header - always in the first pbuf, ensured by udp_input */
|
||||||
|
const struct udp_hdr* udphdr = (void*)(((char*)iphdr) + IPH_LEN(iphdr));
|
||||||
|
buf->toaddr = (struct ip_addr*)&iphdr->dest;
|
||||||
|
buf->toport = udphdr->dest;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys_mbox_trypost(conn->recvmbox, buf) != ERR_OK) {
|
if (sys_mbox_trypost(conn->recvmbox, buf) != ERR_OK) {
|
||||||
|
@ -62,6 +62,11 @@ netbuf *netbuf_new(void)
|
|||||||
buf->p = NULL;
|
buf->p = NULL;
|
||||||
buf->ptr = NULL;
|
buf->ptr = NULL;
|
||||||
buf->addr = NULL;
|
buf->addr = NULL;
|
||||||
|
buf->port = 0;
|
||||||
|
#if LWIP_NETBUF_RECVINFO
|
||||||
|
buf->toaddr = NULL;
|
||||||
|
buf->toport = 0;
|
||||||
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
return buf;
|
return buf;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/pbuf.h"
|
#include "lwip/pbuf.h"
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -43,6 +44,10 @@ struct netbuf {
|
|||||||
struct pbuf *p, *ptr;
|
struct pbuf *p, *ptr;
|
||||||
struct ip_addr *addr;
|
struct ip_addr *addr;
|
||||||
u16_t port;
|
u16_t port;
|
||||||
|
#if LWIP_NETBUF_RECVINFO
|
||||||
|
struct ip_addr *toaddr;
|
||||||
|
u16_t toport;
|
||||||
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Network buffer functions: */
|
/* Network buffer functions: */
|
||||||
@ -69,6 +74,10 @@ void netbuf_first (struct netbuf *buf);
|
|||||||
#define netbuf_len(buf) ((buf)->p->tot_len)
|
#define netbuf_len(buf) ((buf)->p->tot_len)
|
||||||
#define netbuf_fromaddr(buf) ((buf)->addr)
|
#define netbuf_fromaddr(buf) ((buf)->addr)
|
||||||
#define netbuf_fromport(buf) ((buf)->port)
|
#define netbuf_fromport(buf) ((buf)->port)
|
||||||
|
#if LWIP_NETBUF_RECVINFO
|
||||||
|
#define netbuf_destaddr(buf) ((buf)->toaddr)
|
||||||
|
#define netbuf_destport(buf) ((buf)->toport)
|
||||||
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -728,6 +728,13 @@
|
|||||||
#define UDP_TTL (IP_DEFAULT_TTL)
|
#define UDP_TTL (IP_DEFAULT_TTL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf.
|
||||||
|
*/
|
||||||
|
#ifndef LWIP_NETBUF_RECVINFO
|
||||||
|
#define LWIP_NETBUF_RECVINFO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---------------------------------
|
---------------------------------
|
||||||
---------- TCP options ----------
|
---------- TCP options ----------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user