mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 04:12:07 +00:00
Added ip_current_netif() & ip_current_header() to receive extended info about the currently received packet.
This commit is contained in:
parent
99d82c4980
commit
14dba4ae2b
@ -19,6 +19,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2009-05-05 Simon Goldschmidt, Jakob Stoklund Olesen
|
||||||
|
* ip.h, ip.c: Added ip_current_netif() & ip_current_header() to receive
|
||||||
|
extended info about the currently received packet.
|
||||||
|
|
||||||
2009-04-27 Simon Goldschmidt
|
2009-04-27 Simon Goldschmidt
|
||||||
* sys.h: Made SYS_LIGHTWEIGHT_PROT and sys_now() work with NO_SYS=1
|
* sys.h: Made SYS_LIGHTWEIGHT_PROT and sys_now() work with NO_SYS=1
|
||||||
|
|
||||||
|
@ -56,6 +56,45 @@
|
|||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "arch/perf.h"
|
#include "arch/perf.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface that provided the packet for the current callback
|
||||||
|
* invocation.
|
||||||
|
*/
|
||||||
|
static struct netif *current_netif;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header of the input packet currently being processed.
|
||||||
|
*/
|
||||||
|
static const struct ip_hdr *current_header;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the interface that received the current packet.
|
||||||
|
*
|
||||||
|
* This function must only be called from a receive callback (udp_recv,
|
||||||
|
* raw_recv, tcp_accept). It will return NULL otherwise.
|
||||||
|
*
|
||||||
|
* @param pcb Pointer to the pcb receiving a packet.
|
||||||
|
*/
|
||||||
|
struct netif *
|
||||||
|
ip_current_netif()
|
||||||
|
{
|
||||||
|
return current_netif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the IP header of the current packet.
|
||||||
|
*
|
||||||
|
* This function must only be called from a receive callback (udp_recv,
|
||||||
|
* raw_recv, tcp_accept). It will return NULL otherwise.
|
||||||
|
*
|
||||||
|
* @param pcb Pointer to the pcb receiving a packet.
|
||||||
|
*/
|
||||||
|
const struct ip_hdr *
|
||||||
|
ip_current_header()
|
||||||
|
{
|
||||||
|
return current_header;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the appropriate network interface for a given IP address. It
|
* Finds the appropriate network interface for a given IP address. It
|
||||||
* searches the list of network interfaces linearly. A match is found
|
* searches the list of network interfaces linearly. A match is found
|
||||||
@ -388,6 +427,9 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||||||
ip_debug_print(p);
|
ip_debug_print(p);
|
||||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len));
|
LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len));
|
||||||
|
|
||||||
|
current_netif = inp;
|
||||||
|
current_header = iphdr;
|
||||||
|
|
||||||
#if LWIP_RAW
|
#if LWIP_RAW
|
||||||
/* raw input did not eat the packet? */
|
/* raw input did not eat the packet? */
|
||||||
if (raw_input(p, inp) == 0)
|
if (raw_input(p, inp) == 0)
|
||||||
@ -440,6 +482,9 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_netif = NULL;
|
||||||
|
current_header = NULL;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
|||||||
err_t ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
err_t ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
|
u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
|
||||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||||
|
struct netif *ip_current_netif();
|
||||||
|
const struct ip_hdr *ip_current_header();
|
||||||
|
|
||||||
#define IP_HLEN 20
|
#define IP_HLEN 20
|
||||||
|
|
||||||
|
@ -114,6 +114,9 @@ err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
|||||||
u8_t ttl, u8_t proto,
|
u8_t ttl, u8_t proto,
|
||||||
struct netif *netif);
|
struct netif *netif);
|
||||||
|
|
||||||
|
#define ip_current_netif() NULL
|
||||||
|
#define ip_current_header() NULL
|
||||||
|
|
||||||
#if IP_DEBUG
|
#if IP_DEBUG
|
||||||
void ip_debug_print(struct pbuf *p);
|
void ip_debug_print(struct pbuf *p);
|
||||||
#endif /* IP_DEBUG */
|
#endif /* IP_DEBUG */
|
||||||
|
Loading…
Reference in New Issue
Block a user