diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-02-11 18:08:03 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-02-11 18:08:03 +0100 |
commit | d6e0e9c402e215dc5659ad525e3e652501f76810 (patch) | |
tree | d3157154f97516235da7c473e962b3410be46359 /sys/src/9/port/ethersink.c | |
parent | debb786fea3d6ea8018c3d83cdedfdbff0703441 (diff) |
kernel: move devether and wifi to port/
the only architecture dependence of devether was enabling interrupts,
which is now done at the end of the driver's reset() function now.
the wifi stack and dummy ethersink also go to port/.
do the IRQ2->IRQ9 hack for pc kernels in intrenabale(), so not
every caller of intrenable() has to be aware of it.
Diffstat (limited to 'sys/src/9/port/ethersink.c')
-rw-r--r-- | sys/src/9/port/ethersink.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sys/src/9/port/ethersink.c b/sys/src/9/port/ethersink.c new file mode 100644 index 000000000..a005af3a8 --- /dev/null +++ b/sys/src/9/port/ethersink.c @@ -0,0 +1,60 @@ +/* + * An ethernet /dev/null. + * Useful as a bridging target with ethernet-based VPN. + */ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "io.h" +#include "../port/error.h" +#include "../port/netif.h" +#include "../port/etherif.h" + +static long +ctl(Ether *ether, void *buf, long n) +{ + uchar ea[Eaddrlen]; + Cmdbuf *cb; + + cb = parsecmd(buf, n); + if(cb->nf >= 2 + && strcmp(cb->f[0], "ea")==0 + && parseether(ea, cb->f[1]) == 0){ + free(cb); + memmove(ether->ea, ea, Eaddrlen); + memmove(ether->addr, ether->ea, Eaddrlen); + return 0; + } + free(cb); + error(Ebadctl); + return -1; /* not reached */ +} + +static void +nop(Ether*) +{ +} + +static int +reset(Ether* ether) +{ + if(ether->type==nil) + return -1; + ether->mbps = 1000; + ether->attach = nop; + ether->transmit = nop; + ether->ifstat = nil; + ether->ctl = ctl; + ether->promiscuous = nil; + ether->multicast = nil; + ether->arg = ether; + return 0; +} + +void +ethersinklink(void) +{ + addethercard("sink", reset); +} |