include/ud_int.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
1 /***************************************
2 $Revision: 1.14 $
3
4 Semi-internal header file for UD module
5
6 Status: NOT REVUED, NOT TESTED
7
8 Author(s): Andrei Robachevsky
9
10 ******************/ /******************
11 Modification History:
12 andrei (17/01/2000) Created.
13 ******************/ /******************
14 Copyright (c) 2000 RIPE NCC
15
16 All Rights Reserved
17
18 Permission to use, copy, modify, and distribute this software and its
19 documentation for any purpose and without fee is hereby granted,
20 provided that the above copyright notice appear in all copies and that
21 both that copyright notice and this permission notice appear in
22 supporting documentation, and that the name of the author not be
23 used in advertising or publicity pertaining to distribution of the
24 software without specific, written prior permission.
25
26 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
28 AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
29 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
30 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
31 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 ***************************************/
33 #ifndef _UD_INT_H
34 #define _UD_INT_H
35
36 #include <stdio.h>
37 #include <strings.h>
38 #include <glib.h>
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <unistd.h>
42
43 #include "defs.h"
44 #include "mysql_driver.h"
45 #include "iproutines.h"
46 #include "rp.h"
47 #include "nh.h"
48
49 #include "ca_configFns.h"
50 #include "ca_dictSyms.h"
51 #include "ca_macros.h"
52 #include "ca_srcAttribs.h"
53
54
55
56
57 #include "globaldefs.h"
58 /* #include "isnic.h" */
59 #include "bitmask.h"
60 #include "which_keytypes.h"
61
62
63 /*+ String sizes +*/
64 #define STR_S 63
65 #define STR_M 255
66 #define STR_L 1023
67 #define STR_XL 4095
68 #define STR_XXL 16383
69 #define STR_XXXL 65535
70
71
72 #define MAX_NIC_HDL 30
73
74
75 /* class type for dummy objects */
76 #define DUMMY_TYPE 100
77
78
79 typedef struct _Attribute_t {
80 A_Type_t type;
81 char *value;
82 } Attribute_t;
83
84 typedef struct _Object_t {
85 C_Type_t type;
86 long id;
87 GSList *attributes;
88 GString *object;
89 } Object_t;
90
91
92 typedef struct _obj_parse_t {
93 Object_t *obj;
94 char *object_name;
95 GSList *class_attr_list;
96 nic_handle_t *nh_ptr;
97 int a_type;
98 int start_object;
99 } Obj_parse_t;
100
101 #define MAX_DUMMIES 256
102
103 typedef struct _Transaction {
104 Object_t *object; /* ptr to the object */
105 C_Type_t class_type;
106 int action; /* indicates wether we are updating/deleting creating a new object */
107 SQ_connection_t *sql_connection;
108 int thread_ins; /* Thread number to mark(backup) creates */
109 int thread_upd; /* Thread number to mark(backup) updates */
110 long object_id; /* Object id which the transaction is carried out for */
111 long sequence_id; /* for last and history tables */
112 int dummy; /* Permission to create dummies for PE, RO objects (initial population) */
113 int ndummy; /* number of attempts to create dummy */
114 long dummy_id[MAX_DUMMIES]; /* to store object_id's of dummies */
115 int load_pass; /* No. of the pass for initial loading , 0 otherwise */
116 int standalone; /* 0 if server */
117 int succeeded;
118 int error;
119 GString *error_script;
120 char *save; /* for saving attribute (U2 & pn:) values */
121 rp_upd_pack_t *packptr; /* To store radix tree data */
122 nic_handle_t *nh; /* To store NIC handle data */
123 ca_dbSource_t *source_hdl;
124 } Transaction_t;
125
126 /*++++++++++++++++++++++++++++++++++++++++++++*/
127
128 /* Definitions for "refer" (domain referral mechanism) */
129 #define S_RIPE "RIPE"
130 #define S_INTERNIC "InterNIC"
131 #define S_SIMPLE "SIMPLE"
132 #define S_CLIENTADDERSS "CLIENTADDRESS"
133
134
135 typedef enum {
136 RF_RIPE=1,
137 RF_INTERNIC,
138 RF_SIMPLE,
139 RF_CLIENTADDRESS
140 } refer_t;
141
142 #define RF_DEF_PORT 43
143
144
145 struct _nrtm {
146 const char *server; /* the hostname of the server */
147 int port;
148 int version;
149 long current_serial;
150 Transaction_t *tr;
151 char object_name[STR_XXL];
152 int op;
153 };
154
155 typedef struct _Log_t {
156 int num_ok;
157 int num_failed;
158 FILE *logfile;
159 } Log_t;
160
161 typedef struct UD_stream_t_ {
162 FILE * stream;
163 int num_skip;
164 int load_pass;
165 int ud_mode;
166 struct _nrtm *nrtm;
167 SQ_connection_t *db_connection;
168 ca_dbSource_t *source_hdl; /* source we are mirroring */
169 Log_t log;
170 char *error_script;
171 } UD_stream_t;
172
173
174
175
176 /*++++++++++++++++++ Function Prototypes +++++++++++++++++++++*/
177
178 int get_NRTM_fd(struct _nrtm *nrtm, int upto_last, char *source);
179
180 int UD_process_stream(UD_stream_t *ud_stream);
181
182 int object_process(Transaction_t *tr);
183
184 int commit(Transaction_t *tr);
185
186 int rollback(Transaction_t *tr);
187
188 int delete(Transaction_t *tr);
189
190
191
192 int isdummy(Transaction_t *tr);
193 long get_object_id(Transaction_t *tr);
194 long get_sequence_id(Transaction_t *tr);
195 char *get_field_str(SQ_connection_t *sql_connection, char *field,
196 char *ref_tbl_name, char *ref_name,
197 char * attr_value, char *condition);
198 char *get_qresult_str(SQ_connection_t *sql_connection, char *query);
199
200
201 void attribute_free(void *data, void *ptr);
202
203 Attribute_t *attribute_upd(Attribute_t *attr, int newtype, char *newvalue);
204
205 Attribute_t *attribute_new1(int type, const char *value);
206
207 Attribute_t *attribute_new(const char *line);
208
209 void object_free(Object_t *obj);
210
211 Object_t *object_new(const char *line);
212
213 void transaction_free(Transaction_t *tr);
214
215 Transaction_t *transaction_new(SQ_connection_t *sql_connection, C_Type_t class_type);
216
217 void get_rx_data(void *element_data, void *tr_ptr);
218
219 void ud_parse_init(Obj_parse_t *parse);
220 void ud_parse_free(Obj_parse_t *parse);
221 Object_t *UD_parse_object(SQ_connection_t *sql_connection, Obj_parse_t *parse, char *line_buff);
222
223
224
225 #if 0
226 void set_rx_orig(rx_bin_data_t *rx_data, char *origin);
227 void set_rx_pref4(char *avalue, rx_bin_data_t *rx_data,
228 unsigned *prefix, unsigned *prefix_length);
229 void set_rx_pref6(char *avalue, rx_bin_data_t *rx_data,
230 ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
231 void set_rx_rang(char *avalue, rx_inum_data_t *rx_data,
232 unsigned *begin_in, unsigned *end_in);
233 int update_rx_inum(rx_oper_mt mode, rx_regid_t reg_id, rx_inum_data_t *rx_data, long in_id);
234 int update_rx_bin(rx_oper_mt mode, rx_regid_t reg_id, rx_bin_data_t *rx_data, long rt_id);
235 int update_rx_dom(rx_oper_mt mode, rx_regid_t reg_id, rx_dom_data_t *rx_data, long dn_id);
236 #endif
237
238 char *convert_rf(char *avalue, int *type, int *port);
239 int convert_as_range(const char *as_range, int *begin, int *end);
240 time_t convert_time(char *asc_time);
241
242
243 long create_serial(Transaction_t *tr);
244
245
246 #endif /* _UD_INT_H */
247