1998-04-23 14:01:15 +00:00
|
|
|
/*
|
|
|
|
* BIRD Internet Routing Daemon -- The Internet Protocol
|
|
|
|
*
|
|
|
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_IP_H_
|
|
|
|
#define _BIRD_IP_H_
|
|
|
|
|
|
|
|
#ifndef IPV6
|
1998-04-28 14:39:34 +00:00
|
|
|
#include "ipv4.h"
|
1998-04-23 14:01:15 +00:00
|
|
|
#else
|
1998-04-28 14:39:34 +00:00
|
|
|
#include "ipv6.h"
|
1998-04-23 14:01:15 +00:00
|
|
|
#endif
|
|
|
|
|
1998-06-01 21:36:58 +00:00
|
|
|
#define ipa_in_net(x,n,p) (!ipa_nonzero(ipa_and(ipa_xor((n),(x)),ipa_mkmask(p))))
|
|
|
|
|
1998-05-03 16:43:39 +00:00
|
|
|
/*
|
|
|
|
* ip_classify() returns either a negative number for invalid addresses
|
|
|
|
* or scope OR'ed together with address type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IADDR_INVALID -1
|
|
|
|
#define IADDR_SCOPE_MASK 0xfff
|
|
|
|
#define IADDR_HOST 0x1000
|
|
|
|
#define IADDR_BROADCAST 0x2000
|
|
|
|
#define IADDR_MULTICAST 0x4000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Address scope
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SCOPE_HOST 0
|
|
|
|
#define SCOPE_LINK 1
|
|
|
|
#define SCOPE_SITE 2
|
1999-08-03 19:36:06 +00:00
|
|
|
#define SCOPE_ORGANIZATION 3
|
|
|
|
#define SCOPE_UNIVERSE 4
|
1998-05-03 16:43:39 +00:00
|
|
|
|
1999-11-25 15:34:20 +00:00
|
|
|
char *ip_scope_text(unsigned);
|
|
|
|
|
1998-05-15 07:56:13 +00:00
|
|
|
/*
|
|
|
|
* Is it a valid network prefix?
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
|
|
|
|
|
1998-06-17 14:26:30 +00:00
|
|
|
/*
|
|
|
|
* Conversions between internal and string representation
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *ip_ntop(ip_addr a, char *);
|
|
|
|
char *ip_ntox(ip_addr a, char *);
|
1998-11-27 19:29:27 +00:00
|
|
|
int ip_pton(char *a, ip_addr *o);
|
1998-06-17 14:26:30 +00:00
|
|
|
|
1998-04-23 14:01:15 +00:00
|
|
|
#endif
|