fred-mod-whoisd
Macros | Functions | Variables
whois-client.c File Reference
#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"
#include "Whois.h"

Macros

#define ID_STATUS_OBJ_LINKED   16
 
#define ID_STATUS_OBJ_MOJEIDCONTACT   24
 
#define raised_exception(ev)   ((ev)->_major != CORBA_NO_EXCEPTION)
 
#define MAX_RETRIES   3
 
#define RETR_SLEEP   100000
 
#define IS_NOT_COMM_FAILURE_EXCEPTION(_ev)   (strcmp((_ev)->_id, "IDL:omg.org/CORBA/COMM_FAILURE:1.0"))
 
#define IS_OBJECT_NOT_FOUND(_ev)   (!strcmp((_ev)->_id, "IDL:ccReg/Whois/ObjectNotFound:1.0"))
 
#define NULL_STRDUP(src)   ((*(src) == '\0') ? NULL : strdup(src))
 
#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)
 
int whois_log_new_message (service_Logger service, const char *sourceIP, const char *content, ccReg_RequestProperties *properties, ccReg_TID *log_entry_id, char *errmsg)
 
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)
 
int whois_corba_call (service_Whois service, const whois_request *wr, general_object *objects, char *timebuf, char *errmsg)
 
void whois_release_data (general_object *objects)
 

Variables

const int IP_ADDR_LEN = 39
 
const int LC_UNIX_WHOIS = 0
 

Detailed Description

Implementation of CORBA backend used for querying CORBA server for information about an object.

Macro Definition Documentation

◆ ID_STATUS_OBJ_LINKED

#define ID_STATUS_OBJ_LINKED   16

ID of object status 'Linked'

◆ ID_STATUS_OBJ_MOJEIDCONTACT

#define ID_STATUS_OBJ_MOJEIDCONTACT   24

ID of object status 'mojeidContact'

◆ IS_NOT_COMM_FAILURE_EXCEPTION

#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.

◆ IS_OBJECT_NOT_FOUND

#define IS_OBJECT_NOT_FOUND (   _ev)    (!strcmp((_ev)->_id, "IDL:ccReg/Whois/ObjectNotFound:1.0"))

True if CORBA exception is ObjectNotFound

◆ MAX_RETRIES

#define MAX_RETRIES   3

Max # of retries when COMM_FAILURE exception during CORBA call occurs.

◆ NULL_STRDUP

#define NULL_STRDUP (   src)    ((*(src) == '\0') ? NULL : strdup(src))

Call strdup on string only if it is not empty, otherwise return NULL.

◆ raised_exception

#define raised_exception (   ev)    ((ev)->_major != CORBA_NO_EXCEPTION)

A shortcut for testing of CORBA exception appearence.

◆ RETR_SLEEP

#define RETR_SLEEP   100000

Sleep interval in microseconds between retries.

Function Documentation

◆ check_duplicates()

int check_duplicates ( int  type,
char *  handle,
general_object objects,
int  index_free 
)

Check for duplicates in array of objects.

Parameters
typeWhich type of objects to look for.
handleHandle of the object.
objectsThe structure for holding any type of object
index_freeFirst free item in array of objects.
Returns
0 if no duplicates are present, 1 otherwise.

◆ whois_close_log_message()

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

Parameters
serviceWhois CORBA object reference.
contentRaw content of the message.
propertiesCustom properties parsed from the content
log_entry_idID of the log entry to be close
errmsgBuffer for error message.
Returns
Status.

◆ whois_corba_call()

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

Parameters
serviceWhois CORBA object reference.
wrWhois request.
objectsArray of resulting objects.
timebufTimestamp.
errmsg
Returns
Status.

◆ whois_log_new_message()

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

Parameters
serviceWhois CORBA object reference.
sourceIPIP of the host which sent the request.
contentRaw content of the message.
propertiesCustom properties parsed from the content
log_entry_idOutput of ID from event logger
errmsgBuffer for error message.
Returns
Status.

◆ whois_release_data()

void whois_release_data ( general_object objects)

Release data of any of the objects

Parameters
objectsObject to release

Variable Documentation

◆ IP_ADDR_LEN

const int IP_ADDR_LEN = 39

maximum length of a string containing IP address

◆ LC_UNIX_WHOIS

const int LC_UNIX_WHOIS = 0

code of the servie according to the database table ‘service’