Revision 10d807d0

View differences:

sysdep/unix/krt-iface.Y
21 21
krt_if_item:
22 22
   SCAN TIME expr {
23 23
      /* Scan time of 0 means scan on startup only */
24
      ((struct krt_proto *) this_proto)->ifopt.scan_time = $3;
24
      ((struct krt_config *) this_proto)->ifopt.scan_time = $3;
25 25
   }
26 26
 ;
27 27

  
sysdep/unix/krt-iface.h
1 1
/*
2 2
 *	BIRD -- Unix Kernel Interface Syncer -- Setting Parameters
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
13 13
  int scan_time;
14 14
};
15 15

  
16
struct krt_if_status {
17
};
18

  
16 19
#endif
sysdep/unix/krt-set.c
1 1
/*
2 2
 *	BIRD -- Unix Routing Table Syncing
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
115 115
void
116 116
krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
117 117
{
118
  if (x->state != PRS_UP)
119
    return;
118
  if (x->proto_state != PS_UP)
119
    bug("FIXME: krt_set_notify called for downed protocol");
120 120
  if (old)
121 121
    krt_remove_route(old);
122 122
  if (new)
......
124 124
}
125 125

  
126 126
void
127
krt_set_preconfig(struct krt_proto *x)
127
krt_set_start(struct krt_proto *x)
128 128
{
129 129
  if (if_scan_sock < 0)
130 130
    bug("krt set: missing socket");
131 131
  x->p.rt_notify = krt_set_notify;
132 132
}
133

  
134
void
135
krt_set_preconfig(struct krt_config *c)
136
{
137
}
sysdep/unix/krt-set.h
1 1
/*
2 2
 *	BIRD -- Unix Kernel Route Syncer -- Setting Parameters
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
12 12
struct krt_set_params {
13 13
};
14 14

  
15
struct krt_set_status {
16
};
17

  
15 18
void krt_remove_route(rte *old);
16 19
void krt_add_route(rte *new);
17 20
int krt_capable(rte *e);
21
void krt_set_notify(struct proto *x, net *net, rte *new, rte *old);
18 22

  
19 23
#endif
sysdep/unix/krt.Y
21 21
CF_ADDTO(proto, kern_proto '}')
22 22

  
23 23
kern_proto_start: proto_start KERNEL {
24
     if (!(this_proto = cf_krt_proto)) cf_error("Kernel protocol already defined");
25
     cf_krt_proto = NULL;
24
     if (!(this_proto = cf_krt)) cf_error("Kernel protocol already defined");
25
     cf_krt = NULL;
26 26
   }
27 27
 ;
28 28

  
sysdep/unix/krt.h
25 25

  
26 26
extern struct protocol proto_unix_kernel;
27 27

  
28
struct krt_proto {
29
  struct proto p;
28
struct krt_config {
29
  struct proto_config c;
30 30
  struct krt_set_params setopt;
31 31
  struct krt_scan_params scanopt;
32 32
  struct krt_if_params ifopt;
33 33
};
34 34

  
35
extern struct proto *cf_krt_proto;
35
struct krt_proto {
36
  struct proto p;
37
  struct krt_set_status setstat;
38
  struct krt_scan_status scanstat;
39
  struct krt_if_status ifstat;
40
};
41

  
42
extern struct proto_config *cf_krt;
36 43

  
37 44
/* krt-scan.c */
38 45

  
39
void krt_scan_preconfig(struct krt_proto *);
46
void krt_scan_preconfig(struct krt_config *);
40 47
void krt_scan_start(struct krt_proto *);
41 48
void krt_scan_shutdown(struct krt_proto *);
42 49
void krt_scan_ifaces_done(struct krt_proto *);
43 50

  
44 51
/* krt-set.c */
45 52

  
46
void krt_set_preconfig(struct krt_proto *);
53
void krt_set_preconfig(struct krt_config *);
54
void krt_set_start(struct krt_proto *);
47 55

  
48 56
/* sync-if.c */
49 57

  
50
void krt_if_preconfig(struct krt_proto *);
58
void krt_if_preconfig(struct krt_config *);
51 59
void krt_if_start(struct krt_proto *);
52 60
void krt_if_shutdown(struct krt_proto *);
53 61

  
sysdep/unix/sync-if.c
1 1
/*
2 2
 *	BIRD -- Unix Interface Scanning and Syncing
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
174 174
void
175 175
krt_if_start(struct krt_proto *p)
176 176
{
177
  if_scan_timer = tm_new(&root_pool);
177
  struct krt_config *c = (struct krt_config *) p->p.cf;
178

  
179
  if_scan_timer = tm_new(p->p.pool);
178 180
  if_scan_timer->hook = scan_if;
179 181
  if_scan_timer->data = p;
180
  if_scan_timer->recurrent = p->ifopt.scan_time;
182
  if_scan_timer->recurrent = c->ifopt.scan_time;
181 183
  scan_if(if_scan_timer);
182
  tm_start(if_scan_timer, p->ifopt.scan_time);
184
  tm_start(if_scan_timer, c->ifopt.scan_time);
183 185
}
184 186

  
185 187
void
186
krt_if_preconfig(struct krt_proto *p)
188
krt_if_preconfig(struct krt_config *c)
187 189
{
188
  p->ifopt.scan_time = 60;
190
  c->ifopt.scan_time = 60;
189 191
}
190 192

  
191 193
void
192 194
krt_if_shutdown(struct krt_proto *p)
193 195
{
194 196
  tm_stop(if_scan_timer);
195
  rfree(if_scan_timer);
196 197
  /* FIXME: What should we do with interfaces? */
