modules/ud/ud_int.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- UD_commit_serial
- UD_rollback_serial
1 /***************************************
2 $Revision: 1.19 $
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 "erroutines.h"
47 #include "rp.h"
48 #include "nh.h"
49 #include "sk.h"
50
51 #include "ca_configFns.h"
52 #include "ca_dictionary.h"
53 #include "ca_macros.h"
54 #include "ca_srcAttribs.h"
55
56
57
58
59 #include "globaldefs.h"
60 /* #include "isnic.h" */
61 #include "bitmask.h"
62 #include "which_keytypes.h"
63
64
65 /*+ String sizes +*/
66 #define STR_S 63
67 #define STR_M 255
68 #define STR_L 1023
69 #define STR_XL 4095
70 #define STR_XXL 16383
71 #define STR_XXXL 65535
72
73
74 #define MAX_NIC_HDL 30
75
76
77 /* class type for dummy objects */
78 #define DUMMY_TYPE 100
79
80
81 typedef struct _Attribute_t {
82 A_Type_t type;
83 char *value;
84 } Attribute_t;
85
86 typedef struct _Object_t {
87 C_Type_t type;
88 long id;
89 GSList *attributes;
90 GString *object;
91 } Object_t;
92
93
94 typedef struct _obj_parse_t {
95 Object_t *obj;
96 char *object_name;
97 GSList *class_attr_list;
98 GSList *current_attr_list;
99 nic_handle_t *nh_ptr;
100 int a_type;
101 int start_object;
102 } Obj_parse_t;
103
104 #define MAX_DUMMIES 256
105
106 typedef struct _Transaction {
107 int thread_ins; /* Thread number to mark(backup) creates */
108 int thread_upd; /* Thread number to mark(backup) updates */
109 SQ_connection_t *sql_connection;
110 Object_t *object; /* ptr to the object */
111 C_Type_t class_type;
112 long object_id; /* Object id which the transaction is carried out for */
113 long sequence_id; /* for last and history tables */
114 long serial_id; /* serial ID, kept for crash recovery */
115 long transaction_id; /* ID of DBuopdate transaction */
116 int ndummy; /* number of attempts to create dummy */
117 long dummy_id[MAX_DUMMIES]; /* to store object_id's of dummies */
118 int load_pass; /* No. of the pass for initial loading , 0 otherwise */
119 /* XXX later we should merge 'succeeded' & 'error' into single 'succeeded' bitmask */
120 int action; /* indicates wether we are updating/deleting creating a new object */
121 int mode; /* indicates mode of operation (standalone, dummy, update, nrtm) */
122 int succeeded;
123 int error;
124 GString *error_script;
125 GString *query;
126 GString *K; /* object primary key */
127 char *save; /* for saving attribute (U2 & pn:) values */
128 rp_upd_pack_t *packptr; /* To store radix tree data */
129 nic_handle_t *nh; /* To store NIC handle data */
130 ca_dbSource_t *source_hdl;
131 int socket; /* socket to report to DBupdate */
132 } Transaction_t;
133
134 /*++++++++++++++++++++++++++++++++++++++++++++*/
135
136 /* Definitions for "refer" (domain referral mechanism) */
137 #define S_RIPE "RIPE"
138 #define S_INTERNIC "InterNIC"
139 #define S_SIMPLE "SIMPLE"
140 #define S_CLIENTADDERSS "CLIENTADDRESS"
141
142
143 typedef enum {
144 RF_RIPE=1,
145 RF_INTERNIC,
146 RF_SIMPLE,
147 RF_CLIENTADDRESS
148 } refer_t;
149
150 #define RF_DEF_PORT 43
151
152
153 struct _nrtm {
154 char *server; /* the hostname of the server */
155 int port;
156 int version;
157 long current_serial;
158 Transaction_t *tr;
159 char object_name[STR_XXL];
160 int op;
161 };
162
163 typedef struct _Log_t {
164 int num_ok;
165 int num_failed;
166 /* FILE *logfile; */
167 } Log_t;
168
169 typedef struct UD_stream_t_ {
170 FILE * stream;
171 sk_conn_st condat;
172 int num_skip;
173 int load_pass;
174 int ud_mode;
175 struct _nrtm *nrtm;
176 SQ_connection_t *db_connection;
177 ca_dbSource_t *source_hdl; /* source we are mirroring */
178 Log_t log;
179 char *error_script;
180 } UD_stream_t;
181
182
183
184
185 /*++++++++++++++++++ Function Prototypes +++++++++++++++++++++*/
186
187 int get_NRTM_fd(struct _nrtm *nrtm, int upto_last, char *source);
188
189 int UD_process_stream(UD_stream_t *ud_stream);
190
191 int object_process(Transaction_t *tr);
192
193 int UD_commit(Transaction_t *tr);
194 int UD_commit_I(Transaction_t *tr);
195 int UD_commit_II(Transaction_t *tr);
196
197
198 int UD_rollback(Transaction_t *tr);
199
200 int UD_delete(Transaction_t *tr);
201
202 int UD_update_rx(Transaction_t *tr, rx_oper_mt mode);
203
204 int UD_ack(Transaction_t* tr);
205 int UD_check_ref(Transaction_t *tr);
206
207 int isdummy(Transaction_t *tr);
208 long get_object_id(Transaction_t *tr);
209 long get_sequence_id(Transaction_t *tr);
210 char *get_field_str(SQ_connection_t *sql_connection, char *field,
211 char *ref_tbl_name, char *ref_name,
212 char * attr_value, char *condition);
213 char *get_qresult_str(SQ_connection_t *sql_connection, char *query);
214
215
216 void attribute_free(void *data, void *ptr);
217
218 Attribute_t *attribute_upd(Attribute_t *attr, int newtype, char *newvalue);
219
220 Attribute_t *attribute_new1(int type, const char *value);
221
222 Attribute_t *attribute_new(const char *line);
223
224 void object_free(Object_t *obj);
225
226 Object_t *object_new(const char *line);
227
228 void transaction_free(Transaction_t *tr);
229
230 Transaction_t *transaction_new(SQ_connection_t *sql_connection, C_Type_t class_type);
231
232 void get_rx_data(void *element_data, void *tr_ptr);
233
234 void ud_parse_init(Obj_parse_t *parse);
235 void ud_parse_free(Obj_parse_t *parse);
236 Object_t *UD_parse_object(SQ_connection_t *sql_connection, Obj_parse_t *parse, char *line_buff);
237
238
239
240 #if 0
241 void set_rx_orig(rx_bin_data_t *rx_data, char *origin);
242 void set_rx_pref4(char *avalue, rx_bin_data_t *rx_data,
243 unsigned *prefix, unsigned *prefix_length);
244 void set_rx_pref6(char *avalue, rx_bin_data_t *rx_data,
245 ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
246 void set_rx_rang(char *avalue, rx_inum_data_t *rx_data,
247 unsigned *begin_in, unsigned *end_in);
248 int update_rx_inum(rx_oper_mt mode, rx_regid_t reg_id, rx_inum_data_t *rx_data, long in_id);
249 int update_rx_bin(rx_oper_mt mode, rx_regid_t reg_id, rx_bin_data_t *rx_data, long rt_id);
250 int update_rx_dom(rx_oper_mt mode, rx_regid_t reg_id, rx_dom_data_t *rx_data, long dn_id);
251 #endif
252
253 char *convert_rf(char *avalue, int *type, int *port);
254 int convert_as_range(const char *as_range, int *begin, int *end);
255 time_t convert_time(char *asc_time);
256
257 int UD_lock_serial(Transaction_t *tr);
258 int UD_unlock_serial(Transaction_t *tr);
259 long UD_create_serial(Transaction_t *tr);
260 int UD_comrol_serial(Transaction_t *tr, int commit);
261
262 #define UD_commit_serial(tr) UD_comrol_serial(tr, 1)
/* [<][>][^][v][top][bottom][index][help] */
263 #define UD_rollback_serial(tr) UD_comrol_serial(tr, 0)
/* [<][>][^][v][top][bottom][index][help] */
264 #endif /* _UD_INT_H */
265
266
267
268