Corrected @file tags and restored 'Files' section.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caethernetadapter_singlethread.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
23  *
24  * This file contains the APIs for Ethernet Adapter.
25  */
26
27 #ifndef __CA_ETHERNET_ADAPTER_SINGLETHREAD_H__
28 #define __CA_ETHERNET_ADAPTER_SINGLETHREAD_H__
29
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /**
39  * @brief API to initialize Ethernet Interface.
40  * @param registerCallback      [IN] Callback to register ETHERNET interfaces to Connectivity
41  *                                   Abstraction Layer
42  * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
43  *                                   started at Connectivity Abstraction Layer.
44  * @param netCallback           [IN] Callback to notify the network additions to Connectivity
45  *                                   Abstraction Layer.
46  * @return  #CA_STATUS_OK or Appropriate error code
47  */
48 CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
49                                 CANetworkPacketReceivedCallback networkPacketCallback,
50                                 CANetworkChangeCallback netCallback);
51
52 /**
53  * @brief Start Ethernet Interface adapter.
54  * @return  #CA_STATUS_OK or Appropriate error code
55  */
56 CAResult_t CAStartEthernet();
57
58 /**
59  * @brief Start listening server for receiving multicast search requests
60  * Transport Specific Behavior:
61  * Ethernet Starts Multicast Server on  all available IPs and prefixed port number and
62  * as per OIC Specification.
63  * @return  #CA_STATUS_OK or Appropriate error code
64  */
65 CAResult_t CAStartEthernetListeningServer();
66
67 /**
68  * @brief Start discovery servers for receiving multicast advertisements
69  * Transport Specific Behavior:
70  * Ethernet Starts multicast server on all available IPs and prefixed port
71  * number as per OIC Specification
72  * @return  #CA_STATUS_OK or Appropriate error code
73  */
74 CAResult_t CAStartEthernetDiscoveryServer();
75
76 /**
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 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  * @remark  dataLen must be > 0.
84  */
85 int32_t CASendEthernetUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
86                                   uint32_t dataLen);
87
88 /**
89  * @brief Send Multicast data to the endpoint using the Ethernet connectivity.
90  * @param   data        [IN]    Data which is 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  * @remark  dataLen must be > 0.
94  */
95 int32_t CASendEthernetMulticastData(const void *data, uint32_t dataLen);
96
97 /**
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.
103  */
104 CAResult_t CAGetEthernetInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
105
106 /**
107  * @brief Read Synchronous API callback.
108  * @return  #CA_STATUS_OK or Appropriate error code
109  */
110 CAResult_t CAReadEthernetData();
111
112 /**
113  * @brief Stops Unicast, Multicast servers and close the sockets.
114  * @return  #CA_STATUS_OK or Appropriate error code
115  */
116 CAResult_t CAStopEthernet();
117
118 /**
119  * @brief Terminate the Ethernet connectivity adapter.
120  * Configuration information will be deleted from further use
121  * @return NONE
122  */
123 void CATerminateEthernet();
124
125 #ifdef __cplusplus
126 } /* extern "C" */
127 #endif
128
129 #endif  // #ifndef __CA_ETHERNET_ADAPTER_SINGLETHREAD_H__
130