FreeBSD/Linux Kernel Cross Reference
sys/pc/ethersink.c
1 /*
2 * An ethernet /dev/null.
3 * Useful as a bridging target with ethernet-based VPN.
4 */
5 #include "u.h"
6 #include "../port/lib.h"
7 #include "mem.h"
8 #include "dat.h"
9 #include "fns.h"
10 #include "io.h"
11 #include "../port/error.h"
12 #include "../port/netif.h"
13 #include "etherif.h"
14
15 static long
16 ctl(Ether *ether, void *buf, long n)
17 {
18 uchar ea[Eaddrlen];
19 Cmdbuf *cb;
20
21 cb = parsecmd(buf, n);
22 if(cb->nf >= 2
23 && strcmp(cb->f[0], "ea")==0
24 && parseether(ea, cb->f[1]) == 0){
25 free(cb);
26 memmove(ether->ea, ea, Eaddrlen);
27 memmove(ether->addr, ether->ea, Eaddrlen);
28 return 0;
29 }
30 free(cb);
31 error(Ebadctl);
32 return -1; /* not reached */
33 }
34
35 static void
36 nop(Ether*)
37 {
38 }
39
40 static int
41 reset(Ether* ether)
42 {
43 uchar ea[Eaddrlen];
44
45 if(ether->type==nil)
46 return -1;
47 memset(ea, 0, sizeof ea);
48 ether->mbps = 1000;
49 ether->attach = nop;
50 ether->transmit = nop;
51 ether->irq = -1;
52 ether->interrupt = nil;
53 ether->ifstat = nil;
54 ether->ctl = ctl;
55 ether->promiscuous = nil;
56 ether->multicast = nil;
57 ether->arg = ether;
58 return 0;
59 }
60
61 void
62 ethersinklink(void)
63 {
64 addethercard("sink", reset);
65 }
Cache object: 2c3ca2b055254e4117f379d0024e8bef
|