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 caethernetadapter.h
23 * @brief This file contains the APIs for Ethernet Adapter.
25 #ifndef __CA_ETHERNET_ADAPTER_H__
26 #define __CA_ETHERNET_ADAPTER_H__
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h"
38 * @brief API to initialize Ethernet Interface.
39 * @param registerCallback [IN] Callback to register ETHERNET 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 CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
49 CANetworkPacketReceivedCallback networkPacketCallback,
50 CANetworkChangeCallback netCallback, u_thread_pool_t handle);
53 * @brief Start Ethernet Interface adapter.
54 * @return #CA_STATUS_OK or Appropriate error code
56 CAResult_t CAStartEthernet();
59 * @brief Start listening server for receiving multicast search requests
60 * Transport Specific Behavior:
61 * Ethernet Starts Multicast Server on a particular interface and prefixed port number and
62 * as per OIC Specification.
63 * @return #CA_STATUS_OK or Appropriate error code
65 CAResult_t CAStartEthernetListeningServer();
68 * @brief Start discovery servers for receiving multicast advertisements
69 * Transport Specific Behavior:
70 * Ethernet Starts Start multicast server on a particular interface and prefixed port
71 * number as per OIC Specification
72 * @return #CA_STATUS_OK or Appropriate error code
74 CAResult_t CAStartEthernetDiscoveryServer();
77 * @brief Sends data to the endpoint using the adapter connectivity.
78 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
79 * reference uri and connectivity type) to which the unicast data has to be sent.
80 * @param data [IN] Data which is required to be sent.
81 * @param dataLen [IN] Size of data to be sent.
82 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
83 * @remarks dataLen must be > 0.
85 int32_t CASendEthernetUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
89 * @brief Sends Multicast data to the endpoint using the Ethernet connectivity.
90 * @param data [IN] Data which required to be sent.
91 * @param dataLen [IN] Size of data to be sent.
92 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
93 * @remarks dataLen must be > 0.
95 int32_t CASendEthernetMulticastData(const void *data, uint32_t dataLen);
98 * @brief Get Ethernet Connectivity network information
99 * @param info [OUT] Local connectivity information structures
100 * @param size [OUT] Number of local connectivity structures.
101 * @return #CA_STATUS_OK or Appropriate error code
102 * @remarks info is allocated in this API and should be freed by the caller.
104 CAResult_t CAGetEthernetInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
107 * @brief Read Synchronous API callback.
108 * @return #CA_STATUS_OK or Appropriate error code
110 CAResult_t CAReadEthernetData();
113 * @brief Stops Unicast, Multicast servers and close the sockets.
114 * @return #CA_STATUS_OK or Appropriate error code
116 CAResult_t CAStopEthernet();
119 * @brief Terminate the Ethernet connectivity adapter.
120 * Configuration information will be deleted from further use
123 void CATerminateEthernet();
129 #endif // #ifndef __CA_ETHERNET_ADAPTER_H__