9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Ethernet link status
@ 2003-10-09  4:33 Micah Stetson
  2003-10-09  4:38 ` David Presotto
  0 siblings, 1 reply; 2+ messages in thread
From: Micah Stetson @ 2003-10-09  4:33 UTC (permalink / raw)
  To: 9fans

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] Ethernet link status
  2003-10-09  4:33 [9fans] Ethernet link status Micah Stetson
@ 2003-10-09  4:38 ` David Presotto
  0 siblings, 0 replies; 2+ messages in thread
From: David Presotto @ 2003-10-09  4:38 UTC (permalink / raw)
  To: 9fans

The stats files in connection directories was stupid, because I
originally had a simple structure and that was the easy place to
put the stats files.  I really should move it up but never get
around to it...

In general, stats is meant for generic info common to all types of
interfaces and ifstats for interface specific stuff.   I would say
that link is generic; even the 802.11's have something you might
construe as link (i.e. a base station to talk to).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-09  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-09  4:33 [9fans] Ethernet link status Micah Stetson
2003-10-09  4:38 ` David Presotto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).