• 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_DFINDER_HIDUMP_H
17 #define NSTACKX_DFINDER_HIDUMP_H
18 #include "nstackx_device.h"
19 #include "nstackx_inet.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define DUMP_MSG_ADD_CHECK(ret, data, index, size, fmt, ...) do { \
26     ret = sprintf_s(data + index, size - index, fmt, ##__VA_ARGS__); \
27     if (ret < 0) { \
28         DFINDER_LOGE(TAG, "dumper buffer over %u bytes", size); \
29         return NSTACKX_EFAILED; \
30     } \
31     index += (uint32_t)ret; \
32 } while (0)
33 
34 #ifdef NSTACKX_DFINDER_HIDUMP
35 struct DumpIfaceInfo {
36     const char *ifname;
37     uint8_t state;
38     uint8_t af;
39     const union InetAddr *addr;
40 };
41 
42 int DFinderDump(const char **argv, uint32_t argc, void *softObj, DFinderDumpFunc dump);
43 int DFinderDumpIface(const struct DumpIfaceInfo *info, char *buf, int size);
44 int DumpDeviceInfo(const DeviceInfo *info, char *buf, int size, uint8_t remote);
45 #endif
46 
47 #ifdef __cplusplus
48 }
49 #endif
50 
51 #endif
52