## include/ud_int.h

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. UD_commit_serial
2. UD_rollback_serial

       1 /***************************************
       2   $Revision: 1.16 $
       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_dictSyms.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         nic_handle_t *nh_ptr;
      99         int a_type;
     100         int start_object;
     101 } Obj_parse_t;
     102
     103 #define MAX_DUMMIES 256
     104
     105 typedef struct _Transaction {
     106   int thread_ins;      /* Thread number to mark(backup) creates */
     107   int thread_upd;      /* Thread number to mark(backup) updates */
     108   SQ_connection_t *sql_connection;
     109   Object_t *object;    /* ptr to the object */
     110   C_Type_t class_type;
     111   long object_id;      /* Object id which the transaction is carried out for */
     112   long sequence_id;    /* for last and history tables */
     113   long serial_id;      /* serial ID, kept for crash recovery */
     114   long transaction_id; /* ID of DBuopdate transaction */
     115   /* int dummy; */     /* Permission to create dummies for PE, RO objects (initial population) */
     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 'standalone' & 'dummy' into single 'mode' bitmask */
     120   /* int standalone; *//* 0 if server */
     121   /* XXX later we should merge 'succeeded' & 'error' into single 'succeeded' bitmask */
     122   int action; /* indicates wether we are updating/deleting creating a new object */
     123   int mode;
     124   int succeeded;
     125   int error;
     126   GString *error_script;
     127   GString *query;
     128   GString *K;
     129   char *save; /* for saving attribute (U2 & pn:) values */
     130   rp_upd_pack_t *packptr; /* To store radix tree data */
     131   nic_handle_t *nh; /* To store NIC handle data */
     132   ca_dbSource_t *source_hdl;
     133   int socket; /* socket to report to DBupdate */
     134 } Transaction_t;
     135
     136 /*++++++++++++++++++++++++++++++++++++++++++++*/
     137
     138 /* Definitions for "refer" (domain referral mechanism) */
     139 #define S_RIPE "RIPE"
     140 #define S_INTERNIC "InterNIC"
     141 #define S_SIMPLE "SIMPLE"
     142 #define S_CLIENTADDERSS "CLIENTADDRESS"
     143
     144
     145 typedef enum {
     146  RF_RIPE=1,
     147  RF_INTERNIC,
     148  RF_SIMPLE,
     149  RF_CLIENTADDRESS
     150 } refer_t;
     151
     152 #define RF_DEF_PORT     43
     153
     154
     155 struct _nrtm {
     156  char *server; /* the hostname of the server */
     157  int port;
     158  int version;
     159  long current_serial;
     160  Transaction_t *tr;
     161  char object_name[STR_XXL];
     162  int op;
     163 };
     164
     165 typedef struct _Log_t {
     166  int num_ok;
     167  int num_failed;
     168 /* FILE *logfile; */
     169 } Log_t;
     170
     171 typedef struct UD_stream_t_ {
     172  FILE * stream;
     173  sk_conn_st condat;
     174  int num_skip;
     175  int load_pass;
     176  int ud_mode;
     177  struct _nrtm *nrtm;
     178  SQ_connection_t *db_connection;
     179  ca_dbSource_t *source_hdl; /* source we are mirroring */
     180  Log_t log;
     181  char *error_script;
     182 } UD_stream_t;
     183
     184
     185
     186
     187 /*++++++++++++++++++ Function Prototypes +++++++++++++++++++++*/
     188
     189 int get_NRTM_fd(struct _nrtm *nrtm, int upto_last, char *source);
     190
     191 int UD_process_stream(UD_stream_t *ud_stream);
     192
     193 int object_process(Transaction_t *tr);
     194
     195 int UD_commit(Transaction_t *tr);
     196 int UD_commit_I(Transaction_t *tr);
     197 int UD_commit_II(Transaction_t *tr);
     198
     199
     200 int UD_rollback(Transaction_t *tr);
     201
     202 int UD_delete(Transaction_t *tr);
     203
     204 int UD_update_rx(Transaction_t *tr, rx_oper_mt mode);
     205
     206 int UD_ack(Transaction_t* tr);
     207 int UD_check_ref(Transaction_t *tr);
     208
     209 int isdummy(Transaction_t *tr);
     210 long get_object_id(Transaction_t *tr);
     211 long get_sequence_id(Transaction_t *tr);
     212 char *get_field_str(SQ_connection_t *sql_connection, char *field,
     213                  char *ref_tbl_name, char *ref_name,
     214                  char * attr_value, char *condition);
     215 char *get_qresult_str(SQ_connection_t *sql_connection, char *query);
     216
     217
     218 void attribute_free(void *data, void *ptr);
     219
     220 Attribute_t *attribute_upd(Attribute_t *attr, int newtype, char *newvalue);
     221
     222 Attribute_t *attribute_new1(int type, const char *value);
     223
     224 Attribute_t *attribute_new(const char *line);
     225
     226 void object_free(Object_t *obj);
     227
     228 Object_t *object_new(const char *line);
     229
     230 void transaction_free(Transaction_t *tr);
     231
     232 Transaction_t *transaction_new(SQ_connection_t *sql_connection, C_Type_t class_type);
     233
     234 void get_rx_data(void *element_data, void *tr_ptr);
     235
     236 void ud_parse_init(Obj_parse_t *parse);
     237 void ud_parse_free(Obj_parse_t *parse);
     238 Object_t *UD_parse_object(SQ_connection_t *sql_connection, Obj_parse_t *parse, char *line_buff);
     239
     240
     241
     242 #if 0
     243 void set_rx_orig(rx_bin_data_t *rx_data, char *origin);
     244 void set_rx_pref4(char *avalue, rx_bin_data_t *rx_data,
     245                   unsigned *prefix, unsigned *prefix_length);
     246 void set_rx_pref6(char *avalue, rx_bin_data_t *rx_data,
     247                   ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
     248 void set_rx_rang(char *avalue, rx_inum_data_t *rx_data,
     249                  unsigned *begin_in, unsigned *end_in);
     250 int update_rx_inum(rx_oper_mt mode, rx_regid_t reg_id, rx_inum_data_t *rx_data, long in_id);
     251 int update_rx_bin(rx_oper_mt mode, rx_regid_t reg_id, rx_bin_data_t *rx_data, long rt_id);
     252 int update_rx_dom(rx_oper_mt mode, rx_regid_t reg_id, rx_dom_data_t *rx_data, long dn_id);
     253 #endif
     254
     255 char *convert_rf(char *avalue, int *type, int *port);
     256 int convert_as_range(const char *as_range, int *begin, int *end);
     257 time_t convert_time(char *asc_time);
     258
     259 int UD_lock_serial(Transaction_t *tr);
     260 int UD_unlock_serial(Transaction_t *tr);
     261 long UD_create_serial(Transaction_t *tr);
     262 int UD_comrol_serial(Transaction_t *tr, int commit);
     263
     264 #define UD_commit_serial(tr) UD_comrol_serial(tr, 1)
         /* [<][>][^][v][top][bottom][index][help] */
     265 #define UD_rollback_serial(tr) UD_comrol_serial(tr, 0)
         /* [<][>][^][v][top][bottom][index][help] */
     266 #endif /* _UD_INT_H */
     267
     268
     269
     270

/* [<][>][^][v][top][bottom][index][help] */