source: Evidence/DIM/test2.c@ 142

Last change on this file since 142 was 127, checked in by ogrimm, 15 years ago
First commit of Evidence control system core components
File size: 2.4 KB
Line 
1void register_dns_services(flag)
2register int flag;
3{
4 register DIS_DNS_PACKET *dis_dns_p = &Dis_dns_packet;
5 register int n_services;
6 register SERVICE *servp;
7 register SERVICE_REG *serv_regp;
8 extern int get_node_addr(char *);
9 int dis_hash_service_registered();
10
11 if(!dis_dns_p->src_type)
12 {
13 get_node_name( dis_dns_p->node_name );
14/*
15 strcpy( dis_dns_p->task_name, Task_name );
16*/
17 strncpy( dis_dns_p->task_name, Task_name,
18 MAX_TASK_NAME-4 );
19 dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0';
20 get_node_addr( dis_dns_p->node_addr );
21/*
22 dis_dns_p->port = htovl(Port_number);
23*/
24 dis_dns_p->pid = htovl(getpid());
25 dis_dns_p->protocol = htovl(Protocol);
26 dis_dns_p->src_type = htovl(SRC_DIS);
27 dis_dns_p->format = htovl(MY_FORMAT);
28 }
29 dis_dns_p->port = htovl(Port_number);
30 serv_regp = dis_dns_p->services;
31 n_services = 0;
32 if( flag == NONE ) {
33 dis_dns_p->n_services = htovl(n_services);
34 dis_dns_p->size = htovl( DIS_DNS_HEADER +
35 (n_services*sizeof(SERVICE_REG)));
36 if(Dns_dis_conn_id > 0)
37 {
38 if(!dna_write(Dns_dis_conn_id, &Dis_dns_packet,
39 DIS_DNS_HEADER + n_services*sizeof(SERVICE_REG)))
40 {
41 release_conn(Dns_dis_conn_id,0);
42 }
43 }
44 return;
45 }
46 servp = 0;
47 while( (servp = dis_hash_service_get_next(servp)))
48 {
49 if( flag == MORE )
50 {
51 if( servp->registered )
52 {
53 continue;
54 }
55 }
56 strcpy( serv_regp->service_name, servp->name );
57 strcpy( serv_regp->service_def, servp->def );
58 if(servp->type == COMMAND)
59 serv_regp->service_id = htovl( servp->id | 0x10000000);
60 else
61 serv_regp->service_id = htovl( servp->id );
62 serv_regp++;
63 n_services++;
64 dis_hash_service_registered(servp);
65/*
66 servp->registered = 1;
67*/
68 if( n_services == MAX_SERVICE_UNIT )
69 {
70 dis_dns_p->n_services = htovl(n_services);
71 dis_dns_p->size = htovl(DIS_DNS_HEADER +
72 n_services * sizeof(SERVICE_REG));
73 if(Dns_dis_conn_id > 0)
74 {
75 if( !dna_write(Dns_dis_conn_id,
76 &Dis_dns_packet,
77 DIS_DNS_HEADER + n_services *
78 sizeof(SERVICE_REG)) )
79 {
80 release_conn(Dns_dis_conn_id,0);
81 }
82 }
83 serv_regp = dis_dns_p->services;
84 n_services = 0;
85 }
86 }
87 if( n_services )
88 {
89 dis_dns_p->n_services = htovl(n_services);
90 dis_dns_p->size = htovl(DIS_DNS_HEADER +
91 n_services * sizeof(SERVICE_REG));
92 if(Dns_dis_conn_id > 0)
93 {
94 if( !dna_write(Dns_dis_conn_id, &Dis_dns_packet,
95 DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)))
96 {
97 release_conn(Dns_dis_conn_id,0);
98 }
99 }
100 }
101}
Note: See TracBrowser for help on using the repository browser.