## include/ud_int.h

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

## FUNCTIONS

This source file includes following functions.

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

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