avahi  0.7
address.h File Reference

Definitions and functions to manipulate IP addresses. More...

#include <inttypes.h>
#include <sys/types.h>
#include <avahi-common/cdecl.h>

Go to the source code of this file.

Data Structures

struct  AvahiIPv4Address
 An IPv4 address. More...
 
struct  AvahiIPv6Address
 An IPv6 address. More...
 
struct  AvahiAddress
 Protocol (address family) independent address structure. More...
 

Macros

#define AVAHI_ADDRESS_STR_MAX   40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */
 Maximum size of an address in string form. More...
 
#define AVAHI_IF_VALID(ifindex)   (((ifindex) >= 0) || ((ifindex) == AVAHI_IF_UNSPEC))
 Return TRUE if the specified interface index is valid. More...
 
#define AVAHI_PROTO_VALID(protocol)   (((protocol) == AVAHI_PROTO_INET) || ((protocol) == AVAHI_PROTO_INET6) || ((protocol) == AVAHI_PROTO_UNSPEC))
 Return TRUE if the specified protocol is valid. More...
 

Typedefs

typedef int AvahiProtocol
 Protocol family specification, takes the values AVAHI_PROTO_INET, AVAHI_PROTO_INET6, AVAHI_PROTO_UNSPEC. More...
 
typedef int AvahiIfIndex
 Numeric network interface index. More...
 
typedef struct AvahiIPv4Address AvahiIPv4Address
 An IPv4 address. More...
 
typedef struct AvahiIPv6Address AvahiIPv6Address
 An IPv6 address. More...
 
typedef struct AvahiAddress AvahiAddress
 Protocol (address family) independent address structure. More...
 

Enumerations

enum  {
  AVAHI_PROTO_INET = 0,
  AVAHI_PROTO_INET6 = 1,
  AVAHI_PROTO_UNSPEC = -1
}
 Values for AvahiProtocol. More...
 
enum  { AVAHI_IF_UNSPEC = -1 }
 Special values for AvahiIfIndex. More...
 

Functions

Comparison
int avahi_address_cmp (const AvahiAddress *a, const AvahiAddress *b)
 Compare two addresses. More...
 
String conversion
char * avahi_address_snprint (char *ret_s, size_t length, const AvahiAddress *a)
 Convert the specified address *a to a human readable character string, use AVAHI_ADDRESS_STR_MAX to allocate an array of the right size. More...
 
AvahiAddressavahi_address_parse (const char *s, AvahiProtocol af, AvahiAddress *ret_addr)
 Convert the specified human readable character string to an address structure. More...
 
Protocol/address family handling
int avahi_proto_to_af (AvahiProtocol proto)
 Map AVAHI_PROTO_xxx constants to Unix AF_xxx constants. More...
 
AvahiProtocol avahi_af_to_proto (int af)
 Map Unix AF_xxx constants to AVAHI_PROTO_xxx constants. More...
 
const char * avahi_proto_to_string (AvahiProtocol proto)
 Return a textual representation of the specified protocol number. More...
 

Detailed Description

Definitions and functions to manipulate IP addresses.

Definition in file address.h.

Macro Definition Documentation

◆ AVAHI_ADDRESS_STR_MAX

#define AVAHI_ADDRESS_STR_MAX   40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */

Maximum size of an address in string form.

Examples:
client-browse-services.c.

Definition at line 51 of file address.h.

◆ AVAHI_IF_VALID

#define AVAHI_IF_VALID (   ifindex)    (((ifindex) >= 0) || ((ifindex) == AVAHI_IF_UNSPEC))

Return TRUE if the specified interface index is valid.

Definition at line 54 of file address.h.

◆ AVAHI_PROTO_VALID

#define AVAHI_PROTO_VALID (   protocol)    (((protocol) == AVAHI_PROTO_INET) || ((protocol) == AVAHI_PROTO_INET6) || ((protocol) == AVAHI_PROTO_UNSPEC))

Return TRUE if the specified protocol is valid.

Definition at line 57 of file address.h.

Typedef Documentation

◆ AvahiAddress

typedef struct AvahiAddress AvahiAddress

Protocol (address family) independent address structure.

◆ AvahiIfIndex

typedef int AvahiIfIndex

Numeric network interface index.

Takes OS dependent values and the special constant AVAHI_IF_UNSPEC

Definition at line 36 of file address.h.

◆ AvahiIPv4Address

An IPv4 address.

◆ AvahiIPv6Address

An IPv6 address.

◆ AvahiProtocol

typedef int AvahiProtocol

Protocol family specification, takes the values AVAHI_PROTO_INET, AVAHI_PROTO_INET6, AVAHI_PROTO_UNSPEC.

Definition at line 33 of file address.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Values for AvahiProtocol.

Enumerator
AVAHI_PROTO_INET 

IPv4.

AVAHI_PROTO_INET6 

IPv6.

AVAHI_PROTO_UNSPEC 

Unspecified/all protocol(s)

Definition at line 39 of file address.h.

◆ anonymous enum

anonymous enum

Special values for AvahiIfIndex.

Enumerator
AVAHI_IF_UNSPEC 

Unspecified/all interface(s)

Definition at line 46 of file address.h.

Function Documentation

◆ avahi_address_cmp()

int avahi_address_cmp ( const AvahiAddress a,
const AvahiAddress b 
)

Compare two addresses.

Returns 0 when equal, a negative value when a < b, a positive value when a > b.

◆ avahi_address_parse()

AvahiAddress* avahi_address_parse ( const char *  s,
AvahiProtocol  af,
AvahiAddress ret_addr 
)

Convert the specified human readable character string to an address structure.

Set af to AVAHI_UNSPEC for automatic address family detection.

◆ avahi_address_snprint()

char* avahi_address_snprint ( char *  ret_s,
size_t  length,
const AvahiAddress a 
)

Convert the specified address *a to a human readable character string, use AVAHI_ADDRESS_STR_MAX to allocate an array of the right size.

Examples:
client-browse-services.c.

◆ avahi_af_to_proto()

AvahiProtocol avahi_af_to_proto ( int  af)

Map Unix AF_xxx constants to AVAHI_PROTO_xxx constants.

◆ avahi_proto_to_af()

int avahi_proto_to_af ( AvahiProtocol  proto)

Map AVAHI_PROTO_xxx constants to Unix AF_xxx constants.

◆ avahi_proto_to_string()

const char* avahi_proto_to_string ( AvahiProtocol  proto)

Return a textual representation of the specified protocol number.

i.e. "IPv4", "IPv6" or "UNSPEC"