summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-05-15 09:56:13 +0200
committerMartin Mares <mj@ucw.cz>1998-05-15 09:56:13 +0200
commit25697773b529d80278679978b7416ca9c87e15e9 (patch)
tree8ca875571e57475a15e978abae76aeda58d82149 /lib
parent62aa008abd627c6862310daf65ffd337a920bdbb (diff)
downloadbird-25697773b529d80278679978b7416ca9c87e15e9.tar
bird-25697773b529d80278679978b7416ca9c87e15e9.zip
The library is now glued together from generic and OS-dependent parts
by the `mergedirs' script. Few more IP address manipulation functions and some fixes.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile9
-rw-r--r--lib/Modules19
-rw-r--r--lib/birdlib.h4
-rw-r--r--lib/ip.h6
-rw-r--r--lib/ipv4.c4
-rw-r--r--lib/ipv4.h6
-rw-r--r--lib/ipv6.c4
-rw-r--r--lib/ipv6.h2
-rw-r--r--lib/timer.h26
9 files changed, 40 insertions, 40 deletions
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644
index 6eb14e1..0000000
--- a/lib/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-OBJS=lists.o bitops.o resource.o xmalloc.o mempool.o slab.o md5.o
-
-ifdef IPV6
-OBJS += ipv6.o
-else
-OBJS += ipv4.o
-endif
-
-include $(TOPDIR)/Rules
diff --git a/lib/Modules b/lib/Modules
new file mode 100644
index 0000000..18447e1
--- /dev/null
+++ b/lib/Modules
@@ -0,0 +1,19 @@
+birdlib.h
+bitops.c
+bitops.h
+ip.h
+ipv4.c
+ipv4.h
+ipv6.c
+ipv6.h
+lists.c
+lists.h
+md5.c
+md5.h
+mempool.c
+resource.c
+resource.h
+slab.c
+socket.h
+unaligned.h
+xmalloc.c
diff --git a/lib/birdlib.h b/lib/birdlib.h
index 5e533b6..842fce8 100644
--- a/lib/birdlib.h
+++ b/lib/birdlib.h
@@ -21,8 +21,8 @@
/* Logging and dying */
-void log(char *msg, ...);
-void die(char *msg, ...) NORET;
+void log(char *msg, ...) __attribute__((format(printf,1,2)));
+void die(char *msg, ...) __attribute__((format(printf,1,2))) NORET;
#define L_DEBUG "\001" /* Debugging messages */
#define L_INFO "\002" /* Informational messages */
diff --git a/lib/ip.h b/lib/ip.h
index c368399..87cd3aa 100644
--- a/lib/ip.h
+++ b/lib/ip.h
@@ -35,4 +35,10 @@
#define SCOPE_SITE 2
#define SCOPE_UNIVERSE 3
+/*
+ * Is it a valid network prefix?
+ */
+
+#define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
+
#endif
diff --git a/lib/ipv4.c b/lib/ipv4.c
index 52f5b0b..cc67373 100644
--- a/lib/ipv4.c
+++ b/lib/ipv4.c
@@ -6,6 +6,8 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
+#ifndef IPV6
+
#include "nest/bird.h"
#include "lib/ip.h"
@@ -27,3 +29,5 @@ ipv4_classify(u32 a)
return IADDR_BROADCAST | SCOPE_LINK;
return IADDR_INVALID;
}
+
+#endif
diff --git a/lib/ipv4.h b/lib/ipv4.h
index fa8a27b..de9f4e5 100644
--- a/lib/ipv4.h
+++ b/lib/ipv4.h
@@ -25,7 +25,7 @@ typedef struct ipv4_addr {
} ip_addr;
#define _I(x) (x).addr
-#define _MI(x) ((struct ip_addr) { x })
+#define _MI(x) ((struct ipv4_addr) { x })
#else
@@ -36,6 +36,8 @@ typedef u32 ip_addr;
#endif
+#define BITS_PER_IP_ADDRESS 32
+
#define IPA_NONE (_MI(0))
#define ipa_equal(x,y) (_I(x) == _I(y))
@@ -50,8 +52,6 @@ typedef u32 ip_addr;
#define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
#define ipa_classify(x) ipv4_classify(_I(x))
-unsigned ipv4_mklen(u32);
-u32 ipv4_mkmask(unsigned);
int ipv4_classify(u32);
/* FIXME: Is this hash function uniformly distributed over standard routing tables? */
diff --git a/lib/ipv6.c b/lib/ipv6.c
index e612af7..2d01e83 100644
--- a/lib/ipv6.c
+++ b/lib/ipv6.c
@@ -6,7 +6,11 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
+#ifdef IPV6
+
#include "nest/bird.h"
#include "lib/ip.h"
#error "Ought to implement these."
+
+#endif
diff --git a/lib/ipv6.h b/lib/ipv6.h
index 845955f..08ed5f8 100644
--- a/lib/ipv6.h
+++ b/lib/ipv6.h
@@ -22,6 +22,8 @@ typedef struct ipv4_addr {
#define _I2(a) ((a).addr[2])
#define _I3(a) ((a).addr[3])
+#define BITS_PER_IP_ADDRESS 128
+
#define IPA_NONE _MI(0,0,0,0)
#define ipa_equal(x,y) (!memcmp(&(x),&(y),sizeof(ip_addr)))
diff --git a/lib/timer.h b/lib/timer.h
deleted file mode 100644
index 506e3c9..0000000
--- a/lib/timer.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * BIRD Timers
- *
- * (c) 1998 Martin Mares <mj@ucw.cz>
- *
- * Can be freely distributed and used under the terms of the GNU GPL.
- */
-
-#ifndef _BIRD_TIMER_H_
-#define _BIRD_TIMER_H_
-
-#include "lib/resource.h"
-
-typedef struct timer {
- resource r;
- void (*hook)(struct timer *);
- void *data;
- /* internal fields should be here */
-} timer;
-
-timer *tm_new(pool *, void (*hook)(timer *), void *data);
-void tm_start(timer *, unsigned after);
-void tm_stop(timer *);
-void tm_trigger(timer *);
-
-#endif