/[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.18 by jani, Fri Feb 21 16:43:46 2003 UTC revision 1.19 by likewise, Tue Mar 25 12:59:42 2003 UTC
# Line 236  ip_input(struct pbuf *p, struct netif *i Line 236  ip_input(struct pbuf *p, struct netif *i
236    /* identify the IP header */    /* identify the IP header */
237    iphdr = p->payload;    iphdr = p->payload;
238    if(IPH_V(iphdr) != 4) {    if(IPH_V(iphdr) != 4) {
239      DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number %d\n", IPH_V(iphdr)));      DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %d\n", IPH_V(iphdr)));
240  #if IP_DEBUG  #if IP_DEBUG
241      ip_debug_print(p);      ip_debug_print(p);
242  #endif /* IP_DEBUG */  #endif /* IP_DEBUG */
# Line 255  ip_input(struct pbuf *p, struct netif *i Line 255  ip_input(struct pbuf *p, struct netif *i
255    
256    /* header length exceeds first pbuf length? */      /* header length exceeds first pbuf length? */  
257    if(iphdrlen > p->len) {    if(iphdrlen > p->len) {
258      DEBUGF(IP_DEBUG, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n",      DEBUGF(IP_DEBUG | 2, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n",
259        iphdrlen, p->len));        iphdrlen, p->len));
260      /* free (drop) packet pbufs */      /* free (drop) packet pbufs */
261      pbuf_free(p);      pbuf_free(p);
# Line 270  ip_input(struct pbuf *p, struct netif *i Line 270  ip_input(struct pbuf *p, struct netif *i
270    /* verify checksum */    /* verify checksum */
271    if(inet_chksum(iphdr, iphdrlen) != 0) {    if(inet_chksum(iphdr, iphdrlen) != 0) {
272    
273      DEBUGF(IP_DEBUG, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen)));      DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen)));
274  #if IP_DEBUG  #if IP_DEBUG
275      ip_debug_print(p);      ip_debug_print(p);
276  #endif /* IP_DEBUG */  #endif /* IP_DEBUG */
# Line 320  ip_input(struct pbuf *p, struct netif *i Line 320  ip_input(struct pbuf *p, struct netif *i
320    if(netif == NULL) {    if(netif == NULL) {
321      /* remote port is DHCP server? */      /* remote port is DHCP server? */
322      if(IPH_PROTO(iphdr) == IP_PROTO_UDP) {      if(IPH_PROTO(iphdr) == IP_PROTO_UDP) {
323        DEBUGF(IP_DEBUG, ("ip_input: UDP packet to DHCP client port %u\n",        DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\n",
324         ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));         ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));
325        if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {        if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {
326          DEBUGF(IP_DEBUG, ("ip_input: DHCP packet accepted.\n"));          DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n"));
327          netif = inp;          netif = inp;
328        }        }
329      }      }
# Line 332  ip_input(struct pbuf *p, struct netif *i Line 332  ip_input(struct pbuf *p, struct netif *i
332          /* packet not for us? */            /* packet not for us? */  
333    if(netif == NULL) {    if(netif == NULL) {
334      /* packet not for us, route or discard */      /* packet not for us, route or discard */
335      DEBUGF(IP_DEBUG, ("ip_input: packet not for us.\n"));      DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: packet not for us.\n"));
336  #if IP_FORWARD  #if IP_FORWARD
337      /* non-broadcast packet? */      /* non-broadcast packet? */
338      if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) {      if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) {
# Line 360  ip_input(struct pbuf *p, struct netif *i Line 360  ip_input(struct pbuf *p, struct netif *i
360  #else /* IP_REASSEMBLY */  #else /* IP_REASSEMBLY */
361    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {    if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
362      pbuf_free(p);      pbuf_free(p);
363      DEBUGF(IP_DEBUG, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",      DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",
364                    ntohs(IPH_OFFSET(iphdr))));                    ntohs(IPH_OFFSET(iphdr))));
365  #ifdef IP_STATS  #ifdef IP_STATS
366      ++lwip_stats.ip.opterr;      ++lwip_stats.ip.opterr;
# Line 372  ip_input(struct pbuf *p, struct netif *i Line 372  ip_input(struct pbuf *p, struct netif *i
372  #endif /* IP_REASSEMBLY */  #endif /* IP_REASSEMBLY */
373        
374  #if IP_OPTIONS == 0  #if IP_OPTIONS == 0
375    if(iphdrlen > IP_HLEN) {    if (iphdrlen > IP_HLEN) {
376      DEBUGF(IP_DEBUG, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n"));      DEBUGF(IP_DEBUG | 2, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n"));
377      pbuf_free(p);          pbuf_free(p);    
378  #ifdef IP_STATS  #ifdef IP_STATS
379      ++lwip_stats.ip.opterr;      ++lwip_stats.ip.opterr;
# Line 417  ip_input(struct pbuf *p, struct netif *i Line 417  ip_input(struct pbuf *p, struct netif *i
417      }      }
418      pbuf_free(p);      pbuf_free(p);
419    
420      DEBUGF(IP_DEBUG, ("Unsupported transportation protocol %d\n", IPH_PROTO(iphdr)));      DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr)));
421    
422  #ifdef IP_STATS  #ifdef IP_STATS
423      ++lwip_stats.ip.proterr;      ++lwip_stats.ip.proterr;
# Line 450  ip_output_if(struct pbuf *p, struct ip_a Line 450  ip_output_if(struct pbuf *p, struct ip_a
450        
451    if(dest != IP_HDRINCL) {    if(dest != IP_HDRINCL) {
452      if(pbuf_header(p, IP_HLEN)) {      if(pbuf_header(p, IP_HLEN)) {
453        DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));        DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n"));
454                
455  #ifdef IP_STATS  #ifdef IP_STATS
456        ++lwip_stats.ip.err;        ++lwip_stats.ip.err;
# Line 517  ip_output(struct pbuf *p, struct ip_addr Line 517  ip_output(struct pbuf *p, struct ip_addr
517    struct netif *netif;    struct netif *netif;
518        
519    if((netif = ip_route(dest)) == NULL) {    if((netif = ip_route(dest)) == NULL) {
520      DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr));      DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr));
521    
522  #ifdef IP_STATS  #ifdef IP_STATS
523      ++lwip_stats.ip.rterr;      ++lwip_stats.ip.rterr;

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

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