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