summaryrefslogtreecommitdiff
path: root/sysdep/unix/krt.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2011-11-07 00:31:23 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2011-11-07 00:31:23 +0100
commita7f23f581f5e3efe92ec97dfca7d01c66f31ab04 (patch)
tree3a8f7cffb7abce83b7bce8be87d21be8a2fbff72 /sysdep/unix/krt.c
parent74add5df17c386bd109ebea7b1dac04d1651ae51 (diff)
Implements protocol templates.
Based on the patch from Alexander V. Chernikov. Extended to support almost all protocols. Uses 'protocol bgp NAME from TEMPLATE { ... }' syntax.
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r--sysdep/unix/krt.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 70570703..e5a8ce17 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -216,6 +216,23 @@ kif_reconfigure(struct proto *p, struct proto_config *new)
return 1;
}
+static void
+kif_copy_config(struct proto_config *dest, struct proto_config *src)
+{
+ struct kif_config *d = (struct kif_config *) dest;
+ struct kif_config *s = (struct kif_config *) src;
+
+ /* Shallow copy of everything (just scan_time currently) */
+ proto_copy_rest(dest, src, sizeof(struct krt_config));
+
+ /* Copy primary addr list */
+ cfg_copy_list(&d->primary, &s->primary, sizeof(struct kif_primary_item));
+
+ /* Fix sysdep parts */
+ kif_copy_params(&d->iface, &s->iface);
+}
+
+
struct protocol proto_unix_iface = {
name: "Device",
template: "device%d",
@@ -224,6 +241,7 @@ struct protocol proto_unix_iface = {
start: kif_start,
shutdown: kif_shutdown,
reconfigure: kif_reconfigure,
+ copy_config: kif_copy_config
};
/*
@@ -908,6 +926,19 @@ krt_reconfigure(struct proto *p, struct proto_config *new)
;
}
+static void
+krt_copy_config(struct proto_config *dest, struct proto_config *src)
+{
+ struct krt_config *d = (struct krt_config *) dest;
+ struct krt_config *s = (struct krt_config *) src;
+
+ /* Shallow copy of everything */
+ proto_copy_rest(dest, src, sizeof(struct krt_config));
+
+ /* Fix sysdep parts */
+ krt_set_copy_params(&d->set, &s->set);
+ krt_scan_copy_params(&d->scan, &s->scan);
+}
static int
krt_get_attr(eattr * a, byte * buf, int buflen UNUSED)
@@ -936,6 +967,7 @@ struct protocol proto_unix_kernel = {
start: krt_start,
shutdown: krt_shutdown,
reconfigure: krt_reconfigure,
+ copy_config: krt_copy_config,
get_attr: krt_get_attr,
#ifdef KRT_ALLOW_LEARN
dump: krt_dump,