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_singlethread.h
23 * @brief This file contains the APIs for Single threaded Ethernet Adapter.
25 #ifndef __CA_ETHERNET_ADAPTER_SINGLETHREAD_H__
26 #define __CA_ETHERNET_ADAPTER_SINGLETHREAD_H__
29 #include "caadapterinterface.h"
37 * @brief API to initialize Ethernet Interface.
38 * @param registerCallback [IN] To register Ethernet interfaces to Connectivity Abstraction Layer
39 * @param reqRespCallback [IN] sending responses and discovery messages from unicast , multicast servers
40 * @param netCallback [IN] Intimate the network additions to Connectivity Abstraction Layer.
41 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
43 CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
44 CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback);
47 * @brief Start Ethernet Interface adapter.
48 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
50 CAResult_t CAStartEthernet();
53 * @brief Starting listening server for receiving multicast search requests
54 * Transport Specific Behavior:
55 * Ethernet Starts Multicast Server on all available IPs and prefixed port number and as per OIC Specification.
56 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
58 CAResult_t CAStartEthernetListeningServer();
61 * @brief for starting discovery servers for receiving multicast advertisements
62 * Transport Specific Behavior:
63 * Ethernet Starts Start multicast server on all available IPs and prefixed port number as per OIC Specification
64 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
66 CAResult_t CAStartEthernetDiscoveryServer();
69 * @brief Sends data to the endpoint using the adapter connectivity.
70 * Note: length must be > 0.
71 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
72 * which the unicast data has to be sent.
73 * @param data [IN] Data which required to be sent.
74 * @param dataLen [IN] Size of data to be sent.
75 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
77 uint32_t CASendEthernetUnicastData(const CARemoteEndpoint_t *endpoint, void *data,
81 * @brief Sends Multicast data to the endpoint using the Ethernet connectivity.
82 * Note: length must be > 0.
83 * @param data [IN] Data which required to be sent.
84 * @param dataLen [IN] Size of data to be sent.
85 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
87 uint32_t CASendEthernetMulticastData(void *data, uint32_t dataLen);
90 * @brief Starts notification server on Ethernet adapters.
91 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
93 CAResult_t CAStartEthernetNotifyRecvServers();
96 * @brief Send notification information.
97 * Note: length must be > 0.
98 * @param endpoint [IN] Remote Endpoint information (like ipaddress , port, reference uri and connectivity type) to
99 * which the unicast data has to be sent.
100 * @param data [IN] Data which required to be sent.
101 * @param dataLen [IN] Size of data to be sent.
102 * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
104 uint32_t CASendEthernetNotification(const CARemoteEndpoint_t *endpoint, void *data,
107 * @brief Get Ethernet Connectivity network information
108 * @param info [OUT] Local connectivity information structures
109 * @param size [OUT] Number of local connectivity structures.
110 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
112 CAResult_t CAGetEthernetInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
115 * @brief Read Synchronous API callback.
116 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
118 CAResult_t CAReadEthernetData();
121 * @brief Stopping the adapters and close socket connections
122 * Ethernet Stops all multicast and unicast servers and close sockets.
123 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
125 CAResult_t CAStopEthernet();
128 * @brief Terminate the Ethernet connectivity adapter.
129 * Configuration information will be deleted from further use
131 void CATerminateEthernet();
137 #endif//#ifndef __CA_ETHERNET_ADAPTER_H__