Revision 18c8241a lib/ipv6.h

View differences:

lib/ipv6.h
25 25
#define IPA_NONE _MI(0,0,0,0)
26 26

  
27 27
#define ipa_equal(x,y) (!memcmp(&(x),&(y),sizeof(ip_addr)))
28
#define ipa_nonzero(x) (_I0(a) || _I1(a) || _I2(a) || _I3(a))
28 29
#define ipa_and(a,b) _MI(_I0(a) & _I0(b), \
29 30
			 _I1(a) & _I1(b), \
30 31
			 _I2(a) & _I2(b), \
......
34 35
			_I2(a) | _I2(b), \
35 36
			_I3(a) | _I3(b))
36 37
#define ipa_not(a) _MI(~_I0(a),~_I1(a),~_I2(a),~_I3(a))
37

  
38 38
#define ipa_mkmask(x) ipv6_mkmask(x)
39
#define ipa_mklen(x) ipv6_mklen(x)
39
#define ipa_mklen(x) ipv6_mklen(&(x))
40
#define ipa_hash(x) ipv6_hash(&(x))
41
#define ipa_hton(x) ipv6_hton(&(x))
42
#define ipa_ntoh(x) ipv6_ntoh(&(x))
43
#define ipa_classify(x) ipv6_classify(&(x))
40 44

  
41 45
ip_addr ipv6_mkmask(unsigned);
42
unsigned ipv6_mklen(ip_addr);
46
unsigned ipv6_mklen(ip_addr *);
47
int ipv6_classify(ip_addr *);
48
void ipv6_hton(ip_addr *);
49
void ipv6_ntoh(ip_addr *);
50

  
51
/* FIXME: Is this hash function uniformly distributed over standard routing tables? */
52
static inline unsigned ipv6_hash(ip_addr *a)
53
{
54
  u32 x = _I0(*a) ^ _I1(*a) ^ _I2(*a) ^ _I3(*a);
55
  return x ^ (x >> 16) ^ (x >> 8);
56
}
43 57

  
44 58
#endif

Also available in: Unified diff