Files | |
| file | net.c |
| Network utility functions (license: GPLv2). | |
| file | net.h |
| Network utility header (license: GPLv2). | |
Defines | |
| #define | HTON16(val) |
| Converts a 16-bit integer to network byte order. | |
| #define | HTON32(val) |
| Converts a 32-bit integer to network byte order. | |
| #define | NTOH16(val) |
| Converts a 16-bit integer to host byte order. | |
| #define | NTOH32(val) |
| Converts a 32-bit integer to host byte order. | |
| #define | NET_HEADER_SIZE_ETHERNET |
| The size of an ethernet header. | |
| #define | NET_HEADER_SIZE_IP |
| The size of an IP header. | |
| #define | NET_HEADER_SIZE_TCP |
| The size of a TCP header. | |
| #define | NET_HEADER_SIZE_UDP |
| The size of a UDP header. | |
| #define | ntoh16(n) |
| Converts a 16-bit integer to host byte order. | |
| #define | ntoh32(n) |
| Converts a 32-bit integer to host byte order. | |
Functions | |
| uint16_t | net_calc_checksum (uint16_t checksum, const uint8_t *data, uint16_t data_len, uint8_t skip) |
| Generic Internet checksum implementation. | |
| uint16_t | hton16 (uint16_t h) |
| Converts a 16-bit integer to network byte order. | |
| uint32_t | hton32 (uint32_t h) |
| Converts a 32-bit integer to network byte order. | |
| #define HTON16 | ( | val | ) |
Converts a 16-bit integer to network byte order.
Use this macro for compile time constants only. For variable values use the function hton16() instead. This saves code size.
| [in] | val | A 16-bit integer in host byte order. |
| #define HTON32 | ( | val | ) |
Converts a 32-bit integer to network byte order.
Use this macro for compile time constants only. For variable values use the function hton32() instead. This saves code size.
| [in] | val | A 32-bit integer in host byte order. |
| #define NTOH16 | ( | val | ) |
Converts a 16-bit integer to host byte order.
Use this macro for compile time constants only. For variable values use the function ntoh16() instead. This saves code size.
| [in] | val | A 16-bit integer in network byte order. |
| #define NTOH32 | ( | val | ) |
Converts a 32-bit integer to host byte order.
Use this macro for compile time constants only. For variable values use the function ntoh32() instead. This saves code size.
| [in] | val | A 32-bit integer in network byte order. |
| #define NET_HEADER_SIZE_ETHERNET |
The size of an ethernet header.
| #define NET_HEADER_SIZE_IP |
The size of an IP header.
| #define NET_HEADER_SIZE_TCP |
The size of a TCP header.
| #define NET_HEADER_SIZE_UDP |
The size of a UDP header.
| #define ntoh16 | ( | n | ) |
Converts a 16-bit integer to host byte order.
Use this function on variable values instead of the macro NTOH16(). This saves code size.
| [in] | n | A 16-bit integer in network byte order. |
| #define ntoh32 | ( | n | ) |
Converts a 32-bit integer to host byte order.
Use this function on variable values instead of the macro NTOH32(). This saves code size.
| [in] | n | A 32-bit integer in network byte order. |
| uint16_t net_calc_checksum | ( | uint16_t | checksum, | |
| const uint8_t * | data, | |||
| uint16_t | data_len, | |||
| uint8_t | skip | |||
| ) |
Generic Internet checksum implementation.
Calculates the Internet checksum over some arbitrary data block. Updating the checksum is possible by providing the checksum of some previous data.
| [in] | checksum | The checksum value to start from. Should be zero for the first byte. |
| [in] | data | A pointer to the buffer containing the data to be checksummed. |
| [in] | data_len | The number of bytes to be checksummed. |
| [in] | skip | The position of a two-bytes-value assumed to be zero during checksum calculation. |
| uint16_t hton16 | ( | uint16_t | h | ) |
Converts a 16-bit integer to network byte order.
Use this function on variable values instead of the macro HTON16(). This saves code size.
| [in] | h | A 16-bit integer in host byte order. |
| uint32_t hton32 | ( | uint32_t | h | ) |
Converts a 32-bit integer to network byte order.
Use this function on variable values instead of the macro HTON32(). This saves code size.
| [in] | h | A 32-bit integer in host byte order. |
1.5.5