Revision fe9f1a6d lib/ip.h

View differences:

lib/ip.h
30 30
#define IP4_NONE		_MI4(0)
31 31
#define IP6_NONE		_MI6(0,0,0,0)
32 32

  
33
#define IP4_MAX_PREFIX_LENGTH	32
34
#define IP6_MAX_PREFIX_LENGTH	128
35

  
33 36
#define IP4_MIN_MTU		576
34 37
#define IP6_MIN_MTU		1280
35 38

  
......
39 42
#define IP6_HEADER_LENGTH	40
40 43
#define UDP_HEADER_LENGTH	8
41 44

  
42

  
43 45
#ifdef IPV6
44 46
#define MAX_PREFIX_LENGTH 128
45 47
#define BITS_PER_IP_ADDRESS 128
46 48
#define STD_ADDRESS_P_LENGTH 39
47
#define SIZE_OF_IP_HEADER 40
48 49
#else
49 50
#define MAX_PREFIX_LENGTH 32
50 51
#define BITS_PER_IP_ADDRESS 32
51 52
#define STD_ADDRESS_P_LENGTH 15
52
#define SIZE_OF_IP_HEADER 24
53 53
#endif
54 54

  
55 55

  
......
319 319
static inline ip4_addr ip4_mkmask(uint n)
320 320
{ return _MI4(u32_mkmask(n)); }
321 321

  
322
static inline int ip4_masklen(ip4_addr a)
322
static inline uint ip4_masklen(ip4_addr a)
323 323
{ return u32_masklen(_I(a)); }
324 324

  
325 325
ip6_addr ip6_mkmask(uint n);
326
int ip6_masklen(ip6_addr *a);
326
uint ip6_masklen(ip6_addr *a);
327 327

  
328 328
/* ipX_pxlen() requires that x != y */
329 329
static inline uint ip4_pxlen(ip4_addr a, ip4_addr b)
......
345 345
static inline u32 ip6_getbit(ip6_addr a, uint pos)
346 346
{ return a.addr[pos / 32] & (0x80000000 >> (pos % 32)); }
347 347

  
348
static inline u32 ip4_setbit(ip4_addr *a, uint pos)
349
{ return _I(*a) |= (0x80000000 >> pos); }
350

  
351
static inline u32 ip6_setbit(ip6_addr *a, uint pos)
352
{ return a->addr[pos / 32] |= (0x80000000 >> (pos % 32)); }
353

  
354
static inline u32 ip4_clrbit(ip4_addr *a, uint pos)
355
{ return _I(*a) &= ~(0x80000000 >> pos); }
356

  
357
static inline u32 ip6_clrbit(ip6_addr *a, uint pos)
358
{ return a->addr[pos / 32] &= ~(0x80000000 >> (pos % 32)); }
359

  
348 360
static inline ip4_addr ip4_opposite_m1(ip4_addr a)
349 361
{ return _MI4(_I(a) ^ 1); }
350 362

  
......
364 376
#define ipa_masklen(x) ip6_masklen(&x)
365 377
#define ipa_pxlen(x,y) ip6_pxlen(x,y)
366 378
#define ipa_getbit(x,n) ip6_getbit(x,n)
379
#define ipa_setbit(x,n) ip6_setbit(x,n)
380
#define ipa_clrbit(x,n) ip6_clrbit(x,n)
367 381
#define ipa_opposite_m1(x) ip6_opposite_m1(x)
368 382
#define ipa_opposite_m2(x) ip6_opposite_m2(x)
369 383
#else
......
371 385
#define ipa_masklen(x) ip4_masklen(x)
372 386
#define ipa_pxlen(x,y) ip4_pxlen(x,y)
373 387
#define ipa_getbit(x,n) ip4_getbit(x,n)
388
#define ipa_setbit(x,n) ip4_setbit(x,n)
389
#define ipa_clrbit(x,n) ip4_clrbit(x,n)
374 390
#define ipa_opposite_m1(x) ip4_opposite_m1(x)
375 391
#define ipa_opposite_m2(x) ip4_opposite_m2(x)
376 392
#endif

Also available in: Unified diff