Group pj_ip_helper

group pj_ip_helper

This module provides functions to query local host’s IP interface and routing table.

Functions

void pj_enum_ip_option_default(pj_enum_ip_option *opt)

Get default values of IP enumeration option.

Parameters:

opt – The IP enumeration option.

pj_status_t pj_enum_ip_interface(int af, unsigned *count, pj_sockaddr ifs[])

Enumerate the local IP interfaces currently active in the host.

Parameters:
  • af – Family of the address to be retrieved. Application may specify pj_AF_UNSPEC() to retrieve all addresses, or pj_AF_INET() or pj_AF_INET6() to retrieve interfaces with specific address family.

  • count – On input, specify the number of entries. On output, it will be filled with the actual number of entries.

  • ifs – Array of socket addresses, which address part will be filled with the interface address. The address family part will be initialized with the address family of the IP address.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pj_enum_ip_interface2(const pj_enum_ip_option *opt, unsigned *count, pj_sockaddr ifs[])

Enumerate the local IP interfaces currently active in the host with capability to filter DEPRECATED IPv6 addresses (currently only for Linux).

Parameters:
  • opt – The option, default option will be used if NULL.

  • count – On input, specify the number of entries. On output, it will be filled with the actual number of entries.

  • ifs – Array of socket (with flags) addresses, which address part will be filled with the interface address. The address family part will be initialized with the address family of the IP address.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pj_enum_ip_route(unsigned *count, pj_ip_route_entry routes[])

Enumerate the IP routing table for this host.

Parameters:
  • count – On input, specify the number of routes entries. On output, it will be filled with the actual number of route entries.

  • routes – Array of IP routing entries.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

union pj_ip_route_entry
#include <ip_helper.h>

This structure describes IP routing entry.

Public Members

pj_in_addr if_addr

Local interface IP address.

pj_in_addr dst_addr

Destination IP address.

pj_in_addr mask

Destination mask.

struct pj_ip_route_entry::[anonymous] ipv4

IP routing entry for IP version 4 routing

struct pj_enum_ip_option
#include <ip_helper.h>

This structure describes options for pj_enum_ip_interface2().

Public Members

int af

Family of the address to be retrieved. Application may specify pj_AF_UNSPEC() to retrieve all addresses, or pj_AF_INET() or pj_AF_INET6() to retrieve interfaces with specific address family.

Default: pj_AF_UNSPEC().

pj_bool_t omit_deprecated_ipv6

IPv6 addresses can have a DEPRECATED flag, if this flag is set, any DEPRECATED IPv6 address will be omitted. Currently this is only available for Linux, on other platforms, if this flag is set, pj_enum_ip_interface2() will return PJ_ENOTSUP.

Default: PJ_FALSE.