/[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.2 by adamdunkels, Wed Oct 23 19:44:32 2002 UTC revision 1.3 by likewise, Thu Nov 21 10:32:19 2002 UTC
# Line 28  Line 28 
28   *   *
29   * Author: Adam Dunkels <adam@sics.se>   * Author: Adam Dunkels <adam@sics.se>
30   *   *
31     * $Id$
32   */   */
33    
34  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
# Line 49  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
54    #  include "snmp.h"
55    #endif
56    
57  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
58    
# Line 219  udp_input(struct pbuf *p, struct netif * Line 223  udp_input(struct pbuf *p, struct netif *
223          ++stats.udp.chkerr;          ++stats.udp.chkerr;
224          ++stats.udp.drop;          ++stats.udp.drop;
225  #endif /* UDP_STATS */  #endif /* UDP_STATS */
226    #if LWIP_SNMP > 0
227        snmp_inc_udpinerrors();
228    #endif
229          pbuf_free(p);          pbuf_free(p);
230          goto end;          goto end;
231        }        }
# Line 233  udp_input(struct pbuf *p, struct netif * Line 240  udp_input(struct pbuf *p, struct netif *
240            ++stats.udp.chkerr;            ++stats.udp.chkerr;
241            ++stats.udp.drop;            ++stats.udp.drop;
242  #endif /* UDP_STATS */  #endif /* UDP_STATS */
243    #if LWIP_SNMP > 0
244        snmp_inc_udpinerrors();
245    #endif
246            pbuf_free(p);            pbuf_free(p);
247            goto end;            goto end;
248          }          }
# Line 240  udp_input(struct pbuf *p, struct netif * Line 250  udp_input(struct pbuf *p, struct netif *
250      }      }
251      pbuf_header(p, -UDP_HLEN);          pbuf_header(p, -UDP_HLEN);    
252      if(pcb != NULL) {      if(pcb != NULL) {
253    #if LWIP_SNMP > 0
254          snmp_inc_udpindatagrams();
255    #endif
256        pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);        pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
257      } else {      } else {
258        DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));        DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));
# Line 262  udp_input(struct pbuf *p, struct netif * Line 275  udp_input(struct pbuf *p, struct netif *
275        ++stats.udp.proterr;        ++stats.udp.proterr;
276        ++stats.udp.drop;        ++stats.udp.drop;
277  #endif /* UDP_STATS */  #endif /* UDP_STATS */
278    #if LWIP_SNMP > 0
279        snmp_inc_udpnoports();
280    #endif
281        pbuf_free(p);        pbuf_free(p);
282      }      }
283    } else {    } else {
# Line 281  udp_send(struct udp_pcb *pcb, struct pbu Line 297  udp_send(struct udp_pcb *pcb, struct pbu
297    err_t err;    err_t err;
298    struct pbuf *hdr;    struct pbuf *hdr;
299    
300    
301      DEBUGF(UDP_DEBUG, ("udp_send"));
302    /* hdr will point to the UDP header pbuf if an extra header pbuf has    /* hdr will point to the UDP header pbuf if an extra header pbuf has
303       to be allocated. */       to be allocated. */
304    hdr = NULL;    hdr = NULL;
# Line 293  udp_send(struct udp_pcb *pcb, struct pbu Line 311  udp_send(struct udp_pcb *pcb, struct pbu
311      pbuf_chain(hdr, p);      pbuf_chain(hdr, p);
312      p = hdr;      p = hdr;
313    }    }
314      DEBUGF(UDP_DEBUG, ("udp_send: got pbuf"));
315    
316    udphdr = p->payload;    udphdr = p->payload;
317    udphdr->src = htons(pcb->local_port);    udphdr->src = htons(pcb->local_port);
# Line 316  udp_send(struct udp_pcb *pcb, struct pbu Line 335  udp_send(struct udp_pcb *pcb, struct pbu
335    DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %d\n", p->tot_len));    DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %d\n", p->tot_len));
336        
337    if(pcb->flags & UDP_FLAGS_UDPLITE) {    if(pcb->flags & UDP_FLAGS_UDPLITE) {
338        DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u", p->tot_len));
339      udphdr->len = htons(pcb->chksum_len);      udphdr->len = htons(pcb->chksum_len);
340      /* calculate checksum */      /* calculate checksum */
341      udphdr->chksum = inet_chksum_pseudo(p, src_ip, &(pcb->remote_ip),      udphdr->chksum = inet_chksum_pseudo(p, src_ip, &(pcb->remote_ip),
# Line 324  udp_send(struct udp_pcb *pcb, struct pbu Line 344  udp_send(struct udp_pcb *pcb, struct pbu
344        udphdr->chksum = 0xffff;        udphdr->chksum = 0xffff;
345      }      }
346      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);    
347    #if LWIP_SNMP > 0
348        snmp_inc_udpoutdatagrams();
349    #endif
350    } else {    } else {
351        DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u", p->tot_len));
352      udphdr->len = htons(p->tot_len);      udphdr->len = htons(p->tot_len);
353      /* calculate checksum */      /* calculate checksum */
354      if((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {      if((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {
# Line 334  udp_send(struct udp_pcb *pcb, struct pbu Line 358  udp_send(struct udp_pcb *pcb, struct pbu
358          udphdr->chksum = 0xffff;          udphdr->chksum = 0xffff;
359        }        }
360      }      }
361        DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x", udphdr->chksum));
362    #if LWIP_SNMP > 0
363        snmp_inc_udpoutdatagrams();
364    #endif
365        DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)"));
366      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);    
367    }    }
368    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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