vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 5bfd69bcd2fce3ea03aa5144ed89d6fd58ce4494
parent f86dffdd8e2770c38a34e668de7f9a07377a0a89
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date:   Sun,  6 Jun 2010 01:51:43 +0200

etherve and ethertap consistency, -m used by ethertap

Diffstat:
src/9vx/ethertap.c | 34++++++++++++++++++----------------
src/9vx/etherve.c | 4++--
2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/9vx/ethertap.c b/src/9vx/ethertap.c @@ -24,9 +24,11 @@ #include "a/etherif.h" -extern char *netdev; +extern char *macaddr; +extern char *netdev; -static uchar anyea[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff,}; +extern int eafrom(char *ma); +extern void *veerror(char* err); typedef struct Ctlr Ctlr; struct Ctlr { @@ -36,11 +38,18 @@ struct Ctlr { uchar ea[Eaddrlen]; }; +static uchar anyea[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff,}; +static uchar ea[6] = {0x00, 0x48, 0x01, 0x23, 0x45, 0x67}; + static int -setup(char *dev) +setup(void) { int fd; struct ifreq ifr; + char *dev = "tap0"; + + if(netdev) + dev = netdev; if((fd = open("/dev/net/tun", O_RDWR)) < 0) return -1; @@ -52,6 +61,9 @@ setup(char *dev) return -1; } + if (macaddr && (eafrom(macaddr) == -1)) + return veerror("cannot read mac address"); + return fd; } @@ -127,29 +139,19 @@ tapattach(Ether* e) kproc("taprecv", taprecvkproc, e); } -static uchar eatab[] = { - 0x00, 0x48, 0x01, 0x23, 0x45, 0x60, -}; - static int tappnp(Ether* e) { uchar *ea; Ctlr c; static int nctlr; - char *dev = "tap0"; - if(nctlr >= nelem(eatab)/Eaddrlen) + if(nctlr++ > 0) return -1; - ea = eatab + Eaddrlen*nctlr; memset(&c, 0, sizeof c); - if(netdev) - dev = netdev; - c.fd = setup(dev); - nctlr++; - memcpy(c.ea, ea, Eaddrlen); + c.fd = setup(); if(c.fd== -1){ - print("tap: failed to initialize\n"); + iprint("ve: tap failed to initialize\n"); return -1; } e->ctlr = malloc(sizeof c); diff --git a/src/9vx/etherve.c b/src/9vx/etherve.c @@ -33,7 +33,7 @@ struct Ctlr { static uchar ea[6] = {0x00, 0x48, 0x01, 0x23, 0x45, 0x67}; -static int +int eafrom(char *ma) { int i; @@ -48,7 +48,7 @@ eafrom(char *ma) return 0; } -static void * +void * veerror(char* err) { iprint("ve: %s\n", err);