Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
inet.c File Reference
Functions common to all TCP/IPv4 modules, such as the byte order functions. More...
Go to the source code of this file.
Functions | |
u32_t | inet_addr (const char *cp) |
Ascii internet address interpretation routine. | |
int | inet_aton (const char *cp, struct in_addr *addr) |
Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address. | |
char * | inet_ntoa (struct in_addr addr) |
Convert numeric IP address into decimal dotted ASCII representation. | |
u16_t | htons (u16_t n) |
These are reference implementations of the byte swapping functions. | |
u16_t | ntohs (u16_t n) |
Convert an u16_t from network- to host byte order. | |
u32_t | htonl (u32_t n) |
Convert an u32_t from host- to network byte order. | |
u32_t | ntohl (u32_t n) |
Convert an u32_t from network- to host byte order. |
Detailed Description
Functions common to all TCP/IPv4 modules, such as the byte order functions.
Definition in file inet.c.
Function Documentation
u32_t htonl | ( | u32_t | n ) |
u16_t 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:
-
n u16_t in host byte order
- Returns:
- n in network byte order
u32_t inet_addr | ( | const char * | cp ) |
int inet_aton | ( | const char * | cp, |
struct in_addr * | addr | ||
) |
Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address.
Returns 1 if the address is valid, 0 if not. This replaces inet_addr, the return value from which cannot distinguish between failure and a local broadcast address.
- Parameters:
-
cp IP address in ascii represenation (e.g. "127.0.0.1") addr pointer to which to save the ip address in network order
- Returns:
- 1 if cp could be converted to addr, 0 on failure
char* inet_ntoa | ( | struct in_addr | addr ) |
u32_t ntohl | ( | u32_t | n ) |
Generated on Tue Jul 12 2022 19:17:24 by 1.7.2