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 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 struct in_addr *GetLocalIfaceIp(const struct LocalIface *iface); 64 const char *GetLocalIfaceIpStr(const struct LocalIface *iface); 65 const char *GetLocalIfaceName(const struct LocalIface *iface); 66 CoapCtxType *LocalIfaceGetCoapCtx(const char *ifname); 67 #ifndef DFINDER_USE_MINI_NSTACKX 68 CoapCtxType *LocalIfaceGetCoapCtxByRemoteIp(const struct in_addr *remoteIp, uint8_t serverType); 69 #endif 70 int AddLocalIface(const char *ifname, const struct in_addr *ip); 71 void RemoveLocalIface(const char *ifname); 72 void DestroyLocalIface(struct LocalIface *iface, bool moduleDeinit); 73 74 #ifdef NSTACKX_DFINDER_HIDUMP 75 int LocalIfaceDump(char *buf, size_t size); 76 #endif 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif 83