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 caipadapter_singlethread.h
23 * @brief This file contains the APIs for IP Adapter.
25 #ifndef CA_IP_ADAPTER_SINGLETHREAD_H_
26 #define CA_IP_ADAPTER_SINGLETHREAD_H_
29 #include "caadapterinterface.h"
37 * @brief API to initialize IP Interface.
38 * @param registerCallback [IN] Callback to register IP interfaces to Connectivity
40 * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
41 * started at Connectivity Abstraction Layer.
42 * @param netCallback [IN] Callback to notify the network additions to Connectivity
44 * @return #CA_STATUS_OK or Appropriate error code
46 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
47 CANetworkPacketReceivedCallback networkPacketCallback,
48 CANetworkChangeCallback netCallback);
51 * @brief Start IP Interface adapter.
52 * @return #CA_STATUS_OK or Appropriate error code
54 CAResult_t CAStartIP();
57 * @brief Start listening server for receiving multicast search requests
58 * Transport Specific Behavior:
59 * IP Starts Multicast Server on all available IPs and prefixed port number and
60 * as per OIC Specification.
61 * @return #CA_STATUS_OK or Appropriate error code
63 CAResult_t CAStartIPListeningServer();
66 * @brief Start discovery servers for receiving multicast advertisements
67 * Transport Specific Behavior:
68 * IP Starts multicast server on all available IPs and prefixed port
69 * number as per OIC Specification
70 * @return #CA_STATUS_OK or Appropriate error code
72 CAResult_t CAStartIPDiscoveryServer();
75 * @brief Sends data to the endpoint using the adapter connectivity.
76 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
77 * reference uri and connectivity type) to which the unicast data has to be sent.
78 * @param data [IN] Data which required to be sent.
79 * @param dataLen [IN] Size of data to be sent.
80 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
81 * @remark dataLen must be > 0.
83 int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
87 * @brief Send Multicast data to the endpoint using the IP connectivity.
88 * @param data [IN] Data which is required to be sent.
89 * @param dataLen [IN] Size of data to be sent.
90 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
91 * @remark dataLen must be > 0.
93 int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);
96 * @brief Get IP Connectivity network information
97 * @param info [OUT] Local connectivity information structures
98 * @param size [OUT] Number of local connectivity structures.
99 * @return #CA_STATUS_OK or Appropriate error code
100 * @remarks info is allocated in this API and should be freed by the caller.
102 CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
105 * @brief Read Synchronous API callback.
106 * @return #CA_STATUS_OK or Appropriate error code
108 CAResult_t CAReadIPData();
111 * @brief Stops Unicast, Multicast servers and close the sockets.
112 * @return #CA_STATUS_OK or Appropriate error code
114 CAResult_t CAStopIP();
117 * @brief Terminate the Ethernet connectivity adapter.
118 * Configuration information will be deleted from further use
121 void CATerminateIP();
127 #endif /* CA_IP_ADAPTER_SINGLETHREAD_H_ */