## modules/ud/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.24 $
       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,2001,2002                    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 #include "memwrap.h"
      51
      52 #include "ca_configFns.h"
      53 #include "ca_dictionary.h"
      54 #include "ca_macros.h"
      55 #include "ca_srcAttribs.h"
      56
      57 #include "globaldefs.h"
      58 #include "bitmask.h"
      59 #include "which_keytypes.h"
      60
      61
      62 /*+ String sizes +*/
      63 #define STR_S   63
      64 #define STR_M   255
      65 #define STR_L   1023
      66 #define STR_XL  4095
      67 #define STR_XXL 16383
      68 #define STR_XXXL 65535
      69
      70
      71 #define MAX_NIC_HDL  30
      72
      73
      74
      75 #define MAX_DUMMIES 256
      76
      77 typedef struct _Transaction {
      78   int thread_ins;      /* Thread number to mark(backup) creates */
      79   int thread_upd;      /* Thread number to mark(backup) updates */
      80   SQ_connection_t *sql_connection;
      81   rpsl_object_t *object;    /* ptr to the object */
      82   C_Type_t class_type;
      83   gchar *object_txt; /* textual representation (as submitted) */
      84   long object_id;      /* Object id which the transaction is carried out for */
      85   long sequence_id;    /* for last and history tables */
      86   long serial_id;      /* serial ID, kept for crash recovery */
      87   long transaction_id; /* ID of DBuopdate transaction */
      88   int ndummy; /* number of attempts to create dummy */
      89   long dummy_id[MAX_DUMMIES]; /* to store object_id's of dummies */
      90   int load_pass; /* No. of the pass for initial loading , 0 otherwise */
      91   /* XXX later we should merge 'succeeded' & 'error' into single 'succeeded' bitmask */
      92   int action; /* indicates wether we are updating/deleting creating a new object */
      93   int mode; /* indicates mode of operation (standalone, dummy, update, nrtm) */
      94   int succeeded;
      95   int error;
      96   GString *error_script;
      97   GString *query;
      98   GString *K; /* object primary key */
      99   char *save; /* for saving attribute (U2 & pn:) values */
     100   rp_upd_pack_t *packptr; /* To store radix tree data */
     101   nic_handle_t *nh; /* To store NIC handle data */
     102   ca_dbSource_t *source_hdl;
     103   int socket; /* socket to report to DBupdate */
     104 } Transaction_t;
     105
     106 /*++++++++++++++++++++++++++++++++++++++++++++*/
     107
     108
     109 struct _nrtm {
     110  char *server; /* the hostname of the server */
     111  int port;
     112  int version;
     113  long current_serial;
     114  Transaction_t *tr;
     115  char object_name[STR_XXL];
     116  int op;
     117 };
     118
     119 typedef struct _Log_t {
     120  int num_ok;
     121  int num_failed;
     122 /* FILE *logfile; */
     123 } Log_t;
     124
     125 typedef struct UD_stream_t_ {
     126  FILE * stream;
     127  sk_conn_st condat;
     128  int num_skip;
     129  int load_pass;
     130  int ud_mode;
     131  struct _nrtm *nrtm;
     132  SQ_connection_t *db_connection;
     133  ca_dbSource_t *source_hdl; /* source we are mirroring */
     134  Log_t log;
     135  char *error_script;
     136 } UD_stream_t;
     137
     138
     139
     140
     141 /*++++++++++++++++++ Function Prototypes +++++++++++++++++++++*/
     142
     143 int get_NRTM_fd(struct _nrtm *nrtm, int upto_last, char *source);
     144
     145 int UD_process_stream(UD_stream_t *ud_stream);
     146
     147 int object_process(Transaction_t *tr);
     148
     149 int UD_commit(Transaction_t *tr);
     150 int UD_commit_I(Transaction_t *tr);
     151 int UD_commit_II(Transaction_t *tr);
     152
     153
     154 int UD_rollback(Transaction_t *tr);
     155
     156 int UD_delete(Transaction_t *tr);
     157
     158 int UD_update_rx(Transaction_t *tr, rx_oper_mt mode);
     159
     160 int UD_ack(Transaction_t* tr);
     161 int UD_check_ref(Transaction_t *tr);
     162
     163 int isdummy(Transaction_t *tr);
     164 long get_object_id(Transaction_t *tr);
     165 long get_sequence_id(Transaction_t *tr);
     166 char *get_field_str(SQ_connection_t *sql_connection, const char *field,
     167                     const char *ref_tbl_name, const char *ref_name,
     168                     const char * attr_value,  const char *condition);
     169 char *get_qresult_str(SQ_connection_t *sql_connection, char *query);
     170
     171
     172 void transaction_free(Transaction_t *tr);
     173
     174 Transaction_t *transaction_new(SQ_connection_t *sql_connection, C_Type_t class_type);
     175
     176 void get_rx_data(void *element_data, void *tr_ptr);
     177
     178 void ud_each_primary_key_select(void *element_data, void *result_ptr);
     179
     180 char *convert_rf(const char *avalue, int *type, int *port);
     181 int convert_as_range(const char *as_range, int *begin, int *end);
     182 time_t convert_time(const char *asc_time);
     183
     184 int UD_lock_serial(Transaction_t *tr);
     185 int UD_unlock_serial(Transaction_t *tr);
     186 long UD_create_serial(Transaction_t *tr);
     187 int UD_comrol_serial(Transaction_t *tr, int commit);
     188
     189 #define UD_commit_serial(tr) UD_comrol_serial(tr, 1)
         /* [<][>][^][v][top][bottom][index][help] */
     190 #define UD_rollback_serial(tr) UD_comrol_serial(tr, 0)
         /* [<][>][^][v][top][bottom][index][help] */
     191 #endif /* _UD_INT_H */
     192
     193
     194
     195

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