/[lwip]/lwip/src/core/udp.c
ViewVC logotype

Diff of /lwip/src/core/udp.c

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

revision 1.17 by davidhaas, Thu Feb 6 22:18:56 2003 UTC revision 1.18 by likewise, Mon Feb 10 13:47:47 2003 UTC
# Line 50  Line 50 
50  #include "lwip/stats.h"  #include "lwip/stats.h"
51    
52  #include "arch/perf.h"  #include "arch/perf.h"
53  #if LWIP_SNMP > 0  #include "snmp.h"
 #  include "snmp.h"  
 #endif  
54    
55  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
56    
# Line 259  udp_input(struct pbuf *p, struct netif * Line 257  udp_input(struct pbuf *p, struct netif *
257          ++lwip_stats.udp.chkerr;          ++lwip_stats.udp.chkerr;
258          ++lwip_stats.udp.drop;          ++lwip_stats.udp.drop;
259  #endif /* UDP_STATS */  #endif /* UDP_STATS */
260  #if LWIP_SNMP > 0    snmp_inc_udpinerrors();
     snmp_inc_udpinerrors();  
 #endif  
261          pbuf_free(p);          pbuf_free(p);
262          goto end;          goto end;
263        }        }
# Line 276  udp_input(struct pbuf *p, struct netif * Line 272  udp_input(struct pbuf *p, struct netif *
272            ++lwip_stats.udp.chkerr;            ++lwip_stats.udp.chkerr;
273            ++lwip_stats.udp.drop;            ++lwip_stats.udp.drop;
274  #endif /* UDP_STATS */  #endif /* UDP_STATS */
 #if LWIP_SNMP > 0  
275      snmp_inc_udpinerrors();      snmp_inc_udpinerrors();
 #endif  
276            pbuf_free(p);            pbuf_free(p);
277            goto end;            goto end;
278          }          }
# Line 286  udp_input(struct pbuf *p, struct netif * Line 280  udp_input(struct pbuf *p, struct netif *
280      }      }
281      pbuf_header(p, -UDP_HLEN);          pbuf_header(p, -UDP_HLEN);    
282      if(pcb != NULL) {      if(pcb != NULL) {
 #if LWIP_SNMP > 0  
283        snmp_inc_udpindatagrams();        snmp_inc_udpindatagrams();
284  #endif        pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
       pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), udphdr->src);  
285      } else {      } else {
286        DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));        DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));
287                
# Line 307  udp_input(struct pbuf *p, struct netif * Line 299  udp_input(struct pbuf *p, struct netif *
299        ++lwip_stats.udp.proterr;        ++lwip_stats.udp.proterr;
300        ++lwip_stats.udp.drop;        ++lwip_stats.udp.drop;
301  #endif /* UDP_STATS */  #endif /* UDP_STATS */
 #if LWIP_SNMP > 0  
302      snmp_inc_udpnoports();      snmp_inc_udpnoports();
 #endif  
303        pbuf_free(p);        pbuf_free(p);
304      }      }
305    } else {    } else {
# Line 404  udp_send(struct udp_pcb *pcb, struct pbu Line 394  udp_send(struct udp_pcb *pcb, struct pbu
394      if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;      if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
395      /* output to IP */      /* output to IP */
396      err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif);          err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif);    
 #if LWIP_SNMP > 0  
397      snmp_inc_udpoutdatagrams();      snmp_inc_udpoutdatagrams();
 #endif  
398    } else {    } else {
399      DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", p->tot_len));      DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", p->tot_len));
400      udphdr->len = htons(p->tot_len);      udphdr->len = htons(p->tot_len);
# Line 417  udp_send(struct udp_pcb *pcb, struct pbu Line 405  udp_send(struct udp_pcb *pcb, struct pbu
405        if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;        if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
406      }      }
407      DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x\n", udphdr->chksum));      DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x\n", udphdr->chksum));
 #if LWIP_SNMP > 0  
408      snmp_inc_udpoutdatagrams();      snmp_inc_udpoutdatagrams();
 #endif  
409      DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)\n"));      DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)\n"));
410      /* output to IP */      /* output to IP */
411      err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);          err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);    
# Line 519  udp_connect(struct udp_pcb *pcb, struct Line 505  udp_connect(struct udp_pcb *pcb, struct
505    struct udp_pcb *ipcb;    struct udp_pcb *ipcb;
506    
507    if(pcb->local_port == 0) {    if(pcb->local_port == 0) {
508            err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);      err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
509            if(err != ERR_OK)      if(err != ERR_OK)
510                    return err;        return err;
511    }    }
512    
513    ip_addr_set(&pcb->remote_ip, ipaddr);    ip_addr_set(&pcb->remote_ip, ipaddr);
514    pcb->remote_port = port;    pcb->remote_port = port;
515    #if 1
516    pcb->flags |= UDP_FLAGS_CONNECTED;    pcb->flags |= UDP_FLAGS_CONNECTED;
   
517    /* Nail down local IP for netconn_addr()/getsockname() */    /* Nail down local IP for netconn_addr()/getsockname() */
518    if(ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {    if(ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
519      struct netif *netif;      struct netif *netif;
# Line 535  udp_connect(struct udp_pcb *pcb, struct Line 521  udp_connect(struct udp_pcb *pcb, struct
521      if((netif = ip_route(&(pcb->remote_ip))) == NULL) {      if((netif = ip_route(&(pcb->remote_ip))) == NULL) {
522          DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));          DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));
523  #ifdef UDP_STATS  #ifdef UDP_STATS
524          ++lwip_stats.udp.rterr;          ++lwip_stats.udp.rterr;
525  #endif /* UDP_STATS */  #endif /* UDP_STATS */
526          return ERR_RTE;          return ERR_RTE;
527      }      }
# Line 544  udp_connect(struct udp_pcb *pcb, struct Line 530  udp_connect(struct udp_pcb *pcb, struct
530    } else if(ip_addr_isany(&pcb->remote_ip)) {    } else if(ip_addr_isany(&pcb->remote_ip)) {
531      pcb->local_ip.addr = 0;      pcb->local_ip.addr = 0;
532    }    }
533    #endif
534    /* Insert UDP PCB into the list of active UDP PCBs. */    /* Insert UDP PCB into the list of active UDP PCBs. */
535    for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {    for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
536      if(pcb == ipcb) {      if(pcb == ipcb) {

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

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