|
EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
File containing the implementation of the network utilities. More...
#include <stdbool.h>#include <netinet/in.h>#include <arpa/inet.h>#include <errno.h>#include <inttypes.h>#include <sys/socket.h>#include <sys/sysctl.h>#include "allocs.h"#include "net.h"#include "os.h"Functions | |
| bool | validate_ipv4_string (const char *ip) |
| Checks whether a string denotes a IPv4 address. More... | |
| int | ip_2_nbo (const char *ip, const char *subnet_mask, in_addr_t *addr) |
IP string to struct in_addr_t converter. More... | |
| int | ip4_2_buf (const char *ip, uint8_t buf[static IP_ALEN]) |
| IP string to buffer. More... | |
| const char * | bit32_2_ip (uint32_t addr, char ip[static OS_INET_ADDRSTRLEN]) |
| Convert a 32 bit number IP to an IP string. More... | |
| const char * | inaddr4_2_ip (const struct in_addr *addr, char ip[static OS_INET_ADDRSTRLEN]) |
| Convert the in_addr encoded IP4 address to an IP string. More... | |
| const char * | inaddr6_2_ip (const struct in6_addr *addr, char ip[static OS_INET6_ADDRSTRLEN]) |
| Convert the in6_addr encoded IP6 address to an IP string. More... | |
| uint8_t | get_short_subnet (const char *subnet_mask) |
| Convert from a string subnet mask to a short integer version. More... | |
| int | get_ip_host (const char *ip, const char *subnet_mask, uint32_t *host) |
| Get the host identifier from an IP address string. More... | |
| int | disable_pmtu_discovery (int sock) |
| Disable the PMTU discovery for sockets. More... | |
| int | edge_hwaddr_aton2 (const char *txt, uint8_t *addr) |
| Convert ASCII string to MAC address (in any known format) More... | |
File containing the implementation of the network utilities.
| const char* bit32_2_ip | ( | uint32_t | addr, |
| char | ip[static OS_INET_ADDRSTRLEN] | ||
| ) |
Convert a 32 bit number IP to an IP string.
| addr | The IP in 32 bit format | |
| [out] | ip | The output buffer to store the IP. Must be at least OS_INET_ADDRSTRLEN chars long. |
ip on success) | NULL | on error (see errno). |
| int disable_pmtu_discovery | ( | int | sock | ) |
Disable the PMTU discovery for sockets.
| [in] | sock | The socket descriptor |
| int edge_hwaddr_aton2 | ( | const char * | txt, |
| uint8_t * | addr | ||
| ) |
Convert ASCII string to MAC address (in any known format)
| [in] | txt | MAC address as a string (e.g., 00:11:22:33:44:55 or 0011.2233.4455) |
| [out] | addr | Buffer for the MAC address (ETHER_ADDR_LEN = 6 bytes) |
| int get_ip_host | ( | const char * | ip, |
| const char * | subnet_mask, | ||
| uint32_t * | host | ||
| ) |
Get the host identifier from an IP address string.
| ip | The IP address string | |
| subnet_mask | The subnet mask string | |
| [out] | host | The returned host indentifier |
| uint8_t get_short_subnet | ( | const char * | subnet_mask | ) |
Convert from a string subnet mask to a short integer version.
| subnet_mask | The subnet mask string |
| const char* inaddr4_2_ip | ( | const struct in_addr * | addr, |
| char | ip[static OS_INET_ADDRSTRLEN] | ||
| ) |
Convert the in_addr encoded IP4 address to an IP string.
| addr | The in_addr encoded IP | |
| [out] | ip | The output buffer to store the IP. Must be at least OS_INET_ADDRSTRLEN chars long. |
ip on success) | NULL | on error (see errno). |
| const char* inaddr6_2_ip | ( | const struct in6_addr * | addr, |
| char | ip[static OS_INET6_ADDRSTRLEN] | ||
| ) |
Convert the in6_addr encoded IP6 address to an IP string.
| addr | The in6_addr encoded IP | |
| [out] | ip | The output buffer to store the IP. Must be at least OS_INET6_ADDRSTRLEN chars long. |
ip on success) | NULL | on error (see errno). |
| int ip4_2_buf | ( | const char * | ip, |
| uint8_t | buf[static IP_ALEN] | ||
| ) |
IP string to buffer.
| ip | The IP address string | |
| [out] | buf | The output buffer of size IP_ALEN |
| int ip_2_nbo | ( | const char * | ip, |
| const char * | subnetMask, | ||
| in_addr_t * | addr | ||
| ) |
IP string to struct in_addr_t converter.
| ip | The IP address string | |
| subnetMask | The IP address subnet mask | |
| [out] | addr | The output struct in_addr_t value |
| bool validate_ipv4_string | ( | const char * | ip | ) |
Checks whether a string denotes a IPv4 address.
| ip | The IP in fromat x.y.z.q |