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

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

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

revision 1.20 by softins, Tue Jul 27 14:43:58 2004 UTC revision 1.21 by kieranm, Sun Sep 12 16:17:58 2004 UTC
# Line 46  Line 46 
46  #include "lwip/def.h"  #include "lwip/def.h"
47  #include "lwip/inet.h"  #include "lwip/inet.h"
48    
49    #include "lwip/sys.h"
50    
51    /* This is a reference implementation of the checksum algorithm
52    
53     - it may not work on all architectures, and all processors, particularly
54       if they have issues with alignment and 16 bit access.
55    
56     - in this case you will need to port it to your architecture and
57       #define LWIP_CHKSUM <your_checksum_routine>
58       in your sys_arch.h
59    */
60    #ifndef LWIP_CHKSUM
61    #define LWIP_CHKSUM lwip_standard_chksum
62  static u16_t  static u16_t
63  lwip_chksum(void *dataptr, int len)  lwip_standard_chksum(void *dataptr, int len)
64  {  {
65    u32_t acc;    u32_t acc;
66    
# Line 75  lwip_chksum(void *dataptr, int len) Line 86  lwip_chksum(void *dataptr, int len)
86    
87    return (u16_t)acc;    return (u16_t)acc;
88  }  }
89    #endif
90    
91  /* inet_chksum_pseudo:  /* inet_chksum_pseudo:
92   *   *
# Line 96  inet_chksum_pseudo(struct pbuf *p, Line 108  inet_chksum_pseudo(struct pbuf *p,
108    for(q = p; q != NULL; q = q->next) {    for(q = p; q != NULL; q = q->next) {
109      LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n",      LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n",
110        (void *)q, (void *)q->next));        (void *)q, (void *)q->next));
111      acc += lwip_chksum(q->payload, q->len);      acc += LWIP_CHKSUM(q->payload, q->len);
112      /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/      /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/
113      while (acc >> 16) {      while (acc >> 16) {
114        acc = (acc & 0xffffUL) + (acc >> 16);        acc = (acc & 0xffffUL) + (acc >> 16);
# Line 136  inet_chksum(void *dataptr, u16_t len) Line 148  inet_chksum(void *dataptr, u16_t len)
148  {  {
149    u32_t acc;    u32_t acc;
150    
151    acc = lwip_chksum(dataptr, len);    acc = LWIP_CHKSUM(dataptr, len);
152    while (acc >> 16) {    while (acc >> 16) {
153      acc = (acc & 0xffff) + (acc >> 16);      acc = (acc & 0xffff) + (acc >> 16);
154    }    }
# Line 153  inet_chksum_pbuf(struct pbuf *p) Line 165  inet_chksum_pbuf(struct pbuf *p)
165    acc = 0;    acc = 0;
166    swapped = 0;    swapped = 0;
167    for(q = p; q != NULL; q = q->next) {    for(q = p; q != NULL; q = q->next) {
168      acc += lwip_chksum(q->payload, q->len);      acc += LWIP_CHKSUM(q->payload, q->len);
169      while (acc >> 16) {      while (acc >> 16) {
170        acc = (acc & 0xffffUL) + (acc >> 16);        acc = (acc & 0xffffUL) + (acc >> 16);
171      }      }

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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