This commit is contained in:
Job Snijders
2021-08-18 01:58:47 +00:00
parent cb98214f0c
commit 99f036b186
4 changed files with 51 additions and 37 deletions

View File

@@ -16,7 +16,7 @@ bgpq4_SOURCES=main.c extern.h printer.c expander.c \
sx_maxsockbuf.c \ sx_maxsockbuf.c \
sx_prefix.c sx_prefix.h \ sx_prefix.c sx_prefix.h \
sx_report.c sx_report.h \ sx_report.c sx_report.h \
sx_slentry.c sx_slentry.h sx_slentry.c
EXTRA_DIST=bootstrap README.md CHANGES bgpq4.spec EXTRA_DIST=bootstrap README.md CHANGES bgpq4.spec

View File

@@ -25,9 +25,23 @@
*/ */
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/tree.h>
#include "sx_prefix.h" #include "sx_prefix.h"
#include "sx_slentry.h"
struct sx_slentry {
STAILQ_ENTRY(sx_slentry) entries;
char* text;
};
struct sx_slentry* sx_slentry_new(char* text);
struct sx_tentry {
RB_ENTRY(sx_tentry) entries;
char* text;
};
struct sx_tentry* sx_tentry_new(char* text);
typedef enum { typedef enum {
V_CISCO = 0, V_CISCO = 0,

View File

@@ -59,43 +59,43 @@ typedef struct sx_radix_tree {
} sx_radix_tree_t; } sx_radix_tree_t;
/* most common operations with the tree is to: lookup/insert/unlink */ /* most common operations with the tree is to: lookup/insert/unlink */
struct sx_radix_node* sx_radix_tree_lookup(struct sx_radix_tree* tree, struct sx_radix_node *sx_radix_tree_lookup(struct sx_radix_tree *tree,
struct sx_prefix* prefix); struct sx_prefix *prefix);
struct sx_radix_node* sx_radix_tree_insert(struct sx_radix_tree* tree, struct sx_radix_node *sx_radix_tree_insert(struct sx_radix_tree *tree,
struct sx_prefix* prefix); struct sx_prefix *prefix);
void sx_radix_tree_unlink(struct sx_radix_tree* t, struct sx_radix_node* n); void sx_radix_tree_unlink(struct sx_radix_tree *t, struct sx_radix_node *n);
struct sx_radix_node* sx_radix_tree_lookup_exact(struct sx_radix_tree* tree, struct sx_radix_node *sx_radix_tree_lookup_exact(struct sx_radix_tree *tree,
struct sx_prefix* prefix); struct sx_prefix *prefix);
struct sx_prefix* sx_prefix_alloc(struct sx_prefix* p); struct sx_prefix *sx_prefix_alloc(struct sx_prefix *p);
void sx_prefix_destroy(struct sx_prefix* p); void sx_prefix_destroy(struct sx_prefix *p);
void sx_radix_node_destroy(struct sx_radix_node* p); void sx_radix_node_destroy(struct sx_radix_node *p);
void sx_prefix_adjust_masklen(struct sx_prefix* p); void sx_prefix_adjust_masklen(struct sx_prefix *p);
struct sx_prefix* sx_prefix_new(int af, char* text); struct sx_prefix *sx_prefix_new(int af, char *text);
int sx_prefix_parse(struct sx_prefix* p, int af, char* text); int sx_prefix_parse(struct sx_prefix *p, int af, char *text);
int sx_prefix_range_parse(struct sx_radix_tree* t, int af, unsigned int ml, char* text); int sx_prefix_range_parse(struct sx_radix_tree *t, int af, unsigned int ml, char *text);
int sx_prefix_fprint(FILE* f, struct sx_prefix* p); int sx_prefix_fprint(FILE *f, struct sx_prefix *p);
int sx_prefix_snprintf(struct sx_prefix* p, char* rbuffer, int srb); int sx_prefix_snprintf(struct sx_prefix *p, char *rbuffer, int srb);
int sx_prefix_snprintf_sep(struct sx_prefix* p, char* rbuffer, int srb, char*); int sx_prefix_snprintf_sep(struct sx_prefix *p, char *rbuffer, int srb, char *);
void sx_prefix_snprintf_fmt(struct sx_prefix* p, FILE* f, void sx_prefix_snprintf_fmt(struct sx_prefix *p, FILE *f,
const char* name, const char* fmt, const char *name, const char *fmt, unsigned int aggregateLow,
unsigned int aggregateLow, unsigned int aggregateHi); unsigned int aggregateHi);
int sx_prefix_jsnprintf(struct sx_prefix* p, char* rbuffer, int srb); int sx_prefix_jsnprintf(struct sx_prefix *p, char *rbuffer, int srb);
struct sx_radix_tree* sx_radix_tree_new(int af); struct sx_radix_tree *sx_radix_tree_new(int af);
struct sx_radix_node* sx_radix_node_new(struct sx_prefix* prefix); struct sx_radix_node *sx_radix_node_new(struct sx_prefix *prefix);
struct sx_prefix* sx_prefix_overlay(struct sx_prefix* p, int n); struct sx_prefix *sx_prefix_overlay(struct sx_prefix *p, int n);
int sx_radix_tree_empty(struct sx_radix_tree* t); int sx_radix_tree_empty(struct sx_radix_tree *t);
void sx_radix_node_fprintf(struct sx_radix_node* node, void* udata); void sx_radix_node_fprintf(struct sx_radix_node *node, void *udata);
int sx_radix_node_foreach(struct sx_radix_node* node, int sx_radix_node_foreach(struct sx_radix_node *node,
void (*func)(struct sx_radix_node*, void*), void* udata); void (*func)(struct sx_radix_node *, void *), void *udata);
int sx_radix_tree_foreach(struct sx_radix_tree* tree, int sx_radix_tree_foreach(struct sx_radix_tree *tree,
void (*func)(struct sx_radix_node*, void*), void* udata); void (*func)(struct sx_radix_node *, void *), void *udata);
int sx_radix_tree_aggregate(struct sx_radix_tree* tree); int sx_radix_tree_aggregate(struct sx_radix_tree *tree);
int sx_radix_tree_refine(struct sx_radix_tree* tree, unsigned refine); int sx_radix_tree_refine(struct sx_radix_tree *tree, unsigned refine);
int sx_radix_tree_refineLow(struct sx_radix_tree* tree, unsigned refineLow); int sx_radix_tree_refineLow(struct sx_radix_tree *tree, unsigned refineLow);
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
size_t strlcpy(char* dst, const char* src, size_t size); size_t strlcpy(char *dst, const char *src, size_t size);
#endif #endif
#endif #endif

View File

@@ -28,7 +28,7 @@
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sx_slentry.h" #include "extern.h"
struct sx_slentry * struct sx_slentry *
sx_slentry_new(char *t) sx_slentry_new(char *t)