diff options
author | 2016-05-23 16:12:28 +0000 | |
---|---|---|
committer | 2016-05-23 16:12:28 +0000 | |
commit | cf09440fd03afa7896599d4f9703042f99dedadc (patch) | |
tree | 660d827ec0021a86cea647c70606f0e0e258f14d | |
parent | Remove unused code. (diff) | |
download | wireguard-openbsd-cf09440fd03afa7896599d4f9703042f99dedadc.tar.xz wireguard-openbsd-cf09440fd03afa7896599d4f9703042f99dedadc.zip |
Rename a few constants to avoid confusion.
In ldpd we have the map structure, which is used to represent a label message,
and the fec structure, used to store FECs in the LIB.
As of now, ldpd supports two type of FECs:
* IPv4 prefix (FEC_TYPE_IPV4);
* PWID (FEC_TYPE_PWID).
For the label messages, the following contants were being used:
* FEC_WILDCARD;
* FEC_PREFIX (IPv4 or IPv6);
* FEC_PWID.
Since these contants have similar names to the previous ones, rename
them to:
* MAP_TYPE_WILDCARD;
* MAP_TYPE_PREFIX;
* MAP_TYPE_PWID.
-rw-r--r-- | usr.sbin/ldpd/labelmapping.c | 14 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.c | 14 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde_lib.c | 8 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldp.h | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/log.c | 8 | ||||
-rw-r--r-- | usr.sbin/ldpd/notification.c | 8 |
6 files changed, 32 insertions, 31 deletions
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c index 9b24bdb7890..04a200db160 100644 --- a/usr.sbin/ldpd/labelmapping.c +++ b/usr.sbin/ldpd/labelmapping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: labelmapping.c,v 1.36 2016/05/23 16:04:04 renato Exp $ */ +/* $OpenBSD: labelmapping.c,v 1.37 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -180,7 +180,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, u_int16_t len, u_int16_t type) if ((tlen = tlv_decode_fec_elm(nbr, &lm, buf, feclen, &map)) == -1) goto err; - if (map.type == FEC_PWID && + if (map.type == MAP_TYPE_PWID && type == MSG_TYPE_LABELMAPPING && !(map.flags & F_MAP_PW_ID)) { send_notification_nbr(nbr, S_MISS_MSG, lm.msgid, @@ -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 (map.type == FEC_WILDCARD) { + if (map.type == MAP_TYPE_WILDCARD) { switch (type) { case MSG_TYPE_LABELMAPPING: case MSG_TYPE_LABELREQUEST: @@ -510,7 +510,7 @@ gen_fec_tlv(struct ibuf *buf, struct map *map) if (len) ibuf_add(buf, &map->fec.ipv4.prefix, len); break; - case FEC_PWID: + case MAP_TYPE_PWID: if (map->flags & F_MAP_PW_ID) pw_len += sizeof(u_int32_t); if (map->flags & F_MAP_PW_IFMTU) @@ -561,7 +561,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, off += sizeof(u_int8_t); switch (map->type) { - case FEC_WILDCARD: + case MAP_TYPE_WILDCARD: if (len == FEC_ELM_WCARD_LEN) return (off); else { @@ -570,7 +570,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, return (-1); } break; - case FEC_PREFIX: + case MAP_TYPE_PREFIX: if (len < FEC_ELM_PREFIX_MIN_LEN) { session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid, lm->type); @@ -604,7 +604,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, return (off + PREFIX_SIZE(map->fec.ipv4.prefixlen)); break; - case FEC_PWID: + case MAP_TYPE_PWID: if (len < FEC_PWID_ELM_MIN_LEN) { session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid, lm->type); diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index 909a7a9c942..d51712c09e1 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.42 2016/05/23 15:47:24 renato Exp $ */ +/* $OpenBSD: lde.c,v 1.43 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -266,13 +266,13 @@ lde_dispatch_imsg(int fd, short event, void *bula) lde_check_request(&map, nbr); break; case IMSG_LABEL_RELEASE: - if (map.type == FEC_WILDCARD) + if (map.type == MAP_TYPE_WILDCARD) lde_check_release_wcard(&map, nbr); else lde_check_release(&map, nbr); break; case IMSG_LABEL_WITHDRAW: - if (map.type == FEC_WILDCARD) + if (map.type == MAP_TYPE_WILDCARD) lde_check_withdraw_wcard(&map, nbr); else lde_check_withdraw(&map, nbr); @@ -643,12 +643,12 @@ lde_fec2map(struct fec *fec, struct map *map) switch (fec->type) { case FEC_TYPE_IPV4: - map->type = FEC_PREFIX; + map->type = MAP_TYPE_PREFIX; map->fec.ipv4.prefix = fec->u.ipv4.prefix; map->fec.ipv4.prefixlen = fec->u.ipv4.prefixlen; break; case FEC_TYPE_PWID: - map->type = FEC_PWID; + map->type = MAP_TYPE_PWID; map->fec.pwid.type = fec->u.pwid.type; map->fec.pwid.group_id = 0; map->flags |= F_MAP_PW_ID; @@ -663,12 +663,12 @@ lde_map2fec(struct map *map, struct in_addr nbrid, struct fec *fec) bzero(fec, sizeof(*fec)); switch (map->type) { - case FEC_PREFIX: + case MAP_TYPE_PREFIX: fec->type = FEC_TYPE_IPV4; fec->u.ipv4.prefix.s_addr = map->fec.ipv4.prefix.s_addr; fec->u.ipv4.prefixlen = map->fec.ipv4.prefixlen; break; - case FEC_PWID: + case MAP_TYPE_PWID: fec->type = FEC_TYPE_PWID; fec->u.pwid.type = map->fec.pwid.type; fec->u.pwid.pwid = map->fec.pwid.pwid; diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c index 75eee0c2ff8..0dcc3246a85 100644 --- a/usr.sbin/ldpd/lde_lib.c +++ b/usr.sbin/ldpd/lde_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde_lib.c,v 1.41 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: lde_lib.c,v 1.42 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -407,7 +407,7 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln) lde_req_del(ln, lre, 1); /* RFC 4447 control word and status tlv negotiation */ - if (map->type == FEC_PWID && l2vpn_pw_negotiate(ln, fn, map)) + if (map->type == MAP_TYPE_PWID && l2vpn_pw_negotiate(ln, fn, map)) return; /* @@ -446,10 +446,10 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln) /* LMp.15: install FEC in FIB */ fnh->remote_label = map->label; switch (map->type) { - case FEC_PREFIX: + case MAP_TYPE_PREFIX: lde_send_change_klabel(fn, fnh); break; - case FEC_PWID: + case MAP_TYPE_PWID: pw = (struct l2vpn_pw *) fnh->data; pw->remote_group = map->fec.pwid.group_id; if (map->flags & F_MAP_PW_IFMTU) diff --git a/usr.sbin/ldpd/ldp.h b/usr.sbin/ldpd/ldp.h index a964214de32..f3f1cda854e 100644 --- a/usr.sbin/ldpd/ldp.h +++ b/usr.sbin/ldpd/ldp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldp.h,v 1.23 2016/05/23 16:10:23 renato Exp $ */ +/* $OpenBSD: ldp.h,v 1.24 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -220,10 +220,11 @@ struct address_list_tlv { #define FEC_ELM_WCARD_LEN 1 #define FEC_ELM_PREFIX_MIN_LEN 4 #define FEC_PWID_ELM_MIN_LEN 8 -#define FEC_WILDCARD 0x01 -#define FEC_PREFIX 0x02 -#define FEC_PWID 0x80 -#define FEC_GENPWID 0x81 + +#define MAP_TYPE_WILDCARD 0x01 +#define MAP_TYPE_PREFIX 0x02 +#define MAP_TYPE_PWID 0x80 +#define MAP_TYPE_GENPWID 0x81 #define CONTROL_WORD_FLAG 0x8000 #define PW_TYPE_ETHERNET_TAGGED 0x0004 diff --git a/usr.sbin/ldpd/log.c b/usr.sbin/ldpd/log.c index 7a6d096f87d..ec9e2f60efb 100644 --- a/usr.sbin/ldpd/log.c +++ b/usr.sbin/ldpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.18 2016/05/23 15:47:24 renato Exp $ */ +/* $OpenBSD: log.c,v 1.19 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -342,17 +342,17 @@ log_map(struct map *map) char pstr[64]; switch (map->type) { - case FEC_WILDCARD: + case MAP_TYPE_WILDCARD: if (snprintf(buf, sizeof(buf), "wildcard") < 0) return ("???"); break; - case FEC_PREFIX: + case MAP_TYPE_PREFIX: if (snprintf(buf, sizeof(buf), "%s/%u", inet_ntop(AF_INET, &map->fec.ipv4.prefix, pstr, sizeof(pstr)), map->fec.ipv4.prefixlen) == -1) return ("???"); break; - case FEC_PWID: + case MAP_TYPE_PWID: if (snprintf(buf, sizeof(buf), "pwid %u (%s)", map->fec.pwid.pwid, pw_type_name(map->fec.pwid.type)) == -1) diff --git a/usr.sbin/ldpd/notification.c b/usr.sbin/ldpd/notification.c index 6d4ca1884f9..2c9118fa0ef 100644 --- a/usr.sbin/ldpd/notification.c +++ b/usr.sbin/ldpd/notification.c @@ -1,4 +1,4 @@ -/* $OpenBSD: notification.c,v 1.21 2016/05/23 16:04:04 renato Exp $ */ +/* $OpenBSD: notification.c,v 1.22 2016/05/23 16:12:28 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -55,7 +55,7 @@ send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm) if (nm->flags & F_NOTIF_FEC) { size += TLV_HDR_LEN; switch (nm->fec.type) { - case FEC_PWID: + case MAP_TYPE_PWID: size += FEC_PWID_ELM_MIN_LEN; if (nm->fec.flags & F_MAP_PW_ID) size += sizeof(u_int32_t); @@ -199,8 +199,8 @@ recv_notification(struct nbr *nbr, char *buf, u_int16_t len) } switch (nm.fec.type) { - case FEC_PWID: - case FEC_GENPWID: + case MAP_TYPE_PWID: + case MAP_TYPE_GENPWID: break; default: send_notification_nbr(nbr, S_BAD_TLV_VAL, |