0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Added ipa_xor() and ipa_in_net().

This commit is contained in:
Martin Mares 1998-06-01 21:36:58 +00:00
parent af847acc27
commit 0fe3b28b68
3 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,8 @@
#include "ipv6.h" #include "ipv6.h"
#endif #endif
#define ipa_in_net(x,n,p) (!ipa_nonzero(ipa_and(ipa_xor((n),(x)),ipa_mkmask(p))))
/* /*
* ip_classify() returns either a negative number for invalid addresses * ip_classify() returns either a negative number for invalid addresses
* or scope OR'ed together with address type. * or scope OR'ed together with address type.

View File

@ -44,6 +44,7 @@ typedef u32 ip_addr;
#define ipa_nonzero(x) _I(x) #define ipa_nonzero(x) _I(x)
#define ipa_and(x,y) _MI(_I(x) & _I(y)) #define ipa_and(x,y) _MI(_I(x) & _I(y))
#define ipa_or(x,y) _MI(_I(x) | _I(y)) #define ipa_or(x,y) _MI(_I(x) | _I(y))
#define ipa_xor(x,y) _MI(_I(x) ^ _I(y))
#define ipa_not(x) _MI(~_I(x)) #define ipa_not(x) _MI(~_I(x))
#define ipa_mkmask(x) _MI(u32_mkmask(x)) #define ipa_mkmask(x) _MI(u32_mkmask(x))
#define ipa_mklen(x) u32_masklen(_I(x)) #define ipa_mklen(x) u32_masklen(_I(x))

View File

@ -36,6 +36,10 @@ typedef struct ipv4_addr {
_I1(a) | _I1(b), \ _I1(a) | _I1(b), \
_I2(a) | _I2(b), \ _I2(a) | _I2(b), \
_I3(a) | _I3(b)) _I3(a) | _I3(b))
#define ipa_xor(a,b) _MI(_I0(a) ^ _I0(b), \
_I1(a) ^ _I1(b), \
_I2(a) ^ _I2(b), \
_I3(a) ^ _I3(b))
#define ipa_not(a) _MI(~_I0(a),~_I1(a),~_I2(a),~_I3(a)) #define ipa_not(a) _MI(~_I0(a),~_I1(a),~_I2(a),~_I3(a))
#define ipa_mkmask(x) ipv6_mkmask(x) #define ipa_mkmask(x) ipv6_mkmask(x)
#define ipa_mklen(x) ipv6_mklen(&(x)) #define ipa_mklen(x) ipv6_mklen(&(x))