summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/ifmedia.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2004-12-08 19:18:07 +0000
committersam <sam@FreeBSD.org>2004-12-08 19:18:07 +0000
commit68cd8761a723205e9d0dbd54067af7db9f163492 (patch)
tree65f511158298939a14f40a9fccf4ecc68b18c48a /sbin/ifconfig/ifmedia.c
parentf947a8cc1cf9e160deab254a7ff4be233c0f56d3 (diff)
downloadFreeBSD-src-68cd8761a723205e9d0dbd54067af7db9f163492.zip
FreeBSD-src-68cd8761a723205e9d0dbd54067af7db9f163492.tar.gz
Overhaul to cleanup some of the tangled logic that's grown over the years.
o break per-address family support out into separate files o modularize per-address family and functional operations using a registration mechanism; this permits configuration according to which files you include (but beware that order of the files is important to insure backwards compatibility) o many cleanups to eliminate incestuous behaviour, global variables, and poor coding practices (still much more to fix) The original motivation of this work was to support dynamic addition of functionality based on the interface so we can eliminate the various little control programs and so that vendors can distribute ifconfig plugins that support their in-kernel code. That work is still to be completed. o Update 802.11 support for all the new net80211 functionality; some of these operations (e.g. list *) may be better suited in a different program
Diffstat (limited to 'sbin/ifconfig/ifmedia.c')
-rw-r--r--sbin/ifconfig/ifmedia.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index cdbfc53..7deddd8 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -102,8 +102,8 @@ static struct ifmedia_type_to_subtype *get_toptype_ttos(int);
static struct ifmedia_description *get_subtype_desc(int,
struct ifmedia_type_to_subtype *ttos);
-void
-media_status(int s, struct rt_addrinfo *info __unused)
+static void
+media_status(int s, const struct rt_addrinfo *info __unused)
{
struct ifmediareq ifmr;
int *media_list, i;
@@ -190,7 +190,7 @@ media_status(int s, struct rt_addrinfo *info __unused)
free(media_list);
}
-void
+static void
setmedia(const char *val, int d, int s, const struct afswtch *afp)
{
struct ifmediareq ifmr;
@@ -232,14 +232,14 @@ setmedia(const char *val, int d, int s, const struct afswtch *afp)
err(1, "SIOCSIFMEDIA (media)");
}
-void
+static void
setmediaopt(const char *val, int d, int s, const struct afswtch *afp)
{
domediaopt(val, 0, s);
}
-void
+static void
unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp)
{
@@ -291,7 +291,7 @@ domediaopt(const char *val, int clear, int s)
}
-void
+static void
setmediamode(const char *val, int d, int s, const struct afswtch *afp)
{
struct ifmediareq ifmr;
@@ -777,3 +777,27 @@ print_media_word_ifconfig(int ifmw)
/**********************************************************************
* ...until here.
**********************************************************************/
+
+static struct cmd media_cmds[] = {
+ DEF_CMD_ARG("media", setmedia),
+ DEF_CMD_ARG("mode", setmediamode),
+ DEF_CMD_ARG("mediaopt", setmediaopt),
+ DEF_CMD_ARG("-mediaopt",unsetmediaopt),
+};
+static struct afswtch af_media = {
+ .af_name = "af_media",
+ .af_af = AF_UNSPEC,
+ .af_status = media_status,
+};
+
+static __constructor void
+ifmedia_ctor(void)
+{
+#define N(a) (sizeof(a) / sizeof(a[0]))
+ int i;
+
+ for (i = 0; i < N(media_cmds); i++)
+ cmd_register(&media_cmds[i]);
+ af_register(&af_media);
+#undef N
+}
OpenPOWER on IntegriCloud