Statistics
| Branch: | Revision:

iof-bird-daemon / nest / cli.h @ 11361a10

History | View | Annotate | Download (1.91 KB)

1
/*
2
 *        BIRD Internet Routing Daemon -- Command-Line Interface
3
 *
4
 *        (c) 1999--2000 Martin Mares <mj@ucw.cz>
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
17
#define CLI_MAX_ASYNC_QUEUE 4096
18

    
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
  node n;                                /* Node in list of all log hooks */
27
  pool *pool;
28
  void *priv;                                /* Private to sysdep layer */
29
  byte *rx_buf, *rx_pos, *rx_aux;        /* sysdep */
30
  struct cli_out *tx_buf, *tx_pos, *tx_write;
31
  event *event;
32
  void (*cont)(struct cli *c);
33
  void (*cleanup)(struct cli *c);
34
  void *rover;                                /* Private to continuation routine */
35
  int last_reply;
36
  struct linpool *parser_pool;                /* Pool used during parsing */
37
  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
} cli;
44

    
45
extern pool *cli_pool;
46
extern struct cli *this_cli;                /* Used during parsing */
47

    
48
/* Functions to be called by command handlers */
49

    
50
void cli_printf(cli *, int, char *, ...);
51
#define cli_msg(x...) cli_printf(this_cli, x)
52
void cli_set_log_echo(cli *, unsigned int mask, unsigned int size);
53

    
54
/* Functions provided to sysdep layer */
55

    
56
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
void cli_echo(unsigned int class, byte *msg);
62

    
63
/* Functions provided by sysdep layer */
64

    
65
void cli_write_trigger(cli *);
66
int cli_get_command(cli *);
67

    
68
#endif