Revision 1d2664a4

View differences:

TODO
47 47
shutdown			# order system shutdown
48 48
configure [<file>]
49 49
debug	<what>			# dump debugging information to log
50
show	protocols [<name>]
51
	<name>			# show everything you know about symbol <name>
50
show	<name>			# show everything you know about symbol <name>
52 51
	route [<route>] [table <name>] [filter (<name> | { <inline> })] [where <condition>] [all]
53 52
	status			# router id, version etc.
54 53
	rip ??? [<name>]
55 54
	ospf ??? [<name>]
56 55
	static ??? [<name>]
57
	interfaces [<name>]
58 56
	neighbors		# ???
59 57
	filters [<name>]
60 58
(disable|enable|restart) <protocol>	# or ALL?
doc/reply_codes
23 23

  
24 24
9000	Command too long
25 25
9001	Parse error
26
9002	Invalid symbol type
nest/cli.c
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
8 8

  
9
#include <string.h>
10

  
9 11
#include "nest/bird.h"
10 12
#include "nest/cli.h"
11 13
#include "conf/conf.h"
......
119 121
  struct config f;
120 122
  int res;
121 123

  
122
  f.pool = NULL;
124
  bzero(&f, sizeof(f));
123 125
  f.mem = c->parser_pool;
124 126
  cf_read_hook = cli_cmd_read_hook;
125 127
  cli_rh_pos = c->rx_buf;
nest/proto.c
78 78
void *
79 79
proto_new(struct proto_config *c, unsigned size)
80 80
{
81
  struct protocol *pr = c->proto;
81
  struct protocol *pr = c->protocol;
82 82
  struct proto *p = mb_allocz(proto_pool, size);
83 83

  
84 84
  p->cf = c;
......
90 90
  p->table = c->table->table;
91 91
  p->in_filter = c->in_filter;
92 92
  p->out_filter = c->out_filter;
93
  c->proto = p;
93 94
  return p;
94 95
}
95 96

  
......
136 137

  
137 138
  add_tail(&new_config->protos, &c->n);
138 139
  c->global = new_config;
139
  c->proto = pr;
140
  c->protocol = pr;
140 141
  c->debug = pr->debug;
141 142
  c->name = pr->name;
142 143
  c->out_filter = FILTER_REJECT;
......
174 175
  WALK_LIST(x, c->protos)
175 176
    {
176 177
      debug(" %s", x->name);
177
      p = x->proto;
178
      p = x->protocol;
178 179
      if (p->postconfig)
179 180
	p->postconfig(x);
180 181
    }
......
192 193
  WALK_LIST(x, c->protos)
193 194
    {
194 195
      debug(" %s", x->name);
195
      p = x->proto;
196
      p = x->protocol;
196 197
      q = p->init(x);
197 198
      q->proto_state = PS_DOWN;
198 199
      q->core_state = FS_HUNGRY;
......
458 459
}
459 460

  
460 461
static void
461
proto_do_show(list *l, int verbose)
462
proto_do_show(struct proto *p, int verbose)
463
{
464
  cli_msg(-1002, "%-8s %-8s %-8s %s%s",
465
	  p->name,
466
	  p->proto->name,
467
	  p->table->name,
468
	  proto_state_name(p),
469
	  proto_goal_name(p));
470
  if (verbose)
471
    {
472
      cli_msg(-1006, "\tPreference: %d", p->preference);
473
      cli_msg(-1006, "\tInput filter: %s", filter_name(p->in_filter));
474
      cli_msg(-1006, "\tOutput filter: %s", filter_name(p->out_filter));
475
    }
476
}
477

  
478
static void
479
proto_do_show_list(list *l, int verbose)
462 480
{
463 481
  struct proto *p;
464 482

  
465 483
  WALK_LIST(p, *l)
466
    {
467
      cli_msg(-1002, "%-8s %-8s %-8s %s%s",
468
	      p->name,
469
	      p->proto->name,
470
	      p->table->name,
471
	      proto_state_name(p),
472
	      proto_goal_name(p));
473
      if (verbose)
474
	{
475
	  cli_msg(-1006, "\tPreference: %d", p->preference);
476
	  cli_msg(-1006, "\tInput filter: %s", filter_name(p->in_filter));
477
	  cli_msg(-1006, "\tOutput filter: %s", filter_name(p->out_filter));
478
	}
479
    }
484
    proto_do_show(p, verbose);
480 485
}
481 486

  
482 487
void
483 488
proto_show(struct symbol *s, int verbose)
484 489
{
490
  if (s && s->class != SYM_PROTO)
491
    {
492
      cli_msg(9002, "%s is not a protocol", s->name);
493
      return;
494
    }
485 495
  cli_msg(-2002, "name     proto    table    state");
486
  proto_do_show(&proto_list, verbose);
487
  proto_do_show(&flush_proto_list, verbose);
488
  proto_do_show(&inactive_proto_list, verbose);
496
  if (s)
497
    proto_do_show(((struct proto_config *)s->def)->proto, verbose);
498
  else
499
    {
500
      proto_do_show_list(&proto_list, verbose);
501
      proto_do_show_list(&flush_proto_list, verbose);
502
      proto_do_show_list(&inactive_proto_list, verbose);
503
    }
489 504
  cli_msg(0, "");
490 505
}
nest/protocol.h
74 74
struct proto_config {
75 75
  node n;
76 76
  struct config *global;		/* Global configuration data */
77
  struct protocol *proto;		/* Protocol */
77
  struct protocol *protocol;		/* Protocol */
78
  struct proto *proto;			/* Instance we've created */
78 79
  char *name;
79 80
  unsigned debug, preference, disabled;	/* Generic parameters */
80 81
  struct rtable_config *table;		/* Table we're attached to */

Also available in: Unified diff