fred-mod-whoisd-3.10.2
|
Implementation of CORBA backend used for querying CORBA server for information about an object. More...
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <orbit/orbit.h>
#include <ORBitservices/CosNaming.h>
#include "whois-client.h"
Macros | |
#define | ID_STATUS_OBJ_LINKED 16 |
ID of object status 'Linked'. | |
#define | ID_STATUS_OBJ_MOJEIDCONTACT 24 |
ID of object status 'mojeidContact'. | |
#define | raised_exception(ev) ((ev)->_major != CORBA_NO_EXCEPTION) |
A shortcut for testing of CORBA exception appearence. More... | |
#define | MAX_RETRIES 3 |
Max # of retries when COMM_FAILURE exception during CORBA call occurs. More... | |
#define | RETR_SLEEP 100000 |
Sleep interval in microseconds between retries. More... | |
#define | IS_NOT_COMM_FAILURE_EXCEPTION(_ev) (strcmp((_ev)->_id, "IDL:omg.org/CORBA/COMM_FAILURE:1.0")) |
True if CORBA exception is COMM_FAILURE, which is used in retry loop. More... | |
#define | IS_OBJECT_NOT_FOUND(_ev) (!strcmp((_ev)->_id, "IDL:ccReg/Whois/ObjectNotFound:1.0")) |
True if CORBA exception is ObjectNotFound. | |
#define | NULL_STRDUP(src) ((*(src) == '\0') ? NULL : strdup(src)) |
Call strdup on string only if it is not empty, otherwise return NULL. More... | |
#define | COPY_ADDRESS_LINE(str) do{ if (*(str) != '\0') r->address[line++] = strdup(str); }while(0) |
#define | COPY_ADDRESS_LINE(str) do{ if (*(str) != '\0') c->address[line++] = strdup(str); }while(0) |
Functions | |
int | check_duplicates (int type, char *handle, general_object *objects, int index_free) |
Check for duplicates in array of objects. More... | |
static int | get_registrar_by_handle (service_Whois service, const char *handle, general_object *objects, int *index_free, char *errmsg) |
Search registrar by handle. More... | |
static int | get_contact_by_handle (service_Whois service, const char *handle, general_object *objects, int *index_free, char *errmsg) |
Search contact by handle. More... | |
static void | copy_nsset (general_object *obj, ccReg_NSSetDetail *c_nsset) |
Copy corba representation of nsset object to our representation. More... | |
static void | copy_keyset (general_object *obj, ccReg_KeySetDetail *c_keyset) |
Copy corba representation of keyset object to our representation. More... | |
static int | recurse_nsset (service_Whois service, int rec, obj_nsset *n, general_object *objects, int *index_free, char *errmsg) |
The function does recursion on nsset. More... | |
static int | recurse_keyset (service_Whois service, int rec, obj_keyset *k, general_object *objects, int *index_free, char *errmsg) |
The function does recursion on keyset. More... | |
static int | get_nsset_by_handle (service_Whois service, const char *handle, int rec, general_object *objects, int *index_free, char *errmsg) |
Search nsset by handle and dependent objects if recursion is switched on. More... | |
static int | get_keyset_by_handle (service_Whois service, const char *handle, int rec, general_object *objects, int *index_free, char *errmsg) |
Search keyset by handle and dependent objects if recursion is switched on. More... | |
static int | get_nsset_by_attr (service_Whois service, const char *key, ccReg_NSSetInvKeyType attr, int rec, general_object *objects, int *index_free, char *errmsg) |
Search nsset by its attribute and dependent objects if recursion is switched on. More... | |
static int | get_keyset_by_attr (service_Whois service, const char *key, ccReg_KeySetInvKeyType attr, int rec, general_object *objects, int *index_free, char *errmsg) |
Search keyset by its attribute and dependent objects if recursion is switched on. More... | |
static int | translate_status (service_Whois service, general_object *objects, char *errmsg) |
Translate status ids by domain objects to appropriate strings. More... | |
static void | copy_domain (general_object *obj, ccReg_DomainDetail *c_domain) |
Copy corba representation of domain object to our representation. More... | |
static int | recurse_domain (service_Whois service, int rec, obj_domain *d, general_object *objects, int *index_free, char *errmsg) |
The function does recursion on domain. More... | |
static int | get_domain_by_handle (service_Whois service, const char *handle, int rec, general_object *objects, int *index_free, char *errmsg) |
Search domain by fqdn and dependent objects if recursion is switched on. More... | |
static int | get_domain_by_attr (service_Whois service, const char *key, ccReg_DomainInvKeyType attr, int rec, general_object *objects, int *index_free, char *errmsg) |
Search domain by its attribute and dependent objects if recursion is switched on. More... | |
int | whois_log_new_message (service_Logger service, const char *sourceIP, const char *content, ccReg_RequestProperties *properties, ccReg_TID *log_entry_id, char *errmsg) |
Log a new event using logging daemon. More... | |
int | whois_close_log_message (service_Logger service, const char *content, ccReg_RequestProperties *properties, ccReg_TID log_entry_id, CORBA_long result_code, char *errmsg) |
Update and close existing event using logging daemon. More... | |
int | whois_corba_call (service_Whois service, const whois_request *wr, general_object *objects, char *timebuf, char *errmsg) |
Call the right function for the specific object type / search axis / handle combination. More... | |
void | whois_release_data (general_object *objects) |
Release data of any of the objects. More... | |
Variables | |
const int | IP_ADDR_LEN = 39 |
maximum length of a string containing IP address | |
const int | LC_UNIX_WHOIS = 0 |
code of the servie according to the database table `service' | |
Implementation of CORBA backend used for querying CORBA server for information about an object.
#define IS_NOT_COMM_FAILURE_EXCEPTION | ( | _ev | ) | (strcmp((_ev)->_id, "IDL:omg.org/CORBA/COMM_FAILURE:1.0")) |
True if CORBA exception is COMM_FAILURE, which is used in retry loop.
Referenced by get_contact_by_handle(), get_domain_by_attr(), get_domain_by_handle(), get_keyset_by_attr(), get_keyset_by_handle(), get_nsset_by_attr(), get_nsset_by_handle(), get_registrar_by_handle(), translate_status(), whois_close_log_message(), and whois_log_new_message().
#define MAX_RETRIES 3 |
Max # of retries when COMM_FAILURE exception during CORBA call occurs.
Referenced by get_contact_by_handle(), get_domain_by_attr(), get_domain_by_handle(), get_keyset_by_attr(), get_keyset_by_handle(), get_nsset_by_attr(), get_nsset_by_handle(), get_registrar_by_handle(), translate_status(), whois_close_log_message(), and whois_log_new_message().
#define NULL_STRDUP | ( | src | ) | ((*(src) == '\0') ? NULL : strdup(src)) |
Call strdup on string only if it is not empty, otherwise return NULL.
Referenced by copy_domain(), copy_keyset(), copy_nsset(), get_contact_by_handle(), and get_registrar_by_handle().
#define raised_exception | ( | ev | ) | ((ev)->_major != CORBA_NO_EXCEPTION) |
A shortcut for testing of CORBA exception appearence.
Referenced by get_contact_by_handle(), get_domain_by_attr(), get_domain_by_handle(), get_keyset_by_attr(), get_keyset_by_handle(), get_nsset_by_attr(), get_nsset_by_handle(), get_registrar_by_handle(), translate_status(), whois_close_log_message(), and whois_log_new_message().
#define RETR_SLEEP 100000 |
Sleep interval in microseconds between retries.
Referenced by get_contact_by_handle(), get_domain_by_attr(), get_domain_by_handle(), get_keyset_by_attr(), get_keyset_by_handle(), get_nsset_by_attr(), get_nsset_by_handle(), get_registrar_by_handle(), translate_status(), whois_close_log_message(), and whois_log_new_message().
int check_duplicates | ( | int | type, |
char * | handle, | ||
general_object * | objects, | ||
int | index_free | ||
) |
Check for duplicates in array of objects.
type | Which type of objects to look for. |
handle | Handle of the object. |
objects | The structure for holding any type of object |
index_free | First free item in array of objects. |
References obj_contact::contact, obj_domain::domain, obj_keyset::keyset, obj_nsset::nsset, and obj_registrar::registrar.
Referenced by get_contact_by_handle(), get_domain_by_handle(), get_keyset_by_handle(), get_nsset_by_handle(), and get_registrar_by_handle().
|
static |
Copy corba representation of domain object to our representation.
obj | Field in object array which is destination of copy. |
c_domain | Domain detail returned from CORBA. |
References obj_domain::admin_c, obj_domain::changed, obj_domain::domain, obj_domain::expire, obj_domain::keyset, obj_domain::nsset, NULL_STRDUP, general_object::obj, obj_domain::registered, obj_domain::registrant, obj_domain::registrar, obj_domain::status, obj_domain::status_ids, obj_domain::temp_c, general_object::type, and obj_domain::validated_to.
Referenced by get_domain_by_attr(), and get_domain_by_handle().
|
static |
Copy corba representation of keyset object to our representation.
obj | Field in object array which is destination of copy. |
c_keyset | Keyset detail returned from CORBA. |
References keyset_dsrecord::alg, keyset_dnskey::alg, obj_keyset::changed, obj_keyset::created, keyset_dsrecord::digest, keyset_dsrecord::digest_type, obj_keyset::ds, keyset_dnskey::flags, keyset_dsrecord::key_tag, obj_keyset::keys, obj_keyset::keyset, keyset_dsrecord::max_sig_life, NULL_STRDUP, general_object::obj, keyset_dnskey::protocol, keyset_dnskey::public_key, obj_keyset::registrar, obj_keyset::tech_c, and general_object::type.
Referenced by get_keyset_by_attr(), and get_keyset_by_handle().
|
static |
Copy corba representation of nsset object to our representation.
obj | Field in object array which is destination of copy. |
c_nsset | Nsset detail returned from CORBA. |
References obj_nsset::changed, obj_nsset::created, IP_ADDR_LEN, obj_nsset::nserver, obj_nsset::nserver_addrs, obj_nsset::nsset, NULL_STRDUP, general_object::obj, obj_nsset::registrar, obj_nsset::tech_c, and general_object::type.
Referenced by get_nsset_by_attr(), and get_nsset_by_handle().
|
static |
Search contact by handle.
Supress duplicities in array of objects.
service | Whois CORBA object reference. |
handle | Handle of contact. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References obj_contact::address, obj_contact::changed, check_duplicates(), obj_contact::contact, CORBA_OK, CORBA_SERVICE_FAILED, obj_contact::created, obj_contact::disclose, obj_contact::e_mail, obj_contact::fax_no, ID_STATUS_OBJ_LINKED, IS_NOT_COMM_FAILURE_EXCEPTION, IS_OBJECT_NOT_FOUND, MAX_ERROR_MSG_LEN, MAX_RETRIES, obj_contact::name, NULL_STRDUP, general_object::obj, obj_contact::org, obj_contact::phone, raised_exception, obj_contact::registrar, RETR_SLEEP, and general_object::type.
Referenced by recurse_domain(), recurse_keyset(), recurse_nsset(), and whois_corba_call().
|
static |
Search domain by its attribute and dependent objects if recursion is switched on.
service | Whois CORBA object reference. |
key | Attribute of domain. |
attr | Attribute type. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References copy_domain(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, MAX_ERROR_MSG_LEN, MAX_OBJECT_COUNT, MAX_RETRIES, raised_exception, recurse_domain(), and RETR_SLEEP.
Referenced by whois_corba_call().
|
static |
Search domain by fqdn and dependent objects if recursion is switched on.
Supress duplicates in array of objects
service | Whois CORBA object reference. |
handle | Fqdn of domain. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References check_duplicates(), copy_domain(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, IS_OBJECT_NOT_FOUND, MAX_ERROR_MSG_LEN, MAX_RETRIES, raised_exception, recurse_domain(), and RETR_SLEEP.
Referenced by whois_corba_call().
|
static |
Search keyset by its attribute and dependent objects if recursion is switched on.
service | Whois CORBA object reference. |
key | Attribute of keyset. |
attr | Attribute type. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References copy_keyset(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, MAX_ERROR_MSG_LEN, MAX_OBJECT_COUNT, MAX_RETRIES, raised_exception, recurse_keyset(), and RETR_SLEEP.
Referenced by whois_corba_call().
|
static |
Search keyset by handle and dependent objects if recursion is switched on.
Supress duplicities in array of objects.
service | Whois CORBA object reference. |
handle | Handle of keyset. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References check_duplicates(), copy_keyset(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, IS_OBJECT_NOT_FOUND, MAX_ERROR_MSG_LEN, MAX_RETRIES, raised_exception, recurse_keyset(), and RETR_SLEEP.
Referenced by recurse_domain(), and whois_corba_call().
|
static |
Search nsset by its attribute and dependent objects if recursion is switched on.
service | Whois CORBA object reference. |
key | Attribute of nsset. |
attr | Attribute type. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References copy_nsset(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, MAX_ERROR_MSG_LEN, MAX_OBJECT_COUNT, MAX_RETRIES, raised_exception, recurse_nsset(), and RETR_SLEEP.
Referenced by whois_corba_call().
|
static |
Search nsset by handle and dependent objects if recursion is switched on.
Supress duplicities in array of objects.
service | Whois CORBA object reference. |
handle | Handle of nsset. |
rec | Recursive lookup is performed if true. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References check_duplicates(), copy_nsset(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, IS_OBJECT_NOT_FOUND, MAX_ERROR_MSG_LEN, MAX_RETRIES, raised_exception, recurse_nsset(), and RETR_SLEEP.
Referenced by recurse_domain(), and whois_corba_call().
|
static |
Search registrar by handle.
Supress duplicities in array of objects.
service | Whois CORBA object reference. |
handle | Handle of registrar. |
objects | Array of resulting objects. |
index_free | First free item in array of objects. |
errmsg | Buffer for error message. |
References obj_registrar::address, check_duplicates(), CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, IS_OBJECT_NOT_FOUND, MAX_ERROR_MSG_LEN, MAX_RETRIES, NULL_STRDUP, general_object::obj, obj_registrar::org, obj_registrar::phone, raised_exception, obj_registrar::registrar, RETR_SLEEP, general_object::type, and obj_registrar::url.
Referenced by whois_corba_call().
|
static |
The function does recursion on domain.
service | Whois corba object reference. |
rec | Recursive lookup is performed if true. |
d | Domain object on which recursion is done. |
objects | Array of results. |
index_free | First free index in array of results. |
errmsg | Buffer for error message. |
References obj_domain::admin_c, CORBA_OK, CORBA_OK_LIMIT, get_contact_by_handle(), get_keyset_by_handle(), get_nsset_by_handle(), obj_domain::keyset, MAX_OBJECT_COUNT, obj_domain::nsset, obj_domain::registrant, and obj_domain::temp_c.
Referenced by get_domain_by_attr(), and get_domain_by_handle().
|
static |
The function does recursion on keyset.
service | Whois corba object reference. |
rec | Switches recursion on/off |
k | Keyset object on which recursion is done. |
objects | Array of results. |
index_free | First free index in array of results. |
errmsg | Buffer for error message. |
References CORBA_OK, CORBA_OK_LIMIT, get_contact_by_handle(), MAX_OBJECT_COUNT, and obj_keyset::tech_c.
Referenced by get_keyset_by_attr(), and get_keyset_by_handle().
|
static |
The function does recursion on nsset.
service | Whois corba object reference. |
rec | Switches recursion on/off |
n | Nsset object on which is done recursion. |
objects | Array of results. |
index_free | First free index in array of results. |
errmsg | Buffer for error message. |
References CORBA_OK, CORBA_OK_LIMIT, get_contact_by_handle(), MAX_OBJECT_COUNT, and obj_nsset::tech_c.
Referenced by get_nsset_by_attr(), and get_nsset_by_handle().
|
static |
Translate status ids by domain objects to appropriate strings.
service | Whois corba object reference. |
objects | Array of objects. |
errmsg | Buffer for error message. |
References CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, MAX_ERROR_MSG_LEN, MAX_OBJECT_COUNT, MAX_RETRIES, general_object::obj, raised_exception, RETR_SLEEP, obj_domain::status, obj_domain::status_ids, and general_object::type.
Referenced by whois_corba_call().
int whois_close_log_message | ( | service_Logger | service, |
const char * | content, | ||
ccReg_RequestProperties * | properties, | ||
ccReg_TID | log_entry_id, | ||
CORBA_long | result_code, | ||
char * | errmsg | ||
) |
Update and close existing event using logging daemon.
service | Whois CORBA object reference. |
content | Raw content of the message. |
properties | Custom properties parsed from the content |
log_entry_id | ID of the log entry to be close |
errmsg | Buffer for error message. |
References CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, MAX_ERROR_MSG_LEN, MAX_RETRIES, raised_exception, and RETR_SLEEP.
Referenced by process_whois_query().
int whois_corba_call | ( | service_Whois | service, |
const whois_request * | wr, | ||
general_object * | objects, | ||
char * | timebuf, | ||
char * | errmsg | ||
) |
Call the right function for the specific object type / search axis / handle combination.
The core function of whois module performs actual query.
service | Whois CORBA object reference. |
wr | Whois request. |
objects | Array of resulting objects. |
timebuf | Timestamp. |
errmsg |
References whois_request::axe, CORBA_OK, CORBA_OK_LIMIT, get_contact_by_handle(), get_domain_by_attr(), get_domain_by_handle(), get_keyset_by_attr(), get_keyset_by_handle(), get_nsset_by_attr(), get_nsset_by_handle(), get_registrar_by_handle(), MAX_OBJECT_COUNT, whois_request::norecursion, TIME_BUFFER_LENGTH, translate_status(), whois_request::type, general_object::type, whois_request::value, and whois_release_data().
Referenced by process_whois_query().
int whois_log_new_message | ( | service_Logger | service, |
const char * | sourceIP, | ||
const char * | content, | ||
ccReg_RequestProperties * | properties, | ||
ccReg_TID * | log_entry_id, | ||
char * | errmsg | ||
) |
Log a new event using logging daemon.
Log a message using logging daemon.
service | Whois CORBA object reference. |
sourceIP | IP of the host which sent the request. |
content | Raw content of the message. |
properties | Custom properties parsed from the content |
log_entry_id | Output of ID from event logger |
errmsg | Buffer for error message. |
References CORBA_OK, CORBA_SERVICE_FAILED, IS_NOT_COMM_FAILURE_EXCEPTION, LC_UNIX_WHOIS, MAX_ERROR_MSG_LEN, MAX_RETRIES, raised_exception, and RETR_SLEEP.
Referenced by log_whois_request().
void whois_release_data | ( | general_object * | objects | ) |
Release data of any of the objects.
Release data.
objects | Object to release |
References obj_contact::address, obj_registrar::address, obj_domain::admin_c, obj_domain::changed, obj_nsset::changed, obj_keyset::changed, obj_contact::changed, obj_contact::contact, obj_nsset::created, obj_keyset::created, obj_contact::created, keyset_dsrecord::digest, obj_contact::disclose, obj_domain::domain, obj_keyset::ds, obj_contact::e_mail, obj_domain::expire, obj_contact::fax_no, obj_keyset::keys, obj_domain::keyset, obj_keyset::keyset, MAX_OBJECT_COUNT, obj_contact::name, obj_nsset::nserver, obj_nsset::nserver_addrs, obj_domain::nsset, obj_nsset::nsset, general_object::obj, obj_contact::org, obj_registrar::org, obj_contact::phone, obj_registrar::phone, keyset_dnskey::public_key, obj_domain::registered, obj_domain::registrant, obj_domain::registrar, obj_nsset::registrar, obj_keyset::registrar, obj_contact::registrar, obj_registrar::registrar, obj_domain::status, obj_domain::status_ids, obj_nsset::tech_c, obj_keyset::tech_c, general_object::type, obj_registrar::url, and obj_domain::validated_to.
Referenced by process_whois_query(), and whois_corba_call().