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 ******************************************************************/
24 * This file contains the APIs for Ethernet Adapter.
27 #ifndef __CA_ETHERNET_ADAPTER_H__
28 #define __CA_ETHERNET_ADAPTER_H__
31 #include "caadapterinterface.h"
32 #include "cathreadpool.h"
40 * @brief API to initialize Ethernet Interface.
41 * @param registerCallback [IN] Callback to register ETHERNET interfaces to Connectivity
43 * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
44 * started at Connectivity Abstraction Layer.
45 * @param netCallback [IN] Callback to notify the network additions to Connectivity
47 * @param handle [IN] Threadpool Handle
48 * @return #CA_STATUS_OK or Appropriate error code
50 CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
51 CANetworkPacketReceivedCallback networkPacketCallback,
52 CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
55 * @brief Start Ethernet Interface adapter.
56 * @return #CA_STATUS_OK or Appropriate error code
58 CAResult_t CAStartEthernet();
61 * @brief Start listening server for receiving multicast search requests
62 * Transport Specific Behavior:
63 * Ethernet Starts Multicast Server on a particular interface and prefixed port number and
64 * as per OIC Specification.
65 * @return #CA_STATUS_OK or Appropriate error code
67 CAResult_t CAStartEthernetListeningServer();
70 * @brief Start discovery servers for receiving multicast advertisements
71 * Transport Specific Behavior:
72 * Ethernet Starts Start multicast server on a particular interface and prefixed port
73 * number as per OIC Specification
74 * @return #CA_STATUS_OK or Appropriate error code
76 CAResult_t CAStartEthernetDiscoveryServer();
79 * @brief Sends data to the endpoint using the adapter connectivity.
80 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port,
81 * reference uri and connectivity type) to which the unicast data has to be sent.
82 * @param data [IN] Data which is required to be sent.
83 * @param dataLen [IN] Size of data to be sent.
84 * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
85 * @remarks dataLen must be > 0.
87 int32_t CASendEthernetUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
91 * @brief Sends Multicast data to the endpoint using the Ethernet connectivity.
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 CASendEthernetMulticastData(const void *data, uint32_t dataLen);
100 * @brief Get Ethernet 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 CAGetEthernetInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
109 * @brief Read Synchronous API callback.
110 * @return #CA_STATUS_OK or Appropriate error code
112 CAResult_t CAReadEthernetData();
115 * @brief Stops Unicast, Multicast servers and close the sockets.
116 * @return #CA_STATUS_OK or Appropriate error code
118 CAResult_t CAStopEthernet();
121 * @brief Terminate the Ethernet connectivity adapter.
122 * Configuration information will be deleted from further use
125 void CATerminateEthernet();
131 #endif // #ifndef __CA_ETHERNET_ADAPTER_H__