fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
ip.h File Reference
#include "byte.h"
#include "stralloc.h"
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ip4_address
 
struct  ip6_address
 

Macros

#define V4MAPPREFIX   "::ffff:"
 
#define HOSTNAMELEN   1025
 
#define IP4MLMTU   512
 
#define IP6MLMTU   1280 /* RFC 8200 */
 
#define MTUSIZE   IP6MLMTU
 
#define IP4_FMT   20 /* backwards compatibility */
 
#define IP6_FMT   40 /* " */
 
#define IPFMT   72 /* used in qmail-remote only (temp?) */
 
#define FMT_IP4   IP4_FMT /* more backwards compatibility */
 
#define FMT_IP6   IP6_FMT /* " */
 
#define ip_address   ip4_address /* backward compatibility */
 
#define V6any   V6localnet /* backward compatibility */
 
#define ip6_isv4mapped(ip)   (byte_equal(ip,12,V4mappedprefix))
 

Functions

unsigned int ip4_bytestring (stralloc *, char[4], int)
 ip4_bytestring parse IPv4 address and represent as char string with length prefix
 
unsigned int ip4_cidr (char *, char[4], unsigned long *)
 ip4_cidr parse IPv4 address string concatinated with the prefix length: 192.168.1/24
 
unsigned int ip4_fmt (char *, char[4])
 ip4_fmt converts IPv4 address to dotted decimal string format
 
unsigned int ip4_scan (const char *, char[4])
 ip4_scan parse IPv4 address string and convert to IP address array
 
unsigned int ip4_scanbracket (const char *, char[4])
 ip4_scanbracket parse IPv4 address string enclosed in brackets and convert to IP address array
 
unsigned int ia4_fmt (char *, char[4])
 ia4_fmt converts IPv4 address into DNS inverse nibble format
 
unsigned int ip6_bytestring (stralloc *, char *, int)
 
unsigned int ip6_cidr (char *, char[16], unsigned long *)
 ip6_cidr parse compactified IPv6 address string concatinated with the prefix length: fe80::1/64
 
unsigned int ip6_fmt (char *, char[16])
 ip6_fmt convert IPv6 address to compactified IPv6 address string
 
unsigned int ip6_fmt_flat (char *, char[16])
 ip6_fmt_flat convert IPv6 address to IPv6 address string
 
unsigned int ip6_ifscan (char *, char[16], stralloc *)
 ip6_ifscan parse compactified IPv6 address string concatinated with the interface name: fe80::1eth0
 
unsigned int ip6_scan (const char *, char[16])
 ip6_scan parse compactified IPv6 address string and convert to IPv6 address array
 
unsigned int ip6_scanbracket (const char *, char[16])
 ip6_scanbracket parse IPv6 string address enclosed in brackets
 
unsigned int ip6_scan_flat (const char *, char[16])
 ip6_scan_flat convert IPv6 address string to IPv6 address array
 
unsigned int ia6_fmt (char *, char[16])
 ia6_fmt convert IPv6 address to inverse DNS nibble format 1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.ip6.arpa
 
int fromhex (unsigned char)
 
char tohex (char)
 

Macro Definition Documentation

◆ FMT_IP4

#define FMT_IP4   IP4_FMT /* more backwards compatibility */

Definition at line 44 of file ip.h.

◆ FMT_IP6

#define FMT_IP6   IP6_FMT /* " */

Definition at line 45 of file ip.h.

◆ HOSTNAMELEN

#define HOSTNAMELEN   1025

Definition at line 32 of file ip.h.

◆ IP4_FMT

#define IP4_FMT   20 /* backwards compatibility */

Definition at line 37 of file ip.h.

◆ IP4MLMTU

#define IP4MLMTU   512

Definition at line 33 of file ip.h.

◆ IP6_FMT

#define IP6_FMT   40 /* " */

Definition at line 38 of file ip.h.

◆ ip6_isv4mapped

#define ip6_isv4mapped (   ip)    (byte_equal(ip,12,V4mappedprefix))

Definition at line 105 of file ip.h.

◆ IP6MLMTU

#define IP6MLMTU   1280 /* RFC 8200 */

Definition at line 34 of file ip.h.

◆ ip_address

#define ip_address   ip4_address /* backward compatibility */

Definition at line 50 of file ip.h.

◆ IPFMT

#define IPFMT   72 /* used in qmail-remote only (temp?) */

Definition at line 39 of file ip.h.

◆ MTUSIZE

#define MTUSIZE   IP6MLMTU

Definition at line 35 of file ip.h.

◆ V4MAPPREFIX

#define V4MAPPREFIX   "::ffff:"

Definition at line 31 of file ip.h.

◆ V6any

#define V6any   V6localnet /* backward compatibility */

Definition at line 104 of file ip.h.

Function Documentation

◆ fromhex()

int fromhex ( unsigned char  c)

Definition at line 79 of file fmt.c.

◆ ia4_fmt()

unsigned int ia4_fmt ( char *  s,
char  ip[4] 
)

ia4_fmt converts IPv4 address into DNS inverse nibble format

Parameters
inputIPv4 char array output: IPv4 address string
Returns
int length of address (ok > 0)

