Skip to contentSkip to conversation

mark match

DISCUSSION Peteris Krumins 2 participants 2 messages Mar 29, 2003

lore
Share & tools
lore
#0 lore raw

hi,

what's the point of mask in the mark match?

for example, i want to match anything marked from 1 (1b) to 127 (1111111b), is it possible to do it using a mask?

 nfmark    mask    match
 1      &  127  =  1
 77     &  127  =  77

i see no point in mask.
could anyone explain the use of mask to match multiple nfmarks?

P.Krumins

#1 lore raw
Quoted 6 lines · Peteris Krumins

for example, i want to match anything marked from 1 (1b) to 127 (1111111b), is it possible to do it using a mask?

 nfmark    mask    match
 1      &  127  =  1
 77     &  127  =  77

To be valuable, a mask has to have some low bits to 0. If all mask's bits are set to 1, than it only matches the masked value... For your purpose, you have to use 128 (10000000b) as mask :

	1    & 128 = 0
	77   & 128 = 0
	128  & 128 = 128
	129  & 128 = 128

So, you match 0, with a 128 mask, which may be, I guess, something like "-m mark --mark 0/128".

Note that 0 will also match.

It is basicly the same system as netmasks.

Signature · 4 lines
Cédric Blancher  <[email protected]>
IT systems and networks security - Cartel Sécurité
Phone : +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE