Add != operator to snoopy, remove various stupid functions.
[rsc] --rw-rw-r-- M 1428987 glenda sys 4086 Jan 28 10:50 sys/man/8/snoopy
/n/sourcesdump/2006/0128/plan9/sys/man/8/snoopy:64,69 -
/n/sourcesdump/2006/0129/plan9/sys/man/8/snoopy:64,70
.EX
\fIexpr\fP: \fIprotocol\fP
| \fIfield\fP '=' \fIvalue\fP
+ | \fIfield\fP '!=' \fIvalue\fP
| \fIprotocol\fP '(' \fIexpr\fP ')'
| '(' \fIexpr\fP ')'
| \fIexpr\fP '||' \fIexpr\fP
[rsc] --rw-rw-r-- M 1428987 glenda sys 8958 Jan 28 10:49 sys/src/cmd/ip/snoopy/dhcp.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/dhcp.c:103,120 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/dhcp.c:103,108
OP9auth= 129, // plan9 auth servers
};
- static void
- p_compile(Filter *f)
- {
- sysfatal("unknown bootp field: %s", f->s);
- }
-
- static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
/*
* convert a byte array to hex
*/
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/dhcp.c:471,478 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/dhcp.c:459,466
Proto dhcp =
{
"dhcp",
- p_compile,
- p_filter,
+ nil,
+ nil,
p_seprint,
nil,
nil,
[rsc] --rw-rw-r-- M 1428987 glenda sys 1078 Jan 28 10:49 sys/src/cmd/ip/snoopy/dump.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/dump.c:10,21 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/dump.c:10,15
{
}
- static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
static char tohex[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/dump.c:81,87 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/dump.c:75,81
{
"dump",
p_compile,
- p_filter,
+ nil,
p_seprint,
nil,
nil,
[rsc] --rw-rw-r-- M 1428987 glenda sys 1739 Jan 28 10:49 sys/src/cmd/ip/snoopy/filter.y
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/filter.y:12,17 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/filter.y:12,18
%term LOR
%term LAND
%term WORD
+ %term NE
%right '!'
%left '|'
%left '&'
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/filter.y:27,32 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/filter.y:28,41
{ $$ = $1; }
| WORD '=' WORD
{ $2->l = $1; $2->r = $3; $$ = $2; }
+ | WORD NE WORD
+ { $2->l = newfilter();
+ $2->l->op = '=';
+ $2->l->l = $1;
+ $2->l->r = $3;
+ $2->op = '!';
+ $$ = $2;
+ }
| WORD '(' expr ')'
{ $1->l = $3; free($2); free($4); $$ = $1; }
| '(' expr ')'
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/filter.y:84,100 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/filter.y:93,110
}
yylp++;
- if(*yylp == c)
- switch(c){
- case '&':
- c = LAND;
- yylp++;
- break;
- case '|':
- c = LOR;
- yylp++;
- break;
- }
+ if(c == '!' && *yylp == '='){
+ c = NE;
+ yylp++;
+ }
+ else if(c == '&' && *yylp == '&'){
+ c = LAND;
+ yylp++;
+ }
+ else if(c == '|' && *yylp == '|'){
+ c = LOR;
+ yylp++;
+ }
yylval->op = c;
return c;
}
[rsc] --rw-rw-r-- M 1428987 glenda sys 2261 Jan 28 10:49 sys/src/cmd/ip/snoopy/il.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/il.c:102,109 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/il.c:102,108
static char*
pkttype(int t)
{
- char b[10];
-
+ static char b[10];
if(t > 6){
sprint(b, "%d", t);
[rsc] --rw-rw-r-- M 1428987 glenda sys 15607 Jan 28 10:49 sys/src/cmd/ip/snoopy/main.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/main.c:233,239 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/main.c:233,239
return 0;
m->needroot = 0;
}else{
- if(m->pr != nil && !(m->pr->filter)(f, m))
+ if(m->pr && (m->pr->filter==nil || !(m->pr->filter)(f, m)))
return 0;
}
if(f->l == nil)
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/main.c:650,657 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/main.c:650,660
_compile(f->r, last);
break;
case WORD:
- if(last != nil)
+ if(last != nil){
+ if(last->compile == nil)
+ sysfatal("unknown %s subprotocol: %s", f->pr->name, f->s);
(*last->compile)(f);
+ }
if(f->l)
_compile(f->l, f->pr);
break;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/main.c:658,663 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/main.c:661,669
case '=':
if(last == nil)
sysfatal("internal error: compilewalk: badly formed tree");
+
+ if(last->compile == nil)
+ sysfatal("unknown %s field: %s", f->pr->name, f->s);
(*last->compile)(f);
break;
default:
[rsc] --rw-rw-r-- M 1428987 glenda sys 879 Jan 28 10:50 sys/src/cmd/ip/snoopy/mkfile
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/mkfile:53,58 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/mkfile:53,60
main.c\
${POBJS:%.$O=%.c}\
+ CLEANFILES=protos.c protos.h
+
</sys/src/cmd/mkone
protos.h: mkfile
[rsc] --rw-rw-r-- M 1428987 glenda sys 555 Jan 28 10:49 sys/src/cmd/ip/snoopy/ninep.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ninep.c:5,23 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ninep.c:5,11
#include "dat.h"
#include "protos.h"
- static void
- p_compile(Filter *f)
- {
- sysfatal("unknown ninep field: %s", f->s);
- }
-
static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
- static int
p_seprint(Msg *m)
{
Fcall f;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ninep.c:44,51 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ninep.c:32,39
Proto ninep =
{
"ninep",
- p_compile,
- p_filter,
+ nil,
+ nil,
p_seprint,
nil,
nil,
[rsc] --rw-rw-r-- M 1428987 glenda sys 7369 Jan 28 10:49 sys/src/cmd/ip/snoopy/ospf.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ospf.c:90,96 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ospf.c:90,96
};
char*
- seprintospfhello(char *p, char *e, void *a, int)
+ seprintospfhello(char *p, char *e, void *a)
{
Ospfhello *h = a;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ospf.c:327,344 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ospf.c:327,332
return seprint(p, e, ")");
}
- static void
- p_compile(Filter *f)
- {
- sysfatal("unknown ospf field: %s", f->s);
- }
-
- static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
int
p_seprint(Msg *m)
{
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ospf.c:366,372 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ospf.c:354,360
switch (ospf->type) {
case OSPFhello:
- p = seprintospfhello(p, e, ospf->data, x);
+ p = seprintospfhello(p, e, ospf->data);
break;
case OSPFdd:
p = seprintospfdatadesc(p, e, ospf->data, x);
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/ospf.c:392,399 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/ospf.c:380,387
Proto ospf =
{
"ospf",
- p_compile,
- p_filter,
+ nil,
+ nil,
p_seprint,
nil,
nil,
[rsc] --rw-rw-r-- M 1428987 jmk sys 1818 Jan 28 10:49 sys/src/cmd/ip/snoopy/rtcp.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/rtcp.c:31,50 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/rtcp.c:31,37
REPORTLEN = 24,
};
-
- static void
- p_compile(Filter *f)
- {
- sysfatal("unknown rtcp field: %s", f->s);
- }
-
static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
- static int
p_seprint(Msg *m)
{
Hdr*h;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/rtcp.c:86,93 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/rtcp.c:73,80
Proto rtcp = {
"rtcp",
- p_compile,
- p_filter,
+ nil,
+ nil,
p_seprint,
nil,
nil,
[rsc] --rw-rw-r-- M 1428987 jmk sys 1021 Jan 28 10:49 sys/src/cmd/ip/snoopy/rtp.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/rtp.c:17,36 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/rtp.c:17,23
RTPLEN = 12, // Minimum size of an RTP header
};
-
- static void
- p_compile(Filter *f)
- {
- sysfatal("unknown rtp field: %s", f->s);
- }
-
static int
- p_filter(Filter *, Msg *)
- {
- return 0;
- }
-
- static int
p_seprint(Msg *m)
{
Hdr*h;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/ip/snoopy/rtp.c:65,72 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/ip/snoopy/rtp.c:52,59
Proto rtp = {
"rtp",
- p_compile,
- p_filter,
+ nil,
+ nil,
p_seprint,
nil,
nil,
|