summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-10-26 12:22:36 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-10-26 12:22:36 +0000
commited53b13769e7d9220fcd03934fa283cb214a0e23 (patch)
treeafef9b1a2a9b335ce552e0b9349bab47f6b252a0
parent18960c0a7068e83813d671585621a11abd4dbc1b (diff)
struct mapping_entry should just have a struct map instead of own
definition of a FEC mapping. This makes extending struct map simpler and makes it possible to access the additional data in struct map.
-rw-r--r--usr.sbin/ldpd/labelmapping.c40
-rw-r--r--usr.sbin/ldpd/ldpe.h6
-rw-r--r--usr.sbin/ldpd/neighbor.c11
3 files changed, 26 insertions, 31 deletions
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c
index 6667f93decd..7b469a3b03f 100644
--- a/usr.sbin/ldpd/labelmapping.c
+++ b/usr.sbin/ldpd/labelmapping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: labelmapping.c,v 1.13 2010/06/30 01:47:11 claudio Exp $ */
+/* $OpenBSD: labelmapping.c,v 1.14 2010/10/26 12:22:35 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -37,7 +37,7 @@
#include "log.h"
#include "ldpe.h"
-void gen_fec_tlv(struct ibuf *, u_int32_t, u_int8_t);
+void gen_fec_tlv(struct ibuf *, struct in_addr, u_int8_t);
void gen_label_tlv(struct ibuf *, u_int32_t);
u_int32_t tlv_decode_label(struct label_tlv *);
@@ -65,12 +65,12 @@ send_labelmapping(struct nbr *nbr)
size = LDP_HDR_SIZE - TLV_HDR_LEN;
TAILQ_FOREACH(me, &nbr->mapping_list, entry) {
- tlv_size = BASIC_LABEL_MAP_LEN + PREFIX_SIZE(me->prefixlen);
+ tlv_size = BASIC_LABEL_MAP_LEN + PREFIX_SIZE(me->map.prefixlen);
size += tlv_size;
gen_msg_tlv(buf, MSG_TYPE_LABELMAPPING, tlv_size);
- gen_fec_tlv(buf, me->prefix, me->prefixlen);
- gen_label_tlv(buf, me->label);
+ gen_fec_tlv(buf, me->map.prefix, me->map.prefixlen);
+ gen_label_tlv(buf, me->map.label);
}
/* XXX: should we remove them first? */
@@ -174,11 +174,11 @@ send_labelrequest(struct nbr *nbr)
size = LDP_HDR_SIZE - TLV_HDR_LEN;
TAILQ_FOREACH(me, &nbr->request_list, entry) {
- tlv_size = PREFIX_SIZE(me->prefixlen);
+ tlv_size = PREFIX_SIZE(me->map.prefixlen);
size += tlv_size;
gen_msg_tlv(buf, MSG_TYPE_LABELREQUEST, tlv_size);
- gen_fec_tlv(buf, me->prefix, me->prefixlen);
+ gen_fec_tlv(buf, me->map.prefix, me->map.prefixlen);
}
/* XXX: should we remove them first? */
@@ -269,19 +269,19 @@ send_labelwithdraw(struct nbr *nbr)
size = LDP_HDR_SIZE - TLV_HDR_LEN;
TAILQ_FOREACH(me, &nbr->withdraw_list, entry) {
- if (me->label == NO_LABEL)
- tlv_size = PREFIX_SIZE(me->prefixlen);
+ if (me->map.label == NO_LABEL)
+ tlv_size = PREFIX_SIZE(me->map.prefixlen);
else
tlv_size = BASIC_LABEL_MAP_LEN +
- PREFIX_SIZE(me->prefixlen);
+ PREFIX_SIZE(me->map.prefixlen);
size += tlv_size;
gen_msg_tlv(buf, MSG_TYPE_LABELWITHDRAW, tlv_size);
- gen_fec_tlv(buf, me->prefix, me->prefixlen);
+ gen_fec_tlv(buf, me->map.prefix, me->map.prefixlen);
- if (me->label != NO_LABEL)
- gen_label_tlv(buf, me->label);
+ if (me->map.label != NO_LABEL)
+ gen_label_tlv(buf, me->map.label);
}
/* XXX: should we remove them first? */
@@ -396,19 +396,19 @@ send_labelrelease(struct nbr *nbr)
size = LDP_HDR_SIZE - TLV_HDR_LEN;
TAILQ_FOREACH(me, &nbr->release_list, entry) {
- if (me->label == NO_LABEL)
- tlv_size = PREFIX_SIZE(me->prefixlen);
+ if (me->map.label == NO_LABEL)
+ tlv_size = PREFIX_SIZE(me->map.prefixlen);
else
tlv_size = BASIC_LABEL_MAP_LEN +
- PREFIX_SIZE(me->prefixlen);
+ PREFIX_SIZE(me->map.prefixlen);
size += tlv_size;
gen_msg_tlv(buf, MSG_TYPE_LABELRELEASE, tlv_size);
- gen_fec_tlv(buf, me->prefix, me->prefixlen);
+ gen_fec_tlv(buf, me->map.prefix, me->map.prefixlen);
- if (me->label != NO_LABEL)
- gen_label_tlv(buf, me->label);
+ if (me->map.label != NO_LABEL)
+ gen_label_tlv(buf, me->map.label);
}
/* XXX: should we remove them first? */
@@ -555,7 +555,7 @@ recv_labelabortreq(struct nbr *nbr, char *buf, u_int16_t len)
/* Other TLV related functions */
void
-gen_fec_tlv(struct ibuf *buf, u_int32_t prefix, u_int8_t prefixlen)
+gen_fec_tlv(struct ibuf *buf, struct in_addr prefix, u_int8_t prefixlen)
{
struct fec_tlv ft;
u_int8_t type;
diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h
index baccbd1b045..4691859adf8 100644
--- a/usr.sbin/ldpd/ldpe.h
+++ b/usr.sbin/ldpd/ldpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.h,v 1.11 2010/09/06 08:28:43 claudio Exp $ */
+/* $OpenBSD: ldpe.h,v 1.12 2010/10/26 12:22:35 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -31,9 +31,7 @@ TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns;
struct mapping_entry {
TAILQ_ENTRY(mapping_entry) entry;
- u_int32_t label;
- u_int32_t prefix;
- u_int8_t prefixlen;
+ struct map map;
};
struct nbr {
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index f28f9f536e6..918c4fe1b4e 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.21 2010/09/06 08:36:33 claudio Exp $ */
+/* $OpenBSD: neighbor.c,v 1.22 2010/10/26 12:22:35 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -556,10 +556,7 @@ nbr_mapping_add(struct nbr *nbr, struct mapping_head *mh, struct map *map)
me = calloc(1, sizeof(*me));
if (me == NULL)
fatal("nbr_mapping_add");
-
- me->prefix = map->prefix.s_addr;
- me->prefixlen = map->prefixlen;
- me->label = map->label;
+ me->map = *map;
TAILQ_INSERT_TAIL(mh, me, entry);
}
@@ -570,8 +567,8 @@ nbr_mapping_find(struct nbr *nbr, struct mapping_head *mh, struct map *map)
struct mapping_entry *me = NULL;
TAILQ_FOREACH(me, mh, entry) {
- if (me->prefix == map->prefix.s_addr &&
- me->prefixlen == map->prefixlen)
+ if (me->map.prefix.s_addr == map->prefix.s_addr &&
+ me->map.prefixlen == map->prefixlen)
return (me);
}