FACT++  1.0
void register_services ( DIS_DNS_CONN dnsp,
int  flag,
int  dns_flag 
)

Definition at line 812 of file dis.c.

References ALL, COMMAND, Debug_on, serv::def, dim_print_date_time(), DIS_DNS_HEADER, dis_dns_ent::dis_dns_packet, dis_hash_service_get_next(), dis_hash_service_registered(), dna_write(), dis_dns_ent::dns_dis_conn_id, serv::dnsp, DIS_DNS_PACKET::format, get_node_addr(), get_node_name(), serv::id, MAX_REGISTRATION_UNIT, MAX_SERVICE_UNIT, MAX_TASK_NAME, MORE, DIS_DNS_PACKET::n_services, serv::name, DIS_DNS_PACKET::node_addr, DIS_DNS_PACKET::node_name, NONE, DIS_DNS_PACKET::pid, DIS_DNS_PACKET::port, Port_number, Protocol, DIS_DNS_PACKET::protocol, serv::registered, release_conn(), send_dns_update_packet(), SERVICE_REG::service_def, SERVICE_REG::service_id, SERVICE_REG::service_name, DIS_DNS_PACKET::services, DIS_DNS_PACKET::size, SRC_DIS, DIS_DNS_PACKET::src_type, dis_dns_ent::task_name, DIS_DNS_PACKET::task_name, and serv::type.

Referenced by dis_start_serving_dns(), do_register_services(), and recv_dns_dis_rout().

