• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
4  */
5 
6 #ifndef __NETLINK_TYPES_H_
7 #define __NETLINK_TYPES_H_
8 
9 #include <stdio.h>
10 
11 /**
12  * @ingroup utils
13  * Enumeration of dumping variations (dp_type)
14  */
15 enum nl_dump_type {
16 	NL_DUMP_LINE,		/**< Dump object briefly on one line */
17 	NL_DUMP_DETAILS,	/**< Dump all attributes but no statistics */
18 	NL_DUMP_STATS,		/**< Dump all attributes including statistics */
19 	__NL_DUMP_MAX,
20 };
21 #define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
22 
23 /**
24  * @ingroup utils
25  * Dumping parameters
26  */
27 struct nl_dump_params
28 {
29 	/**
30 	 * Specifies the type of dump that is requested.
31 	 */
32 	enum nl_dump_type	dp_type;
33 
34 	/**
35 	 * Specifies the number of whitespaces to be put in front
36 	 * of every new line (indentation).
37 	 */
38 	int			dp_prefix;
39 
40 	/**
41 	 * Causes the cache index to be printed for each element.
42 	 */
43 	int			dp_print_index;
44 
45 	/**
46 	 * Causes each element to be prefixed with the message type.
47 	 */
48 	int			dp_dump_msgtype;
49 
50 	/**
51 	 * A callback invoked for output
52 	 *
53 	 * Passed arguments are:
54 	 *  - dumping parameters
55 	 *  - string to append to the output
56 	 */
57 	void			(*dp_cb)(struct nl_dump_params *, char *);
58 
59 	/**
60 	 * A callback invoked for every new line, can be used to
61 	 * customize the indentation.
62 	 *
63 	 * Passed arguments are:
64 	 *  - dumping parameters
65 	 *  - line number starting from 0
66 	 */
67 	void			(*dp_nl_cb)(struct nl_dump_params *, int);
68 
69 	/**
70 	 * User data pointer, can be used to pass data to callbacks.
71 	 */
72 	void			*dp_data;
73 
74 	/**
75 	 * File descriptor the dumping output should go to
76 	 */
77 	FILE *			dp_fd;
78 
79 	/**
80 	 * Alternatively the output may be redirected into a buffer
81 	 */
82 	char *			dp_buf;
83 
84 	/**
85 	 * Length of the buffer dp_buf
86 	 */
87 	size_t			dp_buflen;
88 
89 	/**
90 	 * PRIVATE
91 	 * Set if a dump was performed prior to the actual dump handler.
92 	 */
93 	int			dp_pre_dump;
94 
95 	/**
96 	 * PRIVATE
97 	 * Owned by the current caller
98 	 */
99 	int			dp_ivar;
100 
101 	unsigned int		dp_line;
102 };
103 
104 #endif
105