ReactOS  0.4.14-dev-614-gbfd8a84
inet.h File Reference
#include "lwip/opt.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
Include dependency graph for inet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

u16_t inet_chksum (void *data, u16_t len)
 
u16_t inet_chksum_pbuf (struct pbuf *p)
 
u16_t inet_chksum_pseudo (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t proto, u32_t proto_len)
 
u32_t inet_addr (const char *cp)
 
s8_t inet_aton (const char *cp, struct in_addr *addr)
 
u16_t htons (u16_t n)
 
u16_t ntohs (u16_t n)
 
u32_t htonl (u32_t n)
 
u32_t ntohl (u32_t n)
 

Function Documentation

◆ htonl()

u32_t htonl ( u32_t  n)

◆ htons()

u16_t htons ( u16_t  n)

Definition at line 20 of file connect.c.

21 {
22  return ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8);
23 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by TestTcpConnect().

◆ inet_addr()

u32_t inet_addr ( const char cp)

Definition at line 307 of file address.c.

315 {
316  ULONG Octets[4] = {0,0,0,0};
317  ULONG i = 0;
318 
319  if(!AddrString)
320  return -1;
321 
322  while(*AddrString)
323  {
324  CHAR c = *AddrString;
325  AddrString++;
326 
327  if(c == '.')
328  {
329  i++;
330  continue;
331  }
332 
333  if(c < '0' || c > '9')
334  return -1;
335 
336  Octets[i] *= 10;
337  Octets[i] += (c - '0');
338 
339  if(Octets[i] > 255)
340  return -1;
341  }
342 
343  return (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
344 }
char CHAR
Definition: xmlstorage.h:175
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
const GLubyte * c
Definition: glext.h:8905
unsigned int ULONG
Definition: retypes.h:1

◆ inet_aton()

s8_t inet_aton ( const char cp,
struct in_addr addr 
)

Definition at line 32 of file compat.c.

34 {
35  ULONG Octets[4] = {0,0,0,0};
36  ULONG i = 0;
37 
38  if(!cp)
39  return 0;
40 
41  while(*cp)
42  {
43  CHAR c = *cp;
44  cp++;
45 
46  if(c == '.')
47  {
48  i++;
49  continue;
50  }
51 
52  if(c < '0' || c > '9')
53  return 0;
54 
55  Octets[i] *= 10;
56  Octets[i] += (c - '0');
57 
58  if(Octets[i] > 255)
59  return 0;
60  }
61 
62  inp->S_un.S_addr = (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
63  return 1;
64 }
char CHAR
Definition: xmlstorage.h:175
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
const GLubyte * c
Definition: glext.h:8905
POINT cp
Definition: magnifier.c:59
unsigned int ULONG
Definition: retypes.h:1

◆ inet_chksum()

u16_t inet_chksum ( void data,
u16_t  len 
)

Definition at line 396 of file inet_chksum.c.

397 {
398  return ~LWIP_CHKSUM(dataptr, len);
399 }
GLenum GLsizei len
Definition: glext.h:6722
#define LWIP_CHKSUM
Definition: inet_chksum.c:59
int const JOCTET * dataptr
Definition: jpeglib.h:1027

Referenced by ip_input(), and tcp_create_segment_wnd().

◆ 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 409 of file inet_chksum.c.

410 {
411  u32_t acc;
412  struct pbuf *q;
413  u8_t swapped;
414 
415  acc = 0;
416  swapped = 0;
417  for(q = p; q != NULL; q = q->next) {
418  acc += LWIP_CHKSUM(q->payload, q->len);
419  acc = FOLD_U32T(acc);
420  if (q->len % 2 != 0) {
421  swapped = 1 - swapped;
422  acc = SWAP_BYTES_IN_WORD(acc);
423  }
424  }
425 
426  if (swapped) {
427  acc = SWAP_BYTES_IN_WORD(acc);
428  }
429  return (u16_t)~(acc & 0xffffUL);
430 }
smooth NULL
Definition: ftsmooth.c:416
Definition: pbuf.h:79
unsigned long u32_t
Definition: cc.h:25
#define SWAP_BYTES_IN_WORD(w)
Definition: inet_chksum.h:47
#define FOLD_U32T(u)
Definition: inet_chksum.h:53
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
unsigned char u8_t
Definition: cc.h:23
#define LWIP_CHKSUM
Definition: inet_chksum.c:59
unsigned short u16_t
Definition: cc.h:24
GLfloat GLfloat p
Definition: glext.h:8902
#define UL
Definition: tui.h:83

◆ 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

◆ ntohl()

u32_t ntohl ( u32_t  n)

◆ ntohs()

u16_t ntohs ( u16_t  n)