diff options
author | Luigi Rizzo <luigi@FreeBSD.org> | 2009-12-12 15:49:28 +0000 |
---|---|---|
committer | Luigi Rizzo <luigi@FreeBSD.org> | 2009-12-12 15:49:28 +0000 |
commit | a50f6188deee7dee9e28c36c5990acb7088e674f (patch) | |
tree | da99ba15d44d8d71eb66b524859a67a893c0ae6c /sys/net/radix.c | |
parent | 1b2aeedc6478dca453b15fb0decb16c78a43c26c (diff) | |
download | src-a50f6188deee7dee9e28c36c5990acb7088e674f.tar.gz src-a50f6188deee7dee9e28c36c5990acb7088e674f.zip |
Make the code buildable in userland so it is easier to test it:
this requires a small reordering of headers and a few #defines to
map functions not available in userland.
Remove a useless #ifndef block at the beginning of the file.
Introduce (temporarily) rn_init2(), see the comment in the code
for the proper long term change.
No ABI or functional change.
MFC after: 7 days
Notes
Notes:
svn path=/head/; revision=200439
Diffstat (limited to 'sys/net/radix.c')
-rw-r--r-- | sys/net/radix.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/sys/net/radix.c b/sys/net/radix.c index a494adf10c78..531dafbcbb0f 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -33,7 +33,6 @@ /* * Routines to build and maintain radix trees for routing lookups. */ -#ifndef _RADIX_H_ #include <sys/param.h> #ifdef _KERNEL #include <sys/lock.h> @@ -42,19 +41,21 @@ #include <sys/systm.h> #include <sys/malloc.h> #include <sys/domain.h> -#else -#include <stdlib.h> -#endif #include <sys/syslog.h> #include <net/radix.h> -#endif - #include "opt_mpath.h" - #ifdef RADIX_MPATH #include <net/radix_mpath.h> #endif - +#else /* !_KERNEL */ +#include <stdio.h> +#include <strings.h> +#include <stdlib.h> +#define log(x, arg...) fprintf(stderr, ## arg) +#define panic(x) fprintf(stderr, "PANIC: %s", x), exit(1) +#define min(a, b) ((a) < (b) ? (a) : (b) ) +#include <net/radix.h> +#endif /* !_KERNEL */ static int rn_walktree_from(struct radix_node_head *h, void *a, void *m, walktree_f_t *f, void *w); @@ -1188,3 +1189,19 @@ rn_init() if (rn_inithead((void **)(void *)&mask_rnhead, 0) == 0) panic("rn_init 2"); } + +#ifndef _KERNEL +/* + * A simple function to make the code usable from userland. + * A proper fix (maybe later) would be to change rn_init() so that it + * takes maxkeylen as an argument, and move the scan of + * domains into net/route.c::route_init(). + */ +void rn_init2(int maxk); +void +rn_init2(int maxk) +{ + max_keylen = maxk; + rn_init(); +} +#endif /* !_KERNEL */ |