-/* $OpenBSD: labelmapping.c,v 1.58 2016/07/16 19:20:16 renato Exp $ */
+/* $OpenBSD: labelmapping.c,v 1.59 2016/08/08 16:45:51 renato Exp $ */
/*
* Copyright (c) 2014, 2015 Renato Westphal <renato@openbsd.org>
switch (me->map.type) {
case MAP_TYPE_PREFIX:
switch (me->map.fec.prefix.af) {
- case AF_IPV4:
+ case AF_INET:
if (label == MPLS_LABEL_IPV6NULL) {
session_shutdown(nbr, S_BAD_TLV_VAL,
msg.id, msg.type);
if (!nbr->v4_enabled)
goto next;
break;
- case AF_IPV6:
+ case AF_INET6:
if (label == MPLS_LABEL_IPV4NULL) {
session_shutdown(nbr, S_BAD_TLV_VAL,
msg.id, msg.type);
ft.length = htons(sizeof(map->type) + sizeof(family) +
sizeof(map->fec.prefix.prefixlen) + len);
err |= ibuf_add(buf, &ft, sizeof(ft));
-
err |= ibuf_add(buf, &map->type, sizeof(map->type));
- family = htons(map->fec.prefix.af);
+ switch (map->fec.prefix.af) {
+ case AF_INET:
+ family = htons(AF_IPV4);
+ break;
+ case AF_INET6:
+ family = htons(AF_IPV6);
+ break;
+ default:
+ fatalx("gen_fec_tlv: unknown af");
+ break;
+ }
err |= ibuf_add(buf, &family, sizeof(family));
err |= ibuf_add(buf, &map->fec.prefix.prefixlen,
sizeof(map->fec.prefix.prefixlen));
/* Address Family */
memcpy(&map->fec.prefix.af, buf + off,
sizeof(map->fec.prefix.af));
- map->fec.prefix.af = ntohs(map->fec.prefix.af);
off += sizeof(map->fec.prefix.af);
- if (map->fec.prefix.af != AF_IPV4 &&
- map->fec.prefix.af != AF_IPV6) {
+ map->fec.prefix.af = ntohs(map->fec.prefix.af);
+ switch (map->fec.prefix.af) {
+ case AF_IPV4:
+ map->fec.prefix.af = AF_INET;
+ break;
+ case AF_IPV6:
+ map->fec.prefix.af = AF_INET6;
+ break;
+ default:
send_notification_nbr(nbr, S_UNSUP_ADDR, msg->id,
msg->type);
return (-1);
memcpy(&map->fec.prefix.prefix, buf + off,
PREFIX_SIZE(map->fec.prefix.prefixlen));
+ /* Just in case... */
+ ldp_applymask(map->fec.prefix.af, &map->fec.prefix.prefix,
+ &map->fec.prefix.prefix, map->fec.prefix.prefixlen);
+
return (off + PREFIX_SIZE(map->fec.prefix.prefixlen));
case MAP_TYPE_PWID:
if (len < FEC_PWID_ELM_MIN_LEN) {
-/* $OpenBSD: lde.c,v 1.62 2016/07/18 21:10:37 benno Exp $ */
+/* $OpenBSD: lde.c,v 1.63 2016/08/08 16:45:51 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
switch (fec->type) {
case FEC_TYPE_IPV4:
map->type = MAP_TYPE_PREFIX;
- map->fec.prefix.af = AF_IPV4;
+ map->fec.prefix.af = AF_INET;
map->fec.prefix.prefix.v4 = fec->u.ipv4.prefix;
map->fec.prefix.prefixlen = fec->u.ipv4.prefixlen;
break;
case FEC_TYPE_IPV6:
map->type = MAP_TYPE_PREFIX;
- map->fec.prefix.af = AF_IPV6;
+ map->fec.prefix.af = AF_INET6;
map->fec.prefix.prefix.v6 = fec->u.ipv6.prefix;
map->fec.prefix.prefixlen = fec->u.ipv6.prefixlen;
break;
switch (map->type) {
case MAP_TYPE_PREFIX:
switch (map->fec.prefix.af) {
- case AF_IPV4:
+ case AF_INET:
fec->type = FEC_TYPE_IPV4;
fec->u.ipv4.prefix = map->fec.prefix.prefix.v4;
fec->u.ipv4.prefixlen = map->fec.prefix.prefixlen;
break;
- case AF_IPV6:
+ case AF_INET6:
fec->type = FEC_TYPE_IPV6;
fec->u.ipv6.prefix = map->fec.prefix.prefix.v6;
fec->u.ipv6.prefixlen = map->fec.prefix.prefixlen;
-/* $OpenBSD: log.c,v 1.29 2016/07/15 17:09:25 renato Exp $ */
+/* $OpenBSD: log.c,v 1.30 2016/08/08 16:45:51 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
log_map(const struct map *map)
{
static char buf[64];
- int af;
switch (map->type) {
case MAP_TYPE_WILDCARD:
return ("???");
break;
case MAP_TYPE_PREFIX:
- switch (map->fec.prefix.af) {
- case AF_IPV4:
- af = AF_INET;
- break;
- case AF_IPV6:
- af = AF_INET6;
- break;
- default:
- return ("???");
- }
-
if (snprintf(buf, sizeof(buf), "%s/%u",
- log_addr(af, &map->fec.prefix.prefix),
+ log_addr(map->fec.prefix.af, &map->fec.prefix.prefix),
map->fec.prefix.prefixlen) == -1)
return ("???");
break;