void register_dns_services(flag) register int flag; { register DIS_DNS_PACKET *dis_dns_p = &Dis_dns_packet; register int n_services; register SERVICE *servp; register SERVICE_REG *serv_regp; extern int get_node_addr(char *); int dis_hash_service_registered(); if(!dis_dns_p->src_type) { get_node_name( dis_dns_p->node_name ); /* strcpy( dis_dns_p->task_name, Task_name ); */ strncpy( dis_dns_p->task_name, Task_name, MAX_TASK_NAME-4 ); dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0'; get_node_addr( dis_dns_p->node_addr ); /* dis_dns_p->port = htovl(Port_number); */ dis_dns_p->pid = htovl(getpid()); dis_dns_p->protocol = htovl(Protocol); dis_dns_p->src_type = htovl(SRC_DIS); dis_dns_p->format = htovl(MY_FORMAT); } dis_dns_p->port = htovl(Port_number); serv_regp = dis_dns_p->services; n_services = 0; if( flag == NONE ) { dis_dns_p->n_services = htovl(n_services); dis_dns_p->size = htovl( DIS_DNS_HEADER + (n_services*sizeof(SERVICE_REG))); if(Dns_dis_conn_id > 0) { if(!dna_write(Dns_dis_conn_id, &Dis_dns_packet, DIS_DNS_HEADER + n_services*sizeof(SERVICE_REG))) { release_conn(Dns_dis_conn_id,0); } } return; } servp = 0; while( (servp = dis_hash_service_get_next(servp))) { if( flag == MORE ) { if( servp->registered ) { continue; } } strcpy( serv_regp->service_name, servp->name ); strcpy( serv_regp->service_def, servp->def ); if(servp->type == COMMAND) serv_regp->service_id = htovl( servp->id | 0x10000000); else serv_regp->service_id = htovl( servp->id ); serv_regp++; n_services++; dis_hash_service_registered(servp); /* servp->registered = 1; */ if( n_services == MAX_SERVICE_UNIT ) { dis_dns_p->n_services = htovl(n_services); dis_dns_p->size = htovl(DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)); if(Dns_dis_conn_id > 0) { if( !dna_write(Dns_dis_conn_id, &Dis_dns_packet, DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)) ) { release_conn(Dns_dis_conn_id,0); } } serv_regp = dis_dns_p->services; n_services = 0; } } if( n_services ) { dis_dns_p->n_services = htovl(n_services); dis_dns_p->size = htovl(DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)); if(Dns_dis_conn_id > 0) { if( !dna_write(Dns_dis_conn_id, &Dis_dns_packet, DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG))) { release_conn(Dns_dis_conn_id,0); } } } }