1 /* ****************************************************************
3 * Copyright 2016 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 ******************************************************************/
30 * This namespace contains the main entrance/functionality to monitoring network changes.
31 * It may be used with OC::CAManager::functionName. To set a custom callback function,
32 * the implementer must make a call to CAManager::setNetworkMonitorHandler.
37 * Data structure to provide the configuration for cautil.
41 /** the flag for ble advertising. */
42 OCTransportBTFlags_t bleFlag;
46 : bleFlag(OC_DEFAULT_BT_FLAGS)
48 CAUtilConfig(OCTransportBTFlags_t bleFlag_)
53 // typedef to get adapter status changes from CA.
54 typedef std::function<void(const std::string&, OCConnectivityType,
55 bool)> ConnectionChangedCallback;
57 // typedef to get connection status changes from CA.
58 typedef std::function<void(OCTransportAdapter, bool)> AdapterChangedCallback;
61 * Set network monitoring handler.
62 * @param adapterHandler adapter state change handler to handle changes for
63 * any transport types.
64 * @param connectionHandler connection state change handler to handle changes for
65 * connection with remote devices.
66 * @return Returns ::OC_STACK_OK if success.
68 OCStackResult setNetworkMonitorHandler(AdapterChangedCallback adapterHandler,
69 ConnectionChangedCallback connectionHandler);
72 * Set port number to use.
73 * @param adapter transport adapter type to assign the specified port number.
74 * @param flag transport flag information.
75 * @param port the specified port number to use.
76 * @return Returns ::OC_STACK_OK if success.
78 OCStackResult setPortNumberToAssign(OCTransportAdapter adapter,
79 OCTransportFlags flag, uint16_t port);
82 * Get the assigned port number.
83 * @param adapter transport adapter type to get the opened port number.
84 * @param flag transport flag information.
85 * @return Returns currently assigned port number.
87 uint16_t getAssignedPortNumber(OCTransportAdapter adapter, OCTransportFlags flag);
90 * Set multicast time to live to control the scope of the multicasts.
91 * @param ttl To be set to any value from 0 to 255.
93 * 0: Are restricted to the same host.
94 * 1: Are restricted to the same subnet.
95 * 32: Are restricted to the same site.
96 * 64: Are restricted to the same region.
97 * 128: Are restricted to the same continent.
98 * 255: Are unrestricted in scope.
99 * We cannot support region, continent and unrestricted in scope.
100 * @return Returns ::OC_STACK_OK if success.
102 OCStackResult setMulticastTTL(size_t ttl);
105 * Get multicast time to live.
106 * @param ttl TTL pointer to get the stored multicast time to live.
107 * @return Returns ::OC_STACK_OK if success.
109 OCStackResult getMulticastTTL(size_t *ttl);
113 * @param[in] config ::CAUtilConfig data
114 * @return Returns ::OC_STACK_OK if success.
116 OCStackResult setBTConfigure(const CAUtilConfig& config);
119 * set CAUtil log preference.
120 * @param[in] level ::OCLogLevel value.
121 * @param[in] hidePrivateLogEntries Private Log Entries.
123 * true : hide private log.
124 * false : show private log.
125 * (privacy : uid, did, access token, etc)
127 void setLogLevel(OCLogLevel level, bool hidePrivateLogEntries);
130 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
131 OCStackResult setAdvertisementData(const char* data, int length);
134 * Set function that will be called before starting advertising.
135 * Provided data and length will be used to set advertisement data.
136 * @param[in] getter Custom bluetooth advertisement data getter callback.
138 void setAdvertisementDataGetter(CAAdvertisementDataGetterCB getter);
141 * set if advertising should be started automatically.
142 * By default advertising is automatically started.
143 * @param[in] autoAdvertisement true for automatic start
145 void setAutoAdvertisement(bool autoAdvertisement);
148 * Scan and set data for custom bluetooth advertisement.
149 * @param[in] data Array with custom bluetooth advertisement data.
150 * @param[in] lenght Lenght of data array.
152 OCStackResult setScanResponseData(const char* data, int length);
156 * start BLE advertising.
157 * @return Returns ::OC_STACK_OK if success.
159 OCStackResult startLEAdvertising();
162 * stop BLE advertising.
163 * @return Returns ::OC_STACK_OK if success.
165 OCStackResult stopLEAdvertising();
168 * Disconnect TCP session.
169 * When there is no transmission for a long time.
170 * Some carrier Vendor is blocking data.
171 * Thur, TCP Session is cleaned through this function.
172 * @param[in] address Address.
173 * @param[in] port Port.
174 * @param[in] flags Transport flag.
175 * @return Returns ::OC_STACK_OK if success.
177 OCStackResult disconnectTCPSession(const char *address,
179 OCTransportFlags flags);
181 OCStackResult startCAGattServer();
182 OCStackResult stopCAGattServer();
183 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
185 * Select the cipher suite for TLS/DTLS handshake.
186 * @param cipher cipher suite (Note : Make sure endianness).
187 * TLS_RSA_WITH_AES_256_CBC_SHA256 0x3D
188 * TLS_RSA_WITH_AES_128_GCM_SHA256 0x009C
189 * TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B
190 * TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE
191 * TLS_ECDHE_ECDSA_WITH_AES_128_CCM 0xC0AC
192 * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023
193 * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024
194 * TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C
195 * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0xC037
196 * TLS_ECDH_anon_WITH_AES_128_CBC_SHA 0xC018
197 * @param adapter transport adapter type.
198 * @return Returns ::OC_STACK_OK if success.
200 OCStackResult setCipherSuite(const uint16_t cipher, OCTransportAdapter adapter);
201 #endif // defined(__WITH_DTLS__) || defined(__WITH_TLS__)
205 #endif // CA_MANAGER_H_