• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NSTACKX_DEVICE_LOCAL_H
17 #define NSTACKX_DEVICE_LOCAL_H
18 
19 #include "nstackx_device.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 enum {
26     REGISTER_TYPE_UPDATE_ALL,
27     REGISTER_TYPE_UPDATE_SPECIFIED,
28 };
29 
30 struct LocalIface;
31 
32 int LocalDeviceInit(EpollDesc epollfd);
33 void LocalDeviceDeinit(void);
34 
35 void ResetLocalDeviceTaskCount(uint8_t isBusy);
36 
37 int RegisterLocalDeviceV2(const NSTACKX_LocalDeviceInfoV2 *devInfo, int registerType);
38 void ConfigureLocalDeviceName(const char *localDeviceName);
39 void SetLocalDeviceHash(uint64_t deviceHash);
40 int SetLocalDeviceCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[]);
41 int32_t SetLocalDeviceServiceData(const char *serviceData);
42 int32_t SetLocalDeviceServiceDataV2(const struct NSTACKX_ServiceData *param, uint32_t cnt);
43 void SetLocalDeviceBusinessType(uint8_t businessType);
44 uint8_t GetLocalDeviceBusinessType(void);
45 
46 int SetLocalDeviceBusinessData(const char *data, bool unicast);
47 int32_t LocalizeNotificationMsg(const char *msg);
48 uint8_t GetLocalDeviceMode(void);
49 void SetLocalDeviceMode(uint8_t mode);
50 
51 #ifndef DFINDER_USE_MINI_NSTACKX
52 int32_t SetLocalDeviceExtendServiceData(const char *extendServiceData);
53 #ifndef _WIN32
54 void DetectLocalIface(void *arg);
55 #endif
56 #endif
57 
58 const char *GetLocalDeviceId(void);
59 DeviceInfo *GetLocalDeviceInfo(void);
60 const char *GetLocalDeviceNetworkName(void);
61 
62 int GetBroadcastIp(const struct LocalIface *iface, char *ipStr, size_t ipStrLen);
63 const char *GetLocalIfaceIpStr(const struct LocalIface *iface);
64 const char *GetLocalIfaceName(const struct LocalIface *iface);
65 const char *GetLocalIfaceServiceData(const struct LocalIface *iface);
66 uint8_t GetLocalIfaceAf(const struct LocalIface *iface);
67 CoapCtxType *LocalIfaceGetCoapCtx(uint8_t af, const char *ifname);
68 #ifndef DFINDER_USE_MINI_NSTACKX
69 CoapCtxType *LocalIfaceGetCoapCtxByRemoteIp(const struct in_addr *remoteIp, uint8_t serverType);
70 #else
71 // only mini device support ipv4, other support ipv4 and ipv6
72 const struct in_addr *GetLocalIfaceIp(const struct LocalIface *iface);
73 #endif
74 int AddLocalIface(const char *ifname, const char *serviceData, uint8_t af, const union InetAddr *addr);
75 void RemoveLocalIface(uint8_t af, const char *ifname);
76 void DestroyLocalIface(struct LocalIface *iface, bool moduleDeinit);
77 
78 #ifdef NSTACKX_DFINDER_HIDUMP
79 int LocalIfaceDump(char *buf, size_t size);
80 #endif
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif
87