]>
git.proxmox.com Git - mirror_frr.git/blob - lib/command_graph.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2016 Cumulus Networks, Inc.
7 * Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
8 * Copyright (C) 2013 by Open Source Routing.
9 * Copyright (C) 2013 by Internet Systems Consortium, Inc. ("ISC")
12 #ifndef _FRR_COMMAND_GRAPH_H
13 #define _FRR_COMMAND_GRAPH_H
27 DECLARE_MTYPE(CMD_ARG
);
34 * The type determines what kind of data the token can match (in the
35 * matching use case) or hold (in the argv use case).
37 /* clang-format off */
40 VARIABLE_TKN
, // almost anything
41 RANGE_TKN
, // integer range
42 IPV4_TKN
, // IPV4 addresses
43 IPV4_PREFIX_TKN
, // IPV4 network prefixes
44 IPV6_TKN
, // IPV6 prefixes
45 IPV6_PREFIX_TKN
, // IPV6 network prefixes
46 MAC_TKN
, // Ethernet address
47 MAC_PREFIX_TKN
, // Ethernet address w/ CIDR mask
48 ASNUM_TKN
, // AS dot format
51 FORK_TKN
, // marks subgraph beginning
52 JOIN_TKN
, // marks subgraph end
53 START_TKN
, // first token in line
54 END_TKN
, // last token in line
55 NEG_ONLY_TKN
, // filter token, match if "no ..." command
57 SPECIAL_TKN
= FORK_TKN
,
61 #define IS_VARYING_TOKEN(x) ((x) >= VARIABLE_TKN && (x) < FORK_TKN)
63 /* Command attributes */
65 CMD_ATTR_YANG
= (1 << 0),
66 CMD_ATTR_HIDDEN
= (1 << 1),
67 CMD_ATTR_DEPRECATED
= (1 << 2),
68 CMD_ATTR_NOSH
= (1 << 3),
79 /* Command token struct. */
81 enum cmd_token_type type
; // token type
82 uint8_t attr
; // token attributes
83 bool allowrepeat
; // matcher allowed to match token repetitively?
87 char *text
; // token text
88 char *desc
; // token description
89 long long min
, max
; // for ranges
90 char *arg
; // user input that matches this token
93 struct graph_node
*forkjoin
; // paired FORK/JOIN for JOIN/FORK
96 /* Structure of command element. */
98 const char *string
; /* Command specification by string. */
99 const char *doc
; /* Documentation of this command. */
100 int daemon
; /* Daemon to which this command belong. */
101 uint32_t attr
; /* Command attributes */
103 /* handler function for command */
104 int (*func
)(const struct cmd_element
*, struct vty
*, int,
105 struct cmd_token
*[]);
107 const char *name
; /* symbol name for debugging */
111 /* text for <cr> command */
112 #define CMD_CR_TEXT "<cr>"
114 /* memory management for cmd_token */
115 extern struct cmd_token
*cmd_token_new(enum cmd_token_type
, uint8_t attr
,
116 const char *text
, const char *desc
);
117 extern struct cmd_token
*cmd_token_dup(struct cmd_token
*);
118 extern void cmd_token_del(struct cmd_token
*);
119 extern void cmd_token_varname_set(struct cmd_token
*token
, const char *varname
);
120 extern void cmd_token_varname_seqappend(struct graph_node
*n
);
121 extern void cmd_token_varname_join(struct graph_node
*n
, const char *varname
);
123 extern void cmd_graph_parse(struct graph
*graph
, const struct cmd_element
*cmd
);
124 extern void cmd_graph_names(struct graph
*graph
);
125 extern void cmd_graph_merge(struct graph
*old
, struct graph
*n
,
128 * Print callback for DOT dumping.
130 * See graph.h for more details.
132 extern void cmd_graph_node_print_cb(struct graph_node
*gn
, struct buffer
*buf
);
134 * Dump command graph to DOT.
137 * A command graph to dump
140 * String allocated with MTYPE_TMP representing this graph
142 char *cmd_graph_dump_dot(struct graph
*cmdgraph
);
148 #endif /* _FRR_COMMAND_GRAPH_H */