#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int argc,char **argv) {
int fd; struct ifreq ifr;
if (argc<3) {
fprintf(stderr,"Usage: ifmv oldname newname\n"); return 1;
}
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket(PF_INET, SOCK_DGRAM, 0)"); return -1;
}
strncpy(ifr.ifr_name,argv[1],sizeof(ifr.ifr_name)); strncpy(ifr.ifr_newname,argv[2],sizeof(ifr.ifr_newname));
if (ioctl(fd, SIOCSIFNAME, &ifr)==-1) {
perror("ioctl(SIOCSIFNAME)"); return 1;
}
return 0;
}
댓글 없음:
댓글 쓰기