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 * @brief 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 * @brief API to initialize IP Interface.
39 * @param registerCallback [IN] Callback to register IP interfaces to Connectivity
41 * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
42 * started at Connectivity Abstraction Layer.
43 * @param netCallback [IN] Callback to notify the network additions to Connectivity
45 * @param handle [IN] Threadpool Handle
46 * @return #CA_STATUS_OK or Appropriate error code
48 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
49 CANetworkPacketReceivedCallback networkPacketCallback,
50 CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
54 * @brief Start IP Interface adapter.
55 * @return #CA_STATUS_OK or Appropriate error code
57 CAResult_t CAStartIP();
60 * @brief Start listening server for receiving multicast search requests
61 * Transport Specific Behavior:
62 * IP Starts Multicast Server on a particular interface and prefixed port number and
63 * as per OIC Specification.
64 * @return #CA_STATUS_OK or Appropriate error code
66 CAResult_t CAStartIPListeningServer();
69 * @brief Start discovery servers for receiving multicast advertisements
70 * Transport Specific Behavior:
71 * IP Starts Start multicast server on a particular interface and prefixed port
72 * number as per OIC Specification
73 * @return #CA_STATUS_OK or Appropriate error code
75 CAResult_t CAStartIPDiscoveryServer();
78 * @brief Sends data to the endpoint using the adapter connectivity.
79 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
80 * reference uri and transport type) to which the unicast data has to be sent.
81 * @param data [IN] Data which is required to be sent.
82 * @param dataLen [IN] Size of data to be sent.
83 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
84 * @remarks dataLen must be > 0.
86 int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
90 * @brief Sends Multicast data to the endpoint using the IP connectivity.
91 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port)
92 * @param data [IN] Data which required to be sent.
93 * @param dataLen [IN] Size of data to be sent.
94 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
95 * @remarks dataLen must be > 0.
97 int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);
100 * @brief Get IP Connectivity network information
101 * @param info [OUT] Local connectivity information structures
102 * @param size [OUT] Number of local connectivity structures.
103 * @return #CA_STATUS_OK or Appropriate error code
104 * @remarks info is allocated in this API and should be freed by the caller.
106 CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
109 * @brief Read Synchronous API callback.
110 * @return #CA_STATUS_OK or Appropriate error code
112 CAResult_t CAReadIPData();
115 * @brief Stops Unicast, Multicast servers and close the sockets.
116 * @return #CA_STATUS_OK or Appropriate error code
118 CAResult_t CAStopIP();
121 * @brief Terminate the IP connectivity adapter.
122 * Configuration information will be deleted from further use
125 void CATerminateIP();
131 #endif // #ifndef CA_IP_ADAPTER_H_