Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

inet6.c File Reference

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/inet.h"

Include dependency graph for inet6.c:

Go to the source code of this file.

Functions

u32_t chksum (void *dataptr, u16_t len)
u16_t inet_chksum_pseudo (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t proto, u32_t proto_len)
u16_t inet_chksum (void *dataptr, u16_t len)
u16_t inet_chksum_pbuf (struct pbuf *p)


Function Documentation

u32_t chksum void *  dataptr,
u16_t  len
[static]
 

Definition at line 65 of file inet6.c.

References htons, len, u16_t, u32_t, and u8_t.

Referenced by inet_chksum(), inet_chksum_pbuf(), and inet_chksum_pseudo().

00066 {
00067   u16_t *sdataptr = dataptr;
00068   u32_t acc;
00069   
00070   
00071   for(acc = 0; len > 1; len -= 2) {
00072     acc += *sdataptr++;
00073   }
00074 
00075   /* add up any odd byte */
00076   if(len == 1) {
00077     acc += htons((u16_t)(*(u8_t *)dataptr) << 8);
00078   }
00079 
00080   return acc;
00081 
00082 }

u16_t inet_chksum void *  dataptr,
u16_t  len
 

Definition at line 139 of file inet6.c.

References chksum(), len, lwip_chksum(), u16_t, and u32_t.

Referenced by icmp_dest_unreach(), icmp_time_exceeded(), ip_frag(), ip_input(), ip_output_if(), and ip_reass().

00140 {
00141   u32_t acc, sum;
00142 
00143   acc = chksum(dataptr, len);
00144   sum = (acc & 0xffff) + (acc >> 16);
00145   sum += (sum >> 16);
00146   return ~(sum & 0xffff);
00147 }

Here is the call graph for this function:

u16_t inet_chksum_pbuf struct pbuf p  ) 
 

Definition at line 150 of file inet6.c.

References chksum(), lwip_chksum(), NULL, u32_t, and u8_t.

Referenced by icmp_input().

00151 {
00152   u32_t acc;
00153   struct pbuf *q;
00154   u8_t swapped;
00155   
00156   acc = 0;
00157   swapped = 0;
00158   for(q = p; q != NULL; q = q->next) {
00159     acc += chksum(q->payload, q->len);
00160     while(acc >> 16) {
00161       acc = (acc & 0xffff) + (acc >> 16);
00162     }    
00163     if(q->len % 2 != 0) {
00164       swapped = 1 - swapped;
00165       acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
00166     }
00167   }
00168  
00169   if(swapped) {
00170     acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
00171   }
00172   return ~(acc & 0xffff);
00173 }

Here is the call graph for this function:

u16_t inet_chksum_pseudo struct pbuf p,
struct ip_addr src,
struct ip_addr dest,
u8_t  proto,
u32_t  proto_len
 

Definition at line 90 of file inet6.c.

References ip_addr::addr, chksum(), htons, NULL, u16_t, u32_t, and u8_t.

Referenced by icmp_input().

00093 {
00094   u32_t acc;
00095   struct pbuf *q;
00096   u8_t swapped, i;
00097 
00098   acc = 0;
00099   swapped = 0;
00100   for(q = p; q != NULL; q = q->next) {    
00101     acc += chksum(q->payload, q->len);
00102     while(acc >> 16) {
00103       acc = (acc & 0xffff) + (acc >> 16);
00104     }
00105     if(q->len % 2 != 0) {
00106       swapped = 1 - swapped;
00107       acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
00108     }
00109   }
00110 
00111   if(swapped) {
00112     acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
00113   }
00114   
00115   for(i = 0; i < 8; i++) {
00116     acc += ((u16_t *)src->addr)[i] & 0xffff;
00117     acc += ((u16_t *)dest->addr)[i] & 0xffff;
00118     while(acc >> 16) {
00119       acc = (acc & 0xffff) + (acc >> 16);
00120     }
00121   }
00122   acc += (u16_t)htons((u16_t)proto);
00123   acc += ((u16_t *)&proto_len)[0] & 0xffff;
00124   acc += ((u16_t *)&proto_len)[1] & 0xffff;
00125 
00126   while(acc >> 16) {
00127     acc = (acc & 0xffff) + (acc >> 16);
00128   }
00129   return ~(acc & 0xffff);
00130 }

Here is the call graph for this function:


Generated on Wed Jan 14 12:59:05 2004 for RTL-lwIP-0.4 by doxygen 1.3.4