]>
git.ipfire.org Git - thirdparty/bird.git/blob - nest/cli.h
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"
15 #define CLI_RX_BUF_SIZE 4096
16 #define CLI_TX_BUF_SIZE 4096
17 #define CLI_MAX_ASYNC_QUEUE 4096
19 #define CLI_MSG_SIZE 500
20 #define CLI_LINE_SIZE 512
24 byte
*wpos
, *outpos
, *end
;
29 node n
; /* Node in list of all log hooks */
31 void *priv
; /* Private to sysdep layer */
32 byte
*rx_buf
, *rx_pos
, *rx_aux
; /* sysdep */
33 struct cli_out
*tx_buf
, *tx_pos
, *tx_write
;
35 void (*cont
)(struct cli
*c
);
36 void (*cleanup
)(struct cli
*c
);
37 void *rover
; /* Private to continuation routine */
39 int restricted
; /* CLI is restricted to read-only commands */
40 struct linpool
*parser_pool
; /* Pool used during parsing */
41 byte
*ring_buf
; /* Ring buffer for asynchronous messages */
42 byte
*ring_end
, *ring_read
, *ring_write
; /* Pointers to the ring buffer */
43 uint ring_overflow
; /* Counter of ring overflows */
44 uint log_mask
; /* Mask of allowed message levels */
45 uint log_threshold
; /* When free < log_threshold, store only important messages */
46 uint async_msg_size
; /* Total size of async messages queued in tx_buf */
49 extern pool
*cli_pool
;
50 extern struct cli
*this_cli
; /* Used during parsing */
52 #define CLI_ASYNC_CODE 10000
54 /* Functions to be called by command handlers */
56 void cli_printf(cli
*, int, char *, ...);
57 #define cli_msg(x...) cli_printf(this_cli, x)
58 void cli_set_log_echo(cli
*, uint mask
, uint size
);
60 /* Functions provided to sysdep layer */
66 void cli_written(cli
*);
67 void cli_echo(uint
class, byte
*msg
);
69 static inline int cli_access_restricted(void)
71 if (this_cli
&& this_cli
->restricted
)
72 return (cli_printf(this_cli
, 8007, "Access denied"), 1);
77 /* Functions provided by sysdep layer */
79 void cli_write_trigger(cli
*);
80 int cli_get_command(cli
*);