Merge "Implementation of connectivity abstraction feature Release v0.5" into connecti...
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caadapterutils.h
1 /******************************************************************
2  *
3  * Copyright 2014 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 /**
22  * @file caadapterutils.h
23  * @brief This file contains common utility function for CA transport adaptors.
24  */
25
26 #ifndef _CA_ADAPTER_UTILS_H_
27 #define _CA_ADAPTER_UTILS_H_
28
29 #include "cacommon.h"
30 #include "logger.h"
31 #include "oic_malloc.h"
32 #include "oic_string.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * @def VERIFY_NON_NULL
41  * @brief Macro to verify the validity of input argument
42  */
43 #define VERIFY_NON_NULL(arg, log_tag, log_message) \
44     if (NULL == arg ){ \
45         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
46         return CA_STATUS_INVALID_PARAM; \
47     } \
48
49 /**
50  * @def VERIFY_NON_NULL_RET
51  * @brief Macro to verify the validity of input argument
52  */
53 #define VERIFY_NON_NULL_RET(arg, log_tag, log_message,ret) \
54     if (NULL == arg ){ \
55         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
56         return ret; \
57     } \
58
59 /**
60  * @def VERIFY_NON_NULL_VOID
61  * @brief Macro to verify the validity of input argument
62  */
63 #define VERIFY_NON_NULL_VOID(arg, log_tag, log_message) \
64     if (NULL == arg ){ \
65         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
66         return; \
67     } \
68
69 /**
70  * @fn CAAdapterCreateLocalEndpoint
71  * @brief Create CALocalConnectivity_t instance.
72  */
73 CALocalConnectivity_t *CAAdapterCreateLocalEndpoint(CAConnectivityType_t type, 
74             const char *address,const char *interfaceName);
75
76 /**
77  * @fn CAAdapterCopyLocalEndpoint
78  * @brief Create CALocalConnectivity_t duplicate instance.
79  */
80 CALocalConnectivity_t *CAAdapterCopyLocalEndpoint(CALocalConnectivity_t *connectivity);
81
82 /**
83  * @fn CAAdapterFreeLocalEndpoint
84  * @brief Deallocate CALocalConnectivity_t instance.
85  */
86 void CAAdapterFreeLocalEndpoint(CALocalConnectivity_t *localEndPoint);
87
88 /**
89  * @fn CAAdapterCreateRemoteEndpoint
90  * @brief Allocate CARemoteEndpoint_t instance.
91  */
92 CARemoteEndpoint_t *CAAdapterCreateRemoteEndpoint(CAConnectivityType_t type, 
93             const char *address,const char *resourceUri);
94
95 /**
96  * @fn CAAdapterCopyRemoteEndpoint
97  * @brief Create CARemoteEndpoint_t duplicate instance.
98  */
99 CARemoteEndpoint_t *CAAdapterCopyRemoteEndpoint(const CARemoteEndpoint_t *remoteEndpoint);
100
101 /**
102  * @fn CAAdapterFreeRemoteEndpoint
103  * @brief Deallocate CARemoteEndpoint_t instance.
104  */
105 void CAAdapterFreeRemoteEndpoint(CARemoteEndpoint_t *remoteEndPoint);
106
107 #ifdef __cplusplus
108 } /* extern "C" */
109 #endif
110 #endif  // _CA_ADAPTER_UTILS_H_