Replace glib threadpool usage with a 'dumb' thread implementation.
[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
23  *
24  * This file contains the APIs for Ethernet Adapter.
25  */
26
27 #ifndef __CA_ETHERNET_ADAPTER_H__
28 #define __CA_ETHERNET_ADAPTER_H__
29
30 #include "cacommon.h"
31 #include "caadapterinterface.h"
32 #include "cathreadpool.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * @brief API to initialize Ethernet Interface.
41  * @param registerCallback      [IN] Callback to register ETHERNET interfaces to Connectivity
42  *                                   Abstraction Layer
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
46  *                                   Abstraction Layer.
47  * @param handle                [IN] Threadpool Handle
48  * @return  #CA_STATUS_OK or Appropriate error code
49  */
50 CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
51                                 CANetworkPacketReceivedCallback networkPacketCallback,
52                                 CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
53
54 /**
55  * @brief Start Ethernet Interface adapter.
56  * @return  #CA_STATUS_OK or Appropriate error code
57  */
58 CAResult_t CAStartEthernet();
59
60 /**
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
66  */
67 CAResult_t CAStartEthernetListeningServer();
68
69 /**
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
75  */
76 CAResult_t CAStartEthernetDiscoveryServer();
77
78 /**
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.
86  */
87 int32_t CASendEthernetUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
88                                    uint32_t dataLen);
89
90 /**
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.
96  */
97 int32_t CASendEthernetMulticastData(const void *data, uint32_t dataLen);
98
99 /**
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.
105  */
106 CAResult_t CAGetEthernetInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
107
108 /**
109  * @brief Read Synchronous API callback.
110  * @return  #CA_STATUS_OK or Appropriate error code
111  */
112 CAResult_t CAReadEthernetData();
113
114 /**
115  * @brief Stops Unicast, Multicast servers and close the sockets.
116  * @return  #CA_STATUS_OK or Appropriate error code
117  */
118 CAResult_t CAStopEthernet();
119
120 /**
121  * @brief Terminate the Ethernet connectivity adapter.
122  * Configuration information will be deleted from further use
123  * @return  NONE
124  */
125 void CATerminateEthernet();
126
127 #ifdef __cplusplus
128 } /* extern "C" */
129 #endif
130
131 #endif  // #ifndef __CA_ETHERNET_ADAPTER_H__
132