Hi
I might be missing something obvious (in which case I apologize!), but I
think that the current behaviour of hostapd(8)'s configuration file
parser in -current is not quite correct when dealing with multiple
matches of the 'not' grammar rule.
Take, for example, the config file excerpt
hostap handle skip type management subtype ! beacon \
with log \
rate 100 / 10 sec
With yydebug set, this gives the following sequence of reads and reductions:
reading 260 (HOSTAP)
reading 266 (HANDLE)
reducing by rule 34 ($$1 :)
reading 307 (SKIP)
reducing by rule 47 (eventopt : SKIP)
reading 267 (TYPE)
reducing by rule 32 (hostapmatch :)
reducing by rule 61 (frm :)
reading 277 (MANAGEMENT)
[1] reducing by rule 183 (not :)
reading 268 (SUBTYPE)
reading 33 ('!')
[2] reducing by rule 184 (not : '!')
reading 280 (BEACON)
reading 272 (WITH)
reducing by rule 87 (frmelems :)
reducing by rule 78 (frmsubtype : BEACON frmelems)
[3] reducing by rule 75 (frmmatchmgmt : SUBTYPE not frmsubtype)
[4] reducing by rule 72 (frmmatchtype : TYPE not MANAGEMENT \
frmmatchmgmt)
reducing by rule 112 (frmmatchdir :)
reducing by rule 119 (frmmatchfrom :)
reducing by rule 121 (frmmatchto :)
reducing by rule 123 (frmmatchbssid :)
reducing by rule 125 (frmmatchrtap :)
reducing by rule 60 (frmmatch : frm frmmatchtype frmmatchdir \
frmmatchfrom frmmatchto frmmatchbssid frmmatchrtap)
reading 303 (LOG)
reading 296 (RATE)
reducing by rule 54 (verbose :)
reducing by rule 49 (action : WITH LOG verbose)
reducing by rule 64 (limit :)
reading 336 (STRING)
reducing by rule 174 (number : STRING)
reading 47 ('/')
reading 336 (STRING)
reducing by rule 174 (number : STRING)
reading 264 (SEC)
reducing by rule 68 (rate : RATE number '/' number SEC)
reducing by rule 36 (event : HOSTAP HANDLE $$1 eventopt \
hostapmatch frmmatch $$2 action limit rate)
When the 'not' rule is reduced, the u_int 'negative' is set to either 0
or 1, depending on the sense of the negation. In this example, it is set
at [1] and [2] (as annotated above), but the actions that use it are not
executed until reductions [3] and [4]. This means that the value
returned by the first reduction (at [1]) is never used; the rule as
parsed is
hostap handle skip type ! management subtype ! beacon \
with log \
rate 100 / 10 sec
which is not what was intended.
I think the following diff fixes this particular instance of the
problem, although I haven't tested it extensively. A better fix might
make 'type ! management subtype ...' invalid, given that (with the
current precedence) it doesn't make much sense -- filtering on data
frame subtypes is both not particularly useful, and not currently supported.
Stephen
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/hostapd/parse.y,v
retrieving revision 1.24
diff -u -p -r1.24 parse.y
--- parse.y 27 Jun 2006 18:14:59 -0000 1.24
+++ parse.y 4 Sep 2006 12:56:26 -0000
@@ -471,12 +471,13 @@ frmmatchtype : /* any */
IEEE80211_FC0_TYPE_DATA;
HOSTAPD_MATCH(TYPE);
}
- | TYPE not MANAGEMENT frmmatchmgmt
+ | TYPE not MANAGEMENT
{
frame_ieee80211->i_fc[0] |=
IEEE80211_FC0_TYPE_MGT;
HOSTAPD_MATCH(TYPE);
}
+ frmmatchmgmt
;
frmmatchmgmt : /* any */
--
Stephen Lewis