2 * $Id: protos_api.h,v 0.0.0.1 2003/09/10
4 * AUTHOR: Petr Smolik petr.smolik@wo.cz
6 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
7 * --------------------------------------------------------------------
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
28 ///////////////////////////////////////////////////////////////////////////////
31 * IPAddressToString - converts IP address IPAddress to its string representation
32 * @ipAddress: source IP address
33 * @buff: output buffer
36 IPAddressToString(IPAddress ipAddress,char *buff);
39 * StringToIPAddress - converts IP address from string into IPAddress
40 * @string: source string
43 StringToIPAddress(const char *string);
46 * NtpTimeToStringMs - converts NtpTime to its text representation in miliseconds
47 * @time: time given in NtpTime structure
48 * @buff: output buffer
51 NtpTimeToStringMs(NtpTime time,char *buff);
54 * NtpTimeToStringUs - converts NtpTime to its text representation in microseconds
55 * @time: time given in NtpTime structure
56 * @buff: output buffer
59 NtpTimeToStringUs(NtpTime time,char *buff);
62 ///////////////////////////////////////////////////////////////////////////////
65 * ORTEDomainStart - start specific threads
66 * @d: domain object handle
67 * @recvUnicastMetatrafficThread: specifies whether recvUnicastMetatrafficThread should be started (ORTE_TRUE) or remain suspended (ORTE_FALSE).
68 * @recvMulticastMetatrafficThread: specifies whether recvMulticastMetatrafficThread should be started (ORTE_TRUE) or remain suspended (ORTE_FALSE).
69 * @recvUnicastUserdataThread: specifies whether recvUnicastUserdataThread should be started (ORTE_TRUE) or remain suspended (ORTE_FALSE).
70 * @recvMulticastUserdataThread: specifies whether recvMulticastUserdataThread should be started (ORTE_TRUE) or remain suspended (ORTE_FALSE).
71 * @sendThread: specifies whether sendThread should be started (ORTE_TRUE) or remain suspended (ORTE_FALSE).
73 * Functions @ORTEDomainAppCreate and @ORTEDomainMgrCreate provide facility to create an object with its threads suspended. Use function @ORTEDomainStart to resume those
77 ORTEDomainStart(ORTEDomain *d,
78 Boolean recvUnicastMetatrafficThread,
79 Boolean recvMulticastMetatrafficThread,
80 Boolean recvUnicastUserdataThread,
81 Boolean recvMulticastUserdataThread,
84 * ORTEDomainPropDefaultGet - returns default properties of a domain
85 * @prop: pointer to struct ORTEDomainProp
87 * Structure ORTEDomainProp referenced by @prop will be filled by its default values. Returns ORTE_TRUE if successful or ORTE_FALSE in case of any error.
90 ORTEDomainPropDefaultGet(ORTEDomainProp *prop);
93 * ORTEDomainInitEvents - initializes list of events
94 * @events: pointer to struct ORTEDomainAppEvents
96 * Initializes structure pointed by @events. Every member is set to NULL. Returns ORTE_TRUE if successful or ORTE_FALSE in case of any error.
99 ORTEDomainInitEvents(ORTEDomainAppEvents *events);
102 ///////////////////////////////////////////////////////////////////////////////
105 * ORTEDomainAppCreate - creates an application object within given domain
106 * @domain: given domain
107 * @prop: properties of application
108 * @events: events associated with application or NULL
109 * @suspended: specifies whether threads of this application should be started as well (ORTE_FALSE) or stay suspended (ORTE_TRUE). See @ORTEDomainStart for details how to resume
112 * Creates new Application object and sets its properties and events. Return handle to created object or NULL in case of any error.
115 ORTEDomainAppCreate(int domain,ORTEDomainProp *prop,ORTEDomainAppEvents *events,
119 * ORTEDomainAppDestroy - destroy Application object
122 * Destroys all application objects in specified domain. Returns ORTE_TRUE or ORTE_FALSE in case of any error.
125 ORTEDomainAppDestroy(ORTEDomain *d);
128 * ORTEDomainAppSubscriptionPatternAdd - create pattern-based subscription
130 * @topic: pattern for topic
131 * @type: pattern for type
132 * @subscriptionCallBack: pointer to callback function which will be called whenever any data are received through this subscription
133 * @param: user params for callback function
135 * This function is intended to be used in application interesded in more published data from possibly more remote applications, which should be received through single
136 * subscription. These different publications are specified by pattern given to @topic and @type parameters.
138 * For example suppose there are publications of topics like @temperatureEngine1, @temperatureEngine2, @temperatureEngine1Backup and @temperatureEngine2Backup
139 * somewhere on our network. We can subscribe to each of Engine1 temperations by creating single subscription with pattern for topic set to "temperatureEngine1*".
140 * Or, if we are interested only in values from backup measurements, we can use pattern "*Backup".
142 * Syntax for patterns is the same as syntax for @fnmatch function, which is employed for pattern recognition.
144 * Returns ORTE_TRUE if successful or ORTE_FALSE in case of any error.
148 ORTEDomainAppSubscriptionPatternAdd(ORTEDomain *d,const char *topic,
149 const char *type,ORTESubscriptionPatternCallBack subscriptionCallBack,
153 * ORTEDomainAppSubscriptionPatternRemove - remove subscription pattern
155 * @topic: pattern to be removed
156 * @type: pattern to be removed
158 * Removes subscritions created by @ORTEDomainAppSubscriptionPatternAdd. Patterns for @type and @topic must be exactly the same strings as when
159 * @ORTEDomainAppSubscriptionPatternAdd function was called.
161 * Returns ORTE_TRUE if successful or ORTE_FALSE if none matching record was found
164 ORTEDomainAppSubscriptionPatternRemove(ORTEDomain *d,const char *topic,
168 * ORTEDomainAppSubscriptionPatternDestroy - destroys all subscription patterns
171 * Destroys all subscription patterns which were specified previously by @ORTEDomainAppSubscriptionPatternAdd function.
173 * Returns ORTE_TRUE if successful or ORTE_FALSE in case of any error.
176 ORTEDomainAppSubscriptionPatternDestroy(ORTEDomain *d);
178 ///////////////////////////////////////////////////////////////////////////////
182 * ORTEDomainMgrCreate - create manager object in given domain
183 * @domain: given domain
184 * @prop: desired manager's properties
185 * @events: manager's event handlers or NULL
186 * @suspended: specifies whether threads of this manager should be started as well (ORTE_FALSE) or stay suspended (ORTE_TRUE). See @ORTEDomainStart for details how to resume
189 * Creates new manager object and sets its properties and events. Return handle to created object or NULL in case of any error.
192 ORTEDomainMgrCreate(int domain, ORTEDomainProp *prop,
193 ORTEDomainAppEvents *events,Boolean suspended);
196 * ORTEDomainMgrDestroy - destroy manager object
197 * @d: manager object to be destroyed
199 * Returns ORTE_TRUE if successful or ORTE_FALSE in case of any error.
202 ORTEDomainMgrDestroy(ORTEDomain *d);
204 ///////////////////////////////////////////////////////////////////////////////
207 * ORTEAppPubAdd - creates new publication
208 * @d: pointer to application object
209 * @topic: name of topic
210 * @typeName: data type description
211 * @instance: output buffer where application stores data for publication
212 * @persistence: persistence of publication
213 * @strength: strength of publication
214 * @sendCallBack: pointer to callback function
215 * @sendCallBackParam: user parameters for callback function
216 * @sendCallBackDelay: periode for timer which issues callback function
218 * Creates new publication object with specified parameters. The @sendCallBack function is called periodically with @sendCallBackDelay periode. In strict reliable mode the @sendCallBack
219 * function will be called only if there is enough room in transmitting queue in order to prevent any data loss. The @sendCallBack function should prepare data to be published by
220 * this publication and place them into @instance buffer.
222 * Returns handle to publication object.
224 extern ORTEPublication *
225 ORTEPublicationCreate(ORTEDomain *d,
227 const char *typeName,
229 NtpTime *persistence,
231 ORTESendCallBack sendCallBack,
232 void *sendCallBackParam,
233 NtpTime *sendCallBackDelay);
235 * ORTEPublicationDestroy - removes a publication
236 * @cstWriter: handle to publication to be removed
238 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstWriter is not valid cstWriter handle.
241 ORTEPublicationDestroy(ORTEPublication *cstWriter);
245 * ORTEPublicationPropertiesGet - read properties of a publication
246 * @cstWriter: pointer to cstWriter object which provides this publication
247 * @pp: pointer to ORTEPublProp structure where values of publication's properties will be stored
249 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstWriter is not valid cstWriter handle.
251 ORTEPublicationPropertiesGet(ORTEPublication *cstWriter,ORTEPublProp *pp);
254 * ORTEPublicationPropertiesSet - set properties of a publication
255 * @cstWriter: pointer to cstWriter object which provides this publication
256 * @pp: pointer to ORTEPublProp structure containing values of publication's properties
258 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstWriter is not valid publication handle.
261 ORTEPublicationPropertiesSet(ORTEPublication *cstWriter,ORTEPublProp *pp);
264 * ORTEAppPublWaitForSubs - waits for given number of subscriptions
265 * @cstWriter: pointer to cstWriter object which provides this publication
266 * @wait: time how long to wait
267 * @retries: number of retries if specified number of subscriptions was not reached
268 * @noSubscriptions: desired number of subscriptions
270 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstWriter is not valid publication handle or ORTE_TIMEOUT if number of retries has been exhausted.
273 ORTEPublicationWaitForSubscriptions(ORTEPublication *cstWriter,
275 unsigned int retries,
276 unsigned int noSubscriptions);
279 * ORTEPublicationGetStatus - removes a publication
280 * @cstWriter: pointer to cstWriter object which provides this publication
281 * @status: pointer to ORTEPublStatus structure
283 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @happ is not valid publication handle.
287 ORTEPublicationGetStatus(ORTEPublication *cstWriter,ORTEPublStatus *status);
290 * ORTEPublicationSend - force publication object to issue new data
291 * @cstWriter: publication object
293 * Returns ORTE_OK if successful.
296 ORTEPublicationSend(ORTEPublication *cstWriter);
299 * ORTEPublicationSendEx - force publication object to issue new data with additional parameters
300 * @cstWriter: publication object
301 * @psp: publication parameters
303 * Returns ORTE_OK if successful.
306 ORTEPublicationSendEx(ORTEPublication *cstWriter,
307 ORTEPublicationSendParam *psp);
310 * ORTEPublicationGetInstance - return pointer to an instance
311 * @cstWriter: publication object
316 ORTEPublicationGetInstance(ORTEPublication *cstWriter);
319 ///////////////////////////////////////////////////////////////////////////////
320 // ORTESubscription.c
323 * ORTESubscriptionCreate - adds a new subscription
324 * @d: pointer to ORTEDomain object where this subscription will be created
325 * @mode: see enum SubscriptionMode
326 * @sType: see enum SubscriptionType
327 * @topic: name of topic
328 * @typeName: name of data type
329 * @instance: pointer to output buffer
330 * @deadline: deadline
331 * @minimumSeparation: minimum time interval between two publications sent by Publisher as requested by Subscriber (strict - minumSep musi byt 0)
332 * @recvCallBack: callback function called when new Subscription has been received or if any change of subscription's status occures
333 * @recvCallBackParam: user parameters for @recvCallBack
334 * @multicastIPAddress: in case multicast subscripton specify multicast IP address or use IPADDRESS_INVALID to unicast communication
336 * Returns handle to Subscription object.
338 extern ORTESubscription *
339 ORTESubscriptionCreate(ORTEDomain *d,
340 SubscriptionMode mode,
341 SubscriptionType sType,
343 const char *typeName,
346 NtpTime *minimumSeparation,
347 ORTERecvCallBack recvCallBack,
348 void *recvCallBackParam,
349 IPAddress multicastIPAddress);
352 * ORTESubscriptionDestroy - removes a subscription
353 * @cstReader: handle to subscriotion to be removed
355 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstReader is not valid subscription handle.
358 ORTESubscriptionDestroy(ORTESubscription *cstReader);
361 * ORTESubscriptionPropertiesGet - get properties of a subscription
362 * @cstReader: handle to publication
363 * @sp: pointer to ORTESubsProp structure where properties of subscrition will be stored
366 ORTESubscriptionPropertiesGet(ORTESubscription *cstReader,ORTESubsProp *sp);
369 * ORTESubscriptionPropertiesSet - set properties of a subscription
370 * @cstReader: handle to publication
371 * @sp: pointer to ORTESubsProp structure containing desired properties of the subscription
373 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstReader is not valid subscription handle.
376 ORTESubscriptionPropertiesSet(ORTESubscription *cstReader,ORTESubsProp *sp);
379 * ORTESubscriptionWaitForPublications - waits for given number of publications
380 * @cstReader: handle to subscription
381 * @wait: time how long to wait
382 * @retries: number of retries if specified number of publications was not reached
383 * @noPublications: desired number of publications
385 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstReader is not valid subscription handle or ORTE_TIMEOUT if number of retries has been exhausted..
388 ORTESubscriptionWaitForPublications(ORTESubscription *cstReader,NtpTime wait,
389 unsigned int retries,unsigned int noPublications);
392 * ORTESubscriptionGetStatus - get status of a subscription
393 * @cstReader: handle to subscription
394 * @status: pointer to ORTESubsStatus structure
396 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstReader is not valid subscription handle.
399 ORTESubscriptionGetStatus(ORTESubscription *cstReader,ORTESubsStatus *status);
402 * ORTESubscriptionPull - read data from receiving buffer
403 * @cstReader: handle to subscription
405 * Returns ORTE_OK if successful or ORTE_BAD_HANDLE if @cstReader is not valid subscription handle.
408 ORTESubscriptionPull(ORTESubscription *cstReader);
411 * ORTESubscriptionGetInstance - return pointer to an instance
412 * @cstReader: publication object
417 ORTESubscriptionGetInstance(ORTESubscription *cstReader);
420 ///////////////////////////////////////////////////////////////////////////////
421 // ORTETypeRegister.c
423 * ORTETypeRegisterAdd - register new data type
424 * @d: domain object handle
425 * @typeName: name of data type
426 * @ts: pointer to serialization function. If NULL data will be copied without any processing.
427 * @ds: deserialization function. If NULL data will be copied without any processing.
428 * @gms: pointer to a function given maximum length of data (in bytes)
429 * @ms: default maximal size
431 * Each data type has to be registered. Main purpose of this process is to define serialization and deserialization functions for given data type. The same data type can be
432 * registered several times, previous registrations of the same type will be overwritten.
434 * Examples of serialization and deserialization functions can be found if contrib/shape/ortedemo_types.c file.
436 * Returns ORTE_OK if new data type has been succesfully registered.
439 ORTETypeRegisterAdd(ORTEDomain *d,const char *typeName,ORTETypeSerialize ts,
440 ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,unsigned int ms);
442 * ORTETypeRegisterDestroyAll - destroy all registered data types
443 * @d: domain object handle
445 * Destroys all data types which were previously registered by function @ORTETypeRegisterAdd.
447 * Return ORTE_OK if all data types has been succesfully destroyed.
450 ORTETypeRegisterDestroyAll(ORTEDomain *d);
452 ///////////////////////////////////////////////////////////////////////////////
455 * ORTEVerbositySet - set verbosity options
456 * @options: verbosity options
458 * There are 10 levels of verbosity ranging from 1 (lowest) to 10 (highest).
459 * It is possible to specify certain level of verbosity for each module of ORTE library. List of all supported modules can be found in linorte/usedSections.txt file.
460 * Every module has been aasigned with a number as can be seen in usedSections.txt file.
464 * Verbosity will be set to level 7 for all modules.
466 * options = "51,7:32,5"
467 * Modules 51 (RTPSCSTWrite.c) will use verbosity level 7 and module 32 (ORTEPublicationTimer.c) will use verbosity level 5.
469 * Maximum number of modules and verbosity levels can be changed in order to save some memory space if small memory footprint is neccessary. These values are defined as macros
470 * MAX_DEBUG_SECTIONS and MAX_DEBUG_LEVEL in file @include/defines.h.
472 * Return ORTE_OK if desired verbosity levels were successfuly set.
475 ORTEVerbositySetOptions(const char *options);
478 * ORTEVerbositySetLogFile - set log file
479 * @logfile: log file name
481 * Sets output file where debug messages will be writen to. By default these messages are written to stdout.
484 ORTEVerbositySetLogFile(const char *logfile);
487 ///////////////////////////////////////////////////////////////////////////////
491 * ORTEInit - initialization of ORTE layer (musi se zavolat)
494 extern void ORTEInit(void);
496 ///////////////////////////////////////////////////////////////////////////////
499 * ORTESleepMs - suspends calling thread for given time
500 * @ms: miliseconds to sleep
503 ORTESleepMs(unsigned int ms);
509 #endif /* _PROTOS_API_H */