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 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