Revision feed8226

View differences:

doc/reply_codes
20 20
1006	Protocol details
21 21
1007	Route list
22 22
1008	Route details
23
1009	Static route list
23 24

  
24 25
8000	Reply too long
25 26
8001	Route not found
proto/static/config.Y
57 57
 | stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; }
58 58
 ;
59 59

  
60
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
61
{ static_show(proto_get_named($3, &proto_static)); } ;
62

  
60 63
CF_CODE
61 64

  
62 65
CF_END
proto/static/static.c
14 14
#include "nest/iface.h"
15 15
#include "nest/protocol.h"
16 16
#include "nest/route.h"
17
#include "nest/cli.h"
17 18
#include "conf/conf.h"
19
#include "lib/string.h"
18 20

  
19 21
#include "static.h"
20 22

  
......
41 43
  e->net = n;
42 44
  e->pflags = 0;
43 45
  rte_update(p->table, n, p, e);
46
  r->installed = 1;
44 47
}
45 48

  
46 49
static void
......
52 55
  n = net_find(p->table, r->net, r->masklen);
53 56
  if (n)
54 57
    rte_update(p->table, n, p, NULL);
58
  r->installed = 0;
55 59
}
56 60

  
57 61
static int
......
177 181
  dump:		static_dump,
178 182
  start:	static_start,
179 183
};
184

  
185
static void
186
static_show_rt(struct static_route *r)
187
{
188
  byte via[STD_ADDRESS_P_LENGTH + 16];
189

  
190
  switch (r->dest)
191
    {
192
    case RTD_ROUTER:	bsprintf(via, "via %I", r->via); break;
193
    case RTD_DEVICE:	bsprintf(via, "to %s", r->if_name); break;
194
    case RTD_BLACKHOLE:	bsprintf(via, "blackhole"); break;
195
    case RTD_UNREACHABLE:	bsprintf(via, "unreachable"); break;
196
    case RTD_PROHIBIT:	bsprintf(via, "prohibited"); break;
197
    default:		bsprintf(via, "???");
198
    }
199
  cli_msg(-1009, "%I/%d %s%s", r->net, r->masklen, via, r->installed ? "" : " (dormant)");
200
}
201

  
202
void
203
static_show(struct proto *P)
204
{
205
  struct static_config *c = (void *) P->cf;
206
  struct static_route *r;
207

  
208
  WALK_LIST(r, c->other_routes)
209
    static_show_rt(r);
210
  WALK_LIST(r, c->iface_routes)
211
    static_show_rt(r);
212
  cli_msg(0, "");
213
}
proto/static/static.h
26 26
  ip_addr via;				/* Destination router */
27 27
  struct neighbor *neigh;
28 28
  byte *if_name;			/* Name for RTD_DEVICE routes */
29
  int installed;			/* Installed in master table */
29 30
};
30 31

  
32
void static_show(struct proto *);
33

  
31 34
#endif

Also available in: Unified diff