modules/rp/rp.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- EXTDEF
- EXTDEF
- EXTDEF
1 /***************************************
2 $Revision: 1.7 $
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
47 #include "ca_defs.h"
48
49
50 typedef struct {
51 rx_fam_t fam;
52 ip_space_t space;
53 union {
54 ip_prefix_t rt;
55 ip_range_t in;
56 } u;
57 } rp_uni_t;
58
59
60
61 typedef ca_dbSource_t * rp_regid_t;
62 typedef A_Type_t rp_attr_t;
63
64
65 typedef struct {
66 rp_attr_t type;
67 rp_uni_t uni;
68 sql_key_t key;
69 union {
70 char *origin;
71 char *domain;
72 } d;
73 } rp_upd_pack_t;
74
75 #ifdef RP_IMPL
76 #define EXTDEF(a,b) a = b;
/* [<][>][^][v][top][bottom][index][help] */
77 #else
78 #define EXTDEF(a,b) extern a;
/* [<][>][^][v][top][bottom][index][help] */
79 #endif
80
81 EXTDEF (GList *rx_forest, NULL) /* linked list of trees */
/* [<][>][^][v][top][bottom][index][help] */
82
83
84 typedef struct {
85 rp_regid_t reg_id; /*+ registry id +*/
86 rp_attr_t attr; /*+ extra tree attribute (within the same reg/spc/fam), allows
87 using the same tree type for different object trees +*/
88
89 rx_tree_t *tree; /*+ tree +*/
90 } rp_tentry_t;
91
92 er_ret_t RP_asc_load(char *filename, int maxobj,
93 int operation, rp_regid_t reg_id);
94 er_ret_t
95 RP_tree_get ( rx_tree_t **treeptr, /*+ answer goes here, please +*/
96 rp_regid_t reg_id, /*+ id of the registry +*/
97 ip_space_t spc_id, /*+ type of space (ipv4/ipv6) +*/
98 rp_attr_t attr /*+ extra tree id (within the same reg/spc/fam +*/
99 );
100 er_ret_t
101 RP_tree_add (
102 rp_regid_t reg_id, /*+ id of the registry +*/
103 rp_attr_t attr, /*+ extra tree id (within the same registry/space/family +*/
104 char *prefixstr, /*+ prefix the tree will cover (string) +*/
105 rx_mem_mt mem_mode, /* memory only, memory+sql, sql only +*/
106 rx_subtree_mt subtrees /*+ one of NONE, AUTO, HAND +*/
107 );
108 er_ret_t RP_init_trees( rp_regid_t reg_id );
109
110
111 er_ret_t
112 RP_asc_search (
113 rx_srch_mt search_mode,
114 int par_a,
115 int par_b,
116 char *key, /*+ search term: (string) prefix/range/IP +*/
117 rp_regid_t reg_id,
118 rp_attr_t attr, /*+ extra tree id (within the same reg/spc/fam +*/
119 GList **anslist, /*+ answers go here, please +*/
120 int max_count /*+ max # of answers. RX_ALLANS == unlimited +*/
121 );
122 er_ret_t
123 RP_uni_node ( rx_oper_mt mode, /*+ MODE={cre|mod|del} +*/
124 rp_uni_t *uni, /*+ unified argument structure +*/
125 rp_attr_t attr, /*+ additional tree attribute +*/
126 rp_regid_t reg_id, /*+ id of the registry +*/
127 void *data, /*+ pointer to the payload +*/
128 unsigned datalen, /*+ length of the payload +*/
129 sql_key_t key /*+ the key to the SQL full-text +*/
130 );
131 er_ret_t
132 RP_asc_node( rx_oper_mt mode, /*+ MODE={cre|mod|del} +*/
133 char *rangstr, /*+ string prefix/range/IP/inaddr +*/
134 rp_attr_t attr, /*+ additional tree attribute +*/
135 rp_regid_t reg_id, /*+ id of the registry +*/
136 void *data, /*+ pointer to the payload +*/
137 unsigned datalen, /*+ length of the payload +*/
138 sql_key_t key /*+ the key to the SQL full-text +*/
139 );
140
141 rx_fam_t RP_attr2fam( rp_attr_t type );
142 int RP_attr2spc(rp_attr_t type, ip_space_t space);
143 er_ret_t
144 RP_asc2uni(char *astr, /*+ string prefix/range/IP/inaddr +*/
145 rp_attr_t attr,
146 rp_uni_t *uni); /* destination pointer */
147 er_ret_t
148 RP_asc2pack(rp_upd_pack_t *pack, rp_attr_t type, char *string);
149
150
151 void RP_pack_set_orig( rp_attr_t attr,rp_upd_pack_t *pack, char *origin);
152 void RP_pack_set_pref4(rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
153 unsigned *prefix, unsigned *prefix_length);
154 void RP_pack_set_revd( rp_attr_t attr,char *avalue, rp_upd_pack_t *pack);
155 void RP_pack_set_pref6(rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
156 ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
157 void RP_pack_set_rang( rp_attr_t attr,char *avalue, rp_upd_pack_t *pack,
158 unsigned *begin_in, unsigned *end_in);
159
160 er_ret_t
161 RP_pack_update(rx_oper_mt mode,
162 rp_upd_pack_t *pack,
163 rp_regid_t reg_id); /*+ id of the registry +*/
164
165
166 er_ret_t
167 RP_pack_node(rx_oper_mt mode,
168 rp_upd_pack_t *pack,
169 rp_regid_t reg_id);
170 er_ret_t
171 RP_pack_node_l(rx_oper_mt mode,
172 rp_upd_pack_t *pack,
173 rx_tree_t *mytree);
174
175 void rp_make_short(rp_upd_pack_t *pack, char **ptr, unsigned *len);
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 */