Revision 25697773

View differences:

Makefile
2 2
# (c) 1998 Martin Mares <mj@ucw.cz>
3 3

  
4 4
TOPDIR=$(shell pwd)
5
OBJDIR=obj
6

  
5 7
CPPFLAGS=-I$(TOPDIR)/sysdep/linux -I$(TOPDIR)
6 8
OPT=-O2
7 9
DEBUG=-g#gdb
8 10
CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
9 11

  
10 12
PROTOCOLS=
11
DIRS=nest $(PROTOCOLS) lib sysdep/linux sysdep/unix
12
ARCHS=$(join $(addsuffix /,$(DIRS)),$(subst /,_,$(addsuffix .a,$(DIRS))))
13
LIBDIRS=sysdep/linux sysdep/unix lib
14
STDDIRS=nest $(PROTOCOLS)
15
DIRS=$(STDDIRS) $(OBJDIR)/lib
16
PARTOBJS=$(join $(addsuffix /,$(STDDIRS)),$(subst /,_,$(addsuffix .o,$(STDDIRS))))
17
LIBS=$(OBJDIR)/lib/birdlib.a
13 18

  
14 19
export
15 20

  
16 21
all: .dep all-dirs bird
17 22

  
18 23
all-dirs:
19
	set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a ; done
24
	set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a all ; done
20 25

  
21
bird: $(ARCHS)
26
bird: $(PARTOBJS) $(LIBS)
22 27
	$(CC) $(LDFLAGS) -o $@ $^
23 28

  
24 29
.dep:
25 30
	$(MAKE) dep
26
	touch .dep
27 31

  
28 32
dep:
33
	mkdir -p $(OBJDIR)
34
	tools/mergedirs $(OBJDIR) $(LIBDIRS)
35
#	for a in $(STDDIRS) ; do mkdir -p $(OBJDIR)/$$a ; done
29 36
	set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a dep ; done
37
	touch .dep
30 38

  
31 39
clean:
40
	rm -rf obj
32 41
	rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name .depend -or -name .#*`
33 42
	rm -f bird .dep
Rules
3 3

  
4 4
THISDIR=$(shell pwd)
5 5
RELDIR=$(subst $(TOPDIR)/,,$(THISDIR))
6
ANAME=$(subst /,_,$(RELDIR)).a
6
ONAME=$(subst /,_,$(RELDIR)).o
7

  
8
ifndef SRCS
7 9
SRCS=$(subst .o,.c,$(OBJS))
10
endif
11

  
12
ifdef OBJS
8 13

  
9
all: $(ANAME)
14
ifdef LIB
10 15

  
11
$(ANAME): $(OBJS)
12
	rm -f $(ANAME)
13
	ar rcs $(ANAME) $(OBJS)
16
all: $(LIB)
14 17

  
15
ifdef OBJS
18
$(LIB): $(OBJS)
19
	rm -f $(LIB)
20
	ar rcs $(LIB) $(OBJS)
21
	ranlib $(LIB)
22

  
23
else
24

  
25
all: $(ONAME)
26

  
27
$(ONAME): $(OBJS)
28
	$(LD) -r -o $(ONAME) $(OBJS)
29

  
30
endif
16 31

  
17 32
dep: $(SRCS)
18 33
	rm -f .depend
lib/Makefile
1
OBJS=lists.o bitops.o resource.o xmalloc.o mempool.o slab.o md5.o
2

  
3
ifdef IPV6
4
OBJS += ipv6.o
5
else
6
OBJS += ipv4.o
7
endif
8

  
9
include $(TOPDIR)/Rules
lib/Modules
1
birdlib.h
2
bitops.c
3
bitops.h
4
ip.h
5
ipv4.c
6
ipv4.h
7
ipv6.c
8
ipv6.h
9
lists.c
10
lists.h
11
md5.c
12
md5.h
13
mempool.c
14
resource.c
15
resource.h
16
slab.c
17
socket.h
18
unaligned.h
19
xmalloc.c
lib/birdlib.h
21 21

  
22 22
/* Logging and dying */
23 23

  
24
void log(char *msg, ...);
25
void die(char *msg, ...) NORET;
24
void log(char *msg, ...) __attribute__((format(printf,1,2)));
25
void die(char *msg, ...) __attribute__((format(printf,1,2))) NORET;
26 26

  
27 27
#define L_DEBUG "\001"			/* Debugging messages */
28 28
#define L_INFO "\002"			/* Informational messages */
lib/ip.h
35 35
#define SCOPE_SITE 2
36 36
#define SCOPE_UNIVERSE 3
37 37

  
38
/*
39
 *	Is it a valid network prefix?
40
 */
41

  
42
#define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
43

  
38 44
#endif
lib/ipv4.c
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
8 8

  
9
#ifndef IPV6
10

  
9 11
#include "nest/bird.h"
10 12
#include "lib/ip.h"
11 13

  
......
27 29
    return IADDR_BROADCAST | SCOPE_LINK;
28 30
  return IADDR_INVALID;
