From c40e05a0dffa33a8724e56121a2b6dcdfa9183e0 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 23 Apr 1998 14:01:15 +0000 Subject: Added IP address manipulation macros, interface declarations and logging. --- lib/ipv4.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/ipv4.h (limited to 'lib/ipv4.h') diff --git a/lib/ipv4.h b/lib/ipv4.h new file mode 100644 index 00000000..e5c1e8ca --- /dev/null +++ b/lib/ipv4.h @@ -0,0 +1,35 @@ +/* + * BIRD -- IP Addresses et Cetera for IPv4 + * + * (c) 1998 Martin Mares + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_IPV4_H_ +#define _BIRD_IPV4_H_ + +#include + +typedef struct ipv4_addr { + u32 addr; +} ip_addr; + +#define _I(x) (x).addr +#define _MI(x) ((struct ip_addr) { x }) + +#define IPA_NONE(_MI(0)) + +#define ipa_equal(x,y) (_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_not(x) _MI(~_I(x)) +#define ipa_mkmask(x) _MI(ipv4_mkmask(x)) +#define ipa_mklen(x) ipv4_mklen(_I(x)) + +unsigned ipv4_mklen(u32); +u32 ipv4_mkmask(unsigned); + +/* ??? htonl and ntohl ??? */ + +#endif -- cgit v1.2.3