Source File up/dbupdate.h

    1    | /******************
    2    |   Copyright (c) 2002                                        RIPE NCC
    3    |
    4    |   All Rights Reserved
    5    |
    6    |   Permission to use, copy, modify, and distribute this software and its
    7    |   documentation for any purpose and without fee is hereby granted,
    8    |   provided that the above copyright notice appear in all copies and that
    9    |   both that copyright notice and this permission notice appear in
    10   |   supporting documentation, and that the name of the author not be
    11   |   used in advertising or publicity pertaining to distribution of the
    12   |   software without specific, written prior permission.
    13   |
    14   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
    15   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
    16   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    17   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    18   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    19   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20   |   ***************************************/
    21   |
    22   | #ifndef UPDATE_UPPER_H
    23   | #define UPDATE_UPPER_H
    24   |
    25   |
    26   | #include <stdio.h>
    27   | #include <stdlib.h>
    28   | #include <string.h>
    29   | #include <stubs.h>
    30   | /*#include <string>*/
    31   | #include <glib.h>
    32   | /*#include <iostream.h>
    33   | #include <fstream>*/
    34   |
    35   | #include <netdb.h>
    36   | #include <sys/types.h>
    37   | #include <netinet/in.h>
    38   | #include <sys/socket.h>
    39   | #include <errno.h>
    40   | #include <unistd.h>
    41   |
    42   | #include "rip.h"
    43   | #undef close
    44   |
    45   | #include <config.h>
    46   | /* #include <istream.h>
    47   | #include "rpsl/object.hh"
    48   | #include "util/rusage.hh"
    49   | #include "util/debug.hh"
    50   | #include "util/trace.hh"
    51   | #include "util/Argv.hh"
    52   | #include "util/version.hh"
    53   | #ifdef IRR_NEEDED
    54   | #include "irr/irr.hh"
    55   | #include "irr/rawhoisc.hh"
    56   | #endif */ /* IRR_NEEDED */
    57   | /* #include "rpsl/schema.hh"
    58   | */
    59   | #include "erroutines.h"
    60   | #include "AU_util.h"
    61   | #include "ack.h"
    62   | #define private private_xx
    63   | #include "mm.h"
    64   | #include "mysql_driver.h"
    65   | /*#include "mail_parser.h"*/
    66   | #undef private
    67   |
    68   |
    69   | #define MAXDATASIZE 100 /* max number of bytes we can get at once */
    70   |
    71   | #define OVR_OK 0 /* override succeded */
    72   |
    73   |
    74   | #define ACK_FILE_PREFIX "ack"
    75   |
    76   | extern char *current_source;
    77   |
    78   | typedef enum {
    79   |   UP_AUTH_OK=0, /* Auth succeded */
    80   |   UP_MOR, /* got more than one object from the db, where extected only one */
    81   |   UP_NSO, /* no such object */
    82   |   UP_AUF, /* auth failed */
    83   |   UP_NIY, /* not implemented yet */
    84   |   UP_ABN, /* as-block does not exist */
    85   |   UP_HOF, /* hierarchical auth failed */
    86   |   UP_OVF, /* override failed */
    87   |   UP_OVS, /* override syntax error */
    88   |   UP_NOM, /* no match. the old & nw versions of the object are not the same */
    89   |   UP_ANE, /* AUTO NIC hdl error */
    90   |   UP_FWD, /* mntner or as-block creation will be forwarded to <HUMAILBOX> */
    91   |   UP_SYN, /* syntax error in the object */
    92   |   UP_NAM, /* name of a person/role object cannot be changed */
    93   |   UP_INT, /* internal error */
    94   |   UP_MFF, /* failed with MAIL-FROM auth method only */
    95   |   UP_MIX, /* failed with mix of MAIL-FROM and other auth methods */
    96   |   UP_OKM  /* Auth succeded but also contained a deprecated MAIL-FROM */
    97   |
    98   | } return_codes;
    99   |
    100  | typedef struct _up_ripupd_result_struct {
    101  |   int result;
    102  |   char * error_str;
    103  | } up_ripupd_result_struct;
    104  |
    105  |
    106  |
    107  | up_ripupd_result_struct * send_object_db(rpsl_object_t * object, char * assigned_NIC, char * operation);
    108  |
    109  | /* char * get_class_type(Object *arg); */
    110  |
    111  | char * get_search_key(rpsl_object_t *object, const char * type);
    112  |
    113  | /* GSList *get_attributes(Object * o, const char * attrib, const char * text); */
    114  |
    115  | char * send_and_get(char * host, int port, char * arg);
    116  |
    117  | int count_objects(char * arg);
    118  |
    119  | char * take_object(char * arg);
    120  |
    121  | char * get_as_block(rpsl_object_t *autnum_object);
    122  |
    123  | char * get_less_specific_domain(rpsl_object_t *domain_object);
    124  |
    125  | char * get_less_specific_set(rpsl_object_t *set_object, const char *type);
    126  |
    127  | char * get_less_specific(rpsl_object_t *inetnum_object, const char *type);
    128  |
    129  | GList *get_mntners(rpsl_object_t * object);
    130  |
    131  | GList *get_auths(char * object_str);
    132  |
    133  | GList *get_attr_list(rpsl_object_t * object, const char * attr_type);
    134  |
    135  | GList *get_mnt_lowers(rpsl_object_t * object);
    136  |
    137  | char *get_override(rpsl_object_t * object);
    138  |
    139  | int check_override(char * string);
    140  |
    141  | GSList * add_to_auth_vector(GSList * list_of_auth_struct, GList * auths, char * mntner_name);
    142  |
    143  | GSList * get_auth_vector(GList * mntners);
    144  |
    145  | GList * get_mntnfy_vector(GList * mntners);
    146  |
    147  | int check_auth(rpsl_object_t *new_object, rpsl_object_t *old_object, const char *type, credentials_struct credentials);
    148  |
    149  | char * get_old_version(rpsl_object_t * object, char * arg);
    150  |
    151  | /* int process_object(char * arg, credentials_struct credentials, GHashTable * NIC_hdl_hash, char * ack_file_name); */
    152  |
    153  | void process_mail_header(credentials_struct * credentials_ptr ,char * header);
    154  |
    155  | int has_ref_to_AUTO_nic_hdl(rpsl_object_t * object);
    156  |
    157  | char * find_email_address(const char * from_line);
    158  |
    159  | char * replace_refs_to_AUTO_NIC_hdl(rpsl_object_t * object, GHashTable * auto_nic_hash , char *arg);
    160  |
    161  | int identical(const char * old_version, rpsl_object_t * object);
    162  |
    163  | int has_AUTO_NIC_hdl(const rpsl_object_t * object);
    164  |
    165  | rpsl_object_t * replace_AUTO_NIC_hdl(rpsl_object_t * object, char * auto_nic_hdl);
    166  |
    167  | /* char * get_class_type_char(char * object); */
    168  |
    169  | void up_string_pack(char *dest, const char *source);
    170  |
    171  | void UP_add_to_upd_log(const char * filename);
    172  |
    173  | void UP_log_networkupdate(const char * object_str, const char * host);
    174  |
    175  |
    176  | #endif