From mboxrd@z Thu Jan 1 00:00:00 1970 From: Micah Stetson To: 9fans@cse.psu.edu Message-ID: <20031009043303.GB3466@epaphras.cnm-vra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: [9fans] Ethernet link status Date: Wed, 8 Oct 2003 21:33:03 -0700 Topicbox-Message-UUID: 694572aa-eacc-11e9-9e20-41e7f4b1d025 I want to make ip/ipconfig run only if my ethernet is plugged in. I use a laptop, and I spend about equal time with and without the ethernet plugged in. So I would like to have something like this in termrc.local: if (grep -s 'link: 1' /net/ether0/0/ifstats) ip/ipconfig It was trivial for me to hack this together for the 82557 (I love Plan 9 device drivers). But I think it would be more generally useful, so I'd like to do it in a way that would make it worth including in the distribution. To that end, I have a few questions. First, should it be in stats, ifstats, or a new file like addr? What is the real difference between stats and ifstats? If I read the manual aright, stats information is not specific to the network medium while ifstats is. Ether seems to be the only medium implemented, though, so I have nothing else to compare to. Is link up/down generic enough for stats? What about T1 interfaces' serial interface up/line protocol down stuff? Should it be more generic, or should I put it in ifstats, or do we care? For now, I put it in ifstats because it made it easier to get the status when it was asked for. Second, since stats and ifstats are in the connection directories, I have to open /net/ether0/clone in order to make sure I can get the status in termrc.local. This seems like needless pain. Why are the stats files in the connection directories, anyway? Third, and most important, are other people willing to do this kind of thing for the other ethernet adapters? Here's a diff for ether82557.c: diff ether82557.c.orig ether82557.c 38a39 > Gstatus = 0x1D, /* General status register */ 405c406 < int i, len, phyaddr; --- > int i, len, phyaddr, link; 458a460,462 > > link = csr8r(ctlr, Gstatus) & 0x1; > len += snprint(p+len, READSTR-len, "link: %d\n", link); Thanks, Micah