## include/ud_int.h

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

## FUNCTIONS

This source file includes following functions.

       1 /***************************************
       2   $Revision: 1.13 $
       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 #define MAX_DUMMIES 256
      92
      93 typedef struct _Transaction {
      94   Object_t *object;    /* ptr to the object */
      95   C_Type_t class_type;
      96   int action; /* indicates wether we are updating/deleting creating a new object */
      97   SQ_connection_t *sql_connection;
      98   int thread_ins;      /* Thread number to mark(backup) creates */
      99   int thread_upd;      /* Thread number to mark(backup) updates */
     100   long object_id;      /* Object id which the transaction is carried out for */
     101   long sequence_id;    /* for last and history tables */
     102   int dummy;           /* Permission to create dummies for PE, RO objects (initial population) */
     103   int ndummy; /* number of attempts to create dummy */
     104   long dummy_id[MAX_DUMMIES]; /* to store object_id's of dummies */
     105   int load_pass; /* No. of the pass for initial loading , 0 otherwise */
     106   int standalone; /* 0 if server */
     107   int succeeded;
     108   int error;
     109   GString *error_script;
     110   char *save; /* for saving attribute (U2 & pn:) values */
     111   rp_upd_pack_t *packptr; /* To store radix tree data */
     112   nic_handle_t *nh; /* To store NIC handle data */
     113   ca_dbSource_t *source_hdl;
     114 } Transaction_t;
     115
     116 /*++++++++++++++++++++++++++++++++++++++++++++*/
     117
     118 /* Definitions for "refer" (domain referral mechanism) */
     119 #define S_RIPE "RIPE"
     120 #define S_INTERNIC "InterNIC"
     121 #define S_SIMPLE "SIMPLE"
     122 #define S_CLIENTADDERSS "CLIENTADDRESS"
     123
     124
     125 typedef enum {
     126  RF_RIPE=1,
     127  RF_INTERNIC,
     128  RF_SIMPLE,
     129  RF_CLIENTADDRESS
     130 } refer_t;
     131
     132 #define RF_DEF_PORT     43
     133
     134
     135 struct _nrtm {
     136  const char *server; /* the hostname of the server */
     137  int port;
     138  int version;
     139  long current_serial;
     140  Transaction_t *tr;
     141  char object_name[STR_XXL];
     142  int op;
     143 };
     144
     145 typedef struct _Log_t {
     146  int num_ok;
     147  int num_failed;
     148  FILE *logfile;
     149 } Log_t;
     150
     151 typedef struct UD_stream_t_ {
     152  FILE * stream;
     153  int num_skip;
     154  int load_pass;
     155  int ud_mode;
     156  struct _nrtm *nrtm;
     157  SQ_connection_t *db_connection;
     158  ca_dbSource_t *source_hdl; /* source we are mirroring */
     159  Log_t log;
     160  char *error_script;
     161 } UD_stream_t;
     162
     163
     164
     165
     166 /*++++++++++++++++++ Function Prototypes +++++++++++++++++++++*/
     167
     168 int get_NRTM_fd(struct _nrtm *nrtm, int upto_last, char *source);
     169
     170 int UD_process_stream(UD_stream_t *ud_stream);
     171
     172 int object_process(Transaction_t *tr);
     173
     174 int commit(Transaction_t *tr);
     175
     176 int rollback(Transaction_t *tr);
     177
     178 int delete(Transaction_t *tr);
     179
     180
     181
     182 int isdummy(Transaction_t *tr);
     183 long get_object_id(Transaction_t *tr);
     184 long get_sequence_id(Transaction_t *tr);
     185 char *get_field_str(SQ_connection_t *sql_connection, char *field,
     186                  char *ref_tbl_name, char *ref_name,
     187                  char * attr_value, char *condition);
     188 char *get_qresult_str(SQ_connection_t *sql_connection, char *query);
     189
     190
     191 void attribute_free(void *data, void *ptr);
     192
     193 Attribute_t *attribute_upd(Attribute_t *attr, int newtype, char *newvalue);
     194
     195 Attribute_t *attribute_new1(int type, const char *value);
     196
     197 Attribute_t *attribute_new(const char *line);
     198
     199 void object_free(Object_t *obj);
     200
     201 Object_t *object_new(const char *line);
     202
     203 void transaction_free(Transaction_t *tr);
     204
     205 Transaction_t *transaction_new(SQ_connection_t *sql_connection, C_Type_t class_type);
     206
     207 void get_rx_data(void *element_data, void *tr_ptr);
     208
     209
     210 #if 0
     211 void set_rx_orig(rx_bin_data_t *rx_data, char *origin);
     212 void set_rx_pref4(char *avalue, rx_bin_data_t *rx_data,
     213                   unsigned *prefix, unsigned *prefix_length);
     214 void set_rx_pref6(char *avalue, rx_bin_data_t *rx_data,
     215                   ip_v6word_t *high, ip_v6word_t *low, unsigned *prefix_length);
     216 void set_rx_rang(char *avalue, rx_inum_data_t *rx_data,
     217                  unsigned *begin_in, unsigned *end_in);
     218 int update_rx_inum(rx_oper_mt mode, rx_regid_t reg_id, rx_inum_data_t *rx_data, long in_id);
     219 int update_rx_bin(rx_oper_mt mode, rx_regid_t reg_id, rx_bin_data_t *rx_data, long rt_id);
     220 int update_rx_dom(rx_oper_mt mode, rx_regid_t reg_id, rx_dom_data_t *rx_data, long dn_id);
     221 #endif
     222
     223 char *convert_rf(char *avalue, int *type, int *port);
     224 int convert_as_range(const char *as_range, int *begin, int *end);
     225 time_t convert_time(char *asc_time);
     226
     227
     228 long create_serial(Transaction_t *tr);
     229
     230
     231 #endif /* _UD_INT_H */
     232

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