Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caipadapter_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 caipadapter_singlethread.h
23  * @brief This file contains the APIs for IP Adapter.
24  */
25 #ifndef CA_IP_ADAPTER_SINGLETHREAD_H_
26 #define CA_IP_ADAPTER_SINGLETHREAD_H_
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @brief API to initialize IP Interface.
38  * @param registerCallback      [IN] Callback to register IP interfaces to Connectivity
39  *                                   Abstraction Layer
40  * @param networkPacketCallback [IN] Callback to notify request and response messages from server(s)
41  *                                   started at Connectivity Abstraction Layer.
42  * @param netCallback           [IN] Callback to notify the network additions to Connectivity
43  *                                   Abstraction Layer.
44  * @return  #CA_STATUS_OK or Appropriate error code
45  */
46 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
47                                 CANetworkPacketReceivedCallback networkPacketCallback,
48                                 CANetworkChangeCallback netCallback);
49
50 /**
51  * @brief Start IP Interface adapter.
52  * @return  #CA_STATUS_OK or Appropriate error code
53  */
54 CAResult_t CAStartIP();
55
56 /**
57  * @brief Start listening server for receiving multicast search requests
58  * Transport Specific Behavior:
59  * IP Starts Multicast Server on  all available IPs and prefixed port number and
60  * as per OIC Specification.
61  * @return  #CA_STATUS_OK or Appropriate error code
62  */
63 CAResult_t CAStartIPListeningServer();
64
65 /**
66  * @brief Start discovery servers for receiving multicast advertisements
67  * Transport Specific Behavior:
68  * IP Starts multicast server on all available IPs and prefixed port
69  * number as per OIC Specification
70  * @return  #CA_STATUS_OK or Appropriate error code
71  */
72 CAResult_t CAStartIPDiscoveryServer();
73
74 /**
75  * @brief Sends data to the endpoint using the adapter connectivity.
76  * @param   endpoint    [IN]    Remote Endpoint information (like ipaddress , port,
77  * reference uri and connectivity type) to which the unicast data has to be sent.
78  * @param   data        [IN]    Data which required to be sent.
79  * @param   dataLen     [IN]    Size of data to be sent.
80  * @return  The number of bytes sent on the network. Return value equal to -1 indicates error.
81  * @remark  dataLen must be > 0.
82  */
83 int32_t CASendIPUnicastData(const CARemoteEndpoint_t *endpoint, const void *data,
84                                   uint32_t dataLen);
85
86 /**
87  * @brief Send Multicast data to the endpoint using the IP connectivity.
88  * @param   data        [IN]    Data which is required to be sent.
89  * @param   dataLen     [IN]    Size of data to be sent.
90  * @return  The number of bytes sent on the network. Return value equal to -1 indicates error.
91  * @remark  dataLen must be > 0.
92  */
93 int32_t CASendIPMulticastData(const void *data, uint32_t dataLen);
94
95 /**
96  * @brief Get IP Connectivity network information
97  * @param   info        [OUT]   Local connectivity information structures
98  * @param   size        [OUT]   Number of local connectivity structures.
99  * @return  #CA_STATUS_OK or Appropriate error code
100  * @remarks info is allocated in this API and should be freed by the caller.
101  */
102 CAResult_t CAGetIPInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
103
104 /**
105  * @brief Read Synchronous API callback.
106  * @return  #CA_STATUS_OK or Appropriate error code
107  */
108 CAResult_t CAReadIPData();
109
110 /**
111  * @brief Stops Unicast, Multicast servers and close the sockets.
112  * @return  #CA_STATUS_OK or Appropriate error code
113  */
114 CAResult_t CAStopIP();
115
116 /**
117  * @brief Terminate the Ethernet connectivity adapter.
118  * Configuration information will be deleted from further use
119  * @return NONE
120  */
121 void CATerminateIP();
122
123 #ifdef __cplusplus
124 } /* extern "C" */
125 #endif
126
127 #endif  /* CA_IP_ADAPTER_SINGLETHREAD_H_ */
128