summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/ethersink.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/9/pc/ethersink.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/9/pc/ethersink.c')
-rwxr-xr-xsys/src/9/pc/ethersink.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/sys/src/9/pc/ethersink.c b/sys/src/9/pc/ethersink.c
new file mode 100755
index 000000000..dd701804f
--- /dev/null
+++ b/sys/src/9/pc/ethersink.c
@@ -0,0 +1,65 @@
+/*
+ * 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 "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)
+{
+ uchar ea[Eaddrlen];
+
+ if(ether->type==nil)
+ return -1;
+ memset(ea, 0, sizeof ea);
+ ether->mbps = 1000;
+ ether->attach = nop;
+ ether->transmit = nop;
+ ether->irq = -1;
+ ether->interrupt = nil;
+ ether->ifstat = nil;
+ ether->ctl = ctl;
+ ether->promiscuous = nil;
+ ether->multicast = nil;
+ ether->arg = ether;
+ return 0;
+}
+
+void
+ethersinklink(void)
+{
+ addethercard("sink", reset);
+}