|
Eris Linux A.P.I. 0.1
API to access Eris Linux system from a custom container
|
Functions to setup network. More...
Functions | |
| int | eris_get_list_of_network_interfaces (char *buffer, size_t size) |
| Get a list of network interfaces. | |
| int | eris_get_network_interface_status (const char *interface, char *buffer, size_t size) |
| Get the status of a network interface. | |
| int | eris_set_network_interface_status (const char *interface, const char *status) |
| Activate or disactivate a network interface. | |
| int | eris_get_network_interface_config (const char *interface, char *buffer, size_t size) |
| Get the configuration of a network interface. | |
| int | eris_set_network_interface_config (const char *interface, const char *autoconf, const char *mode, const char *ip, const char *address, const char *netmask, const char *gateway) |
| Set the configuration of a network interface. | |
| int | eris_get_nameserver_address (char *buffer, size_t size) |
| Get the IP address of the Domain Name Server. | |
| int | eris_is_network_interface_wireless (const char *interface) |
| Indicate whether a network interface is wireless or not. | |
| int | eris_scan_wifi (const char *interface, char *buffer, size_t size) |
| Scan the available Wifi access points. | |
| int | eris_connect_wifi (const char *interface, const char *ssid, const char *password) |
| Connect to a Wifi access point. | |
| int | eris_disconnect_wifi (void) |
| Disconnect to any Wifi access points. | |
| int | eris_get_wifi_quality (const char *interface, char *buffer, size_t size) |
| Get the Wifi connection quality. | |
Functions to setup network.
| int eris_connect_wifi | ( | const char * | interface, |
| const char * | ssid, | ||
| const char * | password ) |
Connect to a Wifi access point.
| interface | The name of the interface. |
| ssid | The identifier of the access point. |
| password | The passphrase to use to connect. |
| int eris_disconnect_wifi | ( | void | ) |
Disconnect to any Wifi access points.
| int eris_get_list_of_network_interfaces | ( | char * | buffer, |
| size_t | size ) |
Get a list of network interfaces.
| buffer | The buffer to fill with the list. |
| size | The size of the buffer. |
This function fills the provided buffer with the space-separated list of available network interfaces.
You can call is_network_interface_wireless() to distinguish between wired and wireless interfaces.
Example of use:
| int eris_get_nameserver_address | ( | char * | buffer, |
| size_t | size ) |
Get the IP address of the Domain Name Server.
| buffer | The buffer to fill with the address. |
| size | The size of the buffer. |
Example of use:
| int eris_get_network_interface_config | ( | const char * | interface, |
| char * | buffer, | ||
| size_t | size ) |
Get the configuration of a network interface.
| interfacce | The name of the interface considered. |
| buffer | The buffer to fill with the configuration. |
| size | The size of the buffer. |
The configuration stored in the buffer is a string with the following space-separated fields:
| int eris_get_network_interface_status | ( | const char * | interface, |
| char * | buffer, | ||
| size_t | size ) |
Get the status of a network interface.
| interface | The name of the interface considered. |
| buffer | The buffer to fill with the status. |
| size | The size of the buffer. |
This function fills the provided buffer with "up" or "down" depending on the status of the interface.
| int eris_get_wifi_quality | ( | const char * | interface, |
| char * | buffer, | ||
| size_t | size ) |
Get the Wifi connection quality.
| interface | The name of the interface. |
| buffer | The buffer to fill with Wifi quality. |
| size | The maximum size of the buffer. |
This function fills the buffer with the a line containing 3 fields. For example:
The values are:
| int eris_is_network_interface_wireless | ( | const char * | interface | ) |
Indicate whether a network interface is wireless or not.
| interface | the name of the interface. |
See list_network_interfaces() for an example of use.
| int eris_scan_wifi | ( | const char * | interface, |
| char * | buffer, | ||
| size_t | size ) |
Scan the available Wifi access points.
| interface | The name of the interface. |
| buffer | The buffer to fill with SSID of access points. |
| size | The maximum size of the buffer. |
This function fills the provided buffer with the line-separated list of SSID of available Wifi access points.
We choose to use \n as list spearator because SSIDs may contain most of the available characters, including spaces.
| int eris_set_network_interface_config | ( | const char * | interface, |
| const char * | autoconf, | ||
| const char * | mode, | ||
| const char * | ip, | ||
| const char * | address, | ||
| const char * | netmask, | ||
| const char * | gateway ) |
Set the configuration of a network interface.
| interface | The name of the interface considered. |
| activate | atboot if the interface has to be activated at boot, ondemand otherwise. |
| mode | dhcp if the address is automatically affected or static otherwise. |
| ip | ipv4 or ipv6 depending of the IP address version (ignored if 3th field is dhcp). |
| address | IP address of the interface (ignored if 3th field is dhcp) |
| netmask | IP mask of the subnet (ignored if 3th field is dhcp) |
| gateway | IP address of the gateway (ignored if 3th field is dhcp) |
Example of use:
| int eris_set_network_interface_status | ( | const char * | interface, |
| const char * | status ) |
Activate or disactivate a network interface.
This function enables the interface if status is "up", or disables it if status is "down". Any other string than "up" or "down" is invalid and this function returns EINVAL in errno.
If the interface activation fails, the function will returns an error.
| interface | The name of the concerned interface. |
| status | The desired status ("up" or "down"). |