48 #include "lwip/icmp.h" 63 #ifndef LWIP_INLINE_IP_CHKSUM 64 #define LWIP_INLINE_IP_CHKSUM 1 66 #if LWIP_INLINE_IP_CHKSUM && CHECKSUM_GEN_IP 67 #define CHECKSUM_GEN_IP_INLINE 1 69 #define CHECKSUM_GEN_IP_INLINE 0 72 #if LWIP_DHCP || defined(LWIP_IP_ACCEPT_UDP_PORT) 73 #define IP_ACCEPT_LINK_LAYER_ADDRESSING 1 80 #if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) 82 #define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(DHCP_CLIENT_PORT)) \ 83 || (LWIP_IP_ACCEPT_UDP_PORT(port))) 84 #elif defined(LWIP_IP_ACCEPT_UDP_PORT) 86 #define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port)) 89 #define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(DHCP_CLIENT_PORT)) 93 #define IP_ACCEPT_LINK_LAYER_ADDRESSING 0 128 #ifdef LWIP_HOOK_IP4_ROUTE 166 ip_canforward(
struct pbuf *
p)
208 if (!ip_canforward(
p)) {
229 #if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF 267 PERF_STOP(
"ip_forward");
311 #if IP_ACCEPT_LINK_LAYER_ADDRESSING 319 iphdr = (
struct ip_hdr *)
p->payload;
330 #ifdef LWIP_HOOK_IP4_INPUT 331 if (LWIP_HOOK_IP4_INPUT(
p, inp)) {
338 iphdr_hlen =
IPH_HL(iphdr);
345 if ((iphdr_hlen >
p->len) || (iphdr_len >
p->tot_len)) {
346 if (iphdr_hlen >
p->len) {
348 (
"IP header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n",
349 iphdr_hlen,
p->len));
351 if (iphdr_len >
p->tot_len) {
353 (
"IP (len %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n",
354 iphdr_len,
p->tot_len));
365 #if CHECKSUM_CHECK_IP 369 (
"Checksum (0x%"X16_F") failed, IP packet dropped.\n",
inet_chksum(iphdr, iphdr_hlen)));
445 #if IP_ACCEPT_LINK_LAYER_ADDRESSING 458 struct udp_hdr *
udphdr = (
struct udp_hdr *)((
u8_t *)iphdr + iphdr_hlen);
461 if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(
udphdr->dest)) {
471 #if IP_ACCEPT_LINK_LAYER_ADDRESSING 517 iphdr = (
struct ip_hdr *)
p->payload;
530 #if IP_OPTIONS_ALLOWED == 0 558 if (raw_input(
p, inp) == 0)
662 #if CHECKSUM_GEN_IP_INLINE 676 u16_t optlen_aligned = 0;
678 #if CHECKSUM_GEN_IP_INLINE 682 optlen_aligned = ((optlen + 3) & ~3);
683 ip_hlen += optlen_aligned;
691 MEMCPY(
p->payload, ip_options, optlen);
692 if (optlen < optlen_aligned) {
694 memset(((
char*)
p->payload) + optlen, 0, optlen_aligned - optlen);
696 #if CHECKSUM_GEN_IP_INLINE 697 for (
i = 0;
i < optlen_aligned/2;
i++) {
698 chk_sum += ((
u16_t*)
p->payload)[
i];
712 iphdr = (
struct ip_hdr *)
p->payload;
713 LWIP_ASSERT(
"check that first pbuf can hold struct ip_hdr",
714 (
p->len >=
sizeof(
struct ip_hdr)));
718 #if CHECKSUM_GEN_IP_INLINE 724 #if CHECKSUM_GEN_IP_INLINE 731 #if CHECKSUM_GEN_IP_INLINE 735 #if CHECKSUM_GEN_IP_INLINE 736 chk_sum += iphdr->_len;
740 #if CHECKSUM_GEN_IP_INLINE 741 chk_sum += iphdr->_id;
752 #if CHECKSUM_GEN_IP_INLINE 755 chk_sum = (chk_sum >> 16) + (chk_sum & 0xFFFF);
756 chk_sum = (chk_sum >> 16) + chk_sum;
758 iphdr->_chksum = chk_sum;
767 iphdr = (
struct ip_hdr *)
p->payload;
837 #if LWIP_NETIF_HWADDRHINT #define ip_addr_islinklocal(addr1)
struct netif * netif_list
#define ip_addr_copy(dest, src)
#define snmp_inc_ipinunknownprotos()
struct netif * netif_default
const struct ip_hdr * current_header
#define IPH_TOS_SET(hdr, tos)
#define IPH_TTL_SET(hdr, ttl)
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
void pbuf_realloc(struct pbuf *p, u16_t new_len)
err_t ip_input(struct pbuf *p, struct netif *inp)
#define snmp_inc_ipoutnoroutes()
#define ip4_addr1_16(ipaddr)
#define snmp_inc_ipoutdiscards()
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
#define PBUF_FLAG_LLBCAST
#define IP_EXPERIMENTAL(a)
#define LWIP_ASSERT(message, assertion)
#define IPH_VHL_SET(hdr, v, hl)
struct netif * ip_route(ip_addr_t *dest)
ip_addr_t current_iphdr_dest
#define ip_addr_isbroadcast(ipaddr, netif)
#define snmp_inc_ipindiscards()
#define PBUF_FLAG_MCASTLOOP
#define snmp_inc_ipinreceives()
u8_t pbuf_free(struct pbuf *p)
#define LWIP_DEBUGF(debug, message)
err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif)
#define snmp_inc_ipindelivers()
#define snmp_inc_ipoutrequests()
#define ip4_addr2_16(ipaddr)
u16_t inet_chksum(void *dataptr, u16_t len)
#define snmp_inc_ipinhdrerrors()
#define NETIF_SET_HWADDRHINT(netif, hint)
#define ip_addr_ismulticast(addr1)
#define MEMCPY(DST, SRC, BYTES)
#define LWIP_DBG_LEVEL_WARNING
#define ip4_addr3_16(ipaddr)
GLenum const GLvoid * addr
#define PBUF_FLAG_LLMCAST
#define snmp_inc_ipinaddrerrors()
err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto)
#define ip4_addr4_16(ipaddr)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define IPH_OFFSET_SET(hdr, off)
#define IPH_ID_SET(hdr, id)
#define ip_addr_isany(addr1)
#define LWIP_DBG_LEVEL_SERIOUS
#define ip_addr_cmp(addr1, addr2)
ip_addr_t current_iphdr_src
struct netif * current_netif
#define IPH_CHKSUM_SET(hdr, chksum)
#define ip_debug_print(p)
#define netif_is_up(netif)
#define IPH_PROTO_SET(hdr, proto)
static void ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
#define LWIP_MAKE_U16(a, b)
#define ip_current_dest_addr()
#define ip_addr_netcmp(addr1, addr2, mask)
#define IPH_LEN_SET(hdr, len)
#define ip4_addr_get_u32(src_ipaddr)
#define snmp_inc_ipforwdatagrams()
#define ip_addr_set_any(ipaddr)