]> git.ipfire.org Git - thirdparty/bird.git/blame - nest/cli.h
Doc: Remove some superfluous slashes
[thirdparty/bird.git] / nest / cli.h
CommitLineData
7d3aab1c
MM
1/*
2 * BIRD Internet Routing Daemon -- Command-Line Interface
3 *
4b87e256 4 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
7d3aab1c
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9#ifndef _BIRD_CLI_H_
10#define _BIRD_CLI_H_
11
12#include "lib/resource.h"
13#include "lib/event.h"
14
15#define CLI_RX_BUF_SIZE 4096
16#define CLI_TX_BUF_SIZE 4096
34350a52 17#define CLI_MAX_ASYNC_QUEUE 4096
7d3aab1c 18
fdf16eb6
OZ
19#define CLI_MSG_SIZE 500
20#define CLI_LINE_SIZE 512
21
7d3aab1c
MM
22struct cli_out {
23 struct cli_out *next;
24 byte *wpos, *outpos, *end;
25 byte buf[0];
26};
27
28typedef struct cli {
34350a52 29 node n; /* Node in list of all log hooks */
7d3aab1c
MM
30 pool *pool;
31 void *priv; /* Private to sysdep layer */
34350a52 32 byte *rx_buf, *rx_pos, *rx_aux; /* sysdep */
7d3aab1c
MM
33 struct cli_out *tx_buf, *tx_pos, *tx_write;
34 event *event;
b9672a84 35 void (*cont)(struct cli *c);
ffb59d24 36 void (*cleanup)(struct cli *c);
b9672a84
MM
37 void *rover; /* Private to continuation routine */
38 int last_reply;
e0a45fb4 39 int restricted; /* CLI is restricted to read-only commands */
bc2fb680 40 struct linpool *parser_pool; /* Pool used during parsing */
34350a52
MM
41 byte *ring_buf; /* Ring buffer for asynchronous messages */
42 byte *ring_end, *ring_read, *ring_write; /* Pointers to the ring buffer */
ae80a2de
PT
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 */
7d3aab1c
MM
47} cli;
48
49extern pool *cli_pool;
bc2fb680 50extern struct cli *this_cli; /* Used during parsing */
7d3aab1c 51
a92cf57d
OZ
52#define CLI_ASYNC_CODE 10000
53
b9672a84
MM
54/* Functions to be called by command handlers */
55
56void cli_printf(cli *, int, char *, ...);
35793769 57#define cli_msg(x...) cli_printf(this_cli, x)
ae80a2de 58void cli_set_log_echo(cli *, uint mask, uint size);
b9672a84
MM
59
60/* Functions provided to sysdep layer */
61
7d3aab1c
MM
62cli *cli_new(void *);
63void cli_init(void);
64void cli_free(cli *);
65void cli_kick(cli *);
66void cli_written(cli *);
ae80a2de 67void cli_echo(uint class, byte *msg);
7d3aab1c 68
e0a45fb4
OZ
69static inline int cli_access_restricted(void)
70{
71 if (this_cli && this_cli->restricted)
72 return (cli_printf(this_cli, 8007, "Access denied"), 1);
73 else
74 return 0;
75}
76
b9672a84 77/* Functions provided by sysdep layer */
7d3aab1c 78
6baef17e 79void cli_write_trigger(cli *);
7d3aab1c
MM
80int cli_get_command(cli *);
81
82#endif