mirror of
git://erdgeist.org/opentracker
synced 2025-03-31 18:42:56 +08:00
mask bits to be checked in ot_net
This commit is contained in:
parent
5805fe5f86
commit
a3251ffac7
@ -385,10 +385,10 @@ void accesslist_cleanup( void ) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int address_in_net( const ot_ip6 address, const ot_net *net ) {
|
int address_in_net( const ot_ip6 address, const ot_net *net ) {
|
||||||
int bits = net->bits;
|
int bits = net->bits, checkbits = ( 0x7f00 >> ( bits & 7 ));
|
||||||
int result = memcmp( address, &net->address, bits >> 3 );
|
int result = memcmp( address, &net->address, bits >> 3 );
|
||||||
if( !result && ( bits & 7 ) )
|
if( !result && ( bits & 7 ) )
|
||||||
result = ( ( 0x7f00 >> ( bits & 7 ) ) & address[bits>>3] ) - net->address[bits>>3];
|
result = ( checkbits & address[bits>>3] ) - ( checkbits & net->address[bits>>3]);
|
||||||
return result == 0;
|
return result == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user