diff options
author | marius <marius@FreeBSD.org> | 2007-01-20 00:56:49 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2007-01-20 00:56:49 +0000 |
commit | 25cab451555567894594068c29a0a21b3bc46ca7 (patch) | |
tree | 7957c9324955339e39e2b05ea0c3e3e1109428c5 /sbin | |
parent | 536c29257b4ebc40eba977edc25de18a8a284275 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 9 | ||||
-rw-r--r-- | sbin/ifconfig/ifmedia.c | 26 |
2 files changed, 32 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 7309965..17b16b8 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd November 27, 2006 +.Dd January 20, 2007 .Dt IFCONFIG 8 .Os .Sh NAME @@ -342,6 +342,11 @@ this directive is used to select between 802.11a and 802.11g .Pq Cm 11g operating modes. +.It Cm inst Ar minst , Cm instance Ar minst +Set the media instance to +.Ar minst . +This is useful for devices which have multiple physical layer interfaces +.Pq PHYs . .It Cm name Ar name Set the interface name to .Ar name . @@ -1294,7 +1299,7 @@ Allow to automatically detect edge status. This is the default for all interfaces added to a bridge. .It Cm -autoedge Ar interface -Disable automatic edge status on +Disable automatic edge status on .Ar interface . .It Cm ptp Ar interface Set the 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", |