Statistics
| Branch: | Revision:

iof-bird-daemon / nest / cli.h @ fbde6c39

History | View | Annotate | Download (1.9 KB)

1 7d3aab1c Martin Mares
/*
2
 *        BIRD Internet Routing Daemon -- Command-Line Interface
3
 *
4 4b87e256 Martin Mares
 *        (c) 1999--2000 Martin Mares <mj@ucw.cz>
5 7d3aab1c Martin Mares
 *
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
17 34350a52 Martin Mares
#define CLI_MAX_ASYNC_QUEUE 4096
18 7d3aab1c Martin Mares
19
struct cli_out {
20
  struct cli_out *next;
21
  byte *wpos, *outpos, *end;
22
  byte buf[0];
23
};
24
25
typedef struct cli {
26 34350a52 Martin Mares
  node n;                                /* Node in list of all log hooks */
27 7d3aab1c Martin Mares
  pool *pool;
28
  void *priv;                                /* Private to sysdep layer */
29 34350a52 Martin Mares
  byte *rx_buf, *rx_pos, *rx_aux;        /* sysdep */
30 7d3aab1c Martin Mares
  struct cli_out *tx_buf, *tx_pos, *tx_write;
31
  event *event;
32 b9672a84 Martin Mares
  void (*cont)(struct cli *c);
33 ffb59d24 Martin Mares
  void (*cleanup)(struct cli *c);
34 b9672a84 Martin Mares
  void *rover;                                /* Private to continuation routine */
35
  int last_reply;
36 bc2fb680 Martin Mares
  struct linpool *parser_pool;                /* Pool used during parsing */
37 34350a52 Martin Mares
  byte *ring_buf;                        /* Ring buffer for asynchronous messages */
38
  byte *ring_end, *ring_read, *ring_write;        /* Pointers to the ring buffer */
39
  unsigned int ring_overflow;                /* Counter of ring overflows */
40
  unsigned int log_mask;                /* Mask of allowed message levels */
41
  unsigned int log_threshold;                /* When free < log_threshold, store only important messages */
42
  unsigned int async_msg_size;                /* Total size of async messages queued in tx_buf */
43 7d3aab1c Martin Mares
} cli;
44
45
extern pool *cli_pool;
46 bc2fb680 Martin Mares
extern struct cli *this_cli;                /* Used during parsing */
47 7d3aab1c Martin Mares
48 b9672a84 Martin Mares
/* Functions to be called by command handlers */
49
50
void cli_printf(cli *, int, char *, ...);
51 35793769 Martin Mares
#define cli_msg(x...) cli_printf(this_cli, x)
52 34350a52 Martin Mares
void cli_set_log_echo(cli *, unsigned int mask, unsigned int size);
53 b9672a84 Martin Mares
54
/* Functions provided to sysdep layer */
55
56 7d3aab1c Martin Mares
cli *cli_new(void *);
57
void cli_init(void);
58
void cli_free(cli *);
59
void cli_kick(cli *);
60
void cli_written(cli *);
61 34350a52 Martin Mares
void cli_echo(unsigned int class, byte *msg);
62 7d3aab1c Martin Mares
63 b9672a84 Martin Mares
/* Functions provided by sysdep layer */
64 7d3aab1c Martin Mares
65
int cli_write(cli *);
66
int cli_get_command(cli *);
67
68
#endif