... using IOCTL's ...
ioctl(skfd, SIOCSIFFLAGS, &ifr);
... with the IFF_UP bit set or not set, depending on whether you want to connect the interface up or down, respectively, that is:
static int set_if_up(char *ifname, short flags) { return set_if_flags(ifname, flags | IFF_UP); } static int set_if_down(char *ifname, short flags) { return set_if_flags(ifname, flags & ~IFF_UP); }
Code copied from Linux Network Documentation .
Andrejs Cainikovs
source share