NAME

ether – Ethernet device

SYNOPSIS

bind –a #ln /net
/net/ether
n/clone
/net/ether
n/addr
/net/ether
n/mtu
/net/ether
n/ifstats
/net/ether
n/stats
/net/ether
n/[0–7]
/net/ether
n/[0–7]/data
/net/ether
n/[0–7]/ctl
/net/ether
n/[0–7]/ifstats
/net/ether
n/[0–7]/stats
/net/ether
n/[0–7]/type

DESCRIPTION

The Ethernet interface, /net/ethern, is a directory containing subdirectories, one for each distinct Ethernet packet type, and clone, addr, mtu, ifstats, and stats files. stats and ifstats are the same as in the subdirectories (see below). Reading addr returns the MAC address of this interface in hex with no punctuation and no trailing newline. Reading mtu returns 3 12–byte numbers: the hardware's minimum MTU, the current MTU and the maximum MTU supported by the interface. The MTU is set by writing mtu n into the ctl file. The number n (optional in the bind) is the device number of the card, permitting multiple cards to be used on a single machine.
Each directory contains files to control the associated connection, receive and send data, and supply statistics. Incoming Ethernet packets are demultiplexed by packet type and passed up the corresponding open connection. Reading from the data file reads packets of that type arriving from the network. A read will terminate at packet boundaries. Each write to the data file causes a packet to be sent. The Ethernet address of the interface is inserted into the packet header as the source address unless l2bridge is set.
A connection is assigned to a packet type by opening its ctl file and writing connect n where n is a decimal integer constant identifying the Ethernet packet type. A type of –1 enables the connection to receive copies of packets of all types. A type of –2 enables the connection to receive copies of the first 64 bytes of packets of all types. If multiple connections are assigned to a given packet type a copy of each packet is passed up each connection.
Some interfaces also accept unique options when written to the ctl (or clone) file; see the description of wavelan in plan9.ini(8). The control messages described in ip(3) under Configuring interfaces from bridge to headersonly are understood. The additional control message nonblocking makes write systems calls to this interface non–blocking iff followed by nothing or a non–zero integer; a following 0 makes writes block on a full output queue.
Reading the ctl file returns the decimal index of the associated connection, 0 through 7. Reading the type file returns the decimal value of the assigned Ethernet packet type. Reading the stats file returns status information such as the Ethernet address of the card and general statistics, independent of the interface; ifstats contains device–specific data and statistics about the card. The format of the stats file is stat:value.... In particular, if link is non–zero, mbps is the current speed of the interface in megabits–per–second. While in and out are the total number of packets input or output and do differ (in the case of dropped packets or loop back) from hardware counters.
An interface normally receives only those packets whose destination address is that of the interface, the broadcast address, ff:ff:ff:ff:ff:ff, or a a multicast address assigned to the interface. Multicast addresses are added by writing addmulti ea and remove by writing remmulti ea to the ctl file. Multicast addresses are automatically dropped when the connection is closed. The interface can be made to receive all packets on the network by writing the string promiscuous to the ctl file. The interface remains promiscuous until the control file is closed by all connections requesting promiscuous mode. The extra packets are passed up connections of types –1 and –2 only.
Writing bridge to the ctl file causes loop back packets to be ignored. This is useful for layer 3 bridging. Writing l2bridge also allows the connection to set the source address and receive packets with any destination address. Writing scanbs [ secs ] starts a scan for wireless base stations and sets the scanning interval to secs. Scanning is terminated when the connection is closed. The default interval is 5s. For wired connections, this command is ignored.

SOURCE

/sys/src/9/*/devether.c
/sys/src/9/port/netif.c

SEE ALSO

ip(3).

BUGS

The multicast interface makes removal of multicast addresses on that rely on hashing difficult.
Interface MTU settings must be greater than those used by ip(3); this is not enforced. NB: interface MTU is different than IP stack's MTU.