ReactOS  0.4.14-dev-1233-gf5658fd
ip.h File Reference
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/netif.h"
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ip_hdr
 

Macros

#define IP_HLEN   40
 
#define IP_PROTO_ICMP   58
 
#define IP_PROTO_UDP   17
 
#define IP_PROTO_UDPLITE   136
 
#define IP_PROTO_TCP   6
 
#define IP_HDRINCL   NULL
 
#define IP_PCB_ADDRHINT
 
#define IP_PCB
 
#define IPH_PROTO(hdr)   (iphdr->nexthdr)
 
#define ip_current_netif()   NULL
 
#define ip_current_header()   NULL
 

Functions

void ip_init (void)
 
struct netifip_route (struct ip_addr *dest)
 
void ip_input (struct pbuf *p, struct netif *inp)
 
err_t ip_output (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto)
 
err_t ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif)
 

Macro Definition Documentation

◆ ip_current_header

#define ip_current_header ( )    NULL

Definition at line 118 of file ip.h.

◆ ip_current_netif

#define ip_current_netif ( )    NULL

Definition at line 117 of file ip.h.

◆ IP_HDRINCL

#define IP_HDRINCL   NULL

Definition at line 59 of file ip.h.

◆ IP_HLEN

#define IP_HLEN   40

Definition at line 46 of file ip.h.

◆ IP_PCB

#define IP_PCB
Value:
struct ip_addr local_ip; \
struct ip_addr remote_ip; \
/* Socket options */ \
u16_t so_options; \
/* Type Of Service */ \
u8_t tos; \
/* Time To Live */ \
u8_t ttl; \
/* link layer address resolution hint */ \
IP_PCB_ADDRHINT

Definition at line 71 of file ip.h.

◆ IP_PCB_ADDRHINT

#define IP_PCB_ADDRHINT

Definition at line 64 of file ip.h.

◆ IP_PROTO_ICMP

#define IP_PROTO_ICMP   58

Definition at line 48 of file ip.h.

◆ IP_PROTO_TCP

#define IP_PROTO_TCP   6

Definition at line 51 of file ip.h.

◆ IP_PROTO_UDP

#define IP_PROTO_UDP   17

Definition at line 49 of file ip.h.

◆ IP_PROTO_UDPLITE

#define IP_PROTO_UDPLITE   136

Definition at line 50 of file ip.h.

◆ IPH_PROTO

#define IPH_PROTO (   hdr)    (iphdr->nexthdr)

Definition at line 99 of file ip.h.

Function Documentation

◆ ip_init()

void ip_init ( void  )

Definition at line 63 of file ip6.c.

64 {
65 }

◆ ip_input()

void ip_input ( struct pbuf p,
struct netif inp 
)

This function is called by the network interface device driver when an IP packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip_forward). The IP checksum is always checked.

Finally, the packet is sent to the upper layer protocol input function.

