version 1.1.2.8, 2010/03/23 13:29:38
|
version 1.2.2.1, 2011/06/13 20:04:12
|
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 17 static void Usage()
|
Line 25 static void Usage()
|
"\n", compiled, compiledby, compilehost); |
"\n", compiled, compiledby, compilehost); |
} |
} |
|
|
|
#ifdef HAVE_KLDNEXT |
static int kldLoad() |
static int kldLoad() |
{ |
{ |
struct module_stat mstat; |
struct module_stat mstat; |
Line 43 static int kldLoad()
|
Line 52 static int kldLoad()
|
|
|
return 1; |
return 1; |
} |
} |
|
#endif |
|
|
// ------------------------------- |
// ------------------------------- |
|
|
Line 74 int main(int argc, char **argv)
|
Line 84 int main(int argc, char **argv)
|
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
|
openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_CONSOLE | LOG_USER); | openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_USER); |
|
|
if (argc) { |
if (argc) { |
strlcpy(szIface, *argv, MAX_STR); |
strlcpy(szIface, *argv, MAX_STR); |
Line 128 int main(int argc, char **argv)
|
Line 138 int main(int argc, char **argv)
|
return 0; |
return 0; |
} |
} |
|
|
|
#ifdef HAVE_KLDNEXT |
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"); |
return 1; |
return 1; |
} else |
} else |
VERB(3) syslog(LOG_NOTICE, "VLAN module ... %s\n", s ? "Loaded" : "Already loaded"); |
VERB(3) syslog(LOG_NOTICE, "VLAN module ... %s\n", s ? "Loaded" : "Already loaded"); |
|
#endif |
|
|
// create vlan |
// create vlan |
memset(&ifr, 0, sizeof ifr); |
memset(&ifr, 0, sizeof ifr); |
Line 149 int main(int argc, char **argv)
|
Line 161 int main(int argc, char **argv)
|
closelog(); |
closelog(); |
return 2; |
return 2; |
} |
} |
|
#ifdef SIOCIFCREATE2 |
if (ioctl(s, SIOCIFCREATE2, &ifr) == -1 && errno != EEXIST) { |
if (ioctl(s, SIOCIFCREATE2, &ifr) == -1 && errno != EEXIST) { |
|
#else |
|
if (ioctl(s, SIOCIFCREATE, &ifr) == -1 && errno != EEXIST) { |
|
#endif |
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)); |
close(s); |
close(s); |
return 2; |
return 2; |
} else | } |
VERB(2) syslog(LOG_NOTICE, "Info:: Created interface=%s\n", MGMT_IFACE); | |
| memset(&ifra, 0, sizeof ifra); |
| #if defined(__FreeBSD__) |
// rename iface |
// rename iface |
|
VERB(2) syslog(LOG_NOTICE, "Info:: Created interface=%s\n", MGMT_IFACE); |
ifr.ifr_data = MGMT_NAME; |
ifr.ifr_data = MGMT_NAME; |
if (errno != EEXIST && ioctl(s, SIOCSIFNAME, &ifr) == -1) { |
if (errno != EEXIST && ioctl(s, SIOCSIFNAME, &ifr) == -1) { |
syslog(LOG_ERR, "Error:: Managment interface=%s ioctl(SIOCSIFNAME) #%d - %s\n", |
syslog(LOG_ERR, "Error:: Managment interface=%s ioctl(SIOCSIFNAME) #%d - %s\n", |
Line 165 int main(int argc, char **argv)
|
Line 184 int main(int argc, char **argv)
|
return 2; |
return 2; |
} else |
} else |
VERB(2) syslog(LOG_NOTICE, "Info:: Managment interface=%s\n", MGMT_NAME); |
VERB(2) syslog(LOG_NOTICE, "Info:: Managment interface=%s\n", MGMT_NAME); |
|
strlcpy(ifra.ifra_name, MGMT_NAME, IFNAMSIZ); |
|
#else |
|
strlcpy(ifra.ifra_name, MGMT_IFACE, IFNAMSIZ); |
|
#endif |
|
|
// assign address & up |
// assign address & up |
memset(&ifra, 0, sizeof ifra); |
|
strlcpy(ifra.ifra_name, MGMT_NAME, IFNAMSIZ); |
|
sin = (struct sockaddr_in*) &ifra.ifra_addr; |
sin = (struct sockaddr_in*) &ifra.ifra_addr; |
sin->sin_len = sizeof ifra.ifra_addr; |
sin->sin_len = sizeof ifra.ifra_addr; |
sin->sin_family = AF_INET; |
sin->sin_family = AF_INET; |