iotivity 0.9.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caethernetadapter.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file caethernetadapter.h
23  * @brief This file contains the APIs for Ethernet Adapter.
24  */
25 #ifndef __CA_ETHERNET_ADAPTER_H__
26 #define __CA_ETHERNET_ADAPTER_H__
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @brief Initialize Ethernet connectivity 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)
42  */
43 CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
44         CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback);
45
46 /**
47  * @brief Start Ethernet Interface adapter.
48  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
49  */
50 CAResult_t CAStartEthernet();
51
52 /**
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)
57  */
58 CAResult_t CAStartEthernetListeningServer();
59
60 /**
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)
65  */
66 CAResult_t CAStartEthernetDiscoveryServer();
67
68 /**
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.
76  */
77 uint32_t CASendEthernetUnicastData(const CARemoteEndpoint_t* endpoint, void* data,
78         uint32_t dataLen);
79
80 /**
81  * @brief Sends Multicast data to the endpoint using the WIFI 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.
86  */
87 uint32_t CASendEthernetMulticastData(void* data, uint32_t dataLen);
88
89 /**
90  * @brief Starts notification server on Ethernet adapters.
91  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
92  */
93 CAResult_t CAStartEthernetNotifyServer();
94
95 /**
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.
103  */
104 uint32_t CASendEthernetNotification(const CARemoteEndpoint_t* endpoint, void* data,
105         uint32_t dataLen);
106 /**
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)
111  */
112 CAResult_t CAGetEthernetInterfaceInformation(CALocalConnectivityt_t** info, uint32_t* size);
113
114 /**
115  * @brief Read Synchronous API callback.
116  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
117  */
118 CAResult_t CAReadEthernetData();
119
120 /**
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)
124  */
125 CAResult_t CAStopEthernet();
126
127 /**
128  * @brief Terminate the Ethernet connectivity adapter.
129  * Configuration information will be deleted from further use
130  */
131 void CATerminateEthernet();
132
133 #ifdef __cplusplus
134 } /* extern "C" */
135 #endif
136
137 #endif