Implementation of connectivity abstraction feature Release v0.3
[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 /**
35  * @def VERIFY_NON_NULL
36  * @brief Macro to verify the validity of input argument
37  */
38 #define VERIFY_NON_NULL(arg, log_tag, log_message) \
39     if (NULL == arg ){ \
40         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
41         return CA_STATUS_INVALID_PARAM; \
42     } \
43
44 /**
45  * @def VERIFY_NON_NULL_RET
46  * @brief Macro to verify the validity of input argument
47  */
48 #define VERIFY_NON_NULL_RET(arg, log_tag, log_message,ret) \
49     if (NULL == arg ){ \
50         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
51         return ret; \
52     } \
53
54 /**
55  * @def VERIFY_NON_NULL_VOID
56  * @brief Macro to verify the validity of input argument
57  */
58 #define VERIFY_NON_NULL_VOID(arg, log_tag, log_message) \
59     if (NULL == arg ){ \
60         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
61         return; \
62     } \
63
64 /**
65  * @fn CAAdapterCreateLocalEndpoint
66  * @brief Create CALocalConnectivity_t instance.
67  */
68 CALocalConnectivity_t *CAAdapterCreateLocalEndpoint(CAConnectivityType_t type, const char *address,
69         const char *interfaceName);
70
71 /**
72  * @fn CAAdapterCopyLocalEndpoint
73  * @brief Create CALocalConnectivity_t duplicate instance.
74  */
75 CALocalConnectivity_t *CAAdapterCopyLocalEndpoint(CALocalConnectivity_t *connectivity);
76
77 /**
78  * @fn CAAdapterFreeLocalEndpoint
79  * @brief Deallocate CALocalConnectivity_t instance.
80  */
81 void CAAdapterFreeLocalEndpoint(CALocalConnectivity_t *localEndPoint);
82
83 /**
84  * @fn CAAdapterCreateRemoteEndpoint
85  * @brief Allocate CARemoteEndpoint_t instance.
86  */
87 CARemoteEndpoint_t *CAAdapterCreateRemoteEndpoint(CAConnectivityType_t type, const char *address,
88         const char *resourceUri);
89
90 /**
91  * @fn CAAdapterCopyRemoteEndpoint
92  * @brief Create CARemoteEndpoint_t duplicate instance.
93  */
94 CARemoteEndpoint_t *CAAdapterCopyRemoteEndpoint(const CARemoteEndpoint_t *remoteEndpoint);
95
96 /**
97  * @fn CAAdapterFreeRemoteEndpoint
98  * @brief Deallocate CARemoteEndpoint_t instance.
99  */
100 void CAAdapterFreeRemoteEndpoint(CARemoteEndpoint_t *remoteEndPoint);
101
102 #endif  // _CA_ADAPTER_UTILS_H_