Definition at line 43 of file ip4.c.

Here is the call graph for this function:

◆ ia6_fmt()

unsigned int ia6_fmt ( char *  s,
char  ip[16] 
)

ia6_fmt convert IPv6 address to inverse DNS nibble format 1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.ip6.arpa

Parameters
inputIPv6 char array output: pointer to IPv6 address string
Returns
int length of address

Definition at line 102 of file ip6.c.

Here is the call graph for this function:

◆ ip4_bytestring()

unsigned int ip4_bytestring ( stralloc ipstring,
char  ip[4],
int  prefix 
)

ip4_bytestring parse IPv4 address and represent as char string with length prefix

Parameters
inputIPv4 char array, prefix length output: pointer to stralloc bytestring
Returns
n: number of bytes, if ok; -1: memory shortage; -2: input error

Definition at line 131 of file ip4.c.

Here is the call graph for this function:

◆ ip4_cidr()

unsigned int ip4_cidr ( char *  s,
char  ip[4],
unsigned long *  plen 
)

ip4_cidr parse IPv4 address string concatinated with the prefix length: 192.168.1/24

Parameters
inputIPv6 char array output: IPv6 char array, long plen
Returns
int length of ip6_address/ip

Definition at line 111 of file ip4.c.

Here is the call graph for this function:

◆ ip4_fmt()

unsigned int ip4_fmt ( char *  s,
char  ip[4] 
)

ip4_fmt converts IPv4 address to dotted decimal string format

Parameters
inputIPv4 char array output: IPv4 address string
Returns
int length of address (ok > 0)

Definition at line 20 of file ip4.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip4_scan()

unsigned int ip4_scan ( const char *  s,
char  ip[4] 
)

ip4_scan parse IPv4 address string and convert to IP address array

Parameters
inputIPv4 address string output: IPv4 char array
Returns
int length of ip_address (ok > 0)

Definition at line 67 of file ip4.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip4_scanbracket()

unsigned int ip4_scanbracket ( const char *  s,
char  ip[4] 
)

ip4_scanbracket parse IPv4 address string enclosed in brackets and convert to IP address array

Parameters
inputIPv4 char array output: IPv4 char array
Returns
int length of ip_address (ok > 0)

Definition at line 92 of file ip4.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip6_bytestring()

unsigned int ip6_bytestring ( stralloc ,
char *  ,
int   
)

◆ ip6_cidr()

unsigned int ip6_cidr ( char *  s,
char  ip[16],
unsigned long *  plen 
)

ip6_cidr parse compactified IPv6 address string concatinated with the prefix length: fe80::1/64

Parameters
inputpointer to IPv6 address string output: IPv6 char array, long plen
Returns
int length of ip6_address/ip

Definition at line 290 of file ip6.c.

Here is the call graph for this function:

◆ ip6_fmt()

unsigned int ip6_fmt ( char *  s,
char  ip[16] 
)

ip6_fmt convert IPv6 address to compactified IPv6 address string

Parameters
inputIPv6 char array output: pointer to IPv6 address string
Returns
int length of address (ok > 0)

Definition at line 21 of file ip6.c.

Here is the call graph for this function:

◆ ip6_fmt_flat()

unsigned int ip6_fmt_flat ( char *  s,
char  ip[16] 
)

ip6_fmt_flat convert IPv6 address to IPv6 address string

Parameters
inputIPv6 char array output: pointer to IPv6 address string
Returns
int length of address (ok > 0)

Definition at line 84 of file ip6.c.

Here is the call graph for this function:

◆ ip6_ifscan()

unsigned int ip6_ifscan ( char *  s,
char  ip[16],
stralloc ifname 
)

ip6_ifscan parse compactified IPv6 address string concatinated with the interface name: fe80::1eth0

Parameters
inputpointer to IPv6 address string output: IPv6 char array, stralloc interface_name
Returns
int length of ip6_address/ip

Definition at line 262 of file ip6.c.

Here is the call graph for this function:

◆ ip6_scan()

unsigned int ip6_scan ( const char *  s,
char  ip[16] 
)

ip6_scan parse compactified IPv6 address string and convert to IPv6 address array

Parameters
inputpointer to IPv6 address string output: IPv6 char array
Returns
int length of ip6_address/ip

Definition at line 151 of file ip6.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip6_scan_flat()

unsigned int ip6_scan_flat ( const char *  s,
char  ip[16] 
)

ip6_scan_flat convert IPv6 address string to IPv6 address array

Parameters
inputpointer to IPv6 address string output: IPv6 char array
Returns
int length of address (ok > 0)

Definition at line 129 of file ip6.c.

Here is the call graph for this function:

◆ ip6_scanbracket()

unsigned int ip6_scanbracket ( const char *  s,
char  ip[16] 
)

ip6_scanbracket parse IPv6 string address enclosed in brackets

Parameters
inputpointer to IPv6 address string output: IPv6 char array
Returns
int length of ip_address (ok > 0)

Definition at line 243 of file ip6.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tohex()

char tohex ( char  num)

Definition at line 70 of file fmt.c.

Here is the caller graph for this function: