On Tue Mar 6 04:55:44 EST 2007, [EMAIL PROTECTED] wrote:
> On 3/6/07, Stevie_Lancaster <[EMAIL PROTECTED]> wrote:
>
> > Thanks for your reply. Under /net there is already a directory ether0.
> > So I guess the device got binded there. Am I right?
>
> I believe it to mean that the device was recognized, but it does not
> mean that it was binded.
i guess this is pedantic but, yes it does mean the device is bound
into the namespace and in most cases you can send and receive
raw ethernet frames.
i've attached an overly-complicated program which prints out the
ip configuration by interface. output is like so:
; ipifc
0:/net/ether0 00a0c973fa3f 1514
205.185.197.2/120 205.185.197.0
0:/net.alt/ether1 000102ed3163 1514
65.14.39.132/123 65.14.39.128
the first line is the ipifc index, a ':', the mountpoint, mac and mtu.
subsequent indented lines are address, a '/', netmask and
network for each configured address. you can get the same
information with
; cat cat /net*/ipifc/?/status>[2=]
but it's a lot harder to read. ;-)
- erik#include <u.h>
#include <libc.h>
#include <ip.h>
char *mtab[10] = {"/net", "/net.alt"};
int nmtab = 2;
void
ipifcprint(char *m, int idx)
{
Ipifc *ifc;
Iplifc *l;
uchar eth[6];
for(ifc = readipifc(m, 0, idx); ifc; ifc = ifc->next){
print("%d:%s ", ifc->index, ifc->dev);
if(myetheraddr(eth, ifc->dev) == 0)
print("\t" "%E", eth);
print("\t" "%d\n", ifc->mtu);
for(l = ifc->lifc; l; l = l->next)
print("\t" "%I%M" "\t" "%I\n", l->ip, l->mask, l->net);
}
// freeipifc(ifc);
}
void
usage(void)
{
fprint(2, "usage: ipfic [-m net mtpt] [interface number] ...\n");
exits("usage");
}
void
main(int argc, char **argv){
char* r;
int i, m;
m = 0;
ARGBEGIN{
case 'm':
if(m++ == 0)
nmtab = 0;
if(++nmtab < nelem(mtab))
mtab[nmtab-1] = EARGF(usage());
break;
}ARGEND;
fmtinstall('I', eipfmt);
fmtinstall('M', eipfmt);
fmtinstall('E', eipfmt);
if(*argv)
for(; *argv; argv++){
i = strtoul(*argv, &r, 0);
if (*r)
usage();
ipifcprint(mtab[0], i);
}
else
for(i = 0; i < nmtab; i++)
ipifcprint(mtab[i], -1);
exits(0);
}