Date: Sun, 12 Jun 2016 23:22:41 GMT From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305116 - soc2016/yuanxunzhang/head/usr.sbin/eaps Message-ID: <201606122322.u5CNMfRa098521@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: yuanxunzhang Date: Sun Jun 12 23:22:41 2016 New Revision: 305116 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305116 Log: EAPS: Create EAPS interface Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Sun Jun 12 22:55:50 2016 (r305115) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Sun Jun 12 23:22:41 2016 (r305116) @@ -31,9 +31,12 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <net/if.h> #include <sys/param.h> #include <sys/file.h> #include <sys/queue.h> +#include <sys/socket.h> +#include <sys/sockio.h> #include <ctype.h> #include <err.h> #include <errno.h> @@ -94,16 +97,24 @@ static void createdomain(int argc, char **argv) { - int error = 0; + int error = 0, s; struct eaps_d *eaps_new; char *domain_name = *(++argv); printf("Create eaps domain %s!\n", domain_name); - eaps_new = (struct eaps_d *) malloc (sizeof(struct eaps_d)); - strlcpy(eaps_new->eaps_name, domain_name, sizeof(eaps_new->eaps_name)); - /* Add to eaps list */ - SLIST_INSERT_HEAD(&head, eaps_new, eaps_entries); + // Create EAPS interface + s = socket(AF_LOCAL, SOCK_DGRAM, 0); + if (s == -1) + err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); + + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + (void) strlcpy(ifr.ifr_name, domain_name, sizeof(ifr.ifr_name)); + + if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) + err(1, "SIOCIFCREATE2"); exit(error); } @@ -126,11 +137,6 @@ printf("No eaps Configuration!\n"); } - /* Display EAPS information*/ - SLIST_FOREACH(eaps, &head, eaps_entries) { - printf("\t%s:\n", eaps->eaps_name); - } - exit(error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606122322.u5CNMfRa098521>