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