[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what are mask_ and shift_



The Classifier does its classification by looking at a certain field
in the packet headers:
int Classifier::classify(Packet *const p)
{
        return (mshift(*((int*) p->access(offset_))));
}

offset_ gives the offset of the field;
mshift is defined as:
        int mshift(int val) { return ((val >> shift_) & mask_); }
so, you can bit-shift the field by 'shift_' and AND it with 'mask_'.
It's useful, for example, when you want to classify by a node address
and you need to get rid of the port bits.

"Nick A. Fikouras" <[email protected]> writes:

> Hi all,
> 
> I' ve seen this message appear several times in the list but nobody has
> answered it yet. In class Classifier, there two variables mask_ and
> shift_, what is their use?
> 
> 
> Thanks in advance,
> 
> nick