From owner-svn-soc-all@freebsd.org Mon Jun 13 05:08:40 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 EE6B5AF1D4D for ; Mon, 13 Jun 2016 05:08:40 +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 D4A222B13 for ; Mon, 13 Jun 2016 05:08:40 +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 u5D58evh014134 for ; Mon, 13 Jun 2016 05:08:40 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5D58dcq014065 for svn-soc-all@FreeBSD.org; Mon, 13 Jun 2016 05:08:39 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Mon, 13 Jun 2016 05:08:39 GMT Message-Id: <201606130508.u5D58dcq014065@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: r305133 - in soc2016/yuanxunzhang/head: sys/net 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: Mon, 13 Jun 2016 05:08:41 -0000 Author: yuanxunzhang Date: Mon Jun 13 05:08:38 2016 New Revision: 305133 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305133 Log: EAPS: Create EAPS interface Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c soc2016/yuanxunzhang/head/sys/net/eaps.h soc2016/yuanxunzhang/head/sys/net/if_types.h soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.c Mon Jun 13 03:45:08 2016 (r305132) +++ soc2016/yuanxunzhang/head/sys/net/eaps.c Mon Jun 13 05:08:38 2016 (r305133) @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -52,5 +54,59 @@ /* * EAPS Protocol Module */ +static int eaps_clone_create(struct if_clone *, int, caddr_t); +static void eaps_clone_destroy(struct ifnet *); + +static VNET_DEFINE(struct if_clone *, eaps_cloner); +#define V_eaps_cloner VNET(V_eaps_cloner) + +static const char eaps_name[] = "EAPS"; + +SYSCTL_DECL(_net_link); +static SYSCTL_NODE(_net_link, IFT_EAPS, eaps, CTLFLAG_RW, 0, "EAPS"); + +static VNET_DEFINE(LIST_HEAD(, eaps_softc), eaps_list); +#define V_eaps_list VNET(eaps_list) +static VNET_DEFINE(struct mtx, eaps_list_mtx); +#define V_eaps_list_mtx VNET(eaps_list_mtx) +#define EAPS_LIST_LOCK_INIT(x) mtx_init(&V_eaps_list_mtx, \ + "EAPS interface list", NULL, MTX_DEF) +#define EAPS_LIST_LOCK_DESTROY(x) mtx_destroy(&V_eaps_list_mtx) +#define EAPS_LIST_LOCK(x) mtx_lock(&V_eaps_list_mtx) +#define EAPS_LIST_UNLOCK(x) mtx_unlock(&V_eaps_list_mtx) + +static void +vnet_eaps_init(const void *unused __unused) +{ + + EAPS_LIST_LOCK_INIT(); + LIST_INIT(&V_eaps_list); + V_eaps_cloner = if_clone_simple(eaps_name, + eaps_clone_create, eaps_clone_destroy, 0); +} +VNET_SYSINIT(vnet_eaps_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_eaps_init, NULL); + + +/* + * eaps_clone_create: + * + * Create a new eaps instance. + */ +static int +eaps_clone_create(struct if_clone *ifc, int unit, caddr_t params) +{ + return (0); +} + +/* + * eaps_clone_destroy: + * + * Destroy a eaps instance. + */ +static void +eaps_clone_destroy(struct ifnet *ifp) +{ + +} -static SLIST_HEAD(slisthead, eaps_d) head = SLIST_HEAD_INITIALIZER(head); Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.h Mon Jun 13 03:45:08 2016 (r305132) +++ soc2016/yuanxunzhang/head/sys/net/eaps.h Mon Jun 13 05:08:38 2016 (r305133) @@ -31,11 +31,15 @@ #ifndef _NET_EAPS_H_ #define _NET_EAPS_H_ + #ifdef _KERNEL -struct eaps_d { - char eaps_name[32]; /* name of the EAPS domain */ - SLIST_ENTRY(eaps_d) eaps_entries; +/* + * Software state for each EAPS Domain + */ +struct eaps_softc { + struct ifnet *sc_ifp; /* make this an interface */ + LIST_ENTRY(eaps_softc) sc_list; }; /* Modified: soc2016/yuanxunzhang/head/sys/net/if_types.h ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/if_types.h Mon Jun 13 03:45:08 2016 (r305132) +++ soc2016/yuanxunzhang/head/sys/net/if_types.h Mon Jun 13 05:08:38 2016 (r305133) @@ -242,7 +242,7 @@ IFT_INFINIBAND = 0xc7, /* Infiniband */ IFT_BRIDGE = 0xd1, /* Transparent bridge interface */ IFT_STF = 0xd7, /* 6to4 interface */ - + IFT_EAPS = 0xd8, /* EAPS interface */ /* * Not based on IANA assignments. Conflicting with IANA assignments. * We should make them negative probably. Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Mon Jun 13 03:45:08 2016 (r305132) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Mon Jun 13 05:08:38 2016 (r305133) @@ -67,9 +67,9 @@ }; int keyword(const char *); -static void createdomain(int, char **, int); -static void deletedomain(int, char **); -static void displayeaps(int, char **); +static void create_domain(int, char **, int); +static void delete_domain(int, char **); +static void display(int, char **); static void usage(const char *); int @@ -86,20 +86,20 @@ if (*(++argv) != NULL) switch (keyword(*argv)) { case K_CREATE: - createdomain(argc, argv, s); + create_domain(argc, argv, s); case K_DELETE: - deletedomain(argc, argv); + delete_domain(argc, argv); case K_DISPLAY: - displayeaps(argc, argv); + display(argc, argv); } usage(*argv); return retval; } static void -createdomain(int argc, char **argv, int s) +create_domain(int argc, char **argv, int s) { int error = 0; char *domain_name = *(++argv); @@ -110,7 +110,7 @@ struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - (void) strlcpy(ifr.ifr_name, "bridge", sizeof(ifr.ifr_name)); + (void) strlcpy(ifr.ifr_name, "eaps", sizeof(ifr.ifr_name)); if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) err(1, "SIOCIFCREATE2"); @@ -119,7 +119,7 @@ } static void -deletedomain(int argc, char **argv) +delete_domain(int argc, char **argv) { int error = 0; printf("Delete eaps domain %s!\n", *(++argv)); @@ -127,7 +127,7 @@ } static void -displayeaps(int argc, char **argv) +display(int argc, char **argv) { int error = 0;