summaryrefslogtreecommitdiff
path: root/proto/pipe/pipe.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-06-01 12:10:10 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-06-01 12:10:10 +0200
commit2d45e09f58c4ce857e10c241cf0e89b51b9ec49c (patch)
tree3355b3a745990f7c60be7ef5c37c3c222f87b054 /proto/pipe/pipe.c
parent23ac9e9a9eefe13918ee7f21a1d0f271a44d9efd (diff)
Adds opaque/transparent pipe mode selection.
Diffstat (limited to 'proto/pipe/pipe.c')
-rw-r--r--proto/pipe/pipe.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c
index 0240d16e..74e1bb3b 100644
--- a/proto/pipe/pipe.c
+++ b/proto/pipe/pipe.c
@@ -51,13 +51,23 @@ pipe_send(struct pipe_proto *p, rtable *dest, net *n, rte *new, rte *old, ea_lis
if (new)
{
memcpy(&a, new->attrs, sizeof(rta));
+
+ if (p->mode == PIPE_OPAQUE)
+ {
+ a.proto = &p->p;
+ a.source = RTS_PIPE;
+ }
+
a.aflags = 0;
a.eattrs = attrs;
e = rte_get_temp(&a);
e->net = nn;
- /* Copy protocol specific embedded attributes. */
- memcpy(&(e->u), &(new->u), sizeof(e->u));
+ if (p->mode == PIPE_TRANSPARENT)
+ {
+ /* Copy protocol specific embedded attributes. */
+ memcpy(&(e->u), &(new->u), sizeof(e->u));
+ }
src = new->attrs->proto;
}
@@ -68,7 +78,7 @@ pipe_send(struct pipe_proto *p, rtable *dest, net *n, rte *new, rte *old, ea_lis
}
dest->pipe_busy = 1;
- rte_update2(dest, nn, &p->p, src, e);
+ rte_update2(dest, nn, &p->p, (p->mode == PIPE_OPAQUE) ? &p->p : src, e);
dest->pipe_busy = 0;
}
@@ -117,7 +127,7 @@ pipe_start(struct proto *P)
memcpy(ph, p, sizeof(struct pipe_proto));
p->phantom = ph;
ph->phantom = p;
- ph->p.accept_ra_types = RA_ANY;
+ ph->p.accept_ra_types = (p->mode == PIPE_OPAQUE) ? RA_OPTIMAL : RA_ANY;
ph->p.rt_notify = pipe_rt_notify_sec;
ph->p.proto_state = PS_UP;
ph->p.core_state = ph->p.core_goal = FS_HAPPY;
@@ -153,7 +163,8 @@ pipe_init(struct proto_config *C)
struct pipe_proto *p = (struct pipe_proto *) P;
p->peer = c->peer->table;
- P->accept_ra_types = RA_ANY;
+ p->mode = c->mode;
+ P->accept_ra_types = (p->mode == PIPE_OPAQUE) ? RA_OPTIMAL : RA_ANY;
P->rt_notify = pipe_rt_notify_pri;
P->import_control = pipe_import_control;
return P;
@@ -175,7 +186,7 @@ pipe_get_status(struct proto *P, byte *buf)
{
struct pipe_proto *p = (struct pipe_proto *) P;
- bsprintf(buf, "-> %s", p->peer->name);
+ bsprintf(buf, "%c> %s", (p->mode == PIPE_OPAQUE) ? '-' : '=', p->peer->name);
}
static int
@@ -184,7 +195,7 @@ pipe_reconfigure(struct proto *p, struct proto_config *new)
struct pipe_config *o = (struct pipe_config *) p->cf;
struct pipe_config *n = (struct pipe_config *) new;
- return o->peer == n->peer;
+ return (o->peer == n->peer) && (o->mode == n->mode);
}
struct protocol proto_pipe = {