## diffname ip/icmp.c 1997/0327
## diff -e /dev/null /n/emeliedump/1997/0327/sys/src/brazil/ip/icmp.c
0a
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "ip.h"
typedef struct Icmp {
byte vihl; /* Version and header length */
byte tos; /* Type of service */
byte length[2]; /* packet length */
byte id[2]; /* Identification */
byte frag[2]; /* Fragment information */
byte ttl; /* Time to live */
byte proto; /* Protocol */
byte ipcksum[2]; /* Header checksum */
byte src[4]; /* Ip source */
byte dst[4]; /* Ip destination */
byte type;
byte code;
byte cksum[2];
byte icmpid[2];
byte seq[2];
byte data[1];
} Icmp;
enum { /* Packet Types */
EchoReply = 0,
Unreachable = 3,
SrcQuench = 4,
EchoRequest = 8,
TimeExceed = 11,
Timestamp = 13,
TimestampReply = 14,
InfoRequest = 15,
InfoReply = 16,
};
enum {
IP_ICMPPROTO = 1,
ICMP_IPSIZE = 20,
ICMP_HDRSIZE = 8,
};
Proto icmp;
extern Fs fs;
static char*
icmpconnect(Conv *c, char **argv, int argc)
{
char *e;
e = Fsstdconnect(c, argv, argc);
Fsconnected(&fs, c, e);
return e;
}
static int
icmpstate(char **s, Conv *c)
{
USED(c);
*s = "Datagram";
return 1;
}
static void
icmpcreate(Conv *c)
{
c->rq = qopen(64*1024, 0, 0, c);
c->wq = qopen(64*1024, 0, 0, 0);
}
static void
icmpannounce(Conv *c)
{
Fsconnected(&fs, c, nil);
}
static void
icmpclose(Conv *c)
{
qclose(c->rq);
qclose(c->wq);
c->laddr = 0;
c->lport = 0;
unlock(c);
}
static void
icmpkick(Conv *c, int l)
{
Icmp *p;
Block *bp;
USED(l);
bp = qget(c->wq);
if(bp == nil)
return;
if(blocklen(bp) < ICMP_IPSIZE + ICMP_HDRSIZE){
freeblist(bp);
return;
}
p = (Icmp *)(bp->rp);
hnputl(p->dst, c->raddr);
hnputl(p->src, c->laddr);
p->proto = IP_ICMPPROTO;
hnputs(p->icmpid, c->lport);
memset(p->cksum, 0, sizeof(p->cksum));
hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE));
ipoput(bp, 0, MAXTTL);
}
static void
goticmpkt(Block *bp)
{
Conv **c, *s;
Icmp *p;
Ipaddr dst;
ushort recid;
p = (Icmp *) bp->rp;
dst = nhgetl(p->src);
recid = nhgets(p->icmpid);
netlog(Logicmp, "goticmpkt from %i to %d\n", dst, recid);
for(c = icmp.conv; *c; c++) {
s = *c;
netlog(Logicmp, "conv %i %d %i %d\n", s->laddr, s->lport, s->raddr, s->rport);
if(s->lport == recid && s->raddr == dst){
qpass(s->rq, bp);
return;
}
}
freeblist(bp);
}
static Block *
mkechoreply(Block *bp)
{
Icmp *q;
byte ip[4];
q = (Icmp *)bp->rp;
memmove(ip, q->src, sizeof(q->dst));
memmove(q->src, q->dst, sizeof(q->src));
memmove(q->dst, ip, sizeof(q->dst));
q->type = EchoReply;
memset(q->cksum, 0, sizeof(q->cksum));
hnputs(q->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE));
return bp;
}
static char *unreachcode[] =
{
[0] "net unreachable",
[1] "host unreachable",
[2] "protocol unreachable",
[3] "port unreachable",
[4] "fragmentation needed and DF set",
[5] "source route failed",
};
static void
icmpiput(Block *bp)
{
int n, iplen;
Icmp *p;
Block *r;
Proto *pr;
char *msg;
char m2[128];
p = (Icmp *)bp->rp;
netlog(Logicmp, "icmpiput %d %d\n", p->type, p->code);
n = blocklen(bp);
if(n < ICMP_IPSIZE+ICMP_HDRSIZE){
icmp.hlenerr++;
goto raise;
}
iplen = nhgets(p->length);
if(iplen > n || (iplen % 1)){
icmp.lenerr++;
goto raise;
}
if(ptclcsum(bp, ICMP_IPSIZE, iplen - ICMP_IPSIZE)){
icmp.csumerr++;
goto raise;
}
switch(p->type) {
case EchoRequest:
r = mkechoreply(bp);
ipoput(r, 0, MAXTTL);
break;
case Unreachable:
if(p->code > 5 || p->code < 0)
msg = unreachcode[1];
else
msg = unreachcode[p->code];
bp->rp += ICMP_IPSIZE+ICMP_HDRSIZE;
if(blocklen(bp) < 8){
icmp.lenerr++;
goto raise;
}
p = (Icmp *)bp->rp;
pr = Fsrcvpcol(&fs, p->proto);
if(pr != nil && pr->advise != nil) {
(*pr->advise)(bp, msg);
return;
}
bp->rp -= ICMP_IPSIZE+ICMP_HDRSIZE;
goticmpkt(bp);
break;
case TimeExceed:
if(p->code == 0){
sprint(m2, "ttl exceeded at %I", p->src);
bp->rp += ICMP_IPSIZE+ICMP_HDRSIZE;
if(blocklen(bp) < 8){
icmp.lenerr++;
goto raise;
}
p = (Icmp *)bp->rp;
pr = Fsrcvpcol(&fs, p->proto);
if(pr != nil && pr->advise != nil) {
(*pr->advise)(bp, m2);
return;
}
}
goticmpkt(bp);
break;
default:
goticmpkt(bp);
break;
}
return;
raise:
freeblist(bp);
}
void
icmpinit(Fs *fs)
{
icmp.name = "icmp";
icmp.kick = icmpkick;
icmp.connect = icmpconnect;
icmp.announce = icmpannounce;
icmp.state = icmpstate;
icmp.create = icmpcreate;
icmp.close = icmpclose;
icmp.rcv = icmpiput;
icmp.ctl = nil;
icmp.advise = nil;
icmp.ipproto = IP_ICMPPROTO;
icmp.nc = 16;
icmp.ptclsize = 0;
Fsproto(fs, &icmp);
}
.
## diffname ip/icmp.c 1997/0403
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0403/sys/src/brazil/ip/icmp.c
79a
return nil;
.
78a
char *e;
e = Fsstdannounce(c, argv, argc);
if(e != nil);
return e;
.
76,77c
static char*
icmpannounce(Conv *c, char **argv, int argc)
.
## diffname ip/icmp.c 1997/0423
## diff -e /n/emeliedump/1997/0403/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0423/sys/src/brazil/ip/icmp.c
184a
USED(m);
.
176c
icmpiput(Media *m, Block *bp)
.
## diffname ip/icmp.c 1997/0903
## diff -e /n/emeliedump/1997/0423/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0903/sys/src/brazil/ip/icmp.c
123a
extern void
icmpnoconv(Block *bp)
{
Block *nbp;
Icmp *p, *np;
p = (Icmp *)bp->rp;
nbp = allocb(ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8);
nbp->wp += ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8;
np = (Icmp *)nbp->rp;
memmove(np->dst, p->src, sizeof(np->dst));
memmove(np->src, p->dst, sizeof(np->src));
memmove(np->data, bp->rp, ICMP_IPSIZE + 8);
np->type = Unreachable;
np->code = 3;
p->proto = IP_ICMPPROTO;
hnputs(p->icmpid, 0);
memset(p->cksum, 0, sizeof(p->cksum));
hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE));
ipoput(nbp, 0, MAXTTL);
}
.
## diffname ip/icmp.c 1997/0904
## diff -e /n/emeliedump/1997/0903/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0904/sys/src/brazil/ip/icmp.c
290c
icmp.advise = icmpadvise;
.
278a
icmpadvise(Block *bp, char *msg)
{
Conv **c, *s;
Icmp *p;
Ipaddr dst;
ushort recid;
p = (Icmp *) bp->rp;
dst = nhgetl(p->dst);
recid = nhgets(p->icmpid);
for(c = icmp.conv; *c; c++) {
s = *c;
if(s->lport == recid && s->raddr == dst){
qhangup(s->rq, msg);
qhangup(s->wq, msg);
break;
}
}
freeblist(bp);
}
void
.
139,142c
np->proto = IP_ICMPPROTO;
hnputs(np->icmpid, 0);
hnputs(np->seq, 0);
memset(np->cksum, 0, sizeof(np->cksum));
hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE));
.
121c
ipoput(bp, 0, c->ttl);
.
## diffname ip/icmp.c 1997/0916
## diff -e /n/emeliedump/1997/0904/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0916/sys/src/brazil/ip/icmp.c
312a
icmp.stats = icmpstats;
.
301a
int
icmpstats(char *buf, int len)
{
int i, n;
n = snprint(buf, len, "\trcvd ");
for(i = 0; i < Maxtype && len > n; i++)
n += snprint(buf+n, len-n, " %d", stats.in[i]);
n += snprint(buf+n, len - n, "\n\tsent ");
for(i = 0; i < Maxtype && len > n; i++)
n += snprint(buf+n, len-n, " %d", stats.out[i]);
if(n < len)
n += snprint(buf+n, len-n, "\n");
return n;
}
.
226a
stats.out[EchoReply]++;
.
223a
if(p->type <= Maxtype)
stats.in[p->type]++;
.
143a
stats.out[Unreachable]++;
.
114a
if(p->type <= Maxtype)
stats.out[p->type]++;
.
49a
static struct Icmpstats
{
ulong in[Maxtype+1];
ulong out[Maxtype+1];
} stats;
.
38a
Maxtype = 16,
.
## diffname ip/icmp.c 1997/0926
## diff -e /n/emeliedump/1997/0916/sys/src/brazil/ip/icmp.c /n/emeliedump/1997/0926/sys/src/brazil/ip/icmp.c
139a
/* don't bother if we haven't gotten any links up yet */
if(Mediabooting())
return;
.
## diffname ip/icmp.c 1998/0217
## diff -e /n/emeliedump/1997/0926/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0217/sys/src/brazil/ip/icmp.c
178a
if(bp->next)
bp = concatblock(bp);
.
## diffname ip/icmp.c 1998/0306
## diff -e /n/emeliedump/1998/0217/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0306/sys/src/brazil/ip/icmp.c
330c
n += snprint(buf+n, len-n, "\n\tsent ");
.
327c
n = snprint(buf, len,
"icmp: csum %d hlen %d len %d order %d rexmit %d\n",
icmp.csumerr, icmp.hlenerr, icmp.lenerr, icmp.order, icmp.rexmit);
n += snprint(buf+n, len-n, "\trcvd ");
.
313c
if(s->lport == recid)
if(ipcmp(s->raddr, dst) == 0){
.
308c
v4tov6(dst, p->dst);
.
304c
uchar dst[IPaddrlen];
.
272c
sprint(m2, "ttl exceeded at %V", p->src);
.
238a
netlog(Logicmp, "icmp checksum error\n");
.
234a
netlog(Logicmp, "icmp length %d\n", iplen);
.
229a
netlog(Logicmp, "icmp hlen %d\n", n);
.
224d
215c
icmpiput(uchar*, Block *bp)
.
200a
.
192c
uchar ip[4];
.
177,180c
if(s->lport == recid)
if(ipcmp(s->raddr, dst) == 0){
.
173d
171c
v4tov6(dst, p->src);
.
167c
uchar dst[IPaddrlen];
.
144a
netlog(Logicmp, "sending icmpnoconv -> %V\n", p->src);
.
140,143d
125,126c
v6tov4(p->dst, c->raddr);
v6tov4(p->src, c->laddr);
.
102c
ipmove(c->laddr, IPnoaddr);
ipmove(c->raddr, IPnoaddr);
.
73,74c
return snprint(state, n, "%s", "Datagram");
.
70c
icmpstate(Conv *c, char *state, int n)
.
11,26c
uchar vihl; /* Version and header length */
uchar tos; /* Type of service */
uchar length[2]; /* packet length */
uchar id[2]; /* Identification */
uchar frag[2]; /* Fragment information */
uchar ttl; /* Time to live */
uchar proto; /* Protocol */
uchar ipcksum[2]; /* Header checksum */
uchar src[4]; /* Ip source */
uchar dst[4]; /* Ip destination */
uchar type;
uchar code;
uchar cksum[2];
uchar icmpid[2];
uchar seq[2];
uchar data[1];
.
## diffname ip/icmp.c 1998/0313
## diff -e /n/emeliedump/1998/0306/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0313/sys/src/brazil/ip/icmp.c
358c
icmp = smalloc(sizeof(Proto));
icmp->priv = smalloc(sizeof(Icmppriv));
icmp->name = "icmp";
icmp->kick = icmpkick;
icmp->connect = icmpconnect;
icmp->announce = icmpannounce;
icmp->state = icmpstate;
icmp->create = icmpcreate;
icmp->close = icmpclose;
icmp->rcv = icmpiput;
icmp->stats = icmpstats;
icmp->ctl = nil;
icmp->advise = icmpadvise;
icmp->ipproto = IP_ICMPPROTO;
icmp->nc = 16;
icmp->ptclsize = 0;
Fsproto(fs, icmp);
.
343,356c
Proto *icmp;
.
334c
n += snprint(buf+n, len-n, " %d", ipriv->out[i]);
.
331c
n += snprint(buf+n, len-n, " %d", ipriv->in[i]);
.
327,328c
"icmp: csum %d hlen %d len %d\n",
ipriv->csumerr, ipriv->hlenerr, ipriv->lenerr);
.
324a
ipriv = icmp->priv;
.
323a
Icmppriv *ipriv;
.
321c
icmpstats(Proto *icmp, char *buf, int len)
.
308c
for(c = icmp->conv; *c; c++) {
.
297c
icmpadvise(Proto *icmp, Block *bp, char *msg)
.
287c
goticmpkt(icmp, bp);
.
284c
goticmpkt(icmp, bp);
.
279c
(*pr->advise)(pr, bp, m2);
.
277c
pr = Fsrcvpcol(icmp->f, p->proto);
.
273c
ipriv->lenerr++;
.
265c
goticmpkt(icmp, bp);
.
260c
(*pr->advise)(pr, bp, msg);
.
258c
pr = Fsrcvpcol(icmp->f, p->proto);
.
254c
ipriv->lenerr++;
.
243,244c
ipriv->out[EchoReply]++;
ipoput(icmp->f, r, 0, MAXTTL);
.
239c
ipriv->in[p->type]++;
.
234,235c
ipriv->csumerr++;
netlog(icmp->f, Logicmp, "icmp checksum error\n");
.
229,230c
ipriv->lenerr++;
netlog(icmp->f, Logicmp, "icmp length %d\n", iplen);
.
223,224c
ipriv->hlenerr++;
netlog(icmp->f, Logicmp, "icmp hlen %d\n", n);
.
220c
netlog(icmp->f, Logicmp, "icmpiput %d %d\n", p->type, p->code);
.
218a
ipriv = icmp->priv;
.
217a
Icmppriv *ipriv;
.
210c
icmpiput(Proto *icmp, uchar*, Block *bp)
.
171c
for(c = icmp->conv; *c; c++) {
.
160c
goticmpkt(Proto *icmp, Block *bp)
.
155,156c
/* stats.out[Unreachable]++; */
ipoput(f, nbp, 0, MAXTTL);
.
141c
netlog(f, Logicmp, "sending icmpnoconv -> %V\n", p->src);
.
135c
icmpnoconv(Fs *f, Block *bp)
.
131c
ipoput(c->p->f, bp, 0, c->ttl);
.
123,124c
if(p->type <= Maxtype){
ipriv = c->p->priv;
ipriv->out[p->type]++;
}
.
111a
Icmppriv *ipriv;
.
91c
Fsconnected(c, nil);
.
64c
Fsconnected(c, e);
.
56c
};
.
53a
/* non-MIB stats */
ulong csumerr; /* checksum errors */
ulong lenerr; /* short packet */
ulong hlenerr; /* short header */
.
49,52c
typedef struct Icmppriv Icmppriv;
struct Icmppriv
.
## diffname ip/icmp.c 1998/0509
## diff -e /n/emeliedump/1998/0313/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0509/sys/src/brazil/ip/icmp.c
285c
pr = Fsrcvpcolx(icmp->f, p->proto);
.
266c
pr = Fsrcvpcolx(icmp->f, p->proto);
.
145a
/* only do this for unicast sources and destinations */
v4tov6(addr, p->dst);
i = ipforme(f, addr);
if((i&Runi) == 0)
return;
v4tov6(addr, p->src);
i = ipforme(f, addr);
if((i&Runi) == 0)
return;
.
143a
int i;
uchar addr[IPaddrlen];
.
## diffname ip/icmp.c 1998/0813
## diff -e /n/emeliedump/1998/0509/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0813/sys/src/brazil/ip/icmp.c
362c
.
349,360c
return snprint(buf,len,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
ipriv->istats.icmpInMsgs,
ipriv->istats.icmpInErrors,
ipriv->in[Unreachable],
ipriv->in[TimeExceed],
ipriv->in[InParmProblem],
ipriv->in[SrcQuench],
ipriv->in[Redirect],
ipriv->in[EchoRequest],
ipriv->in[EchoReply],
ipriv->in[Timestamp],
ipriv->in[TimestampReply],
ipriv->in[AddrMaskRequest],
ipriv->in[AddrMaskReply],
ipriv->istats.icmpOutMsgs,
ipriv->istats.icmpOutErrors,
ipriv->out[Unreachable],
ipriv->out[TimeExceed],
ipriv->out[InParmProblem],
ipriv->out[SrcQuench],
ipriv->out[Redirect],
ipriv->out[EchoRequest],
ipriv->out[EchoReply],
ipriv->out[Timestamp],
ipriv->out[TimestampReply],
ipriv->out[AddrMaskRequest],
ipriv->out[AddrMaskReply]);
.
344d
254a
ipriv->istats.icmpInErrors++;
.
250a
ipriv->istats.icmpInErrors++;
.
243a
ipriv->istats.icmpInErrors++;
.
238a
ipriv->istats.icmpInMsgs++;
.
139a
icmpttlexceeded(Fs *f, uchar *ia, Block *bp)
{
Block *nbp;
Icmp *p, *np;
p = (Icmp *)bp->rp;
netlog(f, Logicmp, "sending icmpttlexceeded -> %V\n", p->src);
nbp = allocb(ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8);
nbp->wp += ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8;
np = (Icmp *)nbp->rp;
memmove(np->dst, p->src, sizeof(np->dst));
v6tov4(np->src, ia);
memmove(np->data, bp->rp, ICMP_IPSIZE + 8);
np->type = TimeExceed;
np->code = 0;
np->proto = IP_ICMPPROTO;
hnputs(np->icmpid, 0);
hnputs(np->seq, 0);
memset(np->cksum, 0, sizeof(np->cksum));
hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE));
/* stats.out[TimeExceed]++; */
ipoput(f, nbp, 0, MAXTTL);
}
extern void
.
135a
ipriv->istats.icmpOutMsgs++;
.
129c
.
126,127c
ipriv = c->p->priv;
if(p->type <= Maxtype)
.
51a
/* MIB Counters */
Icmpstats istats;
.
48a
typedef struct Icmpstats Icmpstats;
struct Icmpstats
{
ulong icmpInMsgs;
ulong icmpInErrors;
// ulong icmpInDestUnreachs;
// ulong icmpInTimeExcds;
// ulong icmpInParmProbs;
// ulong icmpInSrcQuenchs;
// ulong icmpInRedirects;
// ulong icmpInEchos;
// ulong icmpInEchoReps;
// ulong icmpInTimestamps;
// ulong icmpInTimestampReps;
// ulong icmpInAddrMasks;
// ulong icmpInAddrMaskReps;
ulong icmpOutMsgs;
ulong icmpOutErrors;
// ulong icmpOutDestUnreachs;
// ulong icmpOutTimeExcds;
// ulong icmpOutParmProbs;
// ulong icmpOutSrcQuenchs;
// ulong icmpOutRedirects;
// ulong icmpOutEchos;
// ulong icmpOutEchoReps;
// ulong icmpOutTimestamps;
// ulong icmpOutTimestampReps;
// ulong icmpOutAddrMasks;
// ulong icmpOutAddrMaskReps;
};
.
39,40c
AddrMaskRequest = 17,
AddrMaskReply = 18,
Maxtype = 18,
.
34a
InParmProblem = 12,
.
32a
Redirect = 4,
.
## diffname ip/icmp.c 1998/0825
## diff -e /n/emeliedump/1998/0813/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/0825/sys/src/brazil/ip/icmp.c
418c
return snprint(buf,len,"%lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud %lud",
.
## diffname ip/icmp.c 1998/1229
## diff -e /n/emeliedump/1998/0825/sys/src/brazil/ip/icmp.c /n/emeliedump/1998/1229/sys/src/brazil/ip/icmp.c
221c
if(i != 0 && (i&Runi) == 0)
.
## diffname ip/icmp.c 1999/0302
## diff -e /n/emeliedump/1998/1229/sys/src/brazil/ip/icmp.c /n/emeliedump/1999/0302/sys/src/brazil/ip/icmp.c
330a
.
143c
qunlock(c);
.
## diffname ip/icmp.c 1999/0817
## diff -e /n/emeliedump/1999/0302/sys/src/brazil/ip/icmp.c /n/emeliedump/1999/0817/sys/src/brazil/ip/icmp.c
336c
ipoput(icmp->f, r, 0, MAXTTL, DFLTTOS);
.
239c
ipoput(f, nbp, 0, MAXTTL, DFLTTOS);
.
200c
ipoput(f, nbp, 0, MAXTTL, DFLTTOS);
.
174c
ipoput(c->p->f, bp, 0, c->ttl, c->tos);
.
## diffname ip/icmp.c 1999/0825
## diff -e /n/emeliedump/1999/0817/sys/src/brazil/ip/icmp.c /n/emeliedump/1999/0825/sys/src/brazil/ip/icmp.c
258c
bp = concatblock(bp);
if(bp != nil)
qpass(s->rq, bp);
.
## diffname ip/icmp.c 2000/0424
## diff -e /n/emeliedump/1999/0825/sys/src/brazil/ip/icmp.c /n/emeliedump/2000/0424/sys/src/9/ip/icmp.c
467a
icmp->gc = nil;
.
## diffname ip/icmp.c 2000/0706
## diff -e /n/emeliedump/2000/0424/sys/src/9/ip/icmp.c /n/emeliedump/2000/0706/sys/src/9/ip/icmp.c
419,447c
priv = icmp->priv;
p = buf;
e = p+len;
for(i = 0; i < Nstats; i++)
p = seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]);
for(i = 0; i <= Maxtype; i++){
if(icmpnames[i])
p = seprint(p, e, "%s: %lud %lud\n", icmpnames[i], priv->in[i], priv->out[i]);
else
p = seprint(p, e, "%d: %lud %lud\n", i, priv->in[i], priv->out[i]);
}
return p - buf;
.
417c
Icmppriv *priv;
char *p, *e;
int i;
.
367c
ipriv->stats[LenErrs]++;
.
348c
ipriv->stats[LenErrs]++;
.
326,327c
ipriv->stats[InErrors]++;
ipriv->stats[CsumErrs]++;
.
320,321c
ipriv->stats[LenErrs]++;
ipriv->stats[InErrors]++;
.
313,314c
ipriv->stats[InErrors]++;
ipriv->stats[HlenErrs]++;
.
307c
ipriv->stats[InMsgs]++;
.
238d
199d
173c
ipriv->stats[OutMsgs]++;
.
89,92c
/* message counts */
.
86,87c
ulong stats[Nstats];
.
82a
static char *statnames[Nstats] =
{
[InMsgs] "InMsgs",
[InErrors] "InErrors",
[OutMsgs] "OutMsgs",
[CsumErrs] "CsumErrs",
[LenErrs] "LenErrs",
[HlenErrs] "HlenErrs",
};
.
55,80c
InMsgs,
InErrors,
OutMsgs,
CsumErrs,
LenErrs,
HlenErrs,
Nstats,
.
52,53c
enum
.
45a
char *icmpnames[Maxtype+1] =
{
[EchoReply] "EchoReply",
[Unreachable] "Unreachable",
[SrcQuench] "SrcQuench",
[Redirect] "Redirect",
[EchoRequest] "EchoRequest",
[TimeExceed] "TimeExceed",
[InParmProblem] "InParmProblem",
[Timestamp] "Timestamp",
[TimestampReply] "TimestampReply",
[InfoRequest] "InfoRequest",
[InfoReply] "InfoReply",
[AddrMaskRequest] "AddrMaskRequest",
[AddrMaskReply ] "AddrMaskReply ",
};
.
42a
.
33c
Redirect = 5,
.
## diffname ip/icmp.c 2000/1220
## diff -e /n/emeliedump/2000/0706/sys/src/9/ip/icmp.c /n/emeliedump/2000/1220/sys/src/9/ip/icmp.c
148d
## diffname ip/icmp.c 2001/0127
## diff -e /n/emeliedump/2000/1220/sys/src/9/ip/icmp.c /n/emeliedump/2001/0127/sys/src/9/ip/icmp.c
123c
c->rq = qopen(64*1024, 1, 0, c);
.
## diffname ip/icmp.c 2001/0306
## diff -e /n/emeliedump/2001/0127/sys/src/9/ip/icmp.c /n/emeliedump/2001/0306/sys/src/9/ip/icmp.c
157d
151c
icmpkick(Conv *c)
.
## diffname ip/icmp.c 2001/0518
## diff -e /n/emeliedump/2001/0306/sys/src/9/ip/icmp.c /n/emeliedump/2001/0518/sys/src/9/ip/icmp.c
133c
if(e != nil)
.
## diffname ip/icmp.c 2001/0623
## diff -e /n/emeliedump/2001/0518/sys/src/9/ip/icmp.c /n/emeliedump/2001/0623/sys/src/9/ip/icmp.c
296c
icmpiput(Proto *icmp, Ipifc*, Block *bp)
.
193c
v6tov4(np->src, ifc->lifc->local);
.
181c
icmpttlexceeded(Fs *f, Ipifc *ifc, Block *bp)
.
## diffname ip/icmp.c 2001/0703
## diff -e /n/emeliedump/2001/0623/sys/src/9/ip/icmp.c /n/emeliedump/2001/0703/sys/src/9/ip/icmp.c
367c
if(blocklen(bp) < MinAdvise){
.
348c
if(blocklen(bp) < MinAdvise){
.
46a
enum
{
MinAdvise = 24, /* minimum needed for us to advise another protocol */
};
.
## diffname ip/icmp.c 2001/1117
## diff -e /n/emeliedump/2001/0703/sys/src/9/ip/icmp.c /n/emeliedump/2001/1117/sys/src/9/ip/icmp.c
357a
if(code == 5){
v4tov6(dst, p->dst);
update_mtucache(dst, x);
}
.
350a
break;
case 0:
case 1:
case 2:
case 3:
case 4:
msg = unreachcode[p->code];
break;
}
.
349c
break;
case 5:
x = nhgets(p->seq);
.
347c
code = p->code;
switch(code){
default:
.
309a
int code;
ushort x;
uchar dst[IPaddrlen];
.
296c
[4] "unfragmentable",
.
53a
[UnreachableV6] "UnreachableV6",
.
30a
UnreachableV6 = 1,
.
## diffname ip/icmp.c 2001/1122
## diff -e /n/emeliedump/2001/1117/sys/src/9/ip/icmp.c /n/emeliedump/2001/1122/sys/src/9/ip/icmp.c
403a
bp->rp -= ICMP_IPSIZE+ICMP_HDRSIZE;
.
352a
x = 0;
.
## diffname ip/icmp.c 2002/0507
## diff -e /n/emeliedump/2001/1122/sys/src/9/ip/icmp.c /n/emeliedump/2002/0507/sys/src/9/ip/icmp.c
377,380d
361,369d
357,359c
else
.
352,355c
if(p->code > 5 || p->code < 0)
.
349c
ipoput4(icmp->f, r, 0, MAXTTL, DFLTTOS);
.
312,314d
298c
[4] "fragmentation needed and DF set",
.
281a
q->vihl = IP_VER4;
.
247c
ipoput4(f, nbp, 0, MAXTTL, DFLTTOS);
.
221a
p->vihl = IP_VER4;
.
209c
ipoput4(f, nbp, 0, MAXTTL, DFLTTOS);
.
200c
v6tov4(np->src, ia);
.
193a
p->vihl = IP_VER4;
.
188c
icmpttlexceeded(Fs *f, uchar *ia, Block *bp)
.
184c
ipoput4(c->p->f, bp, 0, c->ttl, c->tos);
.
172a
p->vihl = IP_VER4;
.
157c
extern void
.
147c
extern void
.
134c
extern char*
.
127c
extern void
.
120c
extern int
.
109c
extern char*
.
55d
31d
## diffname ip/icmp.c 2002/0529
## diff -e /n/emeliedump/2002/0507/sys/src/9/ip/icmp.c /n/emeliedump/2002/0529/sys/src/9/ip/icmp.c
345a
if (iplen < n)
bp = trimblock(bp, 0, iplen);
.
## diffname ip/icmp.c 2002/0601
## diff -e /n/emeliedump/2002/0529/sys/src/9/ip/icmp.c /n/emeliedump/2002/0601/sys/src/9/ip/icmp.c
115c
return nil;
.
112a
if(e != nil)
return e;
.
## diffname ip/icmp.c 2002/0711
## diff -e /n/emeliedump/2002/0601/sys/src/9/ip/icmp.c /n/emeliedump/2002/0711/sys/src/9/ip/icmp.c
130c
c->rq = qopen(64*1024, Qmsg, 0, c);
.
## diffname ip/icmp.c 2002/0712
## diff -e /n/emeliedump/2002/0711/sys/src/9/ip/icmp.c /n/emeliedump/2002/0712/sys/src/9/ip/icmp.c
458d
159a
Conv *c = x;
.
157,158c
static void
icmpkick(void *x)
.
127,133d
106a
static void icmpkick(void *x);
static void
icmpcreate(Conv *c)
{
c->rq = qopen(64*1024, Qmsg, 0, c);
c->wq = qopen(64*1024, Qkick, icmpkick, c);
}
.
## diffname ip/icmp.c 2002/1014
## diff -e /n/emeliedump/2002/0712/sys/src/9/ip/icmp.c /n/emeliedump/2002/1014/sys/src/9/ip/icmp.c
242a
np->vihl = IP_VER4;
.
227d
203a
np->vihl = IP_VER4;
.
198d
## diffname ip/icmp.c 2002/1204
## diff -e /n/emeliedump/2002/1014/sys/src/9/ip/icmp.c /n/emeliedump/2002/1204/sys/src/9/ip/icmp.c
253a
}
extern void
icmpnoconv(Fs *f, Block *bp)
{
icmpunreachable(f, bp, 3);
}
extern void
icmpcantfrag(Fs *f, Block *bp)
{
icmpunreachable(f, bp, 4);
.
247c
np->code = code;
.
218,219c
static void
icmpunreachable(Fs *f, Block *bp, int code)
.
## diffname ip/icmp.c 2002/1207
## diff -e /n/emeliedump/2002/1204/sys/src/9/ip/icmp.c /n/emeliedump/2002/1207/sys/src/9/ip/icmp.c
265c
icmpunreachable(f, bp, 4, mtu);
.
263c
icmpcantfrag(Fs *f, Block *bp, int mtu)
.
259c
icmpunreachable(f, bp, 3, 0);
.
250c
hnputs(np->seq, seq);
.
219c
icmpunreachable(Fs *f, Block *bp, int code, int seq)
.
## diffname ip/icmp.c 2003/0220
## diff -e /n/emeliedump/2002/1207/sys/src/9/ip/icmp.c /n/emeliedump/2003/0220/sys/src/9/ip/icmp.c
167d
164d
160c
icmpkick(void *x, Block *bp)
.
113c
c->wq = qbypass(icmpkick, c);
.
107c
static void icmpkick(void *x, Block*);
.
## diffname ip/icmp.c 2003/0308
## diff -e /n/emeliedump/2003/0220/sys/src/9/ip/icmp.c /n/emeliedump/2003/0308/sys/src/9/ip/icmp.c
365c
ipoput4(icmp->f, r, 0, MAXTTL, DFLTTOS, nil);
.
251c
ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil);
.
212c
ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil);
.
186c
ipoput4(c->p->f, bp, 0, c->ttl, c->tos, nil);
.
|