475eb7571c351361bed7a592bbf3db1b5848f905
[platform/upstream/iotivity.git] / service / resource-directory / include / rd_client.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef _RESOURCE_DIRECTORY_CLIENT_H_
22 #define _RESOURCE_DIRECTORY_CLIENT_H_
23
24 // Iotivity Base CAPI
25 #include "ocstack.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif // __cplusplus
30
31 /** Max ADDR SIZE */
32 #define MAX_ADDR_STR_SIZE                (40)
33
34 /** Callback function for returning RDDiscovery Result. */
35 typedef int (* OCRDBiasFactorCB)(char addr[MAX_ADDR_STR_SIZE], uint16_t port);
36
37 /** Context structure used sending it as part of the callback context. */
38 typedef struct
39 {
40     /** Stores the context value of the message sent. */
41     void *context;
42     /** Pointing to the callback function that OCRDDiscover() received. */
43     OCRDBiasFactorCB cbFunc;
44 } OCRDClientContextCB;
45
46 /**
47  * Discovers the resource directory.
48  * This function searches a RD server and obtain the bias factor.
49  *
50  * @param cbBiasFactor callback function invoked when bias factor is returned by
51  *                     the Resource Directory Server
52  *
53  * @return ::OC_STACK_OK upon success, ::OC_STACK_ERROR in case of error.
54  */
55 OCStackResult OCRDDiscover(OCRDBiasFactorCB cbBiasFactor);
56
57 /**
58  * Publish resource on the RD.
59  *
60  * @param addr The IP address of the RD, it could be either retrieved via OCRDDiscover().
61  * @param port The port of the RD.
62  * @param num This denotes the number of registered resource handles being passed
63  *            for the remaining arguments.
64  *
65  * @returns ::OC_STACK_OK when successful and OC_STACK_ERROR when query failed.
66  */
67 OCStackResult OCRDPublish(char *addr, uint16_t port, int num, ...);
68
69 #ifdef __cplusplus
70 }
71 #endif // __cplusplus
72
73 #endif //_RESOURCE_DIRECTORY_CLIENT_H_