197 198
}
198 199

  
sysdep/unix/sync-rt.c
1 1
/*
2 2
 *	BIRD -- Unix Routing Table Scanning and Syncing
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
23 23
#include "unix.h"
24 24
#include "krt.h"
25 25

  
26
struct proto *cf_krt_proto;
26
struct proto_config *cf_krt;
27 27

  
28
void
29
krt_start(struct proto *P)
28
static int
29
krt_start(struct proto *p)
30 30
{
31
  struct krt_proto *p = (struct krt_proto *) P;
32
  krt_scan_start(p);
33
  krt_if_start(p);
31
  struct krt_proto *k = (struct krt_proto *) p;
32

  
33
  krt_scan_start(k);
34
  krt_set_start(k);
35
  krt_if_start(k);
36
  return PS_UP;
37
}
38

  
39
int
40
krt_shutdown(struct proto *p)
41
{
42
  struct krt_proto *k = (struct krt_proto *) p;
43

  
44
  krt_scan_shutdown(k);
45
  krt_if_shutdown(k);
46
  return PS_DOWN;
34 47
}
35 48

  
36
void
37
krt_shutdown(struct proto *P, int time)
49
static void
50
krt_preconfig(struct protocol *x, struct config *c)
38 51
{
39
  struct krt_proto *p = (struct krt_proto *) P;
40
  krt_scan_shutdown(p);
41
  krt_if_shutdown(p);
52
  struct krt_config *z = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config));
53

  
54
  cf_krt = &z->c;
55
  z->c.preference = DEF_PREF_UKR;
56
  krt_scan_preconfig(z);
57
  krt_set_preconfig(z);
58
  krt_if_preconfig(z);
42 59
}
43 60

  
44
void
45
krt_preconfig(struct protocol *x)
61
static struct proto *
62
krt_init(struct proto_config *c)
46 63
{
47
  struct krt_proto *p = (struct krt_proto *) proto_new(&proto_unix_kernel, sizeof(struct krt_proto));
64
  struct krt_proto *p = proto_new(c, sizeof(struct krt_proto));
48 65

  
49
  cf_krt_proto = &p->p;
50
  p->p.preference = DEF_PREF_UKR;
51
  p->p.start = krt_start;
52
  p->p.shutdown = krt_shutdown;
53
  krt_scan_preconfig(p);
54
  krt_set_preconfig(p);
55
  krt_if_preconfig(p);
66
  return &p->p;
56 67
}
57 68

  
58 69
struct protocol proto_unix_kernel = {
59
  { NULL, NULL },
60
  "kernel",
61
  0,
62
  NULL,					/* init */
63
  krt_preconfig,
64
  NULL					/* postconfig */
70
  name:		"Kernel",
71
  preconfig:	krt_preconfig,
72
  init:		krt_init,
73
  start:	krt_start,
74
  shutdown:	krt_shutdown,
65 75
};

Also available in: Unified diff