29 31
}
32

  
33
#endif
lib/ipv4.h
25 25
} ip_addr;
26 26

  
27 27
#define _I(x) (x).addr
28
#define _MI(x) ((struct ip_addr) { x })
28
#define _MI(x) ((struct ipv4_addr) { x })
29 29

  
30 30
#else
31 31

  
......
36 36

  
37 37
#endif
38 38

  
39
#define BITS_PER_IP_ADDRESS 32
40

  
39 41
#define IPA_NONE (_MI(0))
40 42

  
41 43
#define ipa_equal(x,y) (_I(x) == _I(y))
......
50 52
#define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
51 53
#define ipa_classify(x) ipv4_classify(_I(x))
52 54

  
53
unsigned ipv4_mklen(u32);
54
u32 ipv4_mkmask(unsigned);
55 55
int ipv4_classify(u32);
56 56

  
57 57
/* FIXME: Is this hash function uniformly distributed over standard routing tables? */
lib/ipv6.c
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
8 8

  
9
#ifdef IPV6
10

  
9 11
#include "nest/bird.h"
10 12
#include "lib/ip.h"
11 13

  
12 14
#error "Ought to implement these."
15

  
16
#endif
lib/ipv6.h
22 22
#define _I2(a) ((a).addr[2])
23 23
#define _I3(a) ((a).addr[3])
24 24

  
25
#define BITS_PER_IP_ADDRESS 128
26

  
25 27
#define IPA_NONE _MI(0,0,0,0)
26 28

  
27 29
#define ipa_equal(x,y) (!memcmp(&(x),&(y),sizeof(ip_addr)))
lib/timer.h
1
/*
2
 *	BIRD Timers
3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

  
9
#ifndef _BIRD_TIMER_H_
10
#define _BIRD_TIMER_H_
11

  
12
#include "lib/resource.h"
13

  
14
typedef struct timer {
15
	resource r;
16
	void (*hook)(struct timer *);
17
	void *data;
18
	/* internal fields should be here */
19
} timer;
20

  
21
timer *tm_new(pool *, void (*hook)(timer *), void *data);
22
void tm_start(timer *, unsigned after);
23
void tm_stop(timer *);
24
void tm_trigger(timer *);
25

  
26
#endif
sysdep/cf/linux-20.h
9 9
#undef CONFIG_TOS
10 10
#undef CONFIG_MULTIPATH
11 11
#undef CONFIG_NETLINK
12

  
13
/*
14
Link: sysdep/linux
15
 */
sysdep/cf/linux-21.h
9 9
#define CONFIG_TOS
10 10
#define CONFIG_MULTIPATH
11 11
#define CONFIG_NETLINK
12

  
13
/*
14
Link: sysdep/linux
15
 */
sysdep/cf/linux-v6.h
11 11
#define CONFIG_TOS
12 12
#define CONFIG_MULTIPATH
13 13
#define CONFIG_NETLINK
14

  
15
/*
16
Link: sysdep/linux
17
 */
sysdep/linux/Makefile
1
include $(TOPDIR)/Rules
sysdep/unix/Makefile
1
OBJS=log.o
2

  
3
include $(TOPDIR)/Rules
sysdep/unix/Modules
1
log.c
2
main.c
3
timer.h
sysdep/unix/main.c
1
/*
2
 *	BIRD Internet Routing Daemon -- Unix Entry Point
3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

  
9
#include <stdio.h>
10

  
11
#include "nest/bird.h"
12
#include "lib/lists.h"
13
#include "lib/resource.h"
14
#include "nest/route.h"
15

  
16
int
17
main(void)
18
{
19
  log(L_INFO "Launching BIRD -1.-1-pre-omega...");
20

  
21
  log_init_debug(NULL);
22
  resource_init();
23

  
24
  return 0;
25
}
sysdep/unix/timer.h
1
/*
2
 *	BIRD Timers
3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

  
9
#ifndef _BIRD_TIMER_H_
10
#define _BIRD_TIMER_H_
11

  
12
#include "lib/resource.h"
13

  
14
typedef struct timer {
15
	resource r;
16
	void (*hook)(struct timer *);
17
	void *data;
18
	/* internal fields should be here */
19
} timer;
20

  
21
timer *tm_new(pool *, void (*hook)(timer *), void *data);
22
void tm_start(timer *, unsigned after);
23
void tm_stop(timer *);
24
void tm_trigger(timer *);
25

  
26
#endif
tools/mergedirs
1
#!/bin/sh
2

  
3
if [ -z "$2" ] ; then
4
	echo "Usage: mergedirs <obj-dir> <list-of-dirs>"
5
	exit 1
6
	fi
7
TOPDIR=`pwd`
8
OBJDIR=$1
9
LIBDIR=$OBJDIR/lib
10
shift
11
echo "Merging system-dependent modules"
12
MODULES=`for a in $@ ; do
13
		sed <$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
14
		done |
15
	sort +0 -1 -u |
16
	cut -d ' ' -f 2`
17
rm -rf $LIBDIR
18
mkdir -p $LIBDIR
19
for a in $MODULES ; do
20
	echo $a
21
	b=`basename $a`
22
	ln -s $TOPDIR/$a $LIBDIR/$b
23
	OBJ=`echo $b | sed '/\.c$/!d;s/\.c$/\.o/'`
24
	if [ -n "$OBJ" ] ; then
25
		OBJS="$OBJS $OBJ"
26
		SRCS="$SRCS \\
27
	\$(TOPDIR)/$a"
28
		fi
29
	done
30
cat >$LIBDIR/Makefile <<EOF
31
OBJS=$OBJS
32
SRCS=$SRCS
33
LIB=birdlib.a
34

  
35
include \$(TOPDIR)/Rules
36
EOF

Also available in: Unified diff