Mstdlib-1.24.0
Network Interface Enumeration

Typedefs

typedef struct M_io_net_iface_ips M_io_net_iface_ips_t
 

Enumerations

enum  M_io_net_iface_ips_flags_t {
  M_NET_IFACE_IPS_FLAG_OFFLINE = 1 << 0 ,
  M_NET_IFACE_IPS_FLAG_LOOPBACK = 1 << 1 ,
  M_NET_IFACE_IPS_FLAG_IPV4 = 1 << 2 ,
  M_NET_IFACE_IPS_FLAG_IPV6 = 1 << 3
}
 

Functions

M_io_net_iface_ips_tM_io_net_iface_ips (int flags)
 
size_t M_io_net_iface_ips_count (M_io_net_iface_ips_t *ips)
 
const char * M_io_net_iface_ips_get_name (M_io_net_iface_ips_t *ips, size_t idx)
 
const char * M_io_net_iface_ips_get_addr (M_io_net_iface_ips_t *ips, size_t idx)
 
M_uint8 M_io_net_iface_ips_get_netmask (M_io_net_iface_ips_t *ips, size_t idx)
 
int M_io_net_iface_ips_get_flags (M_io_net_iface_ips_t *ips, size_t idx)
 
M_list_str_tM_io_net_iface_ips_get_ips (M_io_net_iface_ips_t *ips, int flags, const char *name)
 
M_list_str_tM_io_net_iface_ips_get_names (M_io_net_iface_ips_t *ips, int flags, const char *ipaddr)
 
void M_io_net_iface_ips_free (M_io_net_iface_ips_t *ips)
 
char * M_io_net_iface_ips_flags_to_str (int flags)
 

Detailed Description

Network Interface Enumeration

Typedef Documentation

◆ M_io_net_iface_ips_t

Enumeration Type Documentation

◆ M_io_net_iface_ips_flags_t

Enumerator
M_NET_IFACE_IPS_FLAG_OFFLINE 

Interface is currently offline. For enumeration, by default does not return offline interfaces without this flag.

M_NET_IFACE_IPS_FLAG_LOOPBACK 

Interface is loopback. For enumeration, by default, does not return addresses for loopback interfaces.

M_NET_IFACE_IPS_FLAG_IPV4 

Address is ipv4. For enumeration, only list interfaces and addresses containing ipv4 addresses.

M_NET_IFACE_IPS_FLAG_IPV6 

Address is ipv6. For enumeration, only list interfaces and addresses containing ipv6 addresses.

Function Documentation

◆ M_io_net_iface_ips()

M_io_net_iface_ips_t * M_io_net_iface_ips ( int  flags)

Query OS for network interfaces and ip addresses assigned to interfaces.

Parameters
[in]flagsM_io_net_iface_ips_flags_t flags or 0 for none
Returns
M_io_net_iface_ips_t * on success or NULL on failure. Must be free'd with M_io_net_iface_ips_free()

◆ M_io_net_iface_ips_count()

size_t M_io_net_iface_ips_count ( M_io_net_iface_ips_t ips)

Return count of all interfaces and ip addresses. Note that not all interfaces may contain ip addreses.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
Returns
count

◆ M_io_net_iface_ips_get_name()

const char * M_io_net_iface_ips_get_name ( M_io_net_iface_ips_t ips,
size_t  idx 
)

Return name of interface associated with specified index.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]idxIndex to query
Returns
NULL on failure otherwise a pointer to the name of the interface

◆ M_io_net_iface_ips_get_addr()

const char * M_io_net_iface_ips_get_addr ( M_io_net_iface_ips_t ips,
size_t  idx 
)

Return ip address of interface associated with specified index.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]idxIndex to query
Returns
NULL on failure (or even possibly if no ip address available for interface), otherwise a pointer to the name of the interface

◆ M_io_net_iface_ips_get_netmask()

M_uint8 M_io_net_iface_ips_get_netmask ( M_io_net_iface_ips_t ips,
size_t  idx 
)

Return the netmask for the ip address of interface associated with specified index.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]idxIndex to query
Returns
netmask, only relevant if there is an ip address

◆ M_io_net_iface_ips_get_flags()

int M_io_net_iface_ips_get_flags ( M_io_net_iface_ips_t ips,
size_t  idx 
)

Return flags on interface associated with specified index.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]idxIndex to query
Returns
flags associated with the interface

◆ M_io_net_iface_ips_get_ips()

M_list_str_t * M_io_net_iface_ips_get_ips ( M_io_net_iface_ips_t ips,
int  flags,
const char *  name 
)

Retrieve a list of ip addresses from the result set matching the query. Will only return ip addresses and not any flags or interface names.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]flagsMust specify at least M_NET_IFACE_IPS_FLAG_IPV4 or M_NET_IFACE_IPS_FLAG_IPV6.
[in]nameOnly enumerate for a specific interface name.
Returns
list of ip addresses matching query, NULL on no matches. Must be free'd with M_list_str_destroy().

◆ M_io_net_iface_ips_get_names()

M_list_str_t * M_io_net_iface_ips_get_names ( M_io_net_iface_ips_t ips,
int  flags,
const char *  ipaddr 
)

Retrieve a list of interfaces from the result set matching the query. Will only return interface names and not any flags or ip addresses.

Parameters
[in]ipsValue returned from M_io_net_iface_ips()
[in]flagsIf either M_NET_IFACE_IPS_FLAG_IPV4 or M_NET_IFACE_IPS_FLAG_IPV6 is specified, will exclude interfaces that don't have the specified address class.
[in]ipaddrOptional. Use NULL if not wanted. Search for interface containing specified IP address.
Returns
list of interface names matching query, NULL on no matches. Must be free'd with M_list_str_destroy().

◆ M_io_net_iface_ips_free()

void M_io_net_iface_ips_free ( M_io_net_iface_ips_t ips)

Free the ip address returned from M_io_net_iface_ips().

Parameters
[in]ipsValue returned from M_io_net_iface_ips()

◆ M_io_net_iface_ips_flags_to_str()

char * M_io_net_iface_ips_flags_to_str ( int  flags)

Given a set of flags, convert into human-readable form

Parameters
[in]flagsFlags to print
Returns
human readable string, must be M_free()'d.