Imported Upstream version 1.1.0
[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 /** Callback function for returning RDDiscovery Result. */
32 typedef int (* OCRDBiasFactorCB)(char addr[MAX_ADDR_STR_SIZE], uint16_t port);
33
34 /** Context structure used sending it as part of the callback context. */
35 typedef struct
36 {
37     /** Stores the context value of the message sent. */
38     void *context;
39     /** Pointing to the callback function that OCRDDiscover() received. */
40     OCRDBiasFactorCB cbFunc;
41 } OCRDClientContextCB;
42
43 /**
44  * Discovers the resource directory.
45  * This function searches a RD server and obtain the bias factor.
46  *
47  * @param cbBiasFactor callback function invoked when bias factor is returned by
48  *                     the Resource Directory Server
49  *
50  * @return ::OC_STACK_OK upon success, ::OC_STACK_ERROR in case of error.
51  */
52 OCStackResult OCRDDiscover(OCRDBiasFactorCB cbBiasFactor);
53
54 /**
55  * Publish resource on the RD.
56  *
57  * @param addr The IP address of the RD, it could be either retrieved via OCRDDiscover().
58  * @param port The port of the RD.
59  * @param num This denotes the number of registered resource handles being passed
60  *            for the remaining arguments.
61  *
62  * @returns ::OC_STACK_OK when successful and OC_STACK_ERROR when query failed.
63  */
64 OCStackResult OCRDPublish(char *addr, uint16_t port, int num, ...);
65
66 #ifdef __cplusplus
67 }
68 #endif // __cplusplus
69
70 #endif //_RESOURCE_DIRECTORY_CLIENT_H_