FACT++  1.0
int open_dns ( dim_long  dnsid,
void(*)()  recv_rout,
void(*)()  error_rout,
int  tmout_min,
int  tmout_max,
SRC_TYPES  src_type 
)

Definition at line 313 of file open_dns.c.

References dns_ent::conn_id, dns_ent::connecting, dna_open_client(), DNS_TASK, dtq_add_entry(), dtq_create(), dns_ent::error_rout, get_dns(), get_dns_pars(), i, MAX_DNS_NODE, MAX_NODE_NAME, MAX_TASK_NAME, dns_ent::pending, rand_tmout(), dns_ent::recv_rout, recv_rout(), dns_ent::task_name, TCPIP, Timer_q, and dns_ent::timr_ent.

Referenced by dis_start_serving_dns(), locate_service(), recv_dns_dis_rout(), and request_dns_info().

314 {
315  char nodes[MAX_DNS_NODE];
316  char node_info[MAX_NODE_NAME+4];
317  register char *dns_node, *ptr;
318  register int conn_id;
319  register int timeout, node_exists;
320  int i, dns_port;
321  int rand_tmout();
322  DNS_CONN *connp;
323 
324  conn_id = 0;
325  if( !Timer_q )
326  Timer_q = dtq_create();
327 
328  connp = get_dns((DNS_CONN *)dnsid, src_type);
329  node_exists = get_dns_pars(connp, nodes, &dns_port);
330  if( !(connp->pending) )
331  {
332  if(!node_exists)
333  {
334  return(-2);
335  }
336  ptr = nodes;
337  while(1)
338  {
339  dns_node = ptr;
340  if( (ptr = (char *)strchr(ptr,',')) )
341  {
342  *ptr = '\0';
343  ptr++;
344  }
345  strcpy(node_info,dns_node);
346  for(i = 0; i < 4; i ++)
347  node_info[(int)strlen(node_info)+i+1] = (char)0xff;
348  connp->conn_id = 0;
349  connp->connecting = 1;
350  conn_id = dna_open_client( node_info, DNS_TASK, dns_port,
351  TCPIP, recv_rout, error_rout, src_type );
352  connp->connecting = 0;
353  if(conn_id)
354  break;
355  if( !ptr )
356  break;
357  }
358  connp->conn_id = conn_id;
359  if(!conn_id)
360  {
361  strncpy(connp->task_name, DNS_TASK, (size_t)MAX_TASK_NAME);
362  connp->recv_rout = recv_rout;
363  connp->error_rout = error_rout;
364  connp->pending = 1;
365  timeout = rand_tmout( tmout_min, tmout_max );
366  connp->timr_ent = dtq_add_entry( Timer_q, timeout,
368  connp );
369  return( -1);
370  }
371  }
372  else
373  return(-1);
374  return(conn_id);
375 }
void retry_dns_connection(DNS_CONN *connp)
Definition: open_dns.c:377
int dna_open_client(char *server_node, char *server_task, int port, int server_protocol, void(*read_ast)(), void(*error_ast)(), SRC_TYPES src_type)
Definition: dna.c:733
int i
Definition: db_dim_client.c:21
#define TCPIP
Definition: dim.h:194
char task_name[MAX_TASK_NAME]
Definition: open_dns.c:28
#define DNS_TASK
Definition: dim.h:138
int get_dns_pars(DNS_CONN *connp, char *node, int *port)
Definition: open_dns.c:206
int rand_tmout(int min, int max)
Definition: open_dns.c:161
int dtq_create()
Definition: dtq.c:353
TIMR_ENT * timr_ent
Definition: open_dns.c:32
static void recv_rout(int conn_id, DIS_PACKET *packet, int size, int status)
Definition: dic.c:143
static int Timer_q
Definition: open_dns.c:39
#define MAX_DNS_NODE
Definition: open_dns.c:13
int connecting
Definition: open_dns.c:36
void(* error_rout)()
Definition: open_dns.c:31
int conn_id
Definition: open_dns.c:34
#define MAX_TASK_NAME
Definition: dim.h:181
TIMR_ENT * dtq_add_entry(int queue_id, int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:399
#define MAX_NODE_NAME
Definition: dim.h:180
int pending
Definition: open_dns.c:35
dnsid
Definition: README_v19.txt:372
void(* recv_rout)()
Definition: open_dns.c:30
DNS_CONN * get_dns(DNS_CONN *connp, SRC_TYPES src_type)
Definition: open_dns.c:279

+ Here is the call graph for this function:

+ Here is the caller graph for this function: