1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Virtual terminal interface shell.
3 * Copyright (C) 2000 Kunihiro Ishiguro
10 DECLARE_MGROUP(MVTYSH
);
14 extern struct event_loop
*master
;
16 #define VTYSH_ZEBRA 0x00001
17 #define VTYSH_RIPD 0x00002
18 #define VTYSH_RIPNGD 0x00004
19 #define VTYSH_OSPFD 0x00008
20 #define VTYSH_OSPF6D 0x00010
21 #define VTYSH_BGPD 0x00020
22 #define VTYSH_ISISD 0x00040
23 #define VTYSH_PIMD 0x00080
24 #define VTYSH_LDPD 0x00100
25 #define VTYSH_WATCHFRR 0x00200
26 #define VTYSH_NHRPD 0x00400
27 #define VTYSH_EIGRPD 0x00800
28 #define VTYSH_BABELD 0x01000
29 #define VTYSH_SHARPD 0x02000
30 #define VTYSH_PBRD 0x04000
31 #define VTYSH_STATICD 0x08000
32 #define VTYSH_BFDD 0x10000
33 #define VTYSH_FABRICD 0x20000
34 #define VTYSH_VRRPD 0x40000
35 #define VTYSH_PATHD 0x80000
36 #define VTYSH_PIM6D 0x100000
37 #define VTYSH_MGMTD 0x200000
39 #define VTYSH_WAS_ACTIVE (-2)
41 /* commands in REALLYALL are crucial to correct vtysh operation */
42 #define VTYSH_REALLYALL ~0U
43 /* watchfrr is not in ALL since library CLI functions should not be
44 * run on it (logging & co. should stay in a fixed/frozen config, and
45 * things like prefix lists are not even initialised) */
47 VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
48 VTYSH_LDPD | VTYSH_BGPD | VTYSH_ISISD | VTYSH_PIMD | \
49 VTYSH_PIM6D | VTYSH_NHRPD | VTYSH_EIGRPD | VTYSH_BABELD | \
50 VTYSH_SHARPD | VTYSH_PBRD | VTYSH_STATICD | VTYSH_BFDD | \
51 VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD
52 #define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA
53 #define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD
54 #define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD
55 #define VTYSH_INTERFACE_SUBSET \
56 VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
57 VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | \
58 VTYSH_EIGRPD | VTYSH_BABELD | VTYSH_PBRD | VTYSH_FABRICD | \
60 #define VTYSH_INTERFACE VTYSH_INTERFACE_SUBSET | VTYSH_BGPD
61 #define VTYSH_VRF VTYSH_INTERFACE_SUBSET | VTYSH_STATICD | VTYSH_MGMTD
62 #define VTYSH_KEYS VTYSH_RIPD | VTYSH_EIGRPD | VTYSH_OSPF6D
63 /* Daemons who can process nexthop-group configs */
64 #define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD
65 #define VTYSH_SR VTYSH_ZEBRA|VTYSH_PATHD
66 #define VTYSH_DPDK VTYSH_ZEBRA
68 enum vtysh_write_integrated
{
69 WRITE_INTEGRATED_UNSPECIFIED
,
74 extern enum vtysh_write_integrated vtysh_write_integrated
;
76 extern char frr_config
[];
78 extern bool vtysh_loop_exited
;
80 void vtysh_init_vty(void);
81 void vtysh_uninit(void);
82 void vtysh_init_cmd(void);
83 extern int vtysh_connect_all(const char *optional_daemon_name
);
84 void vtysh_readline_init(void);
85 void vtysh_user_init(void);
87 int vtysh_execute(const char *);
88 int vtysh_execute_no_pager(const char *);
89 int vtysh_execute_command_questionmark(char *input
);
91 char *vtysh_prompt(void);
93 void vtysh_config_write(void);
95 int vtysh_config_from_file(struct vty
*, FILE *);
97 void config_add_line(struct list
*, const char *);
99 int vtysh_mark_file(const char *filename
);
101 int vtysh_apply_config(const char *config_file_path
, bool dry_run
, bool fork
);
102 int vtysh_write_config_integrated(void);
104 void vtysh_config_parse_line(void *, const char *);
106 void vtysh_config_dump(void);
108 void vtysh_config_init(void);
113 /* Child process execution flag. */
114 extern int execute_flag
;
116 extern struct vty
*vty
;
118 extern int user_mode
;
120 extern bool vtysh_add_timestamp
;
122 struct vtysh_client
{
126 char path
[MAXPATHLEN
];
127 struct vtysh_client
*next
;
129 struct event
*log_reader
;
134 extern struct vtysh_client vtysh_client
[22];