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

Definition at line 763 of file dis_old.c.

References ALL, COMMAND, serv::def, 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().

764 {
765  register DIS_DNS_PACKET *dis_dns_p = &(dnsp->dis_dns_packet);
766  register int n_services, tot_n_services;
767  register SERVICE *servp;
768  register SERVICE_REG *serv_regp;
769  int hash_index, new_entries;
770  extern int get_node_addr();
772 
773  if(!dis_dns_p->src_type)
774  {
775  get_node_name( dis_dns_p->node_name );
776 /*
777  strcpy( dis_dns_p->task_name, Task_name );
778 */
779  strncpy( dis_dns_p->task_name, dnsp->task_name,
780  MAX_TASK_NAME-4 );
781  dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0';
782  get_node_addr( dis_dns_p->node_addr );
783 /*
784  dis_dns_p->port = htovl(Port_number);
785 */
786  dis_dns_p->pid = htovl(getpid());
787  dis_dns_p->protocol = htovl(Protocol);
788  dis_dns_p->src_type = htovl(SRC_DIS);
789  dis_dns_p->format = htovl(MY_FORMAT);
790 
791  }
792 
793  dis_dns_p->port = htovl(Port_number);
794  serv_regp = dis_dns_p->services;
795  n_services = 0;
796  tot_n_services = 0;
797  if( flag == NONE ) {
798  dis_dns_p->n_services = htovl(n_services);
799  dis_dns_p->size = htovl( DIS_DNS_HEADER +
800  (n_services*sizeof(SERVICE_REG)));
801  if(dnsp->dns_dis_conn_id > 0)
802  {
803  if(!dna_write(dnsp->dns_dis_conn_id, &(dnsp->dis_dns_packet),
804  DIS_DNS_HEADER + n_services*sizeof(SERVICE_REG)))
805  {
806  release_conn(dnsp->dns_dis_conn_id, 0, 1);
807  }
808  }
809  return;
810  }
811  if(flag == ALL)
812  {
813  servp = 0;
814  hash_index = -1;
815  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)))
816  {
817  if(servp->dnsp == dnsp)
818  servp->registered = 0;
819  }
820  }
821  servp = 0;
822  hash_index = -1;
823  new_entries = 0;
824  if(flag == MORE)
825  new_entries = 1;
826  while( (servp = dis_hash_service_get_next(&hash_index, servp, new_entries)))
827  {
828  if( flag == MORE )
829  {
830  if( servp->registered )
831  {
832  continue;
833  }
834  }
835 
836  if(servp->dnsp != dnsp)
837  continue;
838 
839  strcpy( serv_regp->service_name, servp->name );
840  strcpy( serv_regp->service_def, servp->def );
841  if(servp->type == COMMAND)
842  serv_regp->service_id = htovl( servp->id | 0x10000000);
843  else
844  serv_regp->service_id = htovl( servp->id );
845 
846  serv_regp++;
847  n_services++;
848  dis_hash_service_registered(hash_index, servp);
849  if( n_services == MAX_SERVICE_UNIT )
850  {
851  dis_dns_p->n_services = htovl(n_services);
852  dis_dns_p->size = htovl(DIS_DNS_HEADER +
853  n_services * sizeof(SERVICE_REG));
854  if(dnsp->dns_dis_conn_id > 0)
855  {
856  if( !dna_write(dnsp->dns_dis_conn_id,
857  &(dnsp->dis_dns_packet),
858  DIS_DNS_HEADER + n_services *
859  sizeof(SERVICE_REG)) )
860  {
861  release_conn(dnsp->dns_dis_conn_id, 0, 1);
862  }
863  }
864  serv_regp = dis_dns_p->services;
865  tot_n_services += MAX_SERVICE_UNIT;
866  n_services = 0;
867  continue;
868  }
869  }
870  if( n_services )
871  {
872  dis_dns_p->n_services = htovl(n_services);
873  dis_dns_p->size = htovl(DIS_DNS_HEADER +
874  n_services * sizeof(SERVICE_REG));
875  if(dnsp->dns_dis_conn_id > 0)
876  {
877  if( !dna_write(dnsp->dns_dis_conn_id, &(dnsp->dis_dns_packet),
878  DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)))
879  {
880  release_conn(dnsp->dns_dis_conn_id, 0, 1);
881  }
882 
883  }
884  tot_n_services += n_services;
885  }
886  if(!dns_flag)
887  {
888  if(tot_n_services >= MAX_REGISTRATION_UNIT)
889  {
891  }
892  }
893 }
#define MAX_REGISTRATION_UNIT
Definition: dim.h:161
DIS_DNS_CONN * dnsp
Definition: dis.c:87
int dns_dis_conn_id
Definition: dis.c:44
#define ALL
Definition: dis_old.c:32
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_old.c:2920
int send_dns_update_packet(DIS_DNS_CONN *dnsp)
Definition: dis_old.c:735
static int Port_number
Definition: dis_old.c:121
#define COMMAND
Definition: dim_common.h:10
char task_name[MAX_NAME]
Definition: dis.c:40
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
#define MORE
Definition: dis_old.c:33
#define NONE
Definition: dis_old.c:34
int protocol
Definition: dim.h:277
int service_id
Definition: dim.h:265
int dis_hash_service_registered(int index, SERVICE *servp)
Definition: dis_old.c:2889
int get_node_addr(char *node_addr)
Definition: utilities.c:98
static int Protocol
Definition: dis_old.c:120
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 MAX_TASK_NAME
Definition: dim.h:181
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
int port
Definition: dim.h:276
char def[MAX_NAME]
Definition: dis.c:75
static int release_conn(int conn_id, int print_flg, int dns_flag)
Definition: dis_old.c:2374
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: