--- /sys/src/9/ip/arp.c +++ /sys/src/9/ip/arp.c @@ -70,7 +70,6 @@ newarp6(Arp *arp, uchar *ip, Ipifc *ifc, int addrxt) uint t; Block *next, *xp; Arpent *a, *e, *f, **l; - Medium *m = ifc->m; int empty; /* find oldest entry */ @@ -127,7 +126,7 @@ newarp6(Arp *arp, uchar *ip, Ipifc *ifc, int addrxt) memmove(a->ip, ip, sizeof(a->ip)); a->utime = NOW; a->ctime = 0; - a->type = m; + a->type = ifc->medium; a->rtime = NOW + ReTransTimer; a->rxtsrem = MAX_MULTICAST_SOLICIT; @@ -208,7 +207,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uchar *ip, uchar *mac) { int hash; Arpent *a; - Medium *type = ifc->m; + Medium *type; uchar v6ip[IPaddrlen]; if(version == V4){ @@ -218,6 +217,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uchar *ip, uchar *mac) qlock(arp); hash = haship(ip); + type = ifc->medium; for(a = arp->hash[hash]; a; a = a->hash){ if(memcmp(ip, a->ip, sizeof(a->ip)) == 0) if(type == a->type) @@ -332,7 +332,7 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh) } ifc = r->ifc; - type = ifc->m; + type = ifc->medium; qlock(arp); for(a = arp->hash[haship(ip)]; a; a = a->hash){ @@ -373,8 +373,8 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh) nexterror(); } rlock(ifc); - if(ifc->m != nil) - ifc->m->bwrite(ifc, bp, version, ip); + if(ifc->medium != nil) + ifc->medium->bwrite(ifc, bp, version, ip); else freeb(bp); runlock(ifc); @@ -406,7 +406,7 @@ arpwrite(Fs *fs, char *s, int len) Arp *arp; Block *bp; Arpent *a, *fl, **l; - Medium *m; + Medium *type; char *f[4], buf[256]; uchar ip[IPaddrlen], mac[MAClen]; @@ -455,23 +455,23 @@ arpwrite(Fs *fs, char *s, int len) r = v6lookup(fs, ip, nil); if(r == nil) error("Destination unreachable"); - m = r->ifc->m; - n = parsemac(mac, f[2], m->maclen); + type = r->ifc->medium; + n = parsemac(mac, f[2], type->maclen); break; case 4: - m = ipfindmedium(f[1]); - if(m == nil) + type = ipfindmedium(f[1]); + if(type == nil) error(Ebadarp); if (parseip(ip, f[2]) == -1) error(Ebadip); - n = parsemac(mac, f[3], m->maclen); + n = parsemac(mac, f[3], type->maclen); break; } - if(m->ares == nil) + if(type->ares == nil) error(Ebadarp); - m->ares(fs, V6, ip, mac, n, 0); + type->ares(fs, V6, ip, mac, n, 0); } else if(strcmp(f[0], "del") == 0){ if(n != 2) error(Ebadarg); --- /sys/src/9/ip/ethermedium.c +++ /sys/src/9/ip/ethermedium.c @@ -280,7 +280,7 @@ etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip) a = arpget(er->f->arp, bp, version, ifc, ip, mac); if(a){ /* check for broadcast or multicast */ - bp = multicastarp(er->f, a, ifc->m, mac); + bp = multicastarp(er->f, a, ifc->medium, mac); if(bp==nil){ switch(version){ case V4: @@ -297,7 +297,7 @@ etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip) } /* make it a single block with space for the ether header */ - bp = padblock(bp, ifc->m->hsize); + bp = padblock(bp, ifc->medium->hsize); if(bp->next) bp = concatblock(bp); if(BLEN(bp) < ifc->mintu) @@ -354,7 +354,7 @@ etherread4(void *a) nexterror(); } ifc->in++; - bp->rp += ifc->m->hsize; + bp->rp += ifc->medium->hsize; if(ifc->lifc == nil) freeb(bp); else @@ -393,7 +393,7 @@ etherread6(void *a) nexterror(); } ifc->in++; - bp->rp += ifc->m->hsize; + bp->rp += ifc->medium->hsize; if(ifc->lifc == nil) freeb(bp); else @@ -553,8 +553,8 @@ sendgarp(Ipifc *ifc, uchar *ip) return; n = sizeof(Etherarp); - if(n < ifc->m->mintu) - n = ifc->m->mintu; + if(n < ifc->medium->mintu) + n = ifc->medium->mintu; bp = allocb(n); memset(bp->rp, 0, n); e = (Etherarp*)bp->rp; --- /sys/src/9/ip/icmp6.c +++ /sys/src/9/ip/icmp6.c @@ -534,7 +534,7 @@ icmppkttoobig6(Fs *f, Ipifc *ifc, Block *bp) memmove(np->dst, p->src, IPaddrlen); np->type = PacketTooBigV6; np->code = 0; - hnputl(np->icmpid, ifc->maxtu - ifc->m->hsize); + hnputl(np->icmpid, ifc->maxtu - ifc->medium->hsize); memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); set_cksum(nbp); np->ttl = HOP_LIMIT; --- /sys/src/9/ip/igmp.c +++ /sys/src/9/ip/igmp.c @@ -161,7 +161,7 @@ igmpproc(void *a) if(mp){ /* do a single report and try again */ hnputl(ip, mp->addr); - igmpsendreport(rp->m, ip); + igmpsendreport(rp->medium, ip); free(mp); continue; } @@ -209,7 +209,7 @@ igmpiput(Medium *m, Ipifc *, Block *bp) */ stats.inqueries++; for(rp = igmpalloc.reports; rp; rp = rp->next) - if(rp->m == m) + if(rp->medium == m) break; if(rp != nil) break; /* already reporting */ @@ -222,7 +222,7 @@ igmpiput(Medium *m, Ipifc *, Block *bp) if(rp == nil) break; - rp->m = m; + rp->medium = m; rp->multi = mp; rp->ticks = 0; for(; mp; mp = mp->next) @@ -240,7 +240,7 @@ igmpiput(Medium *m, Ipifc *, Block *bp) stats.inreports++; lrp = &igmpalloc.reports; for(rp = *lrp; rp; rp = *lrp){ - if(rp->m == m) + if(rp->medium == m) break; lrp = &rp->next; } --- /sys/src/9/ip/ip.c +++ /sys/src/9/ip/ip.c @@ -194,14 +194,14 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) runlock(ifc); nexterror(); } - if(ifc->m == nil) + if(ifc->medium == nil) goto raise; /* If we dont need to fragment just send it */ if(c && c->maxfragsize && c->maxfragsize < ifc->maxtu) - medialen = c->maxfragsize - ifc->m->hsize; + medialen = c->maxfragsize - ifc->medium->hsize; else - medialen = ifc->maxtu - ifc->m->hsize; + medialen = ifc->maxtu - ifc->medium->hsize; if(len <= medialen) { if(!gating) hnputs(eh->id, incref(&ip->id4)); @@ -214,7 +214,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) eh->cksum[1] = 0; hnputs(eh->cksum, ipcsum(&eh->vihl)); assert(bp->next == nil); - ifc->m->bwrite(ifc, bp, V4, gate); + ifc->medium->bwrite(ifc, bp, V4, gate); runlock(ifc); poperror(); return 0; @@ -299,7 +299,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) feh->cksum[0] = 0; feh->cksum[1] = 0; hnputs(feh->cksum, ipcsum(&feh->vihl)); - ifc->m->bwrite(ifc, nb, V4, gate); + ifc->medium->bwrite(ifc, nb, V4, gate); ip->stats[FragCreates]++; } ip->stats[FragOKs]++; --- /sys/src/9/ip/ip.h +++ /sys/src/9/ip/ip.h @@ -312,7 +312,7 @@ struct Ipifc Conv *conv; /* link to its conversation structure */ char dev[64]; /* device we're attached to */ - Medium *m; /* Media pointer */ + Medium *medium; /* Media pointer */ int maxtu; /* Maximum transfer unit */ int mintu; /* Minumum tranfer unit */ int mbps; /* megabits per second */ --- /sys/src/9/ip/ipifc.c +++ /sys/src/9/ip/ipifc.c @@ -104,7 +104,7 @@ static char* ipifcbind(Conv *c, char **argv, int argc) { Ipifc *ifc; - Medium *m; + Medium *medium; if(argc < 2) return Ebadarg; @@ -112,12 +112,12 @@ ipifcbind(Conv *c, char **argv, int argc) ifc = (Ipifc*)c->ptcl; /* bind the device to the interface */ - m = ipfindmedium(argv[1]); - if(m == nil) + medium = ipfindmedium(argv[1]); + if(medium == nil) return "unknown interface type"; wlock(ifc); - if(ifc->m != nil){ + if(ifc->medium != nil){ wunlock(ifc); return "interface already bound"; } @@ -127,20 +127,20 @@ ipifcbind(Conv *c, char **argv, int argc) } /* do medium specific binding */ - (*m->bind)(ifc, argc, argv); + (*medium->bind)(ifc, argc, argv); /* set the bound device name */ if(argc > 2) strncpy(ifc->dev, argv[2], sizeof(ifc->dev)); else - snprint(ifc->dev, sizeof ifc->dev, "%s%d", m->name, c->x); + snprint(ifc->dev, sizeof ifc->dev, "%s%d", medium->name, c->x); ifc->dev[sizeof(ifc->dev)-1] = 0; /* set up parameters */ - ifc->m = m; - ifc->mintu = ifc->m->mintu; - ifc->maxtu = ifc->m->maxtu; - if(ifc->m->unbindonclose == 0) + ifc->medium = medium; + ifc->mintu = ifc->medium->mintu; + ifc->maxtu = ifc->medium->maxtu; + if(ifc->medium->unbindonclose == 0) ifc->conv->inuse++; ifc->rp.mflag = 0; /* default not managed */ ifc->rp.oflag = 0; @@ -182,7 +182,7 @@ ipifcunbind(Ipifc *ifc) wlock(ifc); /* dissociate routes */ - if(ifc->m != nil && ifc->m->unbindonclose == 0) + if(ifc->medium != nil && ifc->medium->unbindonclose == 0) ifc->conv->inuse--; ifc->ifcid++; @@ -198,8 +198,8 @@ ipifcunbind(Ipifc *ifc) } /* disassociate device */ - if(ifc->m && ifc->m->unbind) - (*ifc->m->unbind)(ifc); + if(ifc->medium && ifc->medium->unbind) + (*ifc->medium->unbind)(ifc); memset(ifc->dev, 0, sizeof(ifc->dev)); ifc->arg = nil; ifc->reassemble = 0; @@ -209,7 +209,7 @@ ipifcunbind(Ipifc *ifc) qclose(ifc->conv->wq); qclose(ifc->conv->sq); - ifc->m = nil; + ifc->medium = nil; wunlock(ifc); poperror(); return nil; @@ -274,7 +274,7 @@ ipifcinuse(Conv *c) Ipifc *ifc; ifc = (Ipifc*)c->ptcl; - return ifc->m != nil; + return ifc->medium != nil; } /* @@ -300,10 +300,10 @@ ipifckick(void *x) runlock(ifc); nexterror(); } - if(ifc->m == nil || ifc->m->pktin == nil) + if(ifc->medium == nil || ifc->medium->pktin == nil) freeb(bp); else - (*ifc->m->pktin)(c->p->f, ifc, bp); + (*ifc->medium->pktin)(c->p->f, ifc, bp); runlock(ifc); poperror(); } @@ -322,7 +322,7 @@ ipifccreate(Conv *c) ifc = (Ipifc*)c->ptcl; ifc->conv = c; ifc->unbinding = 0; - ifc->m = nil; + ifc->medium = nil; ifc->reassemble = 0; } @@ -334,11 +334,11 @@ static void ipifcclose(Conv *c) { Ipifc *ifc; - Medium *m; + Medium *medium; ifc = (Ipifc*)c->ptcl; - m = ifc->m; - if(m && m->unbindonclose) + medium = ifc->medium; + if(medium != nil && medium->unbindonclose) ipifcunbind(ifc); } @@ -350,10 +350,10 @@ ipifcsetmtu(Ipifc *ifc, char **argv, int argc) { int mtu; - if(argc < 2 || ifc->m == nil) + if(argc < 2 || ifc->medium == nil) return Ebadarg; mtu = strtoul(argv[1], 0, 0); - if(mtu < ifc->m->mintu || mtu > ifc->m->maxtu) + if(mtu < ifc->medium->mintu || mtu > ifc->medium->maxtu) return Ebadarg; ifc->maxtu = mtu; return nil; @@ -371,7 +371,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) Iplifc *lifc, **l; Fs *f; - if(ifc->m == nil) + if(ifc->medium == nil) return "ipifc not yet bound to device"; f = ifc->conv->p->f; @@ -387,7 +387,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) /* fall through */ case 5: mtu = strtoul(argv[4], 0, 0); - if(mtu >= ifc->m->mintu && mtu <= ifc->m->maxtu) + if(mtu >= ifc->medium->mintu && mtu <= ifc->medium->maxtu) ifc->maxtu = mtu; /* fall through */ case 4: @@ -525,8 +525,8 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) } /* register the address on this network for address resolution */ - if(isv4(ip) && ifc->m->areg != nil) - (*ifc->m->areg)(ifc, ip); + if(isv4(ip) && ifc->medium->areg != nil) + (*ifc->medium->areg)(ifc, ip); out: wunlock(ifc); @@ -628,7 +628,7 @@ ipifcrem(Ipifc *ifc, char **argv, int argc) void ipifcaddroute(Fs *f, int vers, uchar *addr, uchar *mask, uchar *gate, int type) { - Medium *m; + Medium *medium; Conv **cp, **e; Ipifc *ifc; @@ -636,9 +636,9 @@ ipifcaddroute(Fs *f, int vers, uchar *addr, uchar *mask, uchar *gate, int type) for(cp = f->ipifc->conv; cp < e; cp++){ if(*cp != nil) { ifc = (Ipifc*)(*cp)->ptcl; - m = ifc->m; - if(m && m->addroute) - m->addroute(ifc, vers, addr, mask, gate, type); + medium = ifc->medium; + if(medium != nil && medium->addroute != nil) + medium->addroute(ifc, vers, addr, mask, gate, type); } } } @@ -646,7 +646,7 @@ ipifcaddroute(Fs *f, int vers, uchar *addr, uchar *mask, uchar *gate, int type) void ipifcremroute(Fs *f, int vers, uchar *addr, uchar *mask) { - Medium *m; + Medium *medium; Conv **cp, **e; Ipifc *ifc; @@ -654,9 +654,9 @@ ipifcremroute(Fs *f, int vers, uchar *addr, uchar *mask) for(cp = f->ipifc->conv; cp < e; cp++){ if(*cp != nil) { ifc = (Ipifc*)(*cp)->ptcl; - m = ifc->m; - if(m && m->remroute) - m->remroute(ifc, vers, addr, mask); + medium = ifc->medium; + if(medium != nil && medium->remroute != nil) + medium->remroute(ifc, vers, addr, mask); } } } @@ -674,7 +674,7 @@ ipifcconnect(Conv* c, char **argv, int argc) ifc = (Ipifc*)c->ptcl; - if(ifc->m == nil) + if(ifc->medium == nil) return "ipifc not yet bound to device"; if(waserror()){ @@ -881,8 +881,8 @@ addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a, int type) else v6addroute(f, tifc, a, IPallbits, a, type); - if((type & Rmulti) && ifc->m->addmulti != nil) - (*ifc->m->addmulti)(ifc, a, lifc->local); + if((type & Rmulti) && ifc->medium->addmulti != nil) + (*ifc->medium->addmulti)(ifc, a, lifc->local); } else lp->ref++; @@ -993,8 +993,8 @@ remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a) if(--(link->ref) != 0) goto out; - if((p->type & Rmulti) && ifc->m->remmulti != nil) - (*ifc->m->remmulti)(ifc, a, lifc->local); + if((p->type & Rmulti) && ifc->medium->remmulti != nil) + (*ifc->medium->remmulti)(ifc, a, lifc->local); /* ref == 0, remove from both chains and free the link */ *l_lifc = link->lifclink; @@ -1528,7 +1528,7 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip) Conv **cp, **e; Ipifc *nifc; Iplifc *lifc; - Medium *m; + Medium *medium; uchar net[IPaddrlen]; /* register the address on any network that will proxy for us */ @@ -1539,8 +1539,8 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip) if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc) continue; rlock(nifc); - m = nifc->m; - if(m == nil || m->addmulti == nil) { + medium = nifc->medium; + if(medium == nil || medium->addmulti == nil) { runlock(nifc); continue; } @@ -1551,7 +1551,7 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip) ipv62smcast(net, ip); addselfcache(f, nifc, lifc, net, Rmulti); arpenter(f, V6, ip, nifc->mac, 6, 0); - // (*m->addmulti)(nifc, net, ip); + // (*medium->addmulti)(nifc, net, ip); break; } } @@ -1563,15 +1563,15 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip) if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc) continue; rlock(nifc); - m = nifc->m; - if(m == nil || m->areg == nil){ + medium = nifc->medium; + if(medium == nil || medium->areg == nil){ runlock(nifc); continue; } for(lifc = nifc->lifc; lifc; lifc = lifc->next){ maskip(ip, lifc->mask, net); if(ipcmp(net, lifc->remote) == 0){ - (*m->areg)(nifc, ip); + (*medium->areg)(nifc, ip); /* e.g., send garp */ break; } } @@ -1656,9 +1656,9 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc) lifc->origint = origint; /* issue "add" ctl msg for v6 link-local addr and prefix len */ - if(!ifc->m->pref2addr) + if(!ifc->medium->pref2addr) return "no pref2addr on interface"; - ifc->m->pref2addr(prefix, ifc->mac); /* mac → v6 link-local addr */ + ifc->medium->pref2addr(prefix, ifc->mac); /* mac → v6 link-local addr */ snprint(addr, sizeof addr, "%I", prefix); snprint(preflen, sizeof preflen, "/%d", plen); params[0] = "add"; --- /sys/src/9/ip/ipv6.c +++ /sys/src/9/ip/ipv6.c @@ -111,14 +111,14 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) nexterror(); } - if(ifc->m == nil) + if(ifc->medium == nil) goto raise; /* If we dont need to fragment just send it */ - medialen = ifc->maxtu - ifc->m->hsize; + medialen = ifc->maxtu - ifc->medium->hsize; if(len <= medialen) { hnputs(eh->ploadlen, len - IP6HDR); - ifc->m->bwrite(ifc, bp, V6, gate); + ifc->medium->bwrite(ifc, bp, V6, gate); runlock(ifc); poperror(); return 0; @@ -209,7 +209,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) xp = xp->next; } - ifc->m->bwrite(ifc, nb, V6, gate); + ifc->medium->bwrite(ifc, nb, V6, gate); ip->stats[FragCreates]++; } ip->stats[FragOKs]++; --- /sys/src/9/ip/tcp.c +++ /sys/src/9/ip/tcp.c @@ -891,12 +891,12 @@ tcpmtu(Proto *tcp, uchar *addr, int version, uint *scale) case V4: mtu = DEF_MSS; if(ifc != nil) - mtu = ifc->maxtu - ifc->m->hsize - (TCP4_PKT + TCP4_HDRSIZE); + mtu = ifc->maxtu - ifc->medium->hsize - (TCP4_PKT + TCP4_HDRSIZE); break; case V6: mtu = DEF_MSS6; if(ifc != nil) - mtu = ifc->maxtu - ifc->m->hsize - (TCP6_PKT + TCP6_HDRSIZE); + mtu = ifc->maxtu - ifc->medium->hsize - (TCP6_PKT + TCP6_HDRSIZE); break; } /*