lwpa  0.1.0
LightWeight Platform Abstraction (lwpa)
View other versions:
lwpa_netint

Overview

A platform-neutral method for enumerating network interfaces.

#include "lwpa_netint.h"

Functions

size_t netint_get_num_interfaces ()
 Get the number of network interfaces present on the system. More...
 
size_t netint_get_interfaces (LwpaNetintInfo *netint_arr, size_t netint_arr_size)
 Enumerate the network interfaces on the system. More...
 
bool netint_get_default_interface (LwpaNetintInfo *netint)
 Get information about the default network interface. More...
 
const LwpaNetintInfonetint_get_iface_for_dest (const LwpaIpAddr *dest, const LwpaNetintInfo *netint_arr, size_t netint_arr_size)
 Get the network interface that the system will choose when routing an IP packet to the specified destination. More...
 

Function Documentation

◆ netint_get_default_interface()

bool netint_get_default_interface ( LwpaNetintInfo netint)

Get information about the default network interface.

Note: If the network interfaces have already been enumerated with netint_get_interfaces(), it is more efficient to inspect the is_default flag of each interface in that existing array.

Parameters
[out]netintPointer to network interface description struct to fill with the information about the default interface.
Returns
true (netint was filled in) or false (error occurred).

◆ netint_get_iface_for_dest()

const LwpaNetintInfo* netint_get_iface_for_dest ( const LwpaIpAddr dest,
const LwpaNetintInfo netint_arr,
size_t  netint_arr_size 
)

Get the network interface that the system will choose when routing an IP packet to the specified destination.

Parameters
[in]destIP address of the destination.
[in]netint_arrArray of network interface description structs previously populated using netint_get_interfaces().
[in]netint_arr_sizeSize of the netint array.
Returns
Pointer to info struct for interface that will be chosen for this destination. This will be a pointer to an element in the netint_arr, or NULL if the route could not be resolved (this will only occur if there is no default interface marked in the array).

◆ netint_get_interfaces()

size_t netint_get_interfaces ( LwpaNetintInfo netint_arr,
size_t  netint_arr_size 
)

Enumerate the network interfaces on the system.

Parameters
[out]netint_arrArray of network interface description structs to fill in with interface info.
[in]netint_arr_sizeSize of the netint array.
Returns
Number of network interfaces that were enumerated, up to a maximum of netint_arr_size, or 0 if there are no interfaces present or an error occurred.

◆ netint_get_num_interfaces()

size_t netint_get_num_interfaces ( )

Get the number of network interfaces present on the system.

Returns
Number of interfaces present.