bglibs: ipv4: IPv4 Address Handling

bglibs

Data Structures | Typedefs | Functions | Variables
ipv4: IPv4 Address Handling

## Data Structures
struct | ipv4addr

## Typedefs
typedef uint16 | ipv4port

## Functions
int | ipv4_parse (const char *s, ipv4addr *addr, const char **end) __DEPRECATED__
const char * | ipv4_scan (const char *s, ipv4addr *addr)
const char * | ipv4_format (const ipv4addr *addr)
const char * | ipv4_format_reverse (const ipv4addr *addr)
unsigned | fmt_ipv4addr (char *buffer, const ipv4addr *addr)
unsigned | fmt_ipv4addr_reverse (char *buffer, const ipv4addr *addr)

## Variables
const ipv4addr | IPV4ADDR_ANY
const ipv4addr | IPV4ADDR_BROADCAST
const ipv4addr | IPV4ADDR_LOOPBACK

## Detailed Description

## Typedef Documentation

## ◆ ipv4port

typedef uint16 ipv4port

IPv4 port number.

## Function Documentation

## ◆ fmt_ipv4addr()

unsigned fmt_ipv4addr | ( | char * | buffer,
|  | const ipv4addr * | addr
| ) |  |

Produce a formatted string from an IPv4 address.

The given buffer must be at least 15 bytes long, or 16 bytes if it needs to contain the standard trailing `NUL` byte.

Returns
  The number of bytes written to the buffer.

Note
  This routine is thread and recursion safe.

References ipv4addr::addr.

Referenced by fmt_ipv4addr_reverse(), and ipv4_format().

## ◆ fmt_ipv4addr_reverse()

unsigned fmt_ipv4addr_reverse | ( | char * | buffer,
|  | const ipv4addr * | addr
| ) |  |

Produce a reverse-formatted string from an IPv4 address.

The given buffer must be at least 15 bytes long, or 16 bytes if it needs to contain the standard trailing `NUL` byte.

Returns
  The number of bytes written to the buffer.

Note
  This routine is thread and recursion safe.

References ipv4addr::addr, fmt_ipv4addr(), IPV4ADDR_ANY, IPV4ADDR_BROADCAST, IPV4ADDR_LOOPBACK, obuf_putsflush(), and outbuf.

Referenced by ipv4_format_reverse().

## ◆ ipv4_format()

const char* ipv4_format | ( | const ipv4addr * | addr | ) |

Produce a formatted C string from an IPv4 address.

Note
  The return value is statically allocated. Multiple calls to this function will return pointers to the same string.

References fmt_ipv4addr().

Referenced by dns_ip4_r(), dns_name4_r(), dns_resolvconfip(), resolve_ipv4addr(), and resolve_ipv4name_n().

## ◆ ipv4_format_reverse()

const char* ipv4_format_reverse | ( | const ipv4addr * | addr | ) |

Produce a reverse-formatted C string from an IPv4 address.

Note
  The return value is statically allocated. Multiple calls to this function will return pointers to the same string.

References fmt_ipv4addr_reverse().

## ◆ ipv4_parse()

int ipv4_parse | ( | const char * | start,
|  | ipv4addr * | addr,
|  | const char ** | end
| ) |  |

Parse an IPv4 address.

Deprecated:
  This function is a wrapper for `ipv4_scan`.

Returns
  Non-zero (true) if parsing succeeded, and sets `*end` to the first character past the end of the address.

References ipv4addr::addr, ipv4_scan(), obuf_flush(), obuf_put2s(), obuf_putc(), obuf_puti(), obuf_puts, and outbuf.

## ◆ ipv4_scan()

const char* ipv4_scan | ( | const char * | start,
|  | ipv4addr * | addr
| ) |  |

Scan a C string for an IPv4 address.

Returns
  `NULL` if parsing failed, otherwise a pointer to the first character after the end of the address.

References ipv4addr::addr.

Referenced by dns_ip4_r(), dns_ip6_r(), dns_read_resolvconf(), ipv4_parse(), and ipv6_scan().

## Variable Documentation

## ◆ IPV4ADDR_ANY

const ipv4addr IPV4ADDR_ANY

IPv4 "any" address constant.

Referenced by fmt_ipv4addr_reverse(), and socket_connect4().

## ◆ IPV4ADDR_BROADCAST

const ipv4addr IPV4ADDR_BROADCAST

IPv4 broadcast address constant.

Referenced by fmt_ipv4addr_reverse().

## ◆ IPV4ADDR_LOOPBACK

const ipv4addr IPV4ADDR_LOOPBACK

IPv4 loopback address constant.

Referenced by fmt_ipv4addr_reverse(), and socket_connect4().