diff options
author | 2015-07-21 05:02:57 +0000 | |
---|---|---|
committer | 2015-07-21 05:02:57 +0000 | |
commit | 8d99d6538d63ae5b2e99e431d1c1c270f26a7305 (patch) | |
tree | e94729c5e09be47c03d35d50d63d86869973ba28 | |
parent | Remove more unused defines. (diff) | |
download | wireguard-openbsd-8d99d6538d63ae5b2e99e431d1c1c270f26a7305.tar.xz wireguard-openbsd-8d99d6538d63ae5b2e99e431d1c1c270f26a7305.zip |
Rename, move and reuse mapping list functions.
ok claudio@
-rw-r--r-- | usr.sbin/ldpd/labelmapping.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 34 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 26 |
4 files changed, 43 insertions, 46 deletions
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c index 2652092c594..18742bac66f 100644 --- a/usr.sbin/ldpd/labelmapping.c +++ b/usr.sbin/ldpd/labelmapping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: labelmapping.c,v 1.33 2015/07/21 04:52:29 renato Exp $ */ +/* $OpenBSD: labelmapping.c,v 1.34 2015/07/21 05:02:57 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -144,6 +144,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, u_int16_t len, u_int16_t type) int feclen, lbllen, tlen; struct mapping_entry *me; struct mapping_head mh; + struct map map; bcopy(buf, &lm, sizeof(lm)); @@ -173,16 +174,15 @@ recv_labelmessage(struct nbr *nbr, char *buf, u_int16_t len, u_int16_t type) TAILQ_INIT(&mh); do { - me = calloc(1, sizeof(*me)); - me->map.messageid = lm.msgid; - TAILQ_INSERT_HEAD(&mh, me, entry); + memset(&map, 0, sizeof(map)); + map.messageid = lm.msgid; if ((tlen = tlv_decode_fec_elm(nbr, &lm, buf, feclen, - &me->map)) == -1) + &map)) == -1) goto err; - if (me->map.type == FEC_PWID && + if (map.type == FEC_PWID && type == MSG_TYPE_LABELMAPPING && - !(me->map.flags & F_MAP_PW_ID)) { + !(map.flags & F_MAP_PW_ID)) { send_notification_nbr(nbr, S_MISS_MSG, lm.msgid, lm.type); return (-1); @@ -192,7 +192,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, u_int16_t len, u_int16_t type) * The Wildcard FEC Element can be used only in the * Label Withdraw and Label Release messages. */ - if (me->map.type == FEC_WILDCARD) { + if (map.type == FEC_WILDCARD) { switch (type) { case MSG_TYPE_LABELMAPPING: case MSG_TYPE_LABELREQUEST: @@ -216,6 +216,8 @@ recv_labelmessage(struct nbr *nbr, char *buf, u_int16_t len, u_int16_t type) goto err; } + mapping_list_add(&mh, &map); + buf += tlen; len -= tlen; feclen -= tlen; diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 53287efaeae..d0f204c35f6 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.37 2015/07/21 04:58:48 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.38 2015/07/21 05:02:57 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -573,16 +573,16 @@ ldpe_dispatch_lde(int fd, short event, void *bula) switch (imsg.hdr.type) { case IMSG_MAPPING_ADD: - nbr_mapping_add(nbr, &nbr->mapping_list, &map); + mapping_list_add(&nbr->mapping_list, &map); break; case IMSG_RELEASE_ADD: - nbr_mapping_add(nbr, &nbr->release_list, &map); + mapping_list_add(&nbr->release_list, &map); break; case IMSG_REQUEST_ADD: - nbr_mapping_add(nbr, &nbr->request_list, &map); + mapping_list_add(&nbr->request_list, &map); break; case IMSG_WITHDRAW_ADD: - nbr_mapping_add(nbr, &nbr->withdraw_list, &map); + mapping_list_add(&nbr->withdraw_list, &map); break; } break; @@ -674,6 +674,30 @@ ldpe_router_id(void) } void +mapping_list_add(struct mapping_head *mh, struct map *map) +{ + struct mapping_entry *me; + + me = calloc(1, sizeof(*me)); + if (me == NULL) + fatal("mapping_list_add"); + me->map = *map; + + TAILQ_INSERT_TAIL(mh, me, entry); +} + +void +mapping_list_clr(struct mapping_head *mh) +{ + struct mapping_entry *me; + + while ((me = TAILQ_FIRST(mh)) != NULL) { + TAILQ_REMOVE(mh, me, entry); + free(me); + } +} + +void ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx) { struct iface *iface; diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index 3dee443458d..e5fc4848f61 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.41 2015/07/21 04:58:48 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.42 2015/07/21 05:02:57 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -153,7 +153,8 @@ int ldpe_imsg_compose_parent(int, pid_t, void *, u_int16_t); int ldpe_imsg_compose_lde(int, u_int32_t, pid_t, void *, u_int16_t); u_int32_t ldpe_router_id(void); -void ldpe_fib_update(int); +void mapping_list_add(struct mapping_head *, struct map *); +void mapping_list_clr(struct mapping_head *); void ldpe_iface_ctl(struct ctl_conn *, unsigned int); /* interface.c */ @@ -217,14 +218,8 @@ void nbr_start_idtimer(struct nbr *); void nbr_stop_idtimer(struct nbr *); int nbr_pending_idtimer(struct nbr *); int nbr_pending_connect(struct nbr *); - int nbr_establish_connection(struct nbr *); -void nbr_mapping_add(struct nbr *, struct mapping_head *, - struct map *); -void mapping_list_clr(struct mapping_head *); - - struct nbr_params *nbr_params_new(struct in_addr); struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr); diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index c7c0c058152..5e2797d56f2 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.51 2015/07/21 05:01:46 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.52 2015/07/21 05:02:57 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -575,30 +575,6 @@ nbr_send_labelmappings(struct nbr *nbr) NULL, 0); } -void -nbr_mapping_add(struct nbr *nbr, struct mapping_head *mh, struct map *map) -{ - struct mapping_entry *me; - - me = calloc(1, sizeof(*me)); - if (me == NULL) - fatal("nbr_mapping_add"); - me->map = *map; - - TAILQ_INSERT_TAIL(mh, me, entry); -} - -void -mapping_list_clr(struct mapping_head *mh) -{ - struct mapping_entry *me; - - while ((me = TAILQ_FIRST(mh)) != NULL) { - TAILQ_REMOVE(mh, me, entry); - free(me); - } -} - struct nbr_params * nbr_params_new(struct in_addr addr) { |