]>
git.ipfire.org Git - thirdparty/bird.git/blob - nest/cli.h
423b2180315a132559720ebefd92b204b1b7bf63
2 * BIRD Internet Routing Daemon -- Command-Line Interface
4 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
12 #include "lib/resource.h"
13 #include "lib/event.h"
14 #include "lib/timer.h"
15 #include "lib/tlists.h"
16 #include "conf/conf.h"
18 #define CLI_RX_BUF_SIZE 4096
19 #define CLI_TX_BUF_SIZE 4096
20 #define CLI_MAX_ASYNC_QUEUE 4096
22 #define CLI_MSG_SIZE 500
23 #define CLI_LINE_SIZE 512
27 byte
*wpos
, *outpos
, *end
;
32 node n
; /* Node in list of all log hooks */
34 void *priv
; /* Private to sysdep layer */
35 byte
*rx_buf
, *rx_pos
; /* sysdep */
36 struct cli_out
*tx_buf
, *tx_pos
, *tx_write
;
38 void (*cont
)(struct cli
*c
);
39 void (*cleanup
)(struct cli
*c
);
40 void *rover
; /* Private to continuation routine */
42 int restricted
; /* CLI is restricted to read-only commands */
43 struct timeformat
*tf
; /* Time format override */
44 struct linpool
*parser_pool
; /* Pool used during parsing */
45 struct linpool
*show_pool
; /* Pool used during route show */
46 byte
*ring_buf
; /* Ring buffer for asynchronous messages */
47 byte
*ring_end
, *ring_read
, *ring_write
; /* Pointers to the ring buffer */
48 uint ring_overflow
; /* Counter of ring overflows */
49 uint log_mask
; /* Mask of allowed message levels */
50 uint log_threshold
; /* When free < log_threshold, store only important messages */
51 uint async_msg_size
; /* Total size of async messages queued in tx_buf */
55 #define TLIST_PREFIX cli_config
56 #define TLIST_TYPE struct cli_config
58 #define TLIST_DEFINED_BEFORE
59 #define TLIST_WANT_ADD_TAIL
60 #define TLIST_WANT_WALK
63 struct config
*config
;
67 #include "lib/tlists.h"
69 void cli_config_listen(struct cli_config
*, const char *);
71 extern pool
*cli_pool
;
72 extern struct cli
*this_cli
; /* Used during parsing */
74 #define CLI_ASYNC_CODE 10000
76 /* Functions to be called by command handlers */
78 void cli_vprintf(cli
*, int, const char *, va_list);
79 static inline void cli_printf(cli
*cli
, int code
, const char *fmt
, ...)
83 cli_vprintf(cli
, code
, fmt
, args
);
87 #define cli_msg(x...) cli_printf(this_cli, x)
88 void cli_set_log_echo(cli
*, uint mask
, uint size
);
89 void cli_set_timeformat(cli
*c
, const struct timeformat tf
);
91 static inline void cli_separator(cli
*c
)
92 { if (c
->last_reply
) cli_printf(c
, -c
->last_reply
, ""); };
94 /* Functions provided to sysdep layer */
96 cli
*cli_new(void *, struct cli_config
*);
100 void cli_written(cli
*);
101 void cli_echo(uint
class, byte
*msg
);
103 static inline int cli_access_restricted(void)
105 if (this_cli
&& this_cli
->restricted
)
106 return (cli_printf(this_cli
, 8007, "Access denied"), 1);
111 /* Functions provided by sysdep layer */
113 void cli_write_trigger(cli
*);
114 int cli_get_command(cli
*);