31 |
*/ |
*/ |
32 |
|
|
33 |
|
|
34 |
/*-----------------------------------------------------------------------------------*/ |
|
35 |
/* ip.c |
/* ip.c |
36 |
* |
* |
37 |
* This is the code for the IP layer for IPv6. |
* This is the code for the IP layer for IPv6. |
38 |
* |
* |
39 |
*/ |
*/ |
40 |
/*-----------------------------------------------------------------------------------*/ |
|
41 |
|
|
42 |
#include "lwip/opt.h" |
#include "lwip/opt.h" |
43 |
|
|
53 |
#include "lwip/stats.h" |
#include "lwip/stats.h" |
54 |
|
|
55 |
#include "arch/perf.h" |
#include "arch/perf.h" |
56 |
/*-----------------------------------------------------------------------------------*/ |
|
57 |
/* ip_init: |
/* ip_init: |
58 |
* |
* |
59 |
* Initializes the IP layer. |
* Initializes the IP layer. |
60 |
*/ |
*/ |
61 |
/*-----------------------------------------------------------------------------------*/ |
|
62 |
void |
void |
63 |
ip_init(void) |
ip_init(void) |
64 |
{ |
{ |
65 |
} |
} |
66 |
/*-----------------------------------------------------------------------------------*/ |
|
67 |
/* ip_route: |
/* ip_route: |
68 |
* |
* |
69 |
* Finds the appropriate network interface for a given IP address. It searches the |
* Finds the appropriate network interface for a given IP address. It searches the |
70 |
* list of network interfaces linearly. A match is found if the masked IP address of |
* list of network interfaces linearly. A match is found if the masked IP address of |
71 |
* the network interface equals the masked IP address given to the function. |
* the network interface equals the masked IP address given to the function. |
72 |
*/ |
*/ |
73 |
/*-----------------------------------------------------------------------------------*/ |
|
74 |
struct netif * |
struct netif * |
75 |
ip_route(struct ip_addr *dest) |
ip_route(struct ip_addr *dest) |
76 |
{ |
{ |
84 |
|
|
85 |
return netif_default; |
return netif_default; |
86 |
} |
} |
87 |
/*-----------------------------------------------------------------------------------*/ |
|
88 |
/* ip_forward: |
/* ip_forward: |
89 |
* |
* |
90 |
* Forwards an IP packet. It finds an appropriate route for the packet, decrements |
* Forwards an IP packet. It finds an appropriate route for the packet, decrements |
91 |
* the TTL value of the packet, adjusts the checksum and outputs the packet on the |
* the TTL value of the packet, adjusts the checksum and outputs the packet on the |
92 |
* appropriate interface. |
* appropriate interface. |
93 |
*/ |
*/ |
94 |
/*-----------------------------------------------------------------------------------*/ |
|
95 |
static void |
static void |
96 |
ip_forward(struct pbuf *p, struct ip_hdr *iphdr) |
ip_forward(struct pbuf *p, struct ip_hdr *iphdr) |
97 |
{ |
{ |
142 |
|
|
143 |
netif->output(netif, p, (struct ip_addr *)&(iphdr->dest)); |
netif->output(netif, p, (struct ip_addr *)&(iphdr->dest)); |
144 |
} |
} |
145 |
/*-----------------------------------------------------------------------------------*/ |
|
146 |
/* ip_input: |
/* ip_input: |
147 |
* |
* |
148 |
* This function is called by the network interface device driver when an IP packet is |
* This function is called by the network interface device driver when an IP packet is |
152 |
* |
* |
153 |
* Finally, the packet is sent to the upper layer protocol input function. |
* Finally, the packet is sent to the upper layer protocol input function. |
154 |
*/ |
*/ |
155 |
/*-----------------------------------------------------------------------------------*/ |
|
156 |
void |
void |
157 |
ip_input(struct pbuf *p, struct netif *inp) { |
ip_input(struct pbuf *p, struct netif *inp) { |
158 |
struct ip_hdr *iphdr; |
struct ip_hdr *iphdr; |
249 |
PERF_STOP("ip_input"); |
PERF_STOP("ip_input"); |
250 |
} |
} |
251 |
|
|
252 |
/*-----------------------------------------------------------------------------------*/ |
|
253 |
/* ip_output_if: |
/* ip_output_if: |
254 |
* |
* |
255 |
* Sends an IP packet on a network interface. This function constructs the IP header |
* Sends an IP packet on a network interface. This function constructs the IP header |
256 |
* and calculates the IP header checksum. If the source IP address is NULL, |
* and calculates the IP header checksum. If the source IP address is NULL, |
257 |
* the IP address of the outgoing network interface is filled in as source address. |
* the IP address of the outgoing network interface is filled in as source address. |
258 |
*/ |
*/ |
259 |
/*-----------------------------------------------------------------------------------*/ |
|
260 |
err_t |
err_t |
261 |
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, |
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, |
262 |
u8_t ttl, |
u8_t ttl, |
311 |
PERF_STOP("ip_output_if"); |
PERF_STOP("ip_output_if"); |
312 |
return netif->output(netif, p, dest); |
return netif->output(netif, p, dest); |
313 |
} |
} |
314 |
/*-----------------------------------------------------------------------------------*/ |
|
315 |
/* ip_output: |
/* ip_output: |
316 |
* |
* |
317 |
* Simple interface to ip_output_if. It finds the outgoing network interface and |
* Simple interface to ip_output_if. It finds the outgoing network interface and |
318 |
* calls upon ip_output_if to do the actual work. |
* calls upon ip_output_if to do the actual work. |
319 |
*/ |
*/ |
320 |
/*-----------------------------------------------------------------------------------*/ |
|
321 |
err_t |
err_t |
322 |
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, |
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, |
323 |
u8_t ttl, u8_t proto) |
u8_t ttl, u8_t proto) |
333 |
|
|
334 |
return ip_output_if (p, src, dest, ttl, proto, netif); |
return ip_output_if (p, src, dest, ttl, proto, netif); |
335 |
} |
} |
336 |
/*-----------------------------------------------------------------------------------*/ |
|
337 |
#if IP_DEBUG |
#if IP_DEBUG |
338 |
void |
void |
339 |
ip_debug_print(struct pbuf *p) |
ip_debug_print(struct pbuf *p) |
383 |
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); |
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); |
384 |
} |
} |
385 |
#endif /* IP_DEBUG */ |
#endif /* IP_DEBUG */ |
386 |
/*-----------------------------------------------------------------------------------*/ |
|