5.4. inet
— Internet utilities¶
Source code: src/inet/inet.h, src/inet/inet.c
Test code: tst/inet/inet/inet.c
Test coverage: src/inet/inet.c
Functions
-
int
inet_module_init
(void)¶ Initialize the inet module. This function must be called before calling any other function in this module.
The module will only be initialized once even if this function is called multiple times.
- Return
- zero(0) or negative error code.
-
int
inet_aton
(const char *src_p, struct inet_ip_addr_t *dst_p)¶ Convert the Internet host address src_p from the IPv4 numbers-and-dots notation into binary form (in network byte order) and stores it in the structure that dst_p points to.
The address supplied in src_p can have one of the following forms:
- a.b.c.d Each of the four numeric parts specifies a byte of the address; the bytes are assigned in left-to-right order to produce the binary address.
- Return
- zero(0) or negative error code.
- Parameters
src_p
-Address a.b.c.d to convert into a number.
dst_p
-Converted address.
-
char *
inet_ntoa
(const struct inet_ip_addr_t *src_p, char *dst_p)¶ Convert the Internet host src_p from the IPv4 binary form (in network byte order) to numbers-and-dots notation and stores it in the structure that dst_p points to.
- Return
- Converted address pointer or NULL on failure.
- Parameters
src_p
-Address to convert into a string.
dst_p
-Converted address as a string.
-
uint16_t
inet_checksum
(void *buf_p, size_t size)¶ Calculate the internet checksum of given buffer.
- Return
- Calculated checksum.
- Parameters
buf_p
-Buffer to calculate the chechsum of.
size
-Size of the buffer.
-
struct
inet_addr_t
¶