libnice Reference Manual | ||||
---|---|---|---|---|
#define NICE_ADDRESS_STRING_LEN NiceAddress; void nice_address_init (NiceAddress *addr); NiceAddress* nice_address_new (void); void nice_address_free (NiceAddress *addr); NiceAddress* nice_address_dup (const NiceAddress *addr); void nice_address_set_ipv4 (NiceAddress *addr, guint32 addr_ipv4); void nice_address_set_ipv6 (NiceAddress *addr, const guchar *addr_ipv6); void nice_address_set_port (NiceAddress *addr, guint port); guint nice_address_get_port (const NiceAddress *addr); gboolean nice_address_set_from_string (NiceAddress *addr, const gchar *str); void nice_address_set_from_sockaddr (NiceAddress *addr, const struct sockaddr *sin); void nice_address_copy_to_sockaddr (const NiceAddress *addr, struct sockaddr *sin); gboolean nice_address_equal (const NiceAddress *a, const NiceAddress *b); void nice_address_to_string (const NiceAddress *addr, gchar *dst); gboolean nice_address_is_private (const NiceAddress *addr); gboolean nice_address_is_valid (const NiceAddress *addr);
The NiceAddress structure will allow you to easily set/get and modify an IPv4 or IPv6 address in order to communicate with the NiceAgent.
#define NICE_ADDRESS_STRING_LEN INET6_ADDRSTRLEN
The maximum string length representation of an address.
When using nice_address_to_string()
make sure the string has a size of
at least NICE_ADDRESS_STRING_LEN
typedef struct { union { struct sockaddr addr; struct sockaddr_in ip4; struct sockaddr_in6 ip6; } s; } NiceAddress;
The NiceAddress structure that represents an IPv4 or IPv6 address.
void nice_address_init (NiceAddress *addr);
Initialize a NiceAddress into an undefined address
addr : |
The NiceAddress to init |
NiceAddress* nice_address_new (void);
Create a new NiceAddress with undefined address
You must free it with nice_address_free()
Returns : | The new NiceAddress |
void nice_address_free (NiceAddress *addr);
Frees a NiceAddress created with nice_address_new()
or nice_address_dup()
addr : |
The NiceAddress to free |
NiceAddress* nice_address_dup (const NiceAddress *addr);
Creates a new NiceAddress with the same address as addr
addr : |
The NiceAddress to dup |
Returns : | The new NiceAddress |
void nice_address_set_ipv4 (NiceAddress *addr, guint32 addr_ipv4);
Set addr
to an IPv4 address using the data from addr_ipv4
This function will reset the port to 0, so make sure you call it before
nice_address_set_port()
addr : |
The NiceAddress to modify |
addr_ipv4 : |
The IPv4 address |
void nice_address_set_ipv6 (NiceAddress *addr, const guchar *addr_ipv6);
Set addr
to an IPv6 address using the data from addr_ipv6
This function will reset the port to 0, so make sure you call it before
nice_address_set_port()
addr : |
The NiceAddress to modify |
addr_ipv6 : |
The IPv6 address |
void nice_address_set_port (NiceAddress *addr, guint port);
Set the port of addr
to port
addr : |
The NiceAddress to modify |
port : |
The port to set |
guint nice_address_get_port (const NiceAddress *addr);
Retreive the port of addr
addr : |
The NiceAddress to query |
Returns : | The port of addr
|
gboolean nice_address_set_from_string (NiceAddress *addr, const gchar *str);
Sets an IPv4 or IPv6 address from the string str
addr : |
The NiceAddress to modify |
str : |
The string to set |
Returns : | TRUE if success, FALSE on error
|
void nice_address_set_from_sockaddr (NiceAddress *addr, const struct sockaddr *sin);
Sets an IPv4 or IPv6 address from the sockaddr structure sin
addr : |
The NiceAddress to modify |
sin : |
The sockaddr to set |
void nice_address_copy_to_sockaddr (const NiceAddress *addr, struct sockaddr *sin);
Fills the sockaddr structure sin
with the address contained in addr
addr : |
The NiceAddress to query |
sin : |
The sockaddr to fill |
gboolean nice_address_equal (const NiceAddress *a, const NiceAddress *b);
Compares two NiceAddress structures to see if they contain the same address
a : |
First NiceAddress to compare |
b : |
Second NiceAddress to compare |
Returns : | TRUE if a and b are the same address, FALSE if they are different
|
void nice_address_to_string (const NiceAddress *addr, gchar *dst);
Transforms the address addr
into a human readable string
addr : |
The NiceAddress to query |
dst : |
The string to fill |
gboolean nice_address_is_private (const NiceAddress *addr);
Verifies if the address in addr
is a private address or not
addr : |
The NiceAddress to query |
Returns : | TRUE if addr is a private address, FALSE otherwise
|
gboolean nice_address_is_valid (const NiceAddress *addr);
Validate whether the NiceAddress addr
is a valid IPv4 or IPv6 address
addr : |
The NiceAddress to query |
Returns : | TRUE if addr is valid, FALSE otherwise
|