• 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 NSTACK_COMMON_H
17 #define NSTACK_COMMON_H
18 #include "nstackx.h"
19 #include "nstackx_list.h"
20 #include "nstackx_epoll.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifdef DFINDER_SAVE_DEVICE_LIST
27 typedef struct {
28     NSTACKX_DeviceInfo *deviceList;
29     uint32_t *deviceCountPtr;
30     sem_t wait;
31 } GetDeviceListMessage;
32 #endif
33 
34 struct DeviceInfo;
35 
36 #ifdef DFINDER_SUPPORT_COVERITY_TAINTED_SET
37 void Coverity_Tainted_Set(void *buf);
38 #else
39 #define Coverity_Tainted_Set(param)
40 #endif
41 
42 bool GetIsNotifyPerDevice(void);
43 void NotifyDeviceListChanged(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceCount);
44 void NotifyDeviceFound(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceCount);
45 #ifndef DFINDER_USE_MINI_NSTACKX
46 void NotifyMsgReceived(const char *moduleName, const char *deviceId, const uint8_t *data,
47     uint32_t len, const char *srcIp);
48 #endif /* END OF DFINDER_USE_MINI_NSTACKX */
49 void NotifyDFinderMsgRecver(DFinderMsgType msgType);
50 EpollDesc GetMainLoopEpollFd(void);
51 List *GetMainLoopEvendChain(void);
52 uint32_t GetDefaultDiscoverInterval(uint32_t discoverCount);
53 int32_t CheckBusinessTypeReplyUnicast(uint8_t businessType);
54 int32_t GetServiceDiscoverInfo(const uint8_t *buf, size_t size, struct DeviceInfo *deviceInfo, char **remoteUrlPtr);
55 List *GetEventNodeChain(void);
56 EpollDesc GetEpollFD(void);
57 
StringHasEOF(const char * str,size_t len)58 static inline bool StringHasEOF(const char *str, size_t len)
59 {
60     ssize_t i;
61     for (i = (ssize_t)len - 1; i >= 0; i--) {
62         if (str[i] == '\0') {
63             return true;
64         }
65     }
66 
67     return false;
68 }
69 
70 #ifdef __cplusplus
71 };
72 #endif
73 
74 #endif /* #ifndef NSTACK_COMMON_H */
75