ReactOS  0.4.14-dev-358-gbef841c
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

static 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)
 

Detailed Description

Functions common to all TCP/IPv6 modules, such as the Internet checksum and the byte order functions.

Definition in file inet6.c.

Function Documentation

◆ chksum()

static u32_t chksum ( void dataptr,
u16_t  len 
)
static

Definition at line 55 of file inet6.c.

56 {
57  u16_t *sdataptr = dataptr;
58  u32_t acc;
59 
60 
61  for(acc = 0; len > 1; len -= 2) {
62  acc += *sdataptr++;
63  }
64 
65  /* add up any odd byte */
66  if (len == 1) {
67  acc += htons((u16_t)(*(u8_t *)dataptr) << 8);
68  }
69 
70  return acc;
71 
72 }
unsigned long u32_t
Definition: cc.h:25
GLenum GLsizei len
Definition: glext.h:6722
unsigned char u8_t
Definition: cc.h:23
int const JOCTET * dataptr
Definition: jpeglib.h:1027
unsigned short u16_t
Definition: cc.h:24
#define htons(x)
Definition: module.h:213

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

◆ inet_chksum()

u16_t inet_chksum ( void dataptr,
u16_t  len 
)

Definition at line 129 of file inet6.c.

130 {
131  u32_t acc, sum;
132 
133  acc = chksum(dataptr, len);
134  sum = (acc & 0xffff) + (acc >> 16);
135  sum += (sum >> 16);
136  return ~(sum & 0xffff);
137 }
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
unsigned long u32_t
Definition: cc.h:25
GLenum GLsizei len
Definition: glext.h:6722
static u32_t chksum(void *dataptr, u16_t len)
Definition: inet6.c:55
int const JOCTET * dataptr
Definition: jpeglib.h:1027

◆ inet_chksum_pbuf()

u16_t inet_chksum_pbuf ( struct pbuf p)

Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).

Parameters
ppbuf chain over that the checksum should be calculated
Returns
checksum (as u16_t) to be saved directly in the protocol header

Definition at line 140 of file inet6.c.

141 {
142  u32_t acc;
143  struct pbuf *q;
144  u8_t swapped;
145 
146  acc = 0;
147  swapped = 0;
148  for(q = p; q != NULL; q = q->next) {
149  acc += chksum(q->payload, q->len);
150  while (acc >> 16) {
151  acc = (acc & 0xffff) + (acc >> 16);
152  }
153  if (q->len % 2 != 0) {
154  swapped = 1 - swapped;
155  acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
156  }
157  }
158 
159  if (swapped) {
160  acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
161  }
162  return ~(acc & 0xffff);
163 }
smooth NULL
Definition: ftsmooth.c:416
Definition: pbuf.h:79
unsigned long u32_t
Definition: cc.h:25
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
static u32_t chksum(void *dataptr, u16_t len)
Definition: inet6.c:55
unsigned char u8_t
Definition: cc.h:23
GLfloat GLfloat p
Definition: glext.h:8902

◆ inet_chksum_pseudo()

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 80 of file inet6.c.

83 {
84  u32_t acc;
85  struct pbuf *q;
86  u8_t swapped, i;
87 
88  acc = 0;
89  swapped = 0;
90  for(q = p; q != NULL; q = q->next) {
91  acc += chksum(q->payload, q->len);
92  while (acc >> 16) {
93  acc = (acc & 0xffff) + (acc >> 16);
94  }
95  if (q->len % 2 != 0) {
96  swapped = 1 - swapped;
97  acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
98  }
99  }
100 
101  if (swapped) {
102  acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
103  }
104 
105  for(i = 0; i < 8; i++) {
106  acc += ((u16_t *)src->addr)[i] & 0xffff;
107  acc += ((u16_t *)dest->addr)[i] & 0xffff;
108  while (acc >> 16) {
109  acc = (acc & 0xffff) + (acc >> 16);
110  }
111  }
112  acc += (u16_t)htons((u16_t)proto);
113  acc += ((u16_t *)&proto_len)[0] & 0xffff;
114  acc += ((u16_t *)&proto_len)[1] & 0xffff;
115 
116  while (acc >> 16) {
117  acc = (acc & 0xffff) + (acc >> 16);
118  }
119  return ~(acc & 0xffff);
120 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
Definition: pbuf.h:79
unsigned long u32_t
Definition: cc.h:25
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLenum src
Definition: glext.h:6340
static u32_t chksum(void *dataptr, u16_t len)
Definition: inet6.c:55
unsigned char u8_t
Definition: cc.h:23
static char * dest
Definition: rtl.c:135
unsigned short u16_t
Definition: cc.h:24
GLfloat GLfloat p
Definition: glext.h:8902
#define htons(x)
Definition: module.h:213