socsvn commit: r308055 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps
yuanxunzhang at FreeBSD.org
yuanxunzhang at FreeBSD.org
Fri Aug 19 20:02:52 UTC 2016
Author: yuanxunzhang
Date: Fri Aug 19 20:02:49 2016
New Revision: 308055
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=308055
Log:
EAPS: set switch mode and set priority interfaces
Modified:
soc2016/yuanxunzhang/head/sys/net/eaps.c
soc2016/yuanxunzhang/head/sys/net/eaps.h
soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c
soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h
Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.c Fri Aug 19 19:31:55 2016 (r308054)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.c Fri Aug 19 20:02:49 2016 (r308055)
@@ -73,6 +73,8 @@
void eaps_attach(struct eaps_softc *);
void eaps_detach(struct eaps_softc *);
void eaps_status(struct eaps_softc *, struct eaps_state *);
+void set_eaps_mode(struct eaps_softc *, struct eaps_state *);
+void set_eaps_priority(struct eaps_softc *, struct eaps_state *);
static VNET_DEFINE(struct if_clone *, eaps_cloner);
#define V_eaps_cloner VNET(eaps_cloner)
@@ -208,6 +210,14 @@
case SIOCSEAPSDOMAIN:
eaps_status(sc, es);
break;
+
+ case SIOCSEAPSMODE:
+ set_eaps_mode(sc, es);
+ break;
+
+ case SIOCSEAPSPRI:
+ set_eaps_priority(sc, es);
+ break;
default:
error = ether_ioctl(ifp, cmd, data);
break;
@@ -254,6 +264,24 @@
}
void
+set_eaps_mode(struct eaps_softc *sc, struct eaps_state *es)
+{
+ printf("Debug print: set_eaps_mode!\n");
+ EAPS_WLOCK(sc);
+ sc->sc_eaps.mode = es->mode;
+ EAPS_WUNLOCK(sc);
+}
+
+void
+set_eaps_priority(struct eaps_softc *sc, struct eaps_state *es)
+{
+ printf("Debug print: set_eaps_priority!\n");
+ EAPS_WLOCK(sc);
+ sc->sc_eaps.priority = es->priority;
+ EAPS_WUNLOCK(sc);
+}
+
+void
eaps_attach(struct eaps_softc *sc)
{
//set eaps domain protocol state to default value
Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.h Fri Aug 19 19:31:55 2016 (r308054)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.h Fri Aug 19 20:02:49 2016 (r308055)
@@ -53,10 +53,9 @@
u_char sc_defaddr[6]; /* Default MAC address */
};
-
-
#define SIOCSEAPSDOMAIN _IOWR('i', 300, struct eaps_state)
-
+#define SIOCSEAPSMODE _IOW('i', 301, struct eaps_state)
+#define SIOCSEAPSPRI _IOW('i', 302, struct eaps_state)
/*
* Extreme Active Protection System (EAPS) definitions.
* Normative reference: draft-shah-extreme-rfc3619bis-02 [Expired I-D]
Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Fri Aug 19 19:31:55 2016 (r308054)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Fri Aug 19 20:02:49 2016 (r308055)
@@ -249,14 +249,54 @@
printf("Debug print: set switch mode is %s!\n", mode);
//check the eaps switch mode
- if ((strcmp(mode, eaps_mode_message[EAPS_MODE_TRANSIT]) != 0)
- && strcmp(mode, eaps_mode_message[EAPS_MODE_MASTER]) != 0) {
- err(1, "Wrong swith mode, swith mode should be transit or master!\n");
+ if (strcmp(mode, eaps_mode_message[EAPS_MODE_TRANSIT]) == 0) {
+ es.mode = EAPS_MODE_TRANSIT;
+ } else if (strcmp(mode, eaps_mode_message[EAPS_MODE_MASTER]) == 0) {
+ es.mode = EAPS_MODE_MASTER;
+ } else {
+ err(1, "Wrong swith mode, swith mode should be either transit or master!\n");
}
+ strlcpy(es.ifname, domain_name, sizeof(es.ifname));
+ if (ioctl(s, SIOCSEAPSMODE, &es) != 0)
+ err(1, "SIOCSEAPSMODE");
+
exit(error);
}
+static void
+set_eaps_priority(int argc, char **argv, int s)
+{
+ int error = 0;
+
+ struct eaps_state es;
+ bzero(&es, sizeof(es));
+
+ char *domain_name = *(++argv);
+
+ // check eaps domain name
+ if (domain_name == NULL) {
+ err(1, "EAPS domain name is NULL!");
+ }
+
+ char *priority = *(++argv);
+ printf("Debug print: set priority mode is %s!\n", priority);
+
+ //check the eaps domain priority
+ if (strcmp(priority, eaps_priority_message[EAPS_PRIORITY_NORMAL]) == 0) {
+ es.priority = EAPS_PRIORITY_NORMAL;
+ } else if (strcmp(priority, eaps_priority_message[EAPS_PRIORITY_HIGH]) == 0) {
+ es.priority = EAPS_PRIORITY_HIGH;
+ } else {
+ err(1, "Wrong priority, priority should be either high or normal!\n");
+ }
+
+ strlcpy(es.ifname, domain_name, sizeof(es.ifname));
+ if (ioctl(s, SIOCSEAPSPRI, &es) != 0)
+ err(1, "SIOCSEAPSPRI");
+
+ exit(error);
+}
static void
usage(const char *cp)
Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Fri Aug 19 19:31:55 2016 (r308054)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Fri Aug 19 20:02:49 2016 (r308055)
@@ -60,6 +60,8 @@
#define EAPS_PRIORITY_NORMAL 0x00 /* EAPS domain priority - normal */
#define EAPS_PRIORITY_HIGH 0x01 /* EAPS domain priority - high (default) */
-
#define SIOCSEAPSDOMAIN _IOWR('i', 300, struct eaps_state)
+#define SIOCSEAPSMODE _IOW('i', 301, struct eaps_state)
+#define SIOCSEAPSPRI _IOW('i', 302, struct eaps_state)
+
More information about the svn-soc-all
mailing list