--- embedtools/src/get1steth.c 2010/03/24 16:43:01 1.1.2.9 +++ embedtools/src/get1steth.c 2011/06/13 20:04:12 1.2.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: get1steth.c,v 1.1.2.9 2010/03/24 16:43:01 misho Exp $ + * $Id: get1steth.c,v 1.2.2.1 2011/06/13 20:04:12 misho Exp $ * *************************************************************************/ #include "global.h" @@ -25,6 +25,7 @@ static void Usage() "\n", compiled, compiledby, compilehost); } +#ifdef HAVE_KLDNEXT static int kldLoad() { struct module_stat mstat; @@ -51,6 +52,7 @@ static int kldLoad() return 1; } +#endif // ------------------------------- @@ -82,7 +84,7 @@ int main(int argc, char **argv) argc -= optind; argv += optind; - openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_CONSOLE | LOG_USER); + openlog("get1steth", LOG_CONS | LOG_PERROR, LOG_USER); if (argc) { strlcpy(szIface, *argv, MAX_STR); @@ -136,12 +138,14 @@ int main(int argc, char **argv) return 0; } +#ifdef HAVE_KLDNEXT s = kldLoad(); if (s == -1) { syslog(LOG_ERR, "Error:: kldload(if_vlan) Can`t operate with vlans ...\n"); return 1; } else VERB(3) syslog(LOG_NOTICE, "VLAN module ... %s\n", s ? "Loaded" : "Already loaded"); +#endif // create vlan memset(&ifr, 0, sizeof ifr); @@ -157,14 +161,21 @@ int main(int argc, char **argv) closelog(); return 2; } +#ifdef SIOCIFCREATE2 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", MGMT_IFACE, errno, strerror(errno)); close(s); 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 + VERB(2) syslog(LOG_NOTICE, "Info:: Created interface=%s\n", MGMT_IFACE); ifr.ifr_data = MGMT_NAME; if (errno != EEXIST && ioctl(s, SIOCSIFNAME, &ifr) == -1) { syslog(LOG_ERR, "Error:: Managment interface=%s ioctl(SIOCSIFNAME) #%d - %s\n", @@ -173,10 +184,12 @@ int main(int argc, char **argv) return 2; } else 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 - memset(&ifra, 0, sizeof ifra); - strlcpy(ifra.ifra_name, MGMT_NAME, IFNAMSIZ); sin = (struct sockaddr_in*) &ifra.ifra_addr; sin->sin_len = sizeof ifra.ifra_addr; sin->sin_family = AF_INET;