1 | /***************************************
2 | $Revision: 1.4 $
3 |
4 | Radix tree (rx). rx_global.h - header file with definition of
5 | global vars for radix
6 |
7 | Status: NOT REVUED, TESTED, INCOMPLETE
8 |
9 | Design and implementation by: Marek Bukowy
10 |
11 | ******************/ /******************
12 | Copyright (c) 1999 RIPE NCC
13 |
14 | All Rights Reserved
15 |
16 | Permission to use, copy, modify, and distribute this software and its
17 | documentation for any purpose and without fee is hereby granted,
18 | provided that the above copyright notice appear in all copies and that
19 | both that copyright notice and this permission notice appear in
20 | supporting documentation, and that the name of the author not be
21 | used in advertising or publicity pertaining to distribution of the
22 | software without specific, written prior permission.
23 |
24 | THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
25 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
26 | AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
27 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
28 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 | ***************************************/
31 |
32 | #ifndef RP_H
33 | #define RP_H
34 |
35 | #include <stddef.h> /* definition of NULL */
36 | #include <glib.h>
37 | /*#include <DF_attribute_enum.def> / * attribute codes */
38 |
39 | #include <defs.h>
40 |
41 | #include <iproutines.h>
42 | #include <erroutines.h>
43 | #include <rxroutines.h>
44 | #include <mysql_driver.h>
45 |
46 | typedef struct {
47 | rx_fam_t fam;
48 | ip_space_t space;
49 | union {
50 | ip_prefix_t rt;
51 | ip_range_t in;
52 | } u;
53 | } rp_uni_t;
54 |
55 |
56 | typedef int rp_regid_t;
57 | typedef A_Type_t rp_attr_t;
58 |
59 |
60 | typedef struct {
61 | rp_attr_t type;
62 | rp_uni_t uni;
63 | sql_key_t key;
64 | union {
65 | char *origin;
66 | char *domain;
67 | } d;
68 | } rp_upd_pack_t;
69 |
70 | #ifdef RP_IMPL
71 | #define EXTDEF(a,b) a = b;
72 | #else
73 | #define EXTDEF(a,b) extern a;
74 | #endif
75 |
76 | EXTDEF (GList *rx_forest, NULL) /* linked list of trees */
77 |
78 |
79 | typedef struct {
80 | rp_regid_t reg_id; /*+ registry id +*/
81 | rp_attr_t attr; /*+ extra tree attribute (within the same reg/spc/fam), allows
82 | using the same tree type for different object trees +*/
83 |
84 | rx_tree_t *tree; /*+ tree +*/
85 | } rp_tentry_t;
86 |
87 | er_ret_t RP_asc_load(char *filename, int maxobj,
88 | int operation, rp_regid_t reg_id);
89 | er_ret_t
90 | RP_tree_get ( rx_tree_t **treeptr, /*+ answer goes here, please +*/
91 | rp_regid_t reg_id, /*+ id of the registry +*/
92 | ip_space_t spc_id, /*+ type of space (ipv4/ipv6) +*/
93 | rp_attr_t attr /*+ extra tree id (within the same reg/spc/fam +*/
94 | );
95 | er_ret_t
96 | RP_tree_add (
97 | rp_regid_t reg_id, /*+ id of the registry +*/
98 | rp_attr_t attr, /*+ extra tree id (within the same registry/space/family +*/
99 | char *prefixstr, /*+ prefix the tree will cover (string) +*/
100 | rx_mem_mt mem_mode, /* memory only, memory+sql, sql only +*/
101 | rx_subtree_mt subtrees /*+ one of NONE, AUTO, HAND +*/
102 | );
103 | er_ret_t RP_init_trees( rp_regid_t reg_id );
104 |
105 |
106 | er_ret_t
107 | RP_asc_search (
108 | rx_srch_mt search_mode,
109 | int par_a,
110 | int par_b,
111 | char *key, /*+ search term: (string) prefix/range/IP +*/
112 | int reg_id,
113 | rp_attr_t attr, /*+ extra tree id (within the same reg/spc/fam +*/
114 | GList **anslist, /*+ answers go here, please +*/
115 | int max_count /*+ max # of answers. RX_ALLANS == unlimited +*/
116 | );
117 | er_ret_t
118 | RP_uni_node ( rx_oper_mt mode, /*+ MODE={cre|mod|del} +*/
119 | rp_uni_t *uni, /*+ unified argument structure +*/
120 | rp_attr_t attr, /*+ additional tree attribute +*/
121 | rp_regid_t reg_id, /*+ id of the registry +*/
122 | void *data, /*+ pointer to the payload +*/
123 | int datalen, /*+ length of the payload +*/
124 | sql_key_t key /*+ the key to the SQL full-text +*/
125 | );
126 | er_ret_t
127 | RP_asc_node( rx_oper_mt mode, /*+ MODE={cre|mod|del} +*/
128 | char *rangstr, /*+ string prefix/range/IP/inaddr +*/
129 | rp_attr_t attr, /*+ additional tree attribute +*/
130 | rp_regid_t reg_id, /*+ id of the registry +*/
131 | void *data, /*+ pointer to the payload +*/
132 | int datalen, /*+ length of the payload +*/
133 | sql_key_t key /*+ the key to the SQL full-text +*/
134 | );
135 |
136 | rx_fam_t RP_attr2fam( rp_attr_t type );
137 | int RP_attr2spc(rp_attr_t type, ip_space_t space);
138 | er_ret_t
139 | RP_asc2uni(char *astr, /*+ string prefix/range/IP/inaddr +*/
140 | rp_attr_t attr,
141 | rp_uni_t *uni); /* destination pointer */
142 | er_ret_t
143 | RP_asc2pack(rp_upd_pack_t *pack, rp_attr_t type, char *string);
144 |
145 |
146 | void RP_pack_set_orig( rp_attr_t attr,rp_upd_pack_t *pack, char *origin);
147 | void RP_pack_set_pref4(rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
148 | unsigned *prefix, unsigned *prefix_length);
149 | void RP_pack_set_revd( rp_attr_t attr,char *avalue, rp_upd_pack_t *pack);
150 | void RP_pack_set_pref6(rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
151 | ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
152 | void RP_pack_set_rang( rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
153 | unsigned *begin_in, unsigned *end_in);
154 |
155 | er_ret_t
156 | RP_pack_update(rx_oper_mt mode,
157 | rp_upd_pack_t *pack,
158 | rp_regid_t reg_id); /*+ id of the registry +*/
159 |
160 |
161 | er_ret_t
162 | RP_pack_node(rx_oper_mt mode,
163 | rp_upd_pack_t *pack,
164 | rp_regid_t reg_id);
165 | er_ret_t
166 | RP_pack_node_l(rx_oper_mt mode,
167 | rp_upd_pack_t *pack,
168 | rx_tree_t *mytree);
169 |
170 | void rp_make_short(rp_upd_pack_t *pack, char **ptr, int *len);
171 | er_ret_t
172 | RP_sql_load_attr_space( int maxobj, int operation,
173 | char *qry,
174 | rp_attr_t attr, ip_space_t space,
175 | rp_regid_t reg_id, SQ_connection_t *con
176 | );
177 | er_ret_t RP_sql_load_reg(rp_regid_t reg_id);
178 | er_ret_t RP_asc_load(char *filename, int maxobj, int operation,
179 | rp_regid_t reg_id);
180 | int RP_attr2spc(rp_attr_t type, ip_space_t space);
181 | #undef EXTDEF
182 | #endif /* RP_H */