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 ******************************************************************/
29 * This namespace contains the main entrance/functionality to monitoring network changes.
30 * It may be used with OC::CAManager::functionName. To set a custom callback function,
31 * the implementer must make a call to CAManager::setNetworkMonitorHandler.
36 * Data structure to provide the configuration for cautil.
40 /** the flag for ble advertising. */
41 OCTransportBTFlags_t bleFlag;
45 : bleFlag(OC_DEFAULT_BT_FLAGS)
47 CAUtilConfig(OCTransportBTFlags_t bleFlag_)
52 // typedef to get adapter status changes from CA.
53 typedef std::function<void(const std::string&, OCConnectivityType,
54 bool)> ConnectionChangedCallback;
56 // typedef to get connection status changes from CA.
57 typedef std::function<void(OCTransportAdapter, bool)> AdapterChangedCallback;
60 * Set network monitoring handler.
61 * @param adapterHandler adapter state change handler to handle changes for
62 * any transport types.
63 * @param connectionHandler connection state change handler to handle changes for
64 * connection with remote devices.
65 * @return Returns ::OC_STACK_OK if success.
67 OCStackResult setNetworkMonitorHandler(AdapterChangedCallback adapterHandler,
68 ConnectionChangedCallback connectionHandler);
71 * Set port number to use.
72 * @param adapter transport adapter type to assign the specified port number.
73 * @param flag transport flag information.
74 * @param port the specified port number to use.
75 * @return Returns ::OC_STACK_OK if success.
77 OCStackResult setPortNumberToAssign(OCTransportAdapter adapter,
78 OCTransportFlags flag, uint16_t port);
81 * Get the assigned port number.
82 * @param adapter transport adapter type to get the opened port number.
83 * @param flag transport flag information.
84 * @return Returns currently assigned port number.
86 uint16_t getAssignedPortNumber(OCTransportAdapter adapter, OCTransportFlags flag);
89 * Set multicast time to live to control the scope of the multicasts.
90 * @param ttl To be set to any value from 0 to 255.
92 * 0: Are restricted to the same host.
93 * 1: Are restricted to the same subnet.
94 * 32: Are restricted to the same site.
95 * 64: Are restricted to the same region.
96 * 128: Are restricted to the same continent.
97 * 255: Are unrestricted in scope.
98 * We cannot support region, continent and unrestricted in scope.
99 * @return Returns ::OC_STACK_OK if success.
101 OCStackResult setMulticastTTL(size_t ttl);
104 * Get multicast time to live.
105 * @param ttl TTL pointer to get the stored multicast time to live.
106 * @return Returns ::OC_STACK_OK if success.
108 OCStackResult getMulticastTTL(size_t *ttl);
112 * @param[in] config ::CAUtilConfig data
113 * @return Returns ::OC_STACK_OK if success.
115 OCStackResult setBTConfigure(const CAUtilConfig& config);
118 * set CAUtil log preference.
119 * @param[in] level ::OCLogLevel value.
120 * @param[in] hidePrivateLogEntries Private Log Entries.
122 * true : hide private log.
123 * false : show private log.
124 * (privacy : uid, did, access token, etc)
126 void setLogLevel(OCLogLevel level, bool hidePrivateLogEntries);
129 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
130 OCStackResult setAdvertisementData(const char* data, int length);
131 OCStackResult setScanResponseData(const char* data, int length);
135 * start BLE advertising.
136 * @return Returns ::OC_STACK_OK if success.
138 OCStackResult startLEAdvertising();
141 * stop BLE advertising.
142 * @return Returns ::OC_STACK_OK if success.
144 OCStackResult stopLEAdvertising();
147 * Disconnect TCP session.
148 * When there is no transmission for a long time.
149 * Some carrier Vendor is blocking data.
150 * Thur, TCP Session is cleaned through this function.
151 * @param[in] address Address.
152 * @param[in] port Port.
153 * @param[in] flags Transport flag.
154 * @return Returns ::OC_STACK_OK if success.
156 OCStackResult disconnectTCPSession(const char *address,
158 OCTransportFlags flags);
160 OCStackResult startCAGattServer();
161 OCStackResult stopCAGattServer();
162 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
164 * Select the cipher suite for TLS/DTLS handshake.
165 * @param cipher cipher suite (Note : Make sure endianness).
166 * TLS_RSA_WITH_AES_256_CBC_SHA256 0x3D
167 * TLS_RSA_WITH_AES_128_GCM_SHA256 0x009C
168 * TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B
169 * TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE
170 * TLS_ECDHE_ECDSA_WITH_AES_128_CCM 0xC0AC
171 * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023
172 * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024
173 * TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C
174 * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0xC037
175 * TLS_ECDH_anon_WITH_AES_128_CBC_SHA 0xC018
176 * @param adapter transport adapter type.
177 * @return Returns ::OC_STACK_OK if success.
179 OCStackResult setCipherSuite(const uint16_t cipher, OCTransportAdapter adapter);
180 #endif // defined(__WITH_DTLS__) || defined(__WITH_TLS__)
184 #endif // CA_MANAGER_H_