Parameters
pthe received IP packet (p->payload points to IP header)
inpthe netif on which this packet was received
Returns
ERR_OK if the packet was processed (could return ERR_* if it wasn't processed, but currently always returns ERR_OK)

Definition at line 305 of file ip.c.

306 {
307  struct ip_hdr *iphdr;
308  struct netif *netif;
309  u16_t iphdr_hlen;
310  u16_t iphdr_len;
311 #if IP_ACCEPT_LINK_LAYER_ADDRESSING
312  int check_ip_src=1;
313 #endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
314 
315  IP_STATS_INC(ip.recv);
317 
318  /* identify the IP header */
319  iphdr = (struct ip_hdr *)p->payload;
320  if (IPH_V(iphdr) != 4) {
321  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr)));
322  ip_debug_print(p);
323  pbuf_free(p);
324  IP_STATS_INC(ip.err);
325  IP_STATS_INC(ip.drop);
327  return ERR_OK;
328  }
329 
330 #ifdef LWIP_HOOK_IP4_INPUT
331  if (LWIP_HOOK_IP4_INPUT(p, inp)) {
332  /* the packet has been eaten */
333  return ERR_OK;
334  }
335 #endif
336 
337  /* obtain IP header length in number of 32-bit words */
338  iphdr_hlen = IPH_HL(iphdr);
339  /* calculate IP header length in bytes */
340  iphdr_hlen *= 4;
341  /* obtain ip length in bytes */
342  iphdr_len = ntohs(IPH_LEN(iphdr));
343 
344  /* header length exceeds first pbuf length, or ip length exceeds total pbuf length? */
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));
350  }
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));
355  }
356  /* free (drop) packet pbufs */
357  pbuf_free(p);
358  IP_STATS_INC(ip.lenerr);
359  IP_STATS_INC(ip.drop);
361  return ERR_OK;
362  }
363 
364  /* verify checksum */
365 #if CHECKSUM_CHECK_IP
366  if (inet_chksum(iphdr, iphdr_hlen) != 0) {
367 
369  ("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen)));
370  ip_debug_print(p);
371  pbuf_free(p);
372  IP_STATS_INC(ip.chkerr);
373  IP_STATS_INC(ip.drop);
375  return ERR_OK;
376  }
377 #endif
378 
379  /* Trim pbuf. This should have been done at the netif layer,
380  * but we'll do it anyway just to be sure that its done. */
381  pbuf_realloc(p, iphdr_len);
382 
383  /* copy IP addresses to aligned ip_addr_t */
385  ip_addr_copy(current_iphdr_src, iphdr->src);
386 
387  /* match packet against an interface, i.e. is this packet for us? */
388 #if LWIP_IGMP
390  if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, &current_iphdr_dest))) {
391  netif = inp;
392  } else {
393  netif = NULL;
394  }
395  } else
396 #endif /* LWIP_IGMP */
397  {
398  /* start trying with inp. if that's not acceptable, start walking the
399  list of configured netifs.
400  'first' is used as a boolean to mark whether we started walking the list */
401  int first = 1;
402  netif = inp;
403  do {
404  LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n",
409 
410  /* interface is up and configured? */
411  if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) {
412  /* unicast to this interface address? */
414  /* or broadcast on this interface network address? */
416  LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
417  netif->name[0], netif->name[1]));
418  /* break out of for loop */
419  break;
420  }
421 #if LWIP_AUTOIP
422  /* connections to link-local addresses must persist after changing
423  the netif's address (RFC3927 ch. 1.9) */
424  if ((netif->autoip != NULL) &&
425  ip_addr_cmp(&current_iphdr_dest, &(netif->autoip->llipaddr))) {
426  LWIP_DEBUGF(IP_DEBUG, ("ip_input: LLA packet accepted on interface %c%c\n",
427  netif->name[0], netif->name[1]));
428  /* break out of for loop */
429  break;
430  }
431 #endif /* LWIP_AUTOIP */
432  }
433  if (first) {
434  first = 0;
435  netif = netif_list;
436  } else {
437  netif = netif->next;
438  }
439  if (netif == inp) {
440  netif = netif->next;
441  }
442  } while(netif != NULL);
443  }
444 
445 #if IP_ACCEPT_LINK_LAYER_ADDRESSING
446  /* Pass DHCP messages regardless of destination address. DHCP traffic is addressed
447  * using link layer addressing (such as Ethernet MAC) so we must not filter on IP.
448  * According to RFC 1542 section 3.1.1, referred by RFC 2131).
449  *
450  * If you want to accept private broadcast communication while a netif is down,
451  * define LWIP_IP_ACCEPT_UDP_PORT(dst_port), e.g.:
452  *
453  * #define LWIP_IP_ACCEPT_UDP_PORT(dst_port) ((dst_port) == PP_NTOHS(12345))
454  */
455  if (netif == NULL) {
456  /* remote port is DHCP server? */
457  if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
458  struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen);
459  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: UDP packet to DHCP client port %"U16_F"\n",
460  ntohs(udphdr->dest)));
461  if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(udphdr->dest)) {
462  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: DHCP packet accepted.\n"));
463  netif = inp;
464  check_ip_src = 0;
465  }
466  }
467  }
468 #endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
469 
470  /* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */
471 #if IP_ACCEPT_LINK_LAYER_ADDRESSING
472  /* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */
473  if (check_ip_src && !ip_addr_isany(&current_iphdr_src))
474 #endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
475  { if ((ip_addr_isbroadcast(&current_iphdr_src, inp)) ||
477  /* packet source is not valid */
478  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n"));
479  /* free (drop) packet pbufs */
480  pbuf_free(p);
481  IP_STATS_INC(ip.drop);
484  return ERR_OK;
485  }
486  }
487 
488  /* packet not for us? */
489  if (netif == NULL) {
490  /* packet not for us, route or discard */
491  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: packet not for us.\n"));
492 #if IP_FORWARD
493  /* non-broadcast packet? */
495  /* try to forward IP packet on (other) interfaces */
496  ip_forward(p, iphdr, inp);
497  } else
498 #endif /* IP_FORWARD */
499  {
502  }
503  pbuf_free(p);
504  return ERR_OK;
505  }
506  /* packet consists of multiple fragments? */
507  if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) {
508 #if IP_REASSEMBLY /* packet fragment reassembly code present? */
509  LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n",
510  ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8));
511  /* reassemble the packet*/
512  p = ip_reass(p);
513  /* packet not fully reassembled yet? */
514  if (p == NULL) {
515  return ERR_OK;
516  }
517  iphdr = (struct ip_hdr *)p->payload;
518 #else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */
519  pbuf_free(p);
520  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n",
521  ntohs(IPH_OFFSET(iphdr))));
522  IP_STATS_INC(ip.opterr);
523  IP_STATS_INC(ip.drop);
524  /* unsupported protocol feature */
526  return ERR_OK;
527 #endif /* IP_REASSEMBLY */
528  }
529 
530 #if IP_OPTIONS_ALLOWED == 0 /* no support for IP options in the IP header? */
531 
532 #if LWIP_IGMP
533  /* there is an extra "router alert" option in IGMP messages which we allow for but do not police */
534  if((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) {
535 #else
536  if (iphdr_hlen > IP_HLEN) {
537 #endif /* LWIP_IGMP */
538  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since there were IP options (while IP_OPTIONS_ALLOWED == 0).\n"));
539  pbuf_free(p);
540  IP_STATS_INC(ip.opterr);
541  IP_STATS_INC(ip.drop);
542  /* unsupported protocol feature */
544  return ERR_OK;
545  }
546 #endif /* IP_OPTIONS_ALLOWED == 0 */
547 
548  /* send to upper layers */
549  LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n"));
550  ip_debug_print(p);
551  LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len));
552 
553  current_netif = inp;
554  current_header = iphdr;
555 
556 #if LWIP_RAW
557  /* raw input did not eat the packet? */
558  if (raw_input(p, inp) == 0)
559 #endif /* LWIP_RAW */
560  {
561  switch (IPH_PROTO(iphdr)) {
562 #if LWIP_UDP
563  case IP_PROTO_UDP:
564 #if LWIP_UDPLITE
565  case IP_PROTO_UDPLITE:
566 #endif /* LWIP_UDPLITE */
568  udp_input(p, inp);
569  break;
570 #endif /* LWIP_UDP */
571 #if LWIP_TCP
572  case IP_PROTO_TCP:
574  tcp_input(p, inp);
575  break;
576 #endif /* LWIP_TCP */
577 #if LWIP_ICMP
578  case IP_PROTO_ICMP:
580  icmp_input(p, inp);
581  break;
582 #endif /* LWIP_ICMP */
583 #if LWIP_IGMP
584  case IP_PROTO_IGMP:
585  igmp_input(p, inp, &current_iphdr_dest);
586  break;
587 #endif /* LWIP_IGMP */
588  default:
589 #if LWIP_ICMP
590  /* send ICMP destination protocol unreachable unless is was a broadcast */
593  p->payload = iphdr;
594  icmp_dest_unreach(p, ICMP_DUR_PROTO);
595  }
596 #endif /* LWIP_ICMP */
597  pbuf_free(p);
598 
599  LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));
600 
601  IP_STATS_INC(ip.proterr);
602  IP_STATS_INC(ip.drop);
604  }
605  }
606 
611 
612  return ERR_OK;
613 }
#define X32_F
Definition: cc.h:41
struct netif * netif_list
Definition: netif.c:75
#define ip_addr_copy(dest, src)
Definition: ip_addr.h:162
#define IPH_ID(hdr)
Definition: ip.h:150
#define snmp_inc_ipinunknownprotos()
Definition: snmp.h:265
#define IP_PROTO_UDPLITE
Definition: ip.h:55
#define IPH_PROTO(hdr)
Definition: ip.h:153
#define IPH_OFFSET(hdr)
Definition: ip.h:151
#define IP_PROTO_ICMP
Definition: ip.h:52
const GLint * first
Definition: glext.h:5794
const struct ip_hdr * current_header
Definition: ip.c:105
void pbuf_realloc(struct pbuf *p, u16_t new_len)
Definition: pbuf.c:430
#define ntohs(x)
Definition: module.h:208
ip_addr_t current_iphdr_dest
Definition: ip.c:109
#define IP_PROTO_IGMP
Definition: ip.h:53
#define ip_addr_isbroadcast(ipaddr, netif)
Definition: ip_addr.h:202
#define IP_DEBUG
Definition: opt.h:1961
#define IP_PROTO_TCP
Definition: ip.h:56
#define snmp_inc_ipindiscards()
Definition: snmp.h:266
smooth NULL
Definition: ftsmooth.c:416
#define snmp_inc_ipinreceives()
Definition: snmp.h:261
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:618
#define IP_HLEN
Definition: ip.h:50
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define PP_HTONS(x)
Definition: def.h:88
#define snmp_inc_ipindelivers()
Definition: snmp.h:267
u16_t inet_chksum(void *dataptr, u16_t len)
Definition: inet_chksum.c:396
Definition: dhcpd.h:79
#define U16_F
Definition: cc.h:36
#define snmp_inc_ipinhdrerrors()
Definition: snmp.h:262
#define ERR_OK
Definition: err.h:52
struct netif * next
Definition: netif.h:138
Definition: dhcpd.h:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define ip_addr_ismulticast(addr1)
Definition: ip_addr.h:208
#define IPH_V(hdr)
Definition: ip.h:146
u8_t flags
Definition: netif.h:192
#define X16_F
Definition: cc.h:38
#define IP_PROTO_UDP
Definition: ip.h:54
Definition: netif.h:136
#define NETIF_FLAG_IGMP
Definition: netif.h:95
ip_addr_t ip_addr
Definition: netif.h:141
#define LWIP_DBG_LEVEL_WARNING
Definition: debug.h:46
#define snmp_inc_ipinaddrerrors()
Definition: snmp.h:263
struct ip_addr src dest
Definition: ip.h:96
#define IP_MF
Definition: dhcpd.h:71
#define ip_addr_isany(addr1)
Definition: ip_addr.h:200
Definition: ip.h:116
#define LWIP_DBG_LEVEL_SERIOUS
Definition: debug.h:47
#define ip_addr_cmp(addr1, addr2)
Definition: ip_addr.h:198
#define IPH_HL(hdr)
Definition: ip.h:147
ip_addr_t current_iphdr_src
Definition: ip.c:107
unsigned char u8_t
Definition: cc.h:23
#define LWIP_DBG_TRACE
Definition: debug.h:57
#define IPH_LEN(hdr)
Definition: ip.h:149
struct netif * current_netif
Definition: ip.c:100
#define IP_STATS_INC(x)
Definition: stats.h:203
char name[2]
Definition: netif.h:194
ip_addr_t netmask
Definition: netif.h:142
#define ip_debug_print(p)
Definition: ip.h:214
#define netif_is_up(netif)
Definition: netif.h:282
unsigned short u16_t
Definition: cc.h:24
#define IP_OFFMASK
Definition: dhcpd.h:72
static void ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
Definition: ip6.c:96
GLfloat GLfloat p
Definition: glext.h:8902
#define ip4_addr_get_u32(src_ipaddr)
Definition: ip_addr.h:181
#define ip_addr_set_any(ipaddr)
Definition: ip_addr.h:170

