summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/ifmedia.c
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2007-01-20 00:56:49 +0000
committermarius <marius@FreeBSD.org>2007-01-20 00:56:49 +0000
commit25cab451555567894594068c29a0a21b3bc46ca7 (patch)
tree7957c9324955339e39e2b05ea0c3e3e1109428c5 /sbin/ifconfig/ifmedia.c
parent536c29257b4ebc40eba977edc25de18a8a284275 (diff)
downloadFreeBSD-src-25cab451555567894594068c29a0a21b3bc46ca7.zip
FreeBSD-src-25cab451555567894594068c29a0a21b3bc46ca7.tar.gz
- Display the media instance numbers and allow the user to set the active
one. This is based on NetBSD but unlike NetBSD this implementation prints the instance number for all media instances and doesn't skip it for the first one as I don't see a reason to suppress it except for the vague reason to preserve the output for single-instance configurations. - Fix some whitespace nits.
Diffstat (limited to 'sbin/ifconfig/ifmedia.c')
-rw-r--r--sbin/ifconfig/ifmedia.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index c768895..df5b23e 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -248,7 +248,6 @@ setmedia(const char *val, int d, int s, const struct afswtch *afp)
{
struct ifmediareq *ifmr;
int subtype;
-
ifmr = getifmediastate(s);
@@ -314,6 +313,24 @@ domediaopt(const char *val, int clear, int s)
callback_register(setifmediacallback, (void *)ifmr);
}
+static void
+setmediainst(const char *val, int d, int s, const struct afswtch *afp)
+{
+ struct ifmediareq *ifmr;
+ int inst;
+
+ ifmr = getifmediastate(s);
+
+ inst = atoi(val);
+ if (inst < 0 || inst > IFM_INST_MAX)
+ errx(1, "invalid media instance: %s", val);
+
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ ifr.ifr_media = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
+
+ ifmr->ifm_current = ifr.ifr_media;
+ callback_register(setifmediacallback, (void *)ifmr);
+}
static void
setmediamode(const char *val, int d, int s, const struct afswtch *afp)
@@ -721,6 +738,9 @@ print_media_word(int ifmw, int print_toptype)
}
}
printf("%s", seen_option ? ">" : "");
+
+ if (print_toptype)
+ printf(" instance %d", IFM_INST(ifmw));
}
static void
@@ -767,6 +787,8 @@ print_media_word_ifconfig(int ifmw)
}
}
}
+
+ printf(" instance %d", IFM_INST(ifmw));
}
/**********************************************************************
@@ -778,6 +800,8 @@ static struct cmd media_cmds[] = {
DEF_CMD_ARG("mode", setmediamode),
DEF_CMD_ARG("mediaopt", setmediaopt),
DEF_CMD_ARG("-mediaopt",unsetmediaopt),
+ DEF_CMD_ARG("inst", setmediainst),
+ DEF_CMD_ARG("instance", setmediainst),
};
static struct afswtch af_media = {
.af_name = "af_media",
OpenPOWER on IntegriCloud