version 1.1.2.6, 2010/01/01 17:24:04
|
version 1.1.2.9, 2010/03/24 16:43:01
|
Line 1
|
Line 1
|
|
/************************************************************************* |
|
* (C) 2010 AITNET - Sofia/Bulgaria - <office@aitbg.com> |
|
* by Michael Pounov <misho@aitbg.com> |
|
* |
|
* $Author$ |
|
* $Id$ |
|
* |
|
*************************************************************************/ |
#include "global.h" |
#include "global.h" |
#include "get1steth.h" |
#include "get1steth.h" |
|
|
Line 76 int main(int argc, char **argv)
|
Line 84 int main(int argc, char **argv)
|
|
|
openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_CONSOLE | LOG_USER); |
openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_CONSOLE | LOG_USER); |
|
|
s = socket(PF_INET, SOCK_STREAM, 0); |
|
if (-1 == s) { |
|
syslog(LOG_ERR, "Error:: socket(INET) #%d - %s\n", errno, strerror(errno)); |
|
closelog(); |
|
return 1; |
|
} |
|
if (argc) { |
if (argc) { |
strlcpy(szIface, *argv, MAX_STR); |
strlcpy(szIface, *argv, MAX_STR); |
VERB(1) syslog(LOG_NOTICE, "Info:: Get CUSTOM first interface %s\n", szIface); |
VERB(1) syslog(LOG_NOTICE, "Info:: Get CUSTOM first interface %s\n", szIface); |
} else { |
} else { |
|
s = socket(PF_INET, SOCK_DGRAM, 0); |
|
if (-1 == s) { |
|
syslog(LOG_ERR, "Error:: socket(INET) #%d - %s\n", errno, strerror(errno)); |
|
closelog(); |
|
return 1; |
|
} |
|
|
getifaddrs(&ifa); |
getifaddrs(&ifa); |
for (ifp = ifa; ifp; ifp = ifp->ifa_next) { |
for (ifp = ifa; ifp; ifp = ifp->ifa_next) { |
if (PF_LINK == ifp->ifa_addr->sa_family && |
if (PF_LINK == ifp->ifa_addr->sa_family && |
Line 110 int main(int argc, char **argv)
|
Line 119 int main(int argc, char **argv)
|
} |
} |
} |
} |
freeifaddrs(ifa); |
freeifaddrs(ifa); |
|
|
|
close(s); |
} |
} |
if (!*szIface) { |
if (!*szIface) { |
syslog(LOG_NOTICE, "Info:: Ethernet interface not found!!!\n"); |
syslog(LOG_NOTICE, "Info:: Ethernet interface not found!!!\n"); |
|
|
close(s); |
|
closelog(); |
closelog(); |
return 1; |
return 1; |
} |
} |
Line 122 int main(int argc, char **argv)
|
Line 132 int main(int argc, char **argv)
|
if (GetOnly) { |
if (GetOnly) { |
printf("%s\n", szIface); |
printf("%s\n", szIface); |
|
|
close(s); |
|
closelog(); |
closelog(); |
return 0; |
return 0; |
} |
} |
Line 130 int main(int argc, char **argv)
|
Line 139 int main(int argc, char **argv)
|
s = kldLoad(); |
s = kldLoad(); |
if (s == -1) { |
if (s == -1) { |
syslog(LOG_ERR, "Error:: kldload(if_vlan) Can`t operate with vlans ...\n"); |
syslog(LOG_ERR, "Error:: kldload(if_vlan) Can`t operate with vlans ...\n"); |
close(s); |
|
return 1; |
return 1; |
} else |
} else |
VERB(1) syslog(LOG_NOTICE, "VLAN module ... %s\n", s ? "Loaded" : "Already loaded"); | VERB(3) syslog(LOG_NOTICE, "VLAN module ... %s\n", s ? "Loaded" : "Already loaded"); |
|
|
// create vlan |
// create vlan |
memset(&ifr, 0, sizeof ifr); |
memset(&ifr, 0, sizeof ifr); |
Line 143 int main(int argc, char **argv)
|
Line 151 int main(int argc, char **argv)
|
strlcpy(ifr.ifr_name, MGMT_IFACE, IFNAMSIZ); |
strlcpy(ifr.ifr_name, MGMT_IFACE, IFNAMSIZ); |
ifr.ifr_data = (void *) &vlr; |
ifr.ifr_data = (void *) &vlr; |
|
|
|
s = socket(PF_INET, SOCK_DGRAM, 0); |
|
if (-1 == s) { |
|
syslog(LOG_ERR, "Error:: socket(INET) #%d - %s\n", errno, strerror(errno)); |
|
closelog(); |
|
return 2; |
|
} |
if (ioctl(s, SIOCIFCREATE2, &ifr) == -1 && errno != EEXIST) { |
if (ioctl(s, SIOCIFCREATE2, &ifr) == -1 && errno != EEXIST) { |
syslog(LOG_ERR, "Error:: Create interface=%s ioctl(SIOCIFCREATE2) #%d - %s\n", |
syslog(LOG_ERR, "Error:: Create interface=%s ioctl(SIOCIFCREATE2) #%d - %s\n", |
MGMT_IFACE, errno, strerror(errno)); |
MGMT_IFACE, errno, strerror(errno)); |