s/qmail  3.3.23
Next generation secure email transport
Data Structures | Macros | Functions
ip.h File Reference
#include "uint32.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  ip_address
 
struct  ip6_address
 

Macros

#define IPFMT   40
 
#define V4MAPPREFIX   "::ffff:"
 
#define HOSTNAMELEN   1025
 

Functions

unsigned int ip4_fmt (char *, struct ip_address *)
 ip4_fmt converts IPv4 address to dotted decimal string format More...
 
unsigned int ip4_scan (struct ip_address *, char *)
 ip4_scan parse IPv4 address string and convert to ip_address More...
 
unsigned int ip4_scanbracket (struct ip_address *, char *)
 ip4_scanbracket parse IPv4 address string enclosed in brackets and convert to ip_address struct More...
 
unsigned int ip4_bitstring (stralloc *, struct ip_address *, int)
 ip4_bitstring parse IPv4 address and represent as char string with length prefix More...
 
unsigned int ip6_fmt (char *, struct ip6_address *)
 ip6_fmt convert IPv6 address to compactified IPv6 address string More...
 
unsigned int ip6_scan (struct ip6_address *, char *)
 ip6_scan parse compactified IPv6 address string and convert to ip6_address struct More...
 
unsigned int ip6_scanbracket (struct ip6_address *, char *)
 ip6_scanbracket parse IPv6 string address enclosed in brackets More...
 
unsigned int ip6_bitstring (stralloc *, struct ip6_address *, int)
 ip6_bitstring parse IPv6 address and represent as char string with length prefix More...
 

Macro Definition Documentation

◆ HOSTNAMELEN

#define HOSTNAMELEN   1025

Definition at line 9 of file ip.h.

◆ IPFMT

#define IPFMT   40

Definition at line 7 of file ip.h.

◆ V4MAPPREFIX

#define V4MAPPREFIX   "::ffff:"

Definition at line 8 of file ip.h.

Function Documentation

◆ ip4_bitstring()

unsigned int ip4_bitstring ( stralloc *  ip4string,
struct ip_address ip4,
int  prefix 
)

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

Parameters
inputpointer to struct IPv4 address, prefix length output: pointer to stralloc bitstring
Returns
0, if ok; 1, memory shortage; 2, input error

Definition at line 293 of file ip.c.

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

◆ ip4_fmt()

unsigned int ip4_fmt ( char *  s,
struct ip_address ip 
)

ip4_fmt converts IPv4 address to dotted decimal string format

Parameters
inputpointer to IPv4 ip_address struct output: pointer to IPv4 address string
Returns
int length of address (ok > 0)

Definition at line 23 of file ip.c.

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

◆ ip4_scan()

unsigned int ip4_scan ( struct ip_address ip,
char *  s 
)

ip4_scan parse IPv4 address string and convert to ip_address

Parameters
inputpointer to IPv4 address string output: pointer to IPv4 ip_address struct
Returns
int lenth of ip_address (ok > 0)

Definition at line 47 of file ip.c.

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

◆ ip4_scanbracket()

unsigned int ip4_scanbracket ( struct ip_address ip,
char *  s 
)

ip4_scanbracket parse IPv4 address string enclosed in brackets and convert to ip_address struct

Parameters
inputpointer to IPv4 address string output: pointer to IPv4 ip_address struct
Returns
int lenth of ip_address (ok > 0)

Definition at line 72 of file ip.c.

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

◆ ip6_bitstring()

unsigned int ip6_bitstring ( stralloc *  ip6string,
struct ip6_address ip6,
int  prefix 
)

ip6_bitstring parse IPv6 address and represent as char string with length prefix

Parameters
inputpointer to struct IPv6 address, prefix length output: pointer to stralloc bit string;
Returns
0, if ok; 1, memory shortage

Definition at line 332 of file ip.c.

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

◆ ip6_fmt()

unsigned int ip6_fmt ( char *  s,
struct ip6_address ip 
)

ip6_fmt convert IPv6 address to compactified IPv6 address string

Compactified IPv6 addresses are really ugly to parse. Syntax: (h = hex digit) [RFC 5952]

  1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
  2. leading 0s in any octet can be suppressed
  3. any number of 0000 may be abbreviated as "::" a) but only once; b) the longest piece or on equal match the first piece, c) a single instance of 0000 as to displayed as 0
  4. The last two words may be written as IPv4 address

Flat ip6 address syntax: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh (32 hex digits)

struct ip6_address format: cccccccccccccccc (16 chars; d[16]) – each char swallows two hex values

Bitstring representation with length prefix: bbbbbbb.........bbbb (max 128 bits); stralloc(ip6string); b = 0 || 1

Parameters
inputpointer to IPv6 ip6_address struct output: pointer to IPv6 address string
Returns
int length of address (ok > 0)

Definition at line 91 of file ip.c.

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

◆ ip6_scan()

unsigned int ip6_scan ( struct ip6_address ip,
char *  s 
)

ip6_scan parse compactified IPv6 address string and convert to ip6_address struct

Parameters
inputpointer to IPv6 address string output: pointer to ip6_address struct
Returns
int length of ip6_address/ip

Definition at line 160 of file ip.c.

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

◆ ip6_scanbracket()

unsigned int ip6_scanbracket ( struct ip6_address ip6,
char *  s 
)

ip6_scanbracket parse IPv6 string address enclosed in brackets

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

Definition at line 264 of file ip.c.

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