diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2011-11-07 00:31:23 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2011-11-07 00:31:23 +0100 |
commit | a7f23f581f5e3efe92ec97dfca7d01c66f31ab04 (patch) | |
tree | 3a8f7cffb7abce83b7bce8be87d21be8a2fbff72 /proto/pipe | |
parent | 74add5df17c386bd109ebea7b1dac04d1651ae51 (diff) | |
download | bird-a7f23f581f5e3efe92ec97dfca7d01c66f31ab04.tar bird-a7f23f581f5e3efe92ec97dfca7d01c66f31ab04.zip |
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 'proto/pipe')
-rw-r--r-- | proto/pipe/config.Y | 2 | ||||
-rw-r--r-- | proto/pipe/pipe.c | 24 |
2 files changed, 17 insertions, 9 deletions
diff --git a/proto/pipe/config.Y b/proto/pipe/config.Y index e1c981b..4478afe 100644 --- a/proto/pipe/config.Y +++ b/proto/pipe/config.Y @@ -23,7 +23,7 @@ CF_GRAMMAR CF_ADDTO(proto, pipe_proto '}') pipe_proto_start: proto_start PIPE { - this_proto = proto_config_new(&proto_pipe, sizeof(struct pipe_config)); + this_proto = proto_config_new(&proto_pipe, sizeof(struct pipe_config), $1); this_proto->preference = DEF_PREF_PIPE; PIPE_CFG->mode = PIPE_TRANSPARENT; } diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c index e557097..420c5a9 100644 --- a/proto/pipe/pipe.c +++ b/proto/pipe/pipe.c @@ -165,14 +165,6 @@ pipe_postconfig(struct proto_config *C) cf_error("Primary table and peer table must be different"); } -static void -pipe_get_status(struct proto *P, byte *buf) -{ - struct pipe_proto *p = (struct pipe_proto *) P; - - bsprintf(buf, "%c> %s", (p->mode == PIPE_OPAQUE) ? '-' : '=', p->peer->name); -} - static int pipe_reconfigure(struct proto *P, struct proto_config *new) { @@ -186,6 +178,21 @@ pipe_reconfigure(struct proto *P, struct proto_config *new) return 1; } +static void +pipe_copy_config(struct proto_config *dest, struct proto_config *src) +{ + /* Just a shallow copy, not many items here */ + proto_copy_rest(dest, src, sizeof(struct pipe_config)); +} + +static void +pipe_get_status(struct proto *P, byte *buf) +{ + struct pipe_proto *p = (struct pipe_proto *) P; + + bsprintf(buf, "%c> %s", (p->mode == PIPE_OPAQUE) ? '-' : '=', p->peer->name); +} + struct protocol proto_pipe = { name: "Pipe", @@ -195,5 +202,6 @@ struct protocol proto_pipe = { start: pipe_start, cleanup: pipe_cleanup, reconfigure: pipe_reconfigure, + copy_config: pipe_copy_config, get_status: pipe_get_status, }; |