77 |
struct netif *netif; |
struct netif *netif; |
78 |
|
|
79 |
for(netif = netif_list; netif != NULL; netif = netif->next) { |
for(netif = netif_list; netif != NULL; netif = netif->next) { |
80 |
if(ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) { |
if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) { |
81 |
return netif; |
return netif; |
82 |
} |
} |
83 |
} |
} |
99 |
|
|
100 |
PERF_START; |
PERF_START; |
101 |
|
|
102 |
if((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) { |
if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) { |
103 |
|
|
104 |
DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for ")); |
DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for ")); |
105 |
#if IP_DEBUG |
#if IP_DEBUG |
110 |
return; |
return; |
111 |
} |
} |
112 |
/* Decrement TTL and send ICMP if ttl == 0. */ |
/* Decrement TTL and send ICMP if ttl == 0. */ |
113 |
if(--iphdr->hoplim == 0) { |
if (--iphdr->hoplim == 0) { |
114 |
/* Don't send ICMP messages in response to ICMP messages */ |
/* Don't send ICMP messages in response to ICMP messages */ |
115 |
if(iphdr->nexthdr != IP_PROTO_ICMP) { |
if (iphdr->nexthdr != IP_PROTO_ICMP) { |
116 |
icmp_time_exceeded(p, ICMP_TE_TTL); |
icmp_time_exceeded(p, ICMP_TE_TTL); |
117 |
} |
} |
118 |
pbuf_free(p); |
pbuf_free(p); |
174 |
iphdr = p->payload; |
iphdr = p->payload; |
175 |
|
|
176 |
|
|
177 |
if(iphdr->v != 6) { |
if (iphdr->v != 6) { |
178 |
DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); |
DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); |
179 |
#if IP_DEBUG |
#if IP_DEBUG |
180 |
ip_debug_print(p); |
ip_debug_print(p); |
196 |
ip_addr_debug_print(&(netif->ip_addr)); |
ip_addr_debug_print(&(netif->ip_addr)); |
197 |
DEBUGF(IP_DEBUG, ("\n")); |
DEBUGF(IP_DEBUG, ("\n")); |
198 |
#endif /* IP_DEBUG */ |
#endif /* IP_DEBUG */ |
199 |
if(ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) { |
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) { |
200 |
break; |
break; |
201 |
} |
} |
202 |
} |
} |
203 |
|
|
204 |
|
|
205 |
if(netif == NULL) { |
if (netif == NULL) { |
206 |
/* packet not for us, route or discard */ |
/* packet not for us, route or discard */ |
207 |
#ifdef IP_FORWARD |
#ifdef IP_FORWARD |
208 |
ip_forward(p, iphdr); |
ip_forward(p, iphdr); |
223 |
|
|
224 |
pbuf_header(p, -IP_HLEN); |
pbuf_header(p, -IP_HLEN); |
225 |
|
|
226 |
switch(iphdr->nexthdr) { |
switch (iphdr->nexthdr) { |
227 |
case IP_PROTO_UDP: |
case IP_PROTO_UDP: |
228 |
udp_input(p); |
udp_input(p); |
229 |
break; |
break; |
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, |
263 |
u8_t proto, struct netif *netif) |
u8_t proto, struct netif *netif) |
264 |
{ |
{ |
267 |
PERF_START; |
PERF_START; |
268 |
|
|
269 |
printf("len %u tot_len %u\n", p->len, p->tot_len); |
printf("len %u tot_len %u\n", p->len, p->tot_len); |
270 |
if(pbuf_header(p, IP_HLEN)) { |
if (pbuf_header(p, IP_HLEN)) { |
271 |
DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); |
DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); |
272 |
#ifdef IP_STATS |
#ifdef IP_STATS |
273 |
++lwip_stats.ip.err; |
++lwip_stats.ip.err; |
280 |
iphdr = p->payload; |
iphdr = p->payload; |
281 |
|
|
282 |
|
|
283 |
if(dest != IP_HDRINCL) { |
if (dest != IP_HDRINCL) { |
284 |
printf("!IP_HDRLINCL\n"); |
printf("!IP_HDRLINCL\n"); |
285 |
iphdr->hoplim = ttl; |
iphdr->hoplim = ttl; |
286 |
iphdr->nexthdr = proto; |
iphdr->nexthdr = proto; |
289 |
|
|
290 |
iphdr->v = 6; |
iphdr->v = 6; |
291 |
|
|
292 |
if(ip_addr_isany(src)) { |
if (ip_addr_isany(src)) { |
293 |
ip_addr_set(&(iphdr->src), &(netif->ip_addr)); |
ip_addr_set(&(iphdr->src), &(netif->ip_addr)); |
294 |
} else { |
} else { |
295 |
ip_addr_set(&(iphdr->src), src); |
ip_addr_set(&(iphdr->src), src); |
323 |
u8_t ttl, u8_t proto) |
u8_t ttl, u8_t proto) |
324 |
{ |
{ |
325 |
struct netif *netif; |
struct netif *netif; |
326 |
if((netif = ip_route(dest)) == NULL) { |
if ((netif = ip_route(dest)) == NULL) { |
327 |
DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr)); |
DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr)); |
328 |
#ifdef IP_STATS |
#ifdef IP_STATS |
329 |
++lwip_stats.ip.rterr; |
++lwip_stats.ip.rterr; |
331 |
return ERR_RTE; |
return ERR_RTE; |
332 |
} |
} |
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 |