vx32

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

commit a67aa934d03346d382256746228fe41c1b73149c
parent 4c6921cc9725d57fa634febc5c2babcd74ccc02e
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date:   Sat, 12 Jun 2010 02:36:30 +0200

etherve can ping now. (an insane amount of) debug iprint()s

Diffstat:
src/9vx/a/devether.c | 15+++++++++------
src/9vx/a/ip/ethermedium.c | 6++++++
src/9vx/devtabve.c | 16++++++++++++++++
src/9vx/ethertap.c | 1+
src/9vx/etherve.c | 32++++++++++----------------------
5 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/src/9vx/a/devether.c b/src/9vx/a/devether.c @@ -163,11 +163,11 @@ etheriq(Ether* ether, Block* bp, int fromwire) /* is it for me? */ tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; -// if(tome||fromme) -// iprint("XXX PACK: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux -> %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux%s%s\n", -// pkt->s[0], pkt->s[1], pkt->s[2],pkt->s[3], pkt->s[4], pkt->s[5], -// pkt->d[0], pkt->d[1], pkt->d[2],pkt->d[3], pkt->d[4], pkt->d[5], -// (tome ? " <<--" : ""), (fromme ? " -->>" : "")); +if(tome||fromme) +iprint("XXX PACK: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux -> %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux%s[%d]%s\n", +pkt->s[0], pkt->s[1], pkt->s[2],pkt->s[3], pkt->s[4], pkt->s[5], +pkt->d[0], pkt->d[1], pkt->d[2],pkt->d[3], pkt->d[4], pkt->d[5], +(tome ? " <<--" : ""), len, (fromme ? " -->>" : "")); /* * Multiplex the packet to all the connections which want it. * If the packet is not to be used subsequently (fromwire != 0), @@ -175,7 +175,9 @@ etheriq(Ether* ether, Block* bp, int fromwire) * saving a copy of the data (usual case hopefully). */ for(fp = ether->ni.f; fp < ep; fp++){ - if((f = *fp) != nil) + if((f = *fp) != nil){ +// if(tome) +// iprint("XXX f->type =%X, type = %X\n", f->type, type); // XXX if(f->type == type || f->type < 0) if(tome || multi || f->prom){ /* Don't want to hear bridged packets */ @@ -196,6 +198,7 @@ etheriq(Ether* ether, Block* bp, int fromwire) else etherrtrace(f, pkt, len); } + } //XXX } if(fx){ diff --git a/src/9vx/a/ip/ethermedium.c b/src/9vx/a/ip/ethermedium.c @@ -161,7 +161,9 @@ etherbind(Ipifc *ifc, int argc, char **argv) * this device. */ snprint(addr, sizeof(addr), "%s!0x800", argv[2]); /* ETIP4 */ +iprint("XXX chandial mchan4: %s\n", &addr); mchan4 = chandial(addr, nil, dir, &cchan4); +iprint("XXX mchan4 = %x\n", mchan4->type); /* * make it non-blocking @@ -200,7 +202,9 @@ etherbind(Ipifc *ifc, int argc, char **argv) * open arp conversation */ snprint(addr, sizeof(addr), "%s!0x806", argv[2]); /* ETARP */ +iprint("XXX chandial achan: %s\n", &addr); achan = chandial(addr, nil, nil, nil); +iprint("XXX achan = %x\n", achan->type); /* * open ipv6 conversation @@ -209,7 +213,9 @@ etherbind(Ipifc *ifc, int argc, char **argv) * this device. */ snprint(addr, sizeof(addr), "%s!0x86DD", argv[2]); /* ETIP6 */ +iprint("XXX chandial mchan6: %s\n", &addr); mchan6 = chandial(addr, nil, dir, &cchan6); +iprint("XXX mchan6 = %x\n", mchan6->type); /* * make it non-blocking diff --git a/src/9vx/devtabve.c b/src/9vx/devtabve.c @@ -64,6 +64,7 @@ extern void ethermediumlink(void); extern void loopbackmediumlink(void); extern void netdevmediumlink(void); void links(void) { +iprint("XXX links\n"); ethermediumlink(); loopbackmediumlink(); netdevmediumlink(); @@ -95,6 +96,21 @@ void (*ipprotoinit[])(Fs*) = { nil, }; +int +eafrom(char *ma, uchar ea[6]) +{ + int i; + char **nc = &ma; + + for(i = 0; i < 6; i++){ + if(!ma) + return -1; + ea[i] = (uchar)strtoul(ma, nc, 16); + ma = *nc+1; + } + return 0; +} + SDifc *sdifc[] = { &sdloopifc, diff --git a/src/9vx/ethertap.c b/src/9vx/ethertap.c @@ -158,6 +158,7 @@ tapifstat(Ether *e, void *a, long n, ulong offset) static void tapattach(Ether* e) { +iprint("XXX tapattach\n"); kproc("taprecv", taprecvkproc, e); } diff --git a/src/9vx/etherve.c b/src/9vx/etherve.c @@ -26,6 +26,8 @@ extern char *macaddr; extern char *netdev; static uvlong txerrs; +extern int eafrom(char *ma, uchar ea[6]); + typedef struct Ctlr Ctlr; struct Ctlr { pcap_t *pd; @@ -33,21 +35,6 @@ struct Ctlr { static uchar ea[6] = {0x00, 0x48, 0x01, 0x23, 0x45, 0x67}; -int -eafrom(char *ma, uchar ea[6]) -{ - int i; - char **nc = &ma; - - for(i = 0; i < 6; i++){ - if(!ma) - return -1; - ea[i] = (uchar)strtoul(ma, nc, 16); - ma = *nc+1; - } - return 0; -} - static void * veerror(char* err) { @@ -75,7 +62,8 @@ setup(void) if (!netdev && (netdev = pcap_lookupdev(errbuf)) == nil) return veerror("cannot find network device"); - if ((pd = pcap_open_live(netdev, 1514, 1, 1, errbuf)) == nil) +// if ((pd = pcap_open_live(netdev, 1514, 1, 1, errbuf)) == nil) + if ((pd = pcap_open_live(netdev, 1514, 1, 1000, errbuf)) == nil) return nil; if (macaddr && (eafrom(macaddr, ea) == -1)) @@ -98,13 +86,13 @@ vepkt(Ctlr *c) struct pcap_pkthdr hdr; Block *b; - if (hdr.caplen) { - b = allocb(1514); - while ((b->rp = pcap_next(c->pd, &hdr)) == nil) ; + b = allocb(1514); + while ((b->rp = pcap_next(c->pd, &hdr)) == nil) ; - b->wp += hdr.caplen; + if (hdr.caplen) { + b->wp = b->rp+hdr.caplen; - // iprint("Got packet len %d\n", hdr.caplen); + iprint("Got packet len %d\n", hdr.caplen); return b; } @@ -119,7 +107,7 @@ verecvkproc(void *v) Block *b; e = v; - while (b = vepkt(e->ctlr)) + while ((b = vepkt(e->ctlr))) if (b != nil) etheriq(e, b, 1); }