/[lwip]/lwip/src/core/ipv4/ip.c
ViewVC logotype

Diff of /lwip/src/core/ipv4/ip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12.2.2 by likewise, Mon Feb 10 23:56:30 2003 UTC revision 1.12.2.3 by likewise, Wed Feb 19 12:27:06 2003 UTC
# Line 108  ip_lookup(void *header, struct netif *in Line 108  ip_lookup(void *header, struct netif *in
108  #if LWIP_UDP > 0  #if LWIP_UDP > 0
109    case IP_PROTO_UDP:    case IP_PROTO_UDP:
110      return udp_lookup(iphdr, inp);      return udp_lookup(iphdr, inp);
     break;  
111  #endif /* LWIP_UDP */  #endif /* LWIP_UDP */
112  #if LWIP_TCP > 0      #if LWIP_TCP > 0    
113    case IP_PROTO_TCP:    case IP_PROTO_TCP:
# Line 116  ip_lookup(void *header, struct netif *in Line 115  ip_lookup(void *header, struct netif *in
115  #endif /* LWIP_TCP */  #endif /* LWIP_TCP */
116    case IP_PROTO_ICMP:    case IP_PROTO_ICMP:
117      return 1;      return 1;
     break;  
118    default:    default:
119      return 0;      return 0;
120    }    }
# Line 198  ip_forward(struct pbuf *p, struct ip_hdr Line 196  ip_forward(struct pbuf *p, struct ip_hdr
196    }    }
197    
198    DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n",    DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n",
199                      iphdr->dest.addr));                      iphdr->dest.addr));
200    
201  #ifdef IP_STATS  #ifdef IP_STATS
202    ++lwip_stats.ip.fw;    ++lwip_stats.ip.fw;
# Line 292  ip_input(struct pbuf *p, struct netif *i Line 290  ip_input(struct pbuf *p, struct netif *i
290    for(netif = netif_list; netif != NULL; netif = netif->next) {    for(netif = netif_list; netif != NULL; netif = netif->next) {
291    
292      DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%lx netif->ip_addr 0x%lx (0x%lx, 0x%lx, 0x%lx)\n",      DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%lx netif->ip_addr 0x%lx (0x%lx, 0x%lx, 0x%lx)\n",
293                        iphdr->dest.addr, netif->ip_addr.addr,                        iphdr->dest.addr, netif->ip_addr.addr,
294                        iphdr->dest.addr & netif->netmask.addr,                        iphdr->dest.addr & netif->netmask.addr,
295                        netif->ip_addr.addr & netif->netmask.addr,                        netif->ip_addr.addr & netif->netmask.addr,
296                        iphdr->dest.addr & ~(netif->netmask.addr)));                        iphdr->dest.addr & ~(netif->netmask.addr)));
297    
298      /* interface configured? */      /* interface configured? */
299      if(!ip_addr_isany(&(netif->ip_addr)))      if(!ip_addr_isany(&(netif->ip_addr)))
# Line 308  ip_input(struct pbuf *p, struct netif *i Line 306  ip_input(struct pbuf *p, struct netif *i
306           /* or restricted broadcast? */           /* or restricted broadcast? */
307           ip_addr_cmp(&(iphdr->dest), IP_ADDR_BROADCAST)) {           ip_addr_cmp(&(iphdr->dest), IP_ADDR_BROADCAST)) {
308           DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",           DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
309                         netif->name[0], netif->name[1]));                         netif->name[0], netif->name[1]));
310           /* break out of for loop */           /* break out of for loop */
311           break;           break;
312        }        }
# Line 330  ip_input(struct pbuf *p, struct netif *i Line 328  ip_input(struct pbuf *p, struct netif *i
328      }      }
329    }    }
330  #endif /* LWIP_DHCP */  #endif /* LWIP_DHCP */
331          /* packet not for us? */            /* packet not for us? */  
332    if(netif == NULL) {    if(netif == NULL) {
333      /* packet not for us, route or discard */      /* packet not for us, route or discard */
334      DEBUGF(IP_DEBUG, ("ip_input: packet not for us.\n"));      DEBUGF(IP_DEBUG, ("ip_input: packet not for us.\n"));
# Line 351  ip_input(struct pbuf *p, struct netif *i Line 349  ip_input(struct pbuf *p, struct netif *i
349    
350  #if IP_REASSEMBLY  #if IP_REASSEMBLY
351    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
352      DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK))*8);      DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8));
353      p = ip_reass(p);      p = ip_reass(p);
354      if(p == NULL) {      if(p == NULL) {
355        return ERR_OK;        return ERR_OK;
# Line 362  ip_input(struct pbuf *p, struct netif *i Line 360  ip_input(struct pbuf *p, struct netif *i
360    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
361      pbuf_free(p);      pbuf_free(p);
362      DEBUGF(IP_DEBUG, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",      DEBUGF(IP_DEBUG, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",
363                    ntohs(IPH_OFFSET(iphdr))));                    ntohs(IPH_OFFSET(iphdr))));
364  #ifdef IP_STATS  #ifdef IP_STATS
365      ++lwip_stats.ip.opterr;      ++lwip_stats.ip.opterr;
366      ++lwip_stats.ip.drop;      ++lwip_stats.ip.drop;
# Line 441  ip_input(struct pbuf *p, struct netif *i Line 439  ip_input(struct pbuf *p, struct netif *i
439  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
440  err_t  err_t
441  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,
442               u8_t ttl,               u8_t ttl,
443               u8_t proto, struct netif *netif)               u8_t proto, struct netif *netif)
444  {  {
445    static struct ip_hdr *iphdr;    static struct ip_hdr *iphdr;
446    static u16_t ip_id = 0;    static u16_t ip_id = 0;
# Line 486  ip_output_if(struct pbuf *p, struct ip_a Line 484  ip_output_if(struct pbuf *p, struct ip_a
484      dest = &(iphdr->dest);      dest = &(iphdr->dest);
485    }    }
486    
487  #if IP_FRAG      #if IP_FRAG    
488    /* don't fragment if interface has mtu set to 0 [loopif] */    /* don't fragment if interface has mtu set to 0 [loopif] */
489    if (netif->mtu && (p->tot_len > netif->mtu))    if (netif->mtu && (p->tot_len > netif->mtu))
490      return ip_frag(p,netif,dest);      return ip_frag(p,netif,dest);
# Line 513  ip_output_if(struct pbuf *p, struct ip_a Line 511  ip_output_if(struct pbuf *p, struct ip_a
511  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
512  err_t  err_t
513  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,
514            u8_t ttl, u8_t proto)            u8_t ttl, u8_t proto)
515  {  {
516    struct netif *netif;    struct netif *netif;
517        
# Line 542  ip_debug_print(struct pbuf *p) Line 540  ip_debug_print(struct pbuf *p)
540    DEBUGF(IP_DEBUG, ("IP header:\n"));    DEBUGF(IP_DEBUG, ("IP header:\n"));
541    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
542    DEBUGF(IP_DEBUG, ("|%2d |%2d |   %2u  |      %4u     | (v, hl, tos, len)\n",    DEBUGF(IP_DEBUG, ("|%2d |%2d |   %2u  |      %4u     | (v, hl, tos, len)\n",
543                      IPH_V(iphdr),                      IPH_V(iphdr),
544                      IPH_HL(iphdr),                      IPH_HL(iphdr),
545                      IPH_TOS(iphdr),                      IPH_TOS(iphdr),
546                      ntohs(IPH_LEN(iphdr))));                      ntohs(IPH_LEN(iphdr))));
547    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
548    DEBUGF(IP_DEBUG, ("|    %5u      |%u%u%u|    %4u   | (id, flags, offset)\n",    DEBUGF(IP_DEBUG, ("|    %5u      |%u%u%u|    %4u   | (id, flags, offset)\n",
549                      ntohs(IPH_ID(iphdr)),                      ntohs(IPH_ID(iphdr)),
550                      ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,                      ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
551                      ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,                      ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
552                      ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,                      ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
553                      ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));                      ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));
554    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
555    DEBUGF(IP_DEBUG, ("|   %2u  |   %2u  |    0x%04x     | (ttl, proto, chksum)\n",    DEBUGF(IP_DEBUG, ("|   %2u  |   %2u  |    0x%04x     | (ttl, proto, chksum)\n",
556                      IPH_TTL(iphdr),                      IPH_TTL(iphdr),
557                      IPH_PROTO(iphdr),                      IPH_PROTO(iphdr),
558                      ntohs(IPH_CHKSUM(iphdr))));                      ntohs(IPH_CHKSUM(iphdr))));
559    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
560    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (src)\n",    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (src)\n",
561                      ntohl(iphdr->src.addr) >> 24 & 0xff,                      ntohl(iphdr->src.addr) >> 24 & 0xff,
562                      ntohl(iphdr->src.addr) >> 16 & 0xff,                      ntohl(iphdr->src.addr) >> 16 & 0xff,
563                      ntohl(iphdr->src.addr) >> 8 & 0xff,                      ntohl(iphdr->src.addr) >> 8 & 0xff,
564                      ntohl(iphdr->src.addr) & 0xff));                      ntohl(iphdr->src.addr) & 0xff));
565    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
566    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (dest)\n",    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (dest)\n",
567                      ntohl(iphdr->dest.addr) >> 24 & 0xff,                      ntohl(iphdr->dest.addr) >> 24 & 0xff,
568                      ntohl(iphdr->dest.addr) >> 16 & 0xff,                      ntohl(iphdr->dest.addr) >> 16 & 0xff,
569                      ntohl(iphdr->dest.addr) >> 8 & 0xff,                      ntohl(iphdr->dest.addr) >> 8 & 0xff,
570                      ntohl(iphdr->dest.addr) & 0xff));                      ntohl(iphdr->dest.addr) & 0xff));
571    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
572  }  }
573  #endif /* IP_DEBUG */  #endif /* IP_DEBUG */

Legend:
Removed from v.1.12.2.2  
changed lines
  Added in v.1.12.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26