ReactOS  0.4.13-dev-1148-g9b75b67
def.c File Reference
#include "lwip/opt.h"
#include "lwip/def.h"
Include dependency graph for def.c:

Go to the source code of this file.

Functions

u16_t lwip_htons (u16_t n)
 
u16_t lwip_ntohs (u16_t n)
 
u32_t lwip_htonl (u32_t n)
 
u32_t lwip_ntohl (u32_t n)
 

Detailed Description

Common functions used throughout the stack.

Definition in file def.c.

Function Documentation

◆ lwip_htonl()

u32_t lwip_htonl ( u32_t  n)

Convert an u32_t from host- to network byte order.

Parameters
nu32_t in host byte order
Returns
n in network byte order

Definition at line 88 of file def.c.

89 {
90  return ((n & 0xff) << 24) |
91  ((n & 0xff00) << 8) |
92  ((n & 0xff0000UL) >> 8) |
93  ((n & 0xff000000UL) >> 24);
94 }
GLdouble n
Definition: glext.h:7729
#define UL
Definition: tui.h:83

Referenced by ip4_addr_netmask_valid(), and lwip_ntohl().

◆ lwip_htons()

u16_t lwip_htons ( u16_t  n)

These are reference implementations of the byte swapping functions. Again with the aim of being simple, correct and fully portable. Byte swapping is the second thing you would want to optimize. You will need to port it to your architecture and in your cc.h:

define LWIP_PLATFORM_BYTESWAP 1 define LWIP_PLATFORM_HTONS(x) <your_htons> define LWIP_PLATFORM_HTONL(x) <your_htonl>

Note ntohs() and ntohl() are merely references to the htonx counterparts.Convert an u16_t from host- to network byte order.

Parameters
nu16_t in host byte order
Returns
n in network byte order

Definition at line 64 of file def.c.

65 {
66  return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
67 }
GLdouble n
Definition: glext.h:7729

Referenced by lwip_ntohs().

◆ lwip_ntohl()

u32_t lwip_ntohl ( u32_t  n)

Convert an u32_t from network- to host byte order.

Parameters
nu32_t in network byte order
Returns
n in host byte order

Definition at line 103 of file def.c.

104 {
105  return lwip_htonl(n);
106 }
GLdouble n
Definition: glext.h:7729
u32_t lwip_htonl(u32_t n)
Definition: def.c:88

◆ lwip_ntohs()

u16_t lwip_ntohs ( u16_t  n)

Convert an u16_t from network- to host byte order.

Parameters
nu16_t in network byte order
Returns
n in host byte order

Definition at line 76 of file def.c.

77 {
78  return lwip_htons(n);
79 }
GLdouble n
Definition: glext.h:7729
u16_t lwip_htons(u16_t n)
Definition: def.c:64