| plan 9 kernel history: overview | file list | diff list |
1998/0306/ip/gre.c (diff list | history)
| 1997/0531/sys/src/9/ip/gre.c:23,42 – 1998/0306/sys/src/9/ip/gre.c:23,42 (short | long | prev | next) | ||
| 1997/0327 | typedef struct GREhdr { /* ip header */ | |
| 1998/0306 | uchar vihl; /* Version and header length */ uchar tos; /* Type of service */ uchar len[2]; /* packet length (including headers) */ uchar id[2]; /* Identification */ uchar frag[2]; /* Fragment information */ uchar Unused; uchar proto; /* Protocol */ uchar cksum[2]; /* checksum */ uchar src[4]; /* Ip source */ uchar dst[4]; /* Ip destination */ | |
| 1997/0327 | /* gre header */ | |
| 1998/0306 | uchar flags[2]; uchar eproto[2]; /* encapsulation protocol */ | |
| 1997/0327 | } GREhdr; Proto gre; | |
| 1997/0531/sys/src/9/ip/gre.c:56,62 – 1998/0306/sys/src/9/ip/gre.c:56,62 | ||
| 1997/0327 | /* make sure noone's already connected to this other sys */ p = c->p; | |
| 1998/0306 | qlock(p); | |
| 1997/0327 | ecp = &p->conv[p->nc]; for(cp = p->conv; cp < ecp; cp++){ tc = *cp; | |
| 1997/0531/sys/src/9/ip/gre.c:66,77 – 1998/0306/sys/src/9/ip/gre.c:66,77 | ||
| 1997/0327 | continue; if(tc->rport == c->rport && tc->raddr == c->raddr){ err = "already connected to that addr/proto"; | |
| 1998/0306 | ipmove(c->laddr, IPnoaddr); ipmove(c->raddr, IPnoaddr); | |
| 1997/0327 | break; } } | |
| 1998/0306 | qunlock(p); | |
| 1997/0327 | ||
| 1997/0403 | if(err != nil) return err; | |
| 1997/0531/sys/src/9/ip/gre.c:81,91 – 1998/0306/sys/src/9/ip/gre.c:81,90 | ||
| 1997/0327 | } static int | |
| 1998/0306 | grestate(Conv *c, char *state, int n) | |
| 1997/0327 | { USED(c); | |
| 1998/0306 | return snprint(state, n, "%s", "Datagram"); | |
| 1997/0327 | } static void | |
| 1997/0531/sys/src/9/ip/gre.c:107,114 – 1998/0306/sys/src/9/ip/gre.c:106,113 | ||
| 1997/0327 | qclose(c->rq); qclose(c->wq); qclose(c->eq); | |
| 1998/0306 | ipmove(c->laddr, IPnoaddr); ipmove(c->raddr, IPnoaddr); | |
| 1997/0327 | c->lport = 0; c->rport = 0; | |
| 1997/0531/sys/src/9/ip/gre.c:122,128 – 1998/0306/sys/src/9/ip/gre.c:121,127 | ||
| 1997/0327 | { GREhdr *ghp; | |
| 1997/0524 | Block *bp; | |
| 1997/0530 |
| |
| 1998/0306 | uchar laddr[IPaddrlen], raddr[IPaddrlen]; | |
| 1997/0327 | USED(l); | |
| 1997/0531/sys/src/9/ip/gre.c:142,157 – 1998/0306/sys/src/9/ip/gre.c:141,157 | ||
| 1997/0327 | ghp = (GREhdr *)(bp->rp); | |
| 1997/0531 |
| |
| 1997/0530 |
| |
| 1997/0531 |
| |
| 1997/0530 |
| |
| 1998/0306 | v4tov6(raddr, ghp->dst); if(ipcmp(raddr, v4prefix) == 0) memmove(ghp->dst, c->raddr + IPv4off, IPv4addrlen); v4tov6(laddr, ghp->src); if(ipcmp(laddr, v4prefix) == 0){ if(ipcmp(c->laddr, IPnoaddr) == 0) findlocalip(c->laddr, raddr); /* pick interface closest to dest */ memmove(ghp->src, c->laddr + IPv4off, IPv4addrlen); } | |
| 1997/0530 | ||
| 1997/0327 | ghp->proto = IP_GREPROTO; | |
| 1997/0530 |
| |
| 1997/0327 | hnputs(ghp->eproto, c->rport); | |
| 1997/0522 | ghp->frag[0] = 0; ghp->frag[1] = 0; | |
| 1997/0531/sys/src/9/ip/gre.c:160,178 – 1998/0306/sys/src/9/ip/gre.c:160,177 | ||
| 1997/0327 | } static void | |
| 1997/0423 |
| |
| 1998/0306 | greiput(uchar*, Block *bp) | |
| 1997/0327 | { int len; GREhdr *ghp; | |
| 1998/0306 | uchar raddr[IPaddrlen]; | |
| 1997/0327 | ||
| 1997/0423 |
| |
| 1997/0327 | ghp = (GREhdr*)(bp->rp); | |
| 1998/0306 | v4tov6(raddr, ghp->src); | |
| 1997/0327 | eproto = nhgets(ghp->eproto); | |
| 1997/0531/sys/src/9/ip/gre.c:180,186 – 1998/0306/sys/src/9/ip/gre.c:179,185 | ||
| 1997/0327 | c = *p; if(c->inuse == 0) continue; | |
| 1998/0306 | if(c->rport == eproto && ipcmp(c->raddr, raddr) == 0) | |
| 1997/0327 | break; } | |
| 1997/0531/sys/src/9/ip/gre.c:216,221 – 1998/0306/sys/src/9/ip/gre.c:215,228 | ||
| 1997/0327 | } } | |
| 1998/0306 | int grestats(char *buf, int len) { return snprint(buf, len, "gre: csum %d hlen %d len %d order %d rexmit %d\n", gre.csumerr, gre.hlenerr, gre.lenerr, gre.order, gre.rexmit); } | |
| 1997/0327 | void greinit(Fs *fs) { | |
| 1997/0531/sys/src/9/ip/gre.c:229,234 – 1998/0306/sys/src/9/ip/gre.c:236,242 | ||
| 1997/0327 | gre.rcv = greiput; gre.ctl = nil; gre.advise = nil; | |
| 1998/0306 | gre.stats = grestats; | |
| 1997/0327 | gre.ipproto = IP_GREPROTO; gre.nc = 64; gre.ptclsize = 0; | |