FACT++  1.0
void send_dns_server_info ( int  conn_id,
int **  bufp,
int *  size 
)

Definition at line 1239 of file dns.c.

References node::conn_id, dll_get_next(), Dns_conns, Memory::free(), Memory::malloc(), MAX_NAME, MAX_NODE_NAME, MAX_TASK_NAME, DNS_SERVER_INFO::n_services, DNS_CONNECTION::n_services, DNS_SERVICE_INFO::name, DNS_SERVER_INFO::node, DNS_SERVER_INFO::pid, serv::serv_id, serv::serv_name, DNS_DID::server, DNS_DID::services, node::servp, SRC_DIS, DNS_SERVICE_INFO::status, DNS_SERVER_INFO::task, and DNS_SERVICE_INFO::type.

Referenced by get_dns_server_info(), and main().

1240 {
1241  static int curr_allocated_size = 0;
1242  static DNS_DID *dns_info_buffer;
1243  DNS_SERVICE *servp;
1244  DNS_SERVER_INFO *dns_server_info;
1245  DNS_SERVICE_INFO *dns_service_info;
1246  DNS_CONNECTION *connp;
1247  int max_size;
1248  int n_services;
1249 
1250  DISABLE_AST
1251  connp = &Dns_conns[conn_id];
1252  if(connp->src_type != SRC_DIS)
1253  {
1254  ENABLE_AST
1255  return;
1256  }
1257  n_services = connp->n_services;
1258  if(n_services == -1)
1259  n_services = 0;
1260  max_size = (int)sizeof(DNS_SERVER_INFO) +
1261  n_services * (int)sizeof(DNS_SERVICE_INFO);
1262  if(!curr_allocated_size)
1263  {
1264  dns_info_buffer = (DNS_DID *)malloc((size_t)max_size);
1265  curr_allocated_size = max_size;
1266  }
1267  else if (max_size > curr_allocated_size)
1268  {
1269  free(dns_info_buffer);
1270  dns_info_buffer = (DNS_DID *)malloc((size_t)max_size);
1271  curr_allocated_size = max_size;
1272  }
1273  dns_server_info = &dns_info_buffer->server;
1274  dns_service_info = dns_info_buffer->services;
1275  strncpy(dns_server_info->task, connp->task_name, (size_t)(MAX_TASK_NAME-4));
1276  strncpy(dns_server_info->node, connp->node_name, (size_t)MAX_NODE_NAME);
1277  dns_server_info->pid = htovl(connp->pid);
1278  dns_server_info->n_services = htovl(connp->n_services);
1279  servp = (DNS_SERVICE *)connp->service_head;
1280  while( (servp = (DNS_SERVICE *) dll_get_next((DLL *) connp->service_head,
1281  (DLL *) servp)) )
1282  {
1283  strncpy(dns_service_info->name, servp->serv_name, (size_t)MAX_NAME);
1284  dns_service_info->status = htovl(1);
1285  if(servp->serv_id & 0x10000000)
1286  dns_service_info->type = htovl(1);
1287  else
1288  dns_service_info->type = htovl(0);
1289  dns_service_info++;
1290  }
1291  *bufp = (int *)dns_info_buffer;
1292  *size = max_size;
1293  ENABLE_AST
1294 }
#define MAX_NAME
Definition: dim.h:182
DllExp DIM_NOSHARE DNS_CONNECTION * Dns_conns
Definition: conn_handler.c:29
char serv_name[MAX_NAME]
Definition: dns.c:49
char node[MAX_NODE_NAME]
Definition: dim.h:338
void * malloc()
Definition: EventBuilder.cc:99
char task[MAX_TASK_NAME]
Definition: dim.h:339
DNS_SERVER_INFO server
Definition: dim.h:345
Definition: dim.h:530
Definition: dis.c:69
char name[MAX_NAME]
Definition: dim.h:331
#define MAX_TASK_NAME
Definition: dim.h:181
int n_services
Definition: dim.h:440
int status
Definition: dim.h:333
int size
Definition: db_dim_server.c:17
void free(void *mem)
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
#define MAX_NODE_NAME
Definition: dim.h:180
Definition: dim.h:344
int n_services
Definition: dim.h:341
DNS_SERVICE_INFO services[1]
Definition: dim.h:346
int serv_id
Definition: dns.c:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function: