Shared library providing C utilities to render networking management with minimal dependencies.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aitor 53d8054c1a Fixed conflicting types for ‘interface_detect_beat_ethtool’. 20 hours ago
backend_src Fixed conflicting types for ‘interface_detect_beat_ethtool’. 20 hours ago
debian Initial release. 6 days ago
CMakeLists.txt Initial release. 6 days ago Fixed a typo in the file 4 days ago


libnetaid is a shared C library based on the RTnetlink service routines of the linux kernel. It provides useful utilities focused to the development of both CLI and GUI user interfaces to render networking management with minimal dependencies and following the KISS principle, together with other tools like wpasupplicant, ifupdown and libiw.


Use the APT package manager to install libnetaid.

apt-get install libnetaid libnetaid-dev

After that, development headers will be located in:

/usr/include/i386-linux-gnu/simple-netaid    (for 32 bits) 
/usr/include/x86_64-linux-gnu/simple-netaid  (for 64 bits)


libnetaid uses sbuf structs to handle char arrays, whose life cycle is (have a look at the sbuf.c file):

struct sbuf s;
sbuf_addch(&s, 'F');     /* adds a character */
sbuf_addstr(&s, "oo");   /* adds an array */

The following example consists of a very simple C program showing the names of the network interfaces:

/ * *
  *  main.c

#include <simple-netaid/sbuf.h>
#include <simple-netaid/interfaces.h>

int main(int argc, char **argv)
	struct sbuf wired_device, wireless_device;
	get_interfaces(&wired_device, &wireless_device);	
	printf("Wired device: %s\n", wired_device.buf);
	printf("Wireless device: %s\n", wireless_device.buf);	
	return 0;

You can build it as follows:

gcc main.c -o main -lnetaid `pkg-config --cflags --libs glib-2.0`

Output example:

Wired device: eth0
Wireless device: wlan0

Another example using netproc might be:

/ * *
  *  main.c
#include <simple-netaid/sbuf.h>
#include <simple-netaid/netproc.h>

int main( int argc, char **argv)
	struct sbuf s;
	printf("%s\n", s.buf);
	return 0;

Output example:

Connected to wlan0
MAC Address=2C:D0:5A:E8:9E:9F
IP Address=


Here you are a list of other available functionalities:

// Brings up the interface (analogous to "ip link set <interface> up")
void interface_up (const char* interface); 
// Brings down the interface (analogous to "ip link set <interface> down")
void interface_down (const char* interface);
// Returns the current status of the interface ( 1 | 0 ) -> ( UP | DOWN )
int get_interface_status (const char* interface);
// Brings up the interface (analogous to "ifup <interface>")
void ifup (const char* interface);
// Brings down the interface (analogous to "ifdown <interface>")
void ifdown (const char* interface);
// Shows all the available active wifis (as root)
void print_active_wifis(const char* wireless_device);
// Wireless connection attempt via wpa_supplicant
void wireless_connection(const char *ifname, const char *essid, const char *password);
// Wired connection attempt
void wired_connection(const char* wired_device);
// Disconnects the network device
void disconnect(const char* device);
// Returns the name of the connected network device, null if we are disconnected.
char* iproute();
// Asigns a detailed information about the network connection to the buffer.
void netproc (struct sbuf* buffer);


Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.