9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Micah Stetson <micah@cnm-vra.com>
To: 9fans@cse.psu.edu
Subject: [9fans] Ethernet link status
Date: Wed,  8 Oct 2003 21:33:03 -0700	[thread overview]
Message-ID: <20031009043303.GB3466@epaphras.cnm-vra.com> (raw)

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



             reply	other threads:[~2003-10-09  4:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09  4:33 Micah Stetson [this message]
2003-10-09  4:38 ` David Presotto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031009043303.GB3466@epaphras.cnm-vra.com \
    --to=micah@cnm-vra.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).