813 {
814  register DIS_DNS_PACKET *dis_dns_p = &(dnsp->dis_dns_packet);
815  register int n_services, tot_n_services;
816  register SERVICE *servp;
817  register SERVICE_REG *serv_regp;
818  int hash_index, new_entries;
819  extern int get_node_addr();
821 
822  if(!dis_dns_p->src_type)
823  {
824  get_node_name( dis_dns_p->node_name );
825 /*
826  strcpy( dis_dns_p->task_name, Task_name );
827 */
828  strncpy( dis_dns_p->task_name, dnsp->task_name,
829  (size_t)(MAX_TASK_NAME-4) );
830  dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0';
831  get_node_addr( dis_dns_p->node_addr );
832 /*
833  dis_dns_p->port = htovl(Port_number);
834 */
835  dis_dns_p->pid = htovl(getpid());
836  dis_dns_p->protocol = htovl(Protocol);
837  dis_dns_p->src_type = htovl(SRC_DIS);
838  dis_dns_p->format = htovl(MY_FORMAT);
839 if(Debug_on)
840 {
842  printf("Registering as %d %s@%s\n",
843  dis_dns_p->pid, dis_dns_p->task_name, dis_dns_p->node_name);
844 }
845 
846  }
847 
848  dis_dns_p->port = htovl(Port_number);
849  serv_regp = dis_dns_p->services;
850  n_services = 0;
851  tot_n_services = 0;
852  if( flag == NONE ) {
853  dis_dns_p->n_services = htovl(n_services);
854  dis_dns_p->size = htovl( DIS_DNS_HEADER +
855  (n_services*(int)sizeof(SERVICE_REG)));
856  if(dnsp->dns_dis_conn_id > 0)
857  {
858 if(Debug_on)
859 {
861  printf("Sending NONE to dns %d as %s@%s, %d services\n",
862  dnsp->dns_dis_conn_id,
863  (&(dnsp->dis_dns_packet))->task_name, (&(dnsp->dis_dns_packet))->node_name, n_services);
864 }
865  if(!dna_write(dnsp->dns_dis_conn_id, &(dnsp->dis_dns_packet),
866  DIS_DNS_HEADER + n_services*(int)sizeof(SERVICE_REG)))
867  {
868  release_conn(dnsp->dns_dis_conn_id, 0, 1);
869  }
870  }
871  return;
872  }
873  if(flag == ALL)
874  {
875  servp = 0;
876  hash_index = -1;
877  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)))
878  {
879  if(servp->dnsp == dnsp)
880  servp->registered = 0;
881  }
882  }
883  servp = 0;
884  hash_index = -1;
885  new_entries = 0;
886  if(flag == MORE)
887  new_entries = 1;
888  while( (servp = dis_hash_service_get_next(&hash_index, servp, new_entries)))
889  {
890  if( flag == MORE )
891  {
892  if( servp->registered )
893  {
894  continue;
895  }
896  }
897 
898  if(servp->dnsp != dnsp)
899  continue;
900 
901 if(Debug_on)
902 {
904  printf("Registering %s\n",
905  servp->name);
906 }
907  strcpy( serv_regp->service_name, servp->name );
908  strcpy( serv_regp->service_def, servp->def );
909  if(servp->type == COMMAND)
910  serv_regp->service_id = htovl( servp->id | 0x10000000);
911  else
912  serv_regp->service_id = htovl( servp->id );
913 
914  serv_regp++;
915  n_services++;
916  dis_hash_service_registered(hash_index, servp);
917  if( n_services == MAX_SERVICE_UNIT )
918  {
919  dis_dns_p->n_services = htovl(n_services);
920  dis_dns_p->size = (int)htovl(DIS_DNS_HEADER +
921  n_services * (int)sizeof(SERVICE_REG));
922  if(dnsp->dns_dis_conn_id > 0)
923  {
924 if(Debug_on)
925 {
927  printf("Sending MAX_SERVICE_UNIT to dns %d as %s@%s, %d services\n",
928  dnsp->dns_dis_conn_id,
929  (&(dnsp->dis_dns_packet))->task_name, (&(dnsp->dis_dns_packet))->node_name, n_services);
930 }
931  if( !dna_write(dnsp->dns_dis_conn_id,
932  &(dnsp->dis_dns_packet),
933  DIS_DNS_HEADER + n_services *
934  (int)sizeof(SERVICE_REG)) )
935  {
936  release_conn(dnsp->dns_dis_conn_id, 0, 1);
937  }
938  }
939  serv_regp = dis_dns_p->services;
940  tot_n_services += MAX_SERVICE_UNIT;
941  n_services = 0;
942  continue;
943  }
944  }
945  if( n_services )
946  {
947  dis_dns_p->n_services = htovl(n_services);
948  dis_dns_p->size = htovl(DIS_DNS_HEADER +
949  n_services * (int)sizeof(SERVICE_REG));
950  if(dnsp->dns_dis_conn_id > 0)
951  {
952 if(Debug_on)
953 {
955  printf("Sending to dns %d as %s@%s, %d services\n",
956  dnsp->dns_dis_conn_id,
957  (&(dnsp->dis_dns_packet))->task_name, (&(dnsp->dis_dns_packet))->node_name, n_services);
958 }
959  if( !dna_write(dnsp->dns_dis_conn_id, &(dnsp->dis_dns_packet),
960  DIS_DNS_HEADER + n_services * (int)sizeof(SERVICE_REG)))
961  {
962  release_conn(dnsp->dns_dis_conn_id, 0, 1);
963  }
964 
965  }
966  tot_n_services += n_services;
967  }
968  if(!dns_flag)
969  {
970  if(tot_n_services >= MAX_REGISTRATION_UNIT)
971  {
973  }
974  }
975 }
#define MAX_REGISTRATION_UNIT
Definition: dim.h:161
DIS_DNS_CONN * dnsp
Definition: dis.c:87
static int Protocol
Definition: dis.c:120
int dns_dis_conn_id
Definition: dis.c:44
int dna_write(int conn_id, void *buffer, int size)
Definition: dna.c:455
SERVICE * dis_hash_service_get_next(int *curr_index, SERVICE *prevp, int new_entries)
Definition: dis.c:3315
int dis_hash_service_registered(int index, SERVICE *servp)
Definition: dis.c:3274
#define COMMAND
Definition: dim_common.h:10
char task_name[MAX_NAME]
Definition: dis.c:40
int send_dns_update_packet(DIS_DNS_CONN *dnsp)
Definition: dis.c:777
int registered
Definition: dis.c:81
char name[MAX_NAME]
Definition: dis.c:72
char node_addr[4]
Definition: dim.h:274
int type
Definition: dis.c:74
char task_name[MAX_TASK_NAME-4]
Definition: dim.h:273
static int release_conn(int conn_id, int print_flg, int dns_flag)
Definition: dis.c:2684
int protocol
Definition: dim.h:277
int service_id
Definition: dim.h:265
int get_node_addr(char *node_addr)
Definition: utilities.c:98
char service_name[MAX_NAME]
Definition: dim.h:264
int n_services
Definition: dim.h:279
int format
Definition: dim.h:278
char node_name[MAX_NODE_NAME]
Definition: dim.h:272
SRC_TYPES src_type
Definition: dim.h:271
Definition: dis.c:69
char service_def[MAX_NAME]
Definition: dim.h:266
#define MORE
Definition: dis.c:33
#define MAX_TASK_NAME
Definition: dim.h:181
#define NONE
Definition: dis.c:34
static int Port_number
Definition: dis.c:121
int size
Definition: dim.h:270
Removed all warnings from DIM sources so that it can be compiled with Wall Wextra on Linux Changed the makefiles so that the default on Linux is now bits The flag
Definition: README_v19.txt:392
#define ALL
Definition: dis.c:32
int port
Definition: dim.h:276
char def[MAX_NAME]
Definition: dis.c:75
void dim_print_date_time()
Definition: utilities.c:134
static int Debug_on
Definition: dis.c:156
int pid
Definition: dim.h:275
#define DIS_DNS_HEADER
Definition: dim.h:283
SERVICE_REG services[MAX_SERVICE_UNIT]
Definition: dim.h:280
int get_node_name(char *node_name)
Definition: utilities.c:33
DIS_DNS_PACKET dis_dns_packet
Definition: dis.c:42
#define MAX_SERVICE_UNIT
Definition: dim.h:160
int id
Definition: dis.c:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function: