1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
22 * @file caadapterutils.h
23 * @brief This file contains common utility function for CA transport adaptors.
26 #ifndef _CA_ADAPTER_UTILS_H_
27 #define _CA_ADAPTER_UTILS_H_
33 #include "oic_malloc.h"
34 #include "oic_string.h"
42 * @def VERIFY_NON_NULL
43 * @brief Macro to verify the validity of input argument
45 #define VERIFY_NON_NULL(arg, log_tag, log_message) \
47 OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
48 return CA_STATUS_INVALID_PARAM; \
52 * @def VERIFY_NON_NULL_RET
53 * @brief Macro to verify the validity of input argument
55 #define VERIFY_NON_NULL_RET(arg, log_tag, log_message,ret) \
57 OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
62 * @def VERIFY_NON_NULL_VOID
63 * @brief Macro to verify the validity of input argument
65 #define VERIFY_NON_NULL_VOID(arg, log_tag, log_message) \
67 OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
72 * @fn CAAdapterCreateLocalEndpoint
73 * @brief Create CALocalConnectivity_t instance.
75 CALocalConnectivity_t *CAAdapterCreateLocalEndpoint(CAConnectivityType_t type,
79 * @fn CAAdapterCopyLocalEndpoint
80 * @brief Create CALocalConnectivity_t duplicate instance.
82 CALocalConnectivity_t *CAAdapterCopyLocalEndpoint(CALocalConnectivity_t *connectivity);
85 * @fn CAAdapterFreeLocalEndpoint
86 * @brief Deallocate CALocalConnectivity_t instance.
88 void CAAdapterFreeLocalEndpoint(CALocalConnectivity_t *localEndPoint);
91 * @fn CAAdapterCreateRemoteEndpoint
92 * @brief Allocate CARemoteEndpoint_t instance.
94 CARemoteEndpoint_t *CAAdapterCreateRemoteEndpoint(CAConnectivityType_t type,
95 const char *address, const char *resourceUri);
98 * @fn CAAdapterCopyRemoteEndpoint
99 * @brief Create CARemoteEndpoint_t duplicate instance.
101 CARemoteEndpoint_t *CAAdapterCopyRemoteEndpoint(
102 const CARemoteEndpoint_t *remoteEndpoint);
105 * @fn CAAdapterFreeRemoteEndpoint
106 * @brief Deallocate CARemoteEndpoint_t instance.
108 void CAAdapterFreeRemoteEndpoint(CARemoteEndpoint_t *remoteEndPoint);
111 * @fn CAAdapterIsSameSubnet
112 * @brief Check if two ip address belong to same subnet
114 bool CAAdapterIsSameSubnet(const char *ipAddress1, const char *ipAddress2,
115 const char *netMask);
119 #endif // _CA_ADAPTER_UTILS_H_