From owner-svn-soc-all@freebsd.org Sun Jun 12 23:22:42 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F1C1AF08CC for ; Sun, 12 Jun 2016 23:22:42 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7598D2B34 for ; Sun, 12 Jun 2016 23:22:42 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u5CNMgjo098523 for ; Sun, 12 Jun 2016 23:22:42 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5CNMfRa098521 for svn-soc-all@FreeBSD.org; Sun, 12 Jun 2016 23:22:41 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Sun, 12 Jun 2016 23:22:41 GMT Message-Id: <201606122322.u5CNMfRa098521@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305116 - soc2016/yuanxunzhang/head/usr.sbin/eaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2016 23:22:42 -0000 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 __FBSDID("$FreeBSD$"); +#include #include #include #include +#include +#include #include #include #include @@ -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); }