Under Solaris, it is very more easy to remove than to add. The network interface can be found thanks to the couple (name, inet address):
N.B.: All checks have been removed for better legibility, but it is very important to check returned code after each request.
// We consider the existence of the variables (unsigned char *) "networkInterfaceName", "inetAddress" which could be respectively "eth0" and "192.168.80.1" for instance.
int socketDescriptor;
struct sockaddr_in *addr;
struct lifreq lifr;
sd = socket(AF_INET, SOCK_DGRAM, 0);
memset(&lifr, 0, sizeof(lifr));
addr = (struct sockaddr_in *) &(lifr.lifr_addr);
strncpy(lifr.lifr_name, networkInterfaceName, sizeof(lifr.lifr_name));
addr->sin_family = AF_INET;
addr->sin_addr.s_addr = inet_addr(inetAddress);
ioctl(socketDescriptor, SIOCLIFREMOVEIF, (caddr_t) &lifr)
close(socketDescriptor);
sharing knowledge earned into design/development/technical delicate and/or difficult situations ...
Labels
Gnu/Linux
(95)
Administration
(83)
StorageHardware
(17)
Programming
(16)
WebBrowser
(15)
General
(11)
GNU/Bash
(7)
Solaris
(7)
Virtualization
(7)
C
(6)
Domotics
(6)
Musics
(5)
Raspberry
(5)
Desktop
(4)
Java
(4)
VersionControlSystems
(4)
ArtificialIntelligence
(2)
Optimization
(2)
multimedia
(2)
Arduino
(1)
Electronics
(1)
LTS
(1)
MacOS
(1)
Mechanics
(1)
Processing
(1)
Robotics
(1)
Ubuntu
(1)
Upgrade
(1)
ez-robot
(1)
No comments:
Post a Comment
Thank you for your visit, let's share your point of view: