vx32

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

commit 7792c92a37520a1624fcbc3c715ecc92a8f8859f
parent aff39c5e39f41bf6e06f9674de4741e40212742a
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date:   Tue, 15 Jun 2010 19:08:25 +0200

functions and data for multiple virtual network devices

Diffstat:
src/9vx/vether.c | 34++++++++++++++++++++++++++++++++++
src/9vx/vether.h | 10++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/src/9vx/vether.c b/src/9vx/vether.c @@ -5,6 +5,9 @@ #include "fns.h" #include "error.h" #include "ip/ip.h" +#include "netif.h" +#include "etherif.h" +#include "vether.h" #include "sd.h" extern int nettap; @@ -27,6 +30,37 @@ extern void espinit(Fs*); extern SDifc sdloopifc; extern SDifc sdaoeifc; +void +setea(char *macaddr) +{ + int i; + char **nc = &macaddr; + + if(nve == 0) + return; + for(i = 0; i < Eaddrlen; i++){ + ve[nve-1].ea[i] = (uchar)strtoul(macaddr, nc, 16); + macaddr = *nc+1; + } +} + +void +addve(char *dev, int tap) +{ + int i; + + static uchar ea[Eaddrlen] = {0x00, 0x00, 0x09, 0x00, 0x00, 0x00}; + + if(nve == MaxEther) + panic("too many virtual ether cards"); + ve[nve].dev = dev; + ve[nve].tap = tap; + /* This ea could conflict with one given by the user */ + memcpy(ve[nve].ea, ea, Eaddrlen); + ea[5]++; + nve++; +} + void links(void) { ethermediumlink(); loopbackmediumlink(); diff --git a/src/9vx/vether.h b/src/9vx/vether.h @@ -0,0 +1,10 @@ +typedef struct Vether Vether; +struct Vether +{ + int tap; + char *dev; + uchar ea[Eaddrlen]; +}; + +static Vether ve[MaxEther+1]; +static int nve = 0;