summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-06-10 09:58:10 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-06-10 09:58:10 +0000
commit38bf32c05341b43c3f094cea79170097648de89f (patch)
treeea143834f22183dda5a52ec2e6e0dd9923b71ef5
parente9ac32bf84e6c5f68608deacf1171d30b57c187f (diff)
Introduce attr_optlen() to get the total lenght of an optional attribute
plus header. Soon needed.
-rw-r--r--usr.sbin/bgpd/rde.h3
-rw-r--r--usr.sbin/bgpd/rde_attr.c11
2 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index dc09c897489..a0862b3f9ec 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.64 2005/04/12 14:32:00 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.65 2005/06/10 09:58:09 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -249,6 +249,7 @@ int rde_decisionflags(void);
/* rde_attr.c */
int attr_write(void *, u_int16_t, u_int8_t, u_int8_t, void *,
u_int16_t);
+int attr_optlen(struct attr *);
void attr_optcopy(struct rde_aspath *, struct rde_aspath *);
int attr_optadd(struct rde_aspath *, u_int8_t, u_int8_t,
void *, u_int16_t);
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c
index 7a1495bd896..0a64a18f14c 100644
--- a/usr.sbin/bgpd/rde_attr.c
+++ b/usr.sbin/bgpd/rde_attr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_attr.c,v 1.46 2005/04/16 19:56:31 claudio Exp $ */
+/* $OpenBSD: rde_attr.c,v 1.47 2005/06/10 09:58:09 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -62,6 +62,15 @@ attr_write(void *p, u_int16_t p_len, u_int8_t flags, u_int8_t type,
}
int
+attr_optlen(struct attr *a)
+{
+ if (a->len > 255)
+ return (4 + a->len);
+ else
+ return (3 + a->len);
+}
+
+int
attr_optadd(struct rde_aspath *asp, u_int8_t flags, u_int8_t type,
void *data, u_int16_t len)
{