Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 3957 Details for
Bug 7994
Patch to net-tools to allow mii-tool to activate/deactive interfaces based on media
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to mii-tool.c to allow activation of interface based on media state
net-tools-1.60-mii-tool-activate.patch (text/plain), 3.46 KB, created by
Pat Double
on 2002-09-16 11:34:07 UTC
(
hide
)
Description:
Patch to mii-tool.c to allow activation of interface based on media state
Filename:
MIME Type:
Creator:
Pat Double
Created:
2002-09-16 11:34:07 UTC
Size:
3.46 KB
patch
obsolete
>diff -u -r net-tools-1.60/mii-tool.c net-tools-1.60pbd/mii-tool.c >--- net-tools-1.60/mii-tool.c 2000-05-21 09:31:17.000000000 -0500 >+++ net-tools-1.60pbd/mii-tool.c 2002-08-20 10:09:15.000000000 -0500 >@@ -81,6 +81,7 @@ > > struct option longopts[] = { > /* { name has_arg *flag val } */ >+ {"activate", 0, 0, 'a'}, /* Bring interface up/down when watching with -w. */ > {"advertise", 1, 0, 'A'}, /* Change capabilities advertised. */ > {"force", 1, 0, 'F'}, /* Change capabilities advertised. */ > {"phy", 1, 0, 'p'}, /* Set PHY (MII address) to report. */ >@@ -100,7 +101,8 @@ > opt_restart = 0, > opt_reset = 0, > opt_log = 0, >- opt_watch = 0; >+ opt_watch = 0, >+ opt_activate = 0; > static int nway_advertise = 0; > static int fixed_speed = 0; > static int override_phy = -1; >@@ -307,6 +309,22 @@ > > /*--------------------------------------------------------------------*/ > >+static void interface_up(char *ifname) >+{ >+ char cmd[128]; >+ sprintf(cmd, "/sbin/ifconfig %s | grep -q UP || /etc/init.d/net.%s start\n", ifname, ifname); >+ system(cmd); >+} >+ >+static void interface_down(char* ifname) >+{ >+ char cmd[128]; >+ sprintf(cmd, "/sbin/ifconfig %s | grep -q UP && /etc/init.d/net.%s stop\n", ifname, ifname); >+ system(cmd); >+} >+ >+/*--------------------------------------------------------------------*/ >+ > static int do_one_xcvr(int skfd, char *ifname, int maybe) > { > struct mii_data *mii = (struct mii_data *)&ifr.ifr_data; >@@ -347,7 +365,16 @@ > mdio_write(skfd, MII_BMCR, bmcr); > } > >- if (!opt_restart && !opt_reset && !fixed_speed && !nway_advertise) >+ if (opt_activate) >+ { >+ int bmsr=mdio_read(skfd, MII_BMSR); >+ if (bmsr & MII_BMSR_LINK_VALID) >+ interface_up(ifname); >+ else >+ interface_down(ifname); >+ } >+ >+ if (!opt_activate && !opt_restart && !opt_reset && !fixed_speed && !nway_advertise) > show_basic_mii(skfd, mii->phy_id); > > return 0; >@@ -372,7 +399,21 @@ > now = (mdio_read(skfd, MII_BMCR) | > (mdio_read(skfd, MII_BMSR) << 16)); > if (status[index] && (status[index] != now)) >- show_basic_mii(skfd, mii->phy_id); >+ { >+ if (opt_activate) >+ { >+ int linkupnow=now & MII_BMSR_LINK_VALID<<16; >+ int linkupbefore=status[index] & MII_BMSR_LINK_VALID<<16; >+ if (linkupnow && !linkupbefore) >+ interface_up(ifname); >+ else if (!linkupnow && linkupbefore) >+ interface_down(ifname); >+ } >+ else >+ { >+ show_basic_mii(skfd, mii->phy_id); >+ } >+ } > status[index] = now; > } > >@@ -386,6 +427,7 @@ > -r, --restart restart autonegotiation > -w, --watch monitor for link status changes > -l, --log with -w, write events to syslog >+ -a, --activate with -w, activate (or deactivate) interface > -A, --advertise=media,... advertise only specified media > -F, --force=media force specified media technology > media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD, >@@ -396,8 +438,9 @@ > int i, c, ret, errflag = 0; > char s[6]; > >- while ((c = getopt_long(argc, argv, "A:F:p:lrRvVw?", longopts, 0)) != EOF) >+ while ((c = getopt_long(argc, argv, "A:F:p:alrRvVw?", longopts, 0)) != EOF) > switch (c) { >+ case 'a': opt_activate++; break; > case 'A': nway_advertise = parse_media(optarg); break; > case 'F': fixed_speed = parse_media(optarg); break; > case 'p': override_phy = atoi(optarg); break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 7994
: 3957 |
4205
|
4206
|
4207
|
4208
|
4476
|
6581