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 #include "coap_app.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 enum { 27 REGISTER_TYPE_UPDATE_ALL, 28 REGISTER_TYPE_UPDATE_SPECIFIED, 29 }; 30 31 struct LocalIface; 32 33 int LocalDeviceInit(EpollDesc epollfd); 34 void LocalDeviceDeinit(void); 35 36 void ResetLocalDeviceTaskCount(uint8_t isBusy); 37 38 int RegisterLocalDeviceV2(const NSTACKX_LocalDeviceInfoV2 *devInfo, int registerType); 39 void ConfigureLocalDeviceName(const char *localDeviceName); 40 void SetLocalDeviceHash(uint64_t deviceHash); 41 int SetLocalDeviceCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[]); 42 int32_t SetLocalDeviceServiceData(const char *serviceData); 43 44 void SetLocalDeviceBusinessType(uint8_t businessType); 45 uint8_t GetLocalDeviceBusinessType(void); 46 47 int SetLocalDeviceBusinessData(const char *data, bool unicast); 48 int32_t LocalizeNotificationMsg(const char *msg); 49 uint8_t GetLocalDeviceMode(void); 50 void SetLocalDeviceMode(uint8_t mode); 51 52 #ifndef DFINDER_USE_MINI_NSTACKX 53 int32_t SetLocalDeviceExtendServiceData(const char *extendServiceData); 54 #ifndef _WIN32 55 void DetectLocalIface(void *arg); 56 #endif 57 #endif 58 59 const char *GetLocalDeviceId(void); 60 DeviceInfo *GetLocalDeviceInfo(void); 61 const char *GetLocalDeviceNetworkName(void); 62 63 int GetBroadcastIp(const struct LocalIface *iface, char *ipStr, size_t ipStrLen); 64 const struct in_addr *GetLocalIfaceIp(const struct LocalIface *iface); 65 const char *GetLocalIfaceIpStr(const struct LocalIface *iface); 66 const char *GetLocalIfaceName(const struct LocalIface *iface); 67 CoapCtxType *LocalIfaceGetCoapCtx(const char *ifname); 68 #ifndef DFINDER_USE_MINI_NSTACKX 69 CoapCtxType *LocalIfaceGetCoapCtxByRemoteIp(const struct in_addr *remoteIp, uint8_t serverType); 70 #endif 71 int AddLocalIface(const char *ifname, const struct in_addr *ip); 72 void RemoveLocalIface(const char *ifname); 73 void DestroyLocalIface(struct LocalIface *iface, bool moduleDeinit); 74 75 #ifdef NSTACKX_DFINDER_HIDUMP 76 int LocalIfaceDump(char *buf, size_t size); 77 #endif 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif 84