Referenced by netif_init(), tcpip_input(), and tcpip_thread().

◆ ip_output()

err_t ip_output ( struct pbuf p,
struct ip_addr src,
struct ip_addr dest,
u8_t  ttl,
u8_t  proto 
)

Definition at line 317 of file ip6.c.

319 {
320  struct netif *netif;
321  if ((netif = ip_route(dest)) == NULL) {
322  LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr));
323  IP_STATS_INC(ip.rterr);
324  return ERR_RTE;
325  }
326 
327  return ip_output_if (p, src, dest, ttl, proto, netif);
328 }
#define X32_F
Definition: cc.h:41
struct netif * ip_route(struct ip_addr *dest)
Definition: ip6.c:75
#define ERR_RTE
Definition: err.h:56
#define IP_DEBUG
Definition: opt.h:1961
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif)
Definition: ip6.c:260
Definition: dhcpd.h:61
Definition: netif.h:136
GLenum src
Definition: glext.h:6340
#define IP_STATS_INC(x)
Definition: stats.h:203
static char * dest
Definition: rtl.c:135
GLfloat GLfloat p
Definition: glext.h:8902

◆ ip_output_if()

err_t ip_output_if ( struct pbuf p,
struct ip_addr src,
struct ip_addr dest,
u8_t  ttl,
u8_t  proto,
struct netif netif 
)

Definition at line 260 of file ip6.c.

263 {
264  struct ip_hdr *iphdr;
265 
266  PERF_START;
267 
268  LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len));
269  if (pbuf_header(p, IP_HLEN)) {
270  LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));
271  IP_STATS_INC(ip.err);
272 
273  return ERR_BUF;
274  }
275  LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len));
276 
277  iphdr = p->payload;
278 
279 
280  if (dest != IP_HDRINCL) {
281  LWIP_DEBUGF(IP_DEBUG, ("!IP_HDRLINCL\n"));
282  iphdr->hoplim = ttl;
283  iphdr->nexthdr = proto;
284  iphdr->len = htons(p->tot_len - IP_HLEN);
285  ip_addr_set(&(iphdr->dest), dest);
286 
287  iphdr->v = 6;
288 
289  if (ip_addr_isany(src)) {
290  ip_addr_set(&(iphdr->src), &(netif->ip_addr));
291  } else {
292  ip_addr_set(&(iphdr->src), src);
293  }
294 
295  } else {
296  dest = &(iphdr->dest);
297  }
298 
299  IP_STATS_INC(ip.xmit);
300 
301  LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %"U16_F")\n", netif->name[0], netif->name[1], p->tot_len));
302 #if IP_DEBUG
303  ip_debug_print(p);
304 #endif /* IP_DEBUG */
305 
306  PERF_STOP("ip_output_if");
307  return netif->output(netif, p, dest);
308 }
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
Definition: pbuf.c:511
netif_output_fn output
Definition: netif.h:151
#define PERF_START
Definition: perf.h:3
#define IP_DEBUG
Definition: opt.h:1961
#define IP_HDRINCL
Definition: ws2ipdef.h:28
#define IP_HLEN
Definition: ip.h:50
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
u16_t len
Definition: ip.h:93
#define U16_F
Definition: cc.h:36
Definition: dhcpd.h:61
u8_t hoplim
Definition: ip.h:95
u8_t nexthdr
Definition: ip.h:94
Definition: netif.h:136
ip_addr_t ip_addr
Definition: netif.h:141
struct ip_addr src dest
Definition: ip.h:96
GLenum src
Definition: glext.h:6340
#define ip_addr_set(dest, src)
Definition: ip_addr.h:164
#define ip_addr_isany(addr1)
Definition: ip_addr.h:200
Definition: ip.h:116
#define ERR_BUF
Definition: err.h:54
u8_t v
Definition: ip.h:86
#define IP_STATS_INC(x)
Definition: stats.h:203
char name[2]
Definition: netif.h:194
#define ip_debug_print(p)
Definition: ip.h:214
static char * dest
Definition: rtl.c:135
GLfloat GLfloat p
Definition: glext.h:8902
#define htons(x)
Definition: module.h:213

Referenced by ip_output().

◆ ip_route()

struct netif* ip_route ( struct ip_addr dest)

Definition at line 75 of file ip6.c.

76 {
77  struct netif *netif;
78 
79  for(netif = netif_list; netif != NULL; netif = netif->next) {
80  if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
81  return netif;
82  }
83  }
84 
85  return netif_default;
86 }
struct netif * netif_list
Definition: netif.c:75
struct netif * netif_default
Definition: netif.c:76
smooth NULL
Definition: ftsmooth.c:416
struct netif * next
Definition: netif.h:138
Definition: netif.h:136
ip_addr_t ip_addr
Definition: netif.h:141
ip_addr_t netmask
Definition: netif.h:142
static char * dest
Definition: rtl.c:135
#define ip_addr_netcmp(addr1, addr2, mask)
Definition: ip_addr.h:194

Referenced by ip_forward(), and ip_output().