]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/ORTEDomain.c
new version 0.2.3
[orte.git] / orte / liborte / ORTEDomain.c
1 /*
2  *  $Id: ORTEDomain.c,v 0.0.0.1         2003/08/21
3  *
4  *  DEBUG:  section 30                  Domain functions
5  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
6  *
7  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
8  *  --------------------------------------------------------------------
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  */ 
21
22 #include "orte_all.h"
23
24 /*****************************************************************************/
25 void
26 ORTEDomainStart(ORTEDomain *d,
27     Boolean recvMetatrafficThread,Boolean recvUserDataThread,Boolean sendThread) {
28   if(!d) return;
29   if ((recvMetatrafficThread) && (d->taskRecvMetatraffic.terminate)) {
30     d->taskRecvMetatraffic.terminate=ORTE_FALSE;
31     pthread_create(&d->taskRecvMetatraffic.thread, NULL,
32                   (void*)&ORTEAppRecvMetatrafficThread, (void *)d); 
33   }
34   if ((recvUserDataThread) && (d->taskRecvUserdata.terminate)) {
35     d->taskRecvUserdata.terminate=ORTE_FALSE;
36     pthread_create(&d->taskRecvUserdata.thread, NULL,
37                   (void*)&ORTEAppRecvUserdataThread, (void *)d); 
38   }
39   if ((sendThread) && (d->taskSend.terminate)) {
40     d->taskSend.terminate=ORTE_FALSE;
41     pthread_create(&d->taskSend.thread, NULL,
42                   (void*)&ORTEAppSendThread, (void *)d); 
43   }
44 }
45
46 /*****************************************************************************/
47 Boolean
48 ORTEDomainPropDefaultGet(ORTEDomainProp *prop) {
49   sock_t        sock;
50
51   memset(prop, 0, sizeof(*prop));
52
53   prop->multicast.enabled=ORTE_FALSE;
54   prop->multicast.ttl=1;
55   prop->multicast.loopBackEnabled=ORTE_TRUE;
56
57   //IFProp
58   sock_init_udp(&sock);
59   sock_bind(&sock,0);
60   sock_get_local_interfaces(&sock,prop->IFProp,&prop->IFCount);
61   sock_cleanup(&sock); 
62
63   prop->mgrs=NULL; //only from localhost
64   prop->appLocalManager=StringToIPAddress("127.0.0.1");
65   prop->keys=NULL; //are assign be orte
66   sprintf(prop->version,ORTE_PACKAGE_STRING\
67                         ", compiled: "\
68                         __DATE__\
69                         " "\
70                         __TIME__);
71                         
72   prop->recvBuffSize=0x4000;
73   prop->sendBuffSize=0x4000; 
74   prop->wireProp.metaBytesPerPacket=1500;
75   prop->wireProp.metaBytesPerFastPacket=1000;
76   prop->wireProp.metabitsPerACKBitmap=32;
77   prop->wireProp.userMaxSerDeserSize=0x4000;
78   
79   //domainBaseProp
80   NTPTIME_BUILD(prop->baseProp.expirationTime,180); //180s
81   NTPTIME_BUILD(prop->baseProp.refreshPeriod,72);    //72s - refresh self parameters
82   NTPTIME_BUILD(prop->baseProp.purgeTime,60);        //60s - purge time of parameters
83   NTPTIME_BUILD(prop->baseProp.repeatAnnounceTime,72);//72s - announcement by HB
84   NTPTIME_BUILD(prop->baseProp.repeatActiveQueryTime,72);//72s - announcement by ACK
85   NtpTimeAssembFromMs(prop->baseProp.delayResponceTimeACKMin,0,10);//10ms - delay before send ACK
86   NtpTimeAssembFromMs(prop->baseProp.delayResponceTimeACKMax,1,0);//1s
87   NtpTimeAssembFromMs(prop->baseProp.maxBlockTime,20,0);//20s
88   prop->baseProp.ACKMaxRetries=10;
89   prop->baseProp.HBMaxRetries=10;
90   
91   PublParamsInit(&prop->publPropDefault);
92   SubsParamsInit(&prop->subsPropDefault);
93   
94   return ORTE_TRUE;
95 }
96
97 /*****************************************************************************/
98 Boolean
99 ORTEDomainInitEvents(ORTEDomainAppEvents *events) {
100   memset(events,0,sizeof(ORTEDomainAppEvents));
101   return ORTE_TRUE;
102 }