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 ******************************************************************/
23 * This file contains the APIs for IP Adapter.
25 #ifndef CA_IP_ADAPTER_H_
26 #define CA_IP_ADAPTER_H_
29 #include "caadapterinterface.h"
30 #include "cathreadpool.h"
38 * API to initialize IP Interface.
39 * @param[in] registerCallback Callback to register IP interfaces to
40 * Connectivity Abstraction Layer.
41 * @param[in] networkPacketCallback Callback to notify request and
42 * response messages from server(s)
43 * started at Connectivity Abstraction Layer.
44 * @param[in] netCallback Callback to notify the network additions
45 * to Connectivity Abstraction Layer.
46 * @param[in] errorCallback Callback to notify the network errors to
47 * Connectivity Abstraction Layer.
48 * @param[in] handle Threadpool Handle.
49 * @return ::CA_STATUS_OK or Appropriate error code
51 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
52 CANetworkPacketReceivedCallback networkPacketCallback,
53 CANetworkChangeCallback netCallback,
54 CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
57 * Start IP Interface adapter.
58 * @return ::CA_STATUS_OK or Appropriate error code.
60 CAResult_t CAStartIP();
63 * Start listening server for receiving multicast search requests.
64 * Transport Specific Behavior:
65 * IP Starts Multicast Server on a particular interface and prefixed port
66 * number and as per OIC Specification.
67 * @return ::CA_STATUS_OK or Appropriate error code.
69 CAResult_t CAStartIPListeningServer();
72 * Start discovery servers for receiving multicast advertisements.
73 * Transport Specific Behavior:
74 * IP Starts multicast server on a particular interface and prefixed port
75 * number as per OIC Specification.
76 * @return ::CA_STATUS_OK or Appropriate error code.
78 CAResult_t CAStartIPDiscoveryServer();
81 * Sends data to the endpoint using the adapter connectivity.
82 * @param[in] endpoint Remote Endpoint information (like ipaddress,
83 * port, reference uri and transport type) to
84 * which the unicast data has to be sent.
85 * @param[in] data Data which is required to be sent.
86 * @param[in] dataLen Size of data to be sent.
87 * @note dataLen must be > 0.
88 * @return The number of bytes sent on the network, or -1 upon error.
90 int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
94 * Send Multicast data to the endpoint using the IP connectivity.
95 * @param[in] endpoint Remote Endpoint information (like ipaddress,
97 * @param[in] data Data which is required to be sent.
98 * @param[in] dataLen Size of data to be sent.
99 * @note dataLen must be > 0.
100 * @return The number of bytes sent on the network, or -1 upon error.
102 int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);
105 * Get IP Connectivity network information.
106 * @param[out] info Local connectivity information structures.
107 * @note info is allocated in this API and should be freed by the caller.
108 * @param[out] size Number of local connectivity structures.
109 * @return ::CA_STATUS_OK or Appropriate error code.
111 CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
114 * Read Synchronous API callback.
115 * @return ::CA_STATUS_OK or Appropriate error code.
117 CAResult_t CAReadIPData();
120 * Stops Unicast, Multicast servers and close the sockets.
121 * @return ::CA_STATUS_OK or Appropriate error code.
123 CAResult_t CAStopIP();
126 * Terminate the IP connectivity adapter.
127 * Configuration information will be deleted from further use.
129 void CATerminateIP();
135 #endif // CA_IP_ADAPTER_H_