Revision feed8226 proto/static/static.c

View differences:

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
}

Also available in: Unified diff