Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Classes | Macros | Functions | Variables
ip_address.h File Reference

IP address type. More...

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "types.h"
Include dependency graph for ip_address.h:

Go to the source code of this file.

Classes

union  ip_address_t
 
struct  ip_prefix_t
 

Macros

#define bytes_to_bits(x)   (x * 8)
 
#define IPV6_ADDR_LEN   16 /* bytes */
 
#define IPV4_ADDR_LEN   4 /* bytes */
 
#define IPV6_ADDR_LEN_BITS   bytes_to_bits(IPV6_ADDR_LEN)
 
#define IPV4_ADDR_LEN_BITS   bytes_to_bits(IPV4_ADDR_LEN)
 
#define INET_ADDRSTRLEN   16
 
#define INET6_ADDRSTRLEN   46
 
#define IP_MAX_ADDR_LEN   IPV6_ADDR_LEN
 
#define DUMMY_PORT   1234
 
#define MAXSZ_IP4_ADDRESS_   INET_ADDRSTRLEN - 1
 
#define MAXSZ_IP6_ADDRESS_   INET6_ADDRSTRLEN - 1
 
#define MAXSZ_IP_ADDRESS_   MAXSZ_IP6_ADDRESS_
 
#define MAXSZ_IP4_ADDRESS   MAXSZ_IP4_ADDRESS_ + 1
 
#define MAXSZ_IP6_ADDRESS   MAXSZ_IP6_ADDRESS_ + 1
 
#define MAXSZ_IP_ADDRESS   MAXSZ_IP_ADDRESS_ + 1
 
#define MAXSZ_PREFIX_   MAXSZ_IP_ADDRESS_ + 1 + 3
 
#define MAXSZ_PREFIX   MAXSZ_PREFIX_ + 1
 
#define IP_ANY(family)   (family == AF_INET) ? IPV4_ANY : IPV6_ANY
 
#define MAX_PORT   1 << (8 * sizeof(u16))
 
#define IS_VALID_PORT(x)   ((x > 0) && ((int)x < MAX_PORT))
 
#define MAXSZ_PORT_   5
 
#define MAXSZ_PORT   MAXSZ_PORT_ + 1
 
#define IS_VALID_FAMILY(x)   ((x == AF_INET) || (x == AF_INET6))
 
#define MAXSZ_PROTO_   8 /* inetX:// */
 
#define MAXSZ_PROTO   MAXSZ_PROTO_ + NULLTERM
 
#define MAXSZ_URL4_   MAXSZ_PROTO_ + MAXSZ_IP4_ADDRESS_ + MAXSZ_PORT_
 
#define MAXSZ_URL6_   MAXSZ_PROTO_ + MAXSZ_IP6_ADDRESS_ + MAXSZ_PORT_
 
#define MAXSZ_URL_   MAXSZ_URL6_
 
#define MAXSZ_URL4   MAXSZ_URL4_ + NULLTERM
 
#define MAXSZ_URL6   MAXSZ_URL6_ + NULLTERM
 
#define MAXSZ_URL   MAXSZ_URL_ + NULLTERM
 

Functions

int ip_address_get_family (const char *ip_address)
 
int ip_address_len (int family)
 
const u8 * ip_address_get_buffer (const ip_address_t *ip_address, int family)
 
int ip_address_ntop (const ip_address_t *ip_address, char *dst, const size_t len, int family)
 
int ip_address_pton (const char *ip_address_str, ip_address_t *ip_address)
 
int ip_address_snprintf (char *s, size_t size, const ip_address_t *ip_address, int family)
 
int ip_address_to_sockaddr (const ip_address_t *ip_address, struct sockaddr *sa, int family)
 
int ip_address_cmp (const ip_address_t *ip1, const ip_address_t *ip2, int family)
 
int ip_address_empty (const ip_address_t *ip)
 
int ip_prefix_pton (const char *ip_address_str, ip_prefix_t *ip_prefix)
 
int ip_prefix_ntop_short (const ip_prefix_t *ip_prefix, char *dst, size_t size)
 
int ip_prefix_ntop (const ip_prefix_t *ip_prefix, char *dst, size_t size)
 
int ip_prefix_len (const ip_prefix_t *prefix)
 
bool ip_prefix_empty (const ip_prefix_t *prefix)
 
int ip_prefix_to_sockaddr (const ip_prefix_t *prefix, struct sockaddr *sa)
 
int ip_prefix_cmp (const ip_prefix_t *prefix1, const ip_prefix_t *prefix2)
 
int url_snprintf (char *s, size_t size, int family, const ip_address_t *ip_address, u16 port)
 

Variables

const ip_address_t IPV4_LOOPBACK
 
const ip_address_t IPV6_LOOPBACK
 
const ip_address_t IPV4_ANY
 
const ip_address_t IPV6_ANY
 
const ip_address_t IP_ADDRESS_EMPTY
 

Detailed Description

IP address type.