No binary change after "strip -s".
-/* $OpenBSD: address.c,v 1.27 2016/07/01 23:29:55 renato Exp $ */
+/* $OpenBSD: address.c,v 1.28 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
int
recv_address(struct nbr *nbr, char *buf, uint16_t len)
{
- struct ldp_msg addr;
+ struct ldp_msg msg;
struct address_list_tlv alt;
enum imsg_type type;
struct lde_addr lde_addr;
- memcpy(&addr, buf, sizeof(addr));
+ memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
len -= LDP_MSG_SIZE;
/* Address List TLV */
if (len < sizeof(alt)) {
- session_shutdown(nbr, S_BAD_MSG_LEN, addr.msgid, addr.type);
+ session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
return (-1);
}
memcpy(&alt, buf, sizeof(alt));
- if (ntohs(alt.length) != len - TLV_HDR_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, addr.msgid, addr.type);
+ if (ntohs(alt.length) != len - TLV_HDR_SIZE) {
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
return (-1);
}
if (ntohs(alt.type) != TLV_TYPE_ADDRLIST) {
- session_shutdown(nbr, S_UNKNOWN_TLV, addr.msgid, addr.type);
+ session_shutdown(nbr, S_UNKNOWN_TLV, msg.id, msg.type);
return (-1);
}
switch (ntohs(alt.family)) {
return (0);
break;
default:
- send_notification_nbr(nbr, S_UNSUP_ADDR, addr.msgid, addr.type);
+ send_notification_nbr(nbr, S_UNSUP_ADDR, msg.id, msg.type);
return (-1);
}
buf += sizeof(alt);
len -= sizeof(alt);
- if (ntohs(addr.type) == MSG_TYPE_ADDR)
+ if (ntohs(msg.type) == MSG_TYPE_ADDR)
type = IMSG_ADDRESS_ADD;
else
type = IMSG_ADDRESS_DEL;
switch (ntohs(alt.family)) {
case AF_IPV4:
if (len < sizeof(struct in_addr)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, addr.msgid,
- addr.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id,
+ msg.type);
return (-1);
}
break;
case AF_IPV6:
if (len < sizeof(struct in6_addr)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, addr.msgid,
- addr.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id,
+ msg.type);
return (-1);
}
log_debug("%s: lsr-id %s address %s%s", __func__,
inet_ntoa(nbr->id), log_addr(lde_addr.af, &lde_addr.addr),
- ntohs(addr.type) == MSG_TYPE_ADDR ? "" : " (withdraw)");
+ ntohs(msg.type) == MSG_TYPE_ADDR ? "" : " (withdraw)");
ldpe_imsg_compose_lde(type, nbr->peerid, 0, &lde_addr,
sizeof(lde_addr));
memset(&alt, 0, sizeof(alt));
alt.type = TLV_TYPE_ADDRLIST;
- alt.length = htons(size - TLV_HDR_LEN);
+ alt.length = htons(size - TLV_HDR_SIZE);
switch (af) {
case AF_INET:
alt.family = htons(AF_IPV4);
-/* $OpenBSD: hello.c,v 1.55 2016/07/01 23:29:55 renato Exp $ */
+/* $OpenBSD: hello.c,v 1.56 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
}
void
-recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af,
+recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
union ldpd_addr *src, struct iface *iface, int multicast, char *buf,
uint16_t len)
{
log_debug("%s: lsr-id %s: remote transport preference does not "
"match the local preference", __func__, inet_ntoa(lsr_id));
if (nbr)
- session_shutdown(nbr, S_TRANS_MISMTCH, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_TRANS_MISMTCH, msg->id,
+ msg->type);
if (adj)
adj_del(adj, S_SHUTDOWN);
return;
case AF_INET:
if (nbr_adj_count(nbr, AF_INET6) > 0) {
session_shutdown(nbr, S_DS_NONCMPLNCE,
- lm->msgid, lm->type);
+ msg->id, msg->type);
return;
}
break;
case AF_INET6:
if (nbr_adj_count(nbr, AF_INET) > 0) {
session_shutdown(nbr, S_DS_NONCMPLNCE,
- lm->msgid, lm->type);
+ msg->id, msg->type);
return;
}
break;
if (tlv.type != htons(TLV_TYPE_COMMONHELLO))
return (-1);
- if (ntohs(tlv.length) != sizeof(tlv) - TLV_HDR_LEN)
+ if (ntohs(tlv.length) != sizeof(tlv) - TLV_HDR_SIZE)
return (-1);
*holdtime = ntohs(tlv.holdtime);
* given address family".
*/
while (len >= sizeof(tlv)) {
- memcpy(&tlv, buf, TLV_HDR_LEN);
- buf += TLV_HDR_LEN;
- len -= TLV_HDR_LEN;
- total += TLV_HDR_LEN;
+ memcpy(&tlv, buf, TLV_HDR_SIZE);
+ buf += TLV_HDR_SIZE;
+ len -= TLV_HDR_SIZE;
+ total += TLV_HDR_SIZE;
tlv_len = ntohs(tlv.length);
switch (ntohs(tlv.type)) {
-/* $OpenBSD: init.c,v 1.31 2016/07/01 23:29:55 renato Exp $ */
+/* $OpenBSD: init.c,v 1.32 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
int
recv_init(struct nbr *nbr, char *buf, uint16_t len)
{
- struct ldp_msg init;
+ struct ldp_msg msg;
struct sess_prms_tlv sess;
uint16_t max_pdu_len;
int r;
log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
- memcpy(&init, buf, sizeof(init));
+ memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
len -= LDP_MSG_SIZE;
if (len < SESS_PRMS_SIZE) {
- session_shutdown(nbr, S_BAD_MSG_LEN, init.msgid, init.type);
+ session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
return (-1);
}
memcpy(&sess, buf, sizeof(sess));
- if (ntohs(sess.length) != SESS_PRMS_SIZE - TLV_HDR_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, init.msgid, init.type);
+ if (ntohs(sess.length) != SESS_PRMS_LEN) {
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
return (-1);
}
if (ntohs(sess.proto_version) != LDP_VERSION) {
- session_shutdown(nbr, S_BAD_PROTO_VER, init.msgid, init.type);
+ session_shutdown(nbr, S_BAD_PROTO_VER, msg.id, msg.type);
return (-1);
}
if (ntohs(sess.keepalive_time) < MIN_KEEPALIVE) {
- session_shutdown(nbr, S_KEEPALIVE_BAD, init.msgid, init.type);
+ session_shutdown(nbr, S_KEEPALIVE_BAD, msg.id, msg.type);
return (-1);
}
if (sess.lsr_id != leconf->rtr_id.s_addr ||
ntohs(sess.lspace_id) != 0) {
- session_shutdown(nbr, S_NO_HELLO, init.msgid, init.type);
+ session_shutdown(nbr, S_NO_HELLO, msg.id, msg.type);
return (-1);
}
/* just ignore all optional TLVs for now */
r = tlv_decode_opt_init_prms(buf, len);
if (r == -1 || r != len) {
- session_shutdown(nbr, S_BAD_TLV_VAL, init.msgid, init.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
return (-1);
}
memset(&parms, 0, sizeof(parms));
parms.type = htons(TLV_TYPE_COMMONSESSION);
- parms.length = htons(SESS_PRMS_SIZE - TLV_HDR_LEN);
+ parms.length = htons(SESS_PRMS_LEN);
parms.proto_version = htons(LDP_VERSION);
parms.keepalive_time = htons(nbr_get_keepalive(nbr->af, nbr->id));
parms.reserved = 0;
int total = 0;
while (len >= sizeof(tlv)) {
- memcpy(&tlv, buf, TLV_HDR_LEN);
- buf += TLV_HDR_LEN;
- len -= TLV_HDR_LEN;
- total += TLV_HDR_LEN;
+ memcpy(&tlv, buf, TLV_HDR_SIZE);
+ buf += TLV_HDR_SIZE;
+ len -= TLV_HDR_SIZE;
+ total += TLV_HDR_SIZE;
tlv_len = ntohs(tlv.length);
switch (ntohs(tlv.type)) {
-/* $OpenBSD: keepalive.c,v 1.16 2016/05/23 19:11:42 renato Exp $ */
+/* $OpenBSD: keepalive.c,v 1.17 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
int
recv_keepalive(struct nbr *nbr, char *buf, uint16_t len)
{
- struct ldp_msg ka;
+ struct ldp_msg msg;
- memcpy(&ka, buf, sizeof(ka));
+ memcpy(&msg, buf, sizeof(msg));
if (len != LDP_MSG_SIZE) {
- session_shutdown(nbr, S_BAD_MSG_LEN, ka.msgid, ka.type);
+ session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
return (-1);
}
-/* $OpenBSD: l2vpn.c,v 1.20 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: l2vpn.c,v 1.21 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
l2vpn_pw_negotiate(struct lde_nbr *ln, struct fec_node *fn, struct map *map)
{
struct l2vpn_pw *pw;
- struct status_tlv status;
+ struct status_tlv st;
/* NOTE: thanks martini & friends for all this mess */
} else if (!(map->flags & F_MAP_PW_CWORD) &&
(pw->flags & F_PW_CWORD_CONF)) {
/* append a "Wrong C-bit" status code */
- status.status_code = S_WRONG_CBIT;
- status.msg_id = map->messageid;
- status.msg_type = htons(MSG_TYPE_LABELMAPPING);
- lde_send_labelwithdraw(ln, fn, NO_LABEL, &status);
+ st.status_code = S_WRONG_CBIT;
+ st.msg_id = map->msg_id;
+ st.msg_type = htons(MSG_TYPE_LABELMAPPING);
+ lde_send_labelwithdraw(ln, fn, NO_LABEL, &st);
pw->flags &= ~F_PW_CWORD;
lde_send_labelmapping(ln, fn, 1);
struct notify_msg nm;
memset(&nm, 0, sizeof(nm));
- nm.status = S_PW_STATUS;
-
+ nm.status_code = S_PW_STATUS;
nm.pw_status = status;
nm.flags |= F_NOTIF_PW_STATUS;
-
lde_fec2map(fec, &nm.fec);
nm.flags |= F_NOTIF_FEC;
-/* $OpenBSD: labelmapping.c,v 1.54 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: labelmapping.c,v 1.55 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2014, 2015 Renato Westphal <renato@openbsd.org>
}
/* calculate size */
- msg_size = LDP_MSG_SIZE + TLV_HDR_LEN;
+ msg_size = LDP_MSG_SIZE + TLV_HDR_SIZE;
switch (me->map.type) {
case MAP_TYPE_WILDCARD:
msg_size += FEC_ELM_WCARD_LEN;
break;
case MAP_TYPE_PWID:
msg_size += FEC_PWID_ELM_MIN_LEN;
-
if (me->map.flags & F_MAP_PW_ID)
- msg_size += sizeof(uint32_t);
+ msg_size += PW_STATUS_TLV_LEN;
if (me->map.flags & F_MAP_PW_IFMTU)
- msg_size += FEC_SUBTLV_IFMTU_LEN;
+ msg_size += FEC_SUBTLV_IFMTU_SIZE;
if (me->map.flags & F_MAP_PW_STATUS)
- msg_size += PW_STATUS_TLV_LEN;
+ msg_size += PW_STATUS_TLV_SIZE;
break;
}
if (me->map.label != NO_LABEL)
- msg_size += LABEL_TLV_LEN;
+ msg_size += LABEL_TLV_SIZE;
if (me->map.flags & F_MAP_REQ_ID)
- msg_size += REQID_TLV_LEN;
+ msg_size += REQID_TLV_SIZE;
if (me->map.flags & F_MAP_STATUS)
msg_size += STATUS_SIZE;
if (me->map.flags & F_MAP_PW_STATUS)
err |= gen_pw_status_tlv(buf, me->map.pw_status);
if (me->map.flags & F_MAP_STATUS)
- err |= gen_status_tlv(buf, me->map.status.code,
- me->map.status.msg_id, me->map.status.msg_type);
+ err |= gen_status_tlv(buf, me->map.st.status_code,
+ me->map.st.msg_id, me->map.st.msg_type);
if (err) {
ibuf_free(buf);
return;
int
recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
{
- struct ldp_msg lm;
+ struct ldp_msg msg;
struct tlv ft;
uint32_t label = NO_LABEL, reqid = 0;
uint32_t pw_status = 0;
struct mapping_head mh;
struct map map;
- memcpy(&lm, buf, sizeof(lm));
+ memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
len -= LDP_MSG_SIZE;
/* FEC TLV */
if (len < sizeof(ft)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm.msgid, lm.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
return (-1);
}
memcpy(&ft, buf, sizeof(ft));
if (ntohs(ft.type) != TLV_TYPE_FEC) {
- send_notification_nbr(nbr, S_MISS_MSG, lm.msgid, lm.type);
+ send_notification_nbr(nbr, S_MISS_MSG, msg.id, msg.type);
return (-1);
}
feclen = ntohs(ft.length);
-
- if (feclen > len - TLV_HDR_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm.msgid, lm.type);
+ if (feclen > len - TLV_HDR_SIZE) {
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
return (-1);
}
- buf += TLV_HDR_LEN; /* just advance to the end of the fec header */
- len -= TLV_HDR_LEN;
+ buf += TLV_HDR_SIZE; /* just advance to the end of the fec header */
+ len -= TLV_HDR_SIZE;
TAILQ_INIT(&mh);
do {
memset(&map, 0, sizeof(map));
- map.messageid = lm.msgid;
+ map.msg_id = msg.id;
- if ((tlen = tlv_decode_fec_elm(nbr, &lm, buf, feclen,
+ if ((tlen = tlv_decode_fec_elm(nbr, &msg, buf, feclen,
&map)) == -1)
goto err;
if (map.type == MAP_TYPE_PWID &&
!(map.flags & F_MAP_PW_ID) &&
type != MSG_TYPE_LABELWITHDRAW &&
type != MSG_TYPE_LABELRELEASE) {
- send_notification_nbr(nbr, S_MISS_MSG, lm.msgid,
- lm.type);
+ send_notification_nbr(nbr, S_MISS_MSG, msg.id,
+ msg.type);
return (-1);
}
case MSG_TYPE_LABELMAPPING:
case MSG_TYPE_LABELREQUEST:
case MSG_TYPE_LABELABORTREQ:
- session_shutdown(nbr, S_UNKNOWN_FEC, lm.msgid,
- lm.type);
+ session_shutdown(nbr, S_UNKNOWN_FEC, msg.id,
+ msg.type);
goto err;
default:
break;
*/
if (type != MSG_TYPE_LABELMAPPING &&
tlen != feclen) {
- session_shutdown(nbr, S_BAD_TLV_VAL, lm.msgid,
- lm.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
/* Mandatory Label TLV */
if (type == MSG_TYPE_LABELMAPPING) {
- lbllen = tlv_decode_label(nbr, &lm, buf, len, &label);
+ lbllen = tlv_decode_label(nbr, &msg, buf, len, &label);
if (lbllen == -1)
goto err;
uint32_t reqbuf, labelbuf, statusbuf;
if (len < sizeof(tlv)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm.msgid,
- lm.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
goto err;
}
- memcpy(&tlv, buf, TLV_HDR_LEN);
- buf += TLV_HDR_LEN;
- len -= TLV_HDR_LEN;
+ memcpy(&tlv, buf, TLV_HDR_SIZE);
+ buf += TLV_HDR_SIZE;
+ len -= TLV_HDR_SIZE;
tlv_len = ntohs(tlv.length);
switch (ntohs(tlv.type)) {
switch (type) {
case MSG_TYPE_LABELMAPPING:
case MSG_TYPE_LABELREQUEST:
- if (tlv_len != 4) {
+ if (tlv_len != REQID_TLV_LEN) {
session_shutdown(nbr, S_BAD_TLV_LEN,
- lm.msgid, lm.type);
+ msg.id, msg.type);
goto err;
}
switch (type) {
case MSG_TYPE_LABELWITHDRAW:
case MSG_TYPE_LABELRELEASE:
- if (tlv_len != 4) {
+ if (tlv_len != LABEL_TLV_LEN) {
session_shutdown(nbr, S_BAD_TLV_LEN,
- lm.msgid, lm.type);
+ msg.id, msg.type);
goto err;
}
case MSG_TYPE_LABELWITHDRAW:
case MSG_TYPE_LABELRELEASE:
/* unsupported */
- session_shutdown(nbr, S_BAD_TLV_VAL, lm.msgid,
- lm.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id,
+ msg.type);
goto err;
break;
default:
break;
case TLV_TYPE_STATUS:
if (tlv_len != STATUS_TLV_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- lm.msgid, lm.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id,
+ msg.type);
goto err;
}
/* ignore */
case TLV_TYPE_PW_STATUS:
switch (type) {
case MSG_TYPE_LABELMAPPING:
- if (tlv_len != 4) {
+ if (tlv_len != PW_STATUS_TLV_LEN) {
session_shutdown(nbr, S_BAD_TLV_LEN,
- lm.msgid, lm.type);
+ msg.id, msg.type);
goto err;
}
default:
if (!(ntohs(tlv.type) & UNKNOWN_FLAG)) {
send_notification_nbr(nbr, S_UNKNOWN_TLV,
- lm.msgid, lm.type);
+ msg.id, msg.type);
}
/* ignore unknown tlv */
break;
case AF_IPV4:
if (label == MPLS_LABEL_IPV6NULL) {
session_shutdown(nbr, S_BAD_TLV_VAL,
- lm.msgid, lm.type);
+ msg.id, msg.type);
goto err;
}
if (!nbr->v4_enabled)
case AF_IPV6:
if (label == MPLS_LABEL_IPV4NULL) {
session_shutdown(nbr, S_BAD_TLV_VAL,
- lm.msgid, lm.type);
+ msg.id, msg.type);
goto err;
}
if (!nbr->v6_enabled)
break;
case MAP_TYPE_PWID:
if (label <= MPLS_LABEL_RESERVED_MAX) {
- session_shutdown(nbr, S_BAD_TLV_VAL, lm.msgid,
- lm.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id,
+ msg.type);
goto err;
}
if (me->map.flags & F_MAP_PW_STATUS)
struct label_tlv lt;
lt.type = htons(TLV_TYPE_GENERICLABEL);
- lt.length = htons(sizeof(label));
+ lt.length = htons(LABEL_TLV_LEN);
lt.label = htonl(label);
return (ibuf_add(buf, <, sizeof(lt)));
}
static int
-tlv_decode_label(struct nbr *nbr, struct ldp_msg *lm, char *buf,
+tlv_decode_label(struct nbr *nbr, struct ldp_msg *msg, char *buf,
uint16_t len, uint32_t *label)
{
struct label_tlv lt;
if (len < sizeof(lt)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid, lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
memcpy(<, buf, sizeof(lt));
if (!(ntohs(lt.type) & TLV_TYPE_GENERICLABEL)) {
- send_notification_nbr(nbr, S_MISS_MSG, lm->msgid, lm->type);
+ send_notification_nbr(nbr, S_MISS_MSG, msg->id, msg->type);
return (-1);
}
switch (htons(lt.type)) {
case TLV_TYPE_GENERICLABEL:
- if (ntohs(lt.length) != sizeof(lt) - TLV_HDR_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ if (ntohs(lt.length) != sizeof(lt) - TLV_HDR_SIZE) {
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
*label != MPLS_LABEL_IPV4NULL &&
*label != MPLS_LABEL_IPV6NULL &&
*label != MPLS_LABEL_IMPLNULL)) {
- session_shutdown(nbr, S_BAD_TLV_VAL, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id,
+ msg->type);
return (-1);
}
break;
case TLV_TYPE_FRLABEL:
default:
/* unsupported */
- session_shutdown(nbr, S_BAD_TLV_VAL, lm->msgid, lm->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id, msg->type);
return (-1);
}
struct reqid_tlv rt;
rt.type = htons(TLV_TYPE_LABELREQUEST);
- rt.length = htons(sizeof(reqid));
+ rt.length = htons(REQID_TLV_LEN);
rt.reqid = htonl(reqid);
return (ibuf_add(buf, &rt, sizeof(rt)));
struct pw_status_tlv st;
st.type = htons(TLV_TYPE_PW_STATUS);
- st.length = htons(sizeof(status));
+ st.length = htons(PW_STATUS_TLV_LEN);
st.value = htonl(status);
return (ibuf_add(buf, &st, sizeof(st)));
break;
case MAP_TYPE_PWID:
if (map->flags & F_MAP_PW_ID)
- pw_len += sizeof(uint32_t);
+ pw_len += PW_STATUS_TLV_LEN;
if (map->flags & F_MAP_PW_IFMTU)
- pw_len += FEC_SUBTLV_IFMTU_LEN;
+ pw_len += FEC_SUBTLV_IFMTU_SIZE;
len = FEC_PWID_ELM_MIN_LEN + pw_len;
struct subtlv stlv;
stlv.type = SUBTLV_IFMTU;
- stlv.length = FEC_SUBTLV_IFMTU_LEN;
+ stlv.length = FEC_SUBTLV_IFMTU_SIZE;
err |= ibuf_add(buf, &stlv, sizeof(uint16_t));
ifmtu = htons(map->fec.pwid.ifmtu);
}
int
-tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf,
+tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
uint16_t len, struct map *map)
{
uint16_t off = 0;
if (len == FEC_ELM_WCARD_LEN)
return (off);
else {
- session_shutdown(nbr, S_BAD_TLV_VAL, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id,
+ msg->type);
return (-1);
}
break;
case MAP_TYPE_PREFIX:
if (len < FEC_ELM_PREFIX_MIN_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
off += sizeof(map->fec.prefix.af);
if (map->fec.prefix.af != AF_IPV4 &&
map->fec.prefix.af != AF_IPV6) {
- send_notification_nbr(nbr, S_UNSUP_ADDR, lm->msgid,
- lm->type);
+ send_notification_nbr(nbr, S_UNSUP_ADDR, msg->id,
+ msg->type);
return (-1);
}
map->fec.prefix.prefixlen = buf[off];
off += sizeof(uint8_t);
if (len < off + PREFIX_SIZE(map->fec.prefix.prefixlen)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
return (off + PREFIX_SIZE(map->fec.prefix.prefixlen));
case MAP_TYPE_PWID:
if (len < FEC_PWID_ELM_MIN_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
off += sizeof(uint8_t);
if (len != FEC_PWID_ELM_MIN_LEN + pw_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
return (off);
if (pw_len < sizeof(uint32_t)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, lm->msgid,
- lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
struct subtlv stlv;
if (pw_len < sizeof(stlv)) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- lm->msgid, lm->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
return (-1);
}
memcpy(&stlv, buf + off, sizeof(stlv));
switch (stlv.type) {
case SUBTLV_IFMTU:
- if (stlv.length != FEC_SUBTLV_IFMTU_LEN) {
+ if (stlv.length != FEC_SUBTLV_IFMTU_SIZE) {
session_shutdown(nbr, S_BAD_TLV_LEN,
- lm->msgid, lm->type);
+ msg->id, msg->type);
return (-1);
}
memcpy(&map->fec.pwid.ifmtu, buf + off +
- SUBTLV_HDR_LEN, sizeof(uint16_t));
+ SUBTLV_HDR_SIZE, sizeof(uint16_t));
map->fec.pwid.ifmtu = ntohs(map->fec.pwid.ifmtu);
map->flags |= F_MAP_PW_IFMTU;
break;
return (off);
default:
- send_notification_nbr(nbr, S_UNKNOWN_FEC, lm->msgid, lm->type);
+ send_notification_nbr(nbr, S_UNKNOWN_FEC, msg->id, msg->type);
break;
}
-/* $OpenBSD: lde.c,v 1.60 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: lde.c,v 1.61 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
break;
}
- switch (nm.status) {
+ switch (nm.status_code) {
case S_PW_STATUS:
l2vpn_recv_pw_status(ln, &nm);
break;
lre = (struct lde_req *)fec_find(&ln->recv_req, &fn->fec);
if (lre) {
/* set label request msg id in the mapping response. */
- map.requestid = lre->msgid;
+ map.requestid = lre->msg_id;
map.flags = F_MAP_REQ_ID;
/* SL.7: delete record of pending request */
void
lde_send_labelwithdraw(struct lde_nbr *ln, struct fec_node *fn, uint32_t label,
- struct status_tlv *status)
+ struct status_tlv *st)
{
struct lde_wdraw *lw;
struct map map;
map.label = label;
}
- if (status) {
- map.status.code = status->status_code;
- map.status.msg_id = status->msg_id;
- map.status.msg_type = status->msg_type;
+ if (st) {
+ map.st.status_code = st->status_code;
+ map.st.msg_id = st->msg_id;
+ map.st.msg_type = st->msg_type;
map.flags |= F_MAP_STATUS;
}
}
void
-lde_send_notification(uint32_t peerid, uint32_t code, uint32_t msgid,
- uint16_t type)
+lde_send_notification(uint32_t peerid, uint32_t status_code, uint32_t msg_id,
+ uint16_t msg_type)
{
struct notify_msg nm;
memset(&nm, 0, sizeof(nm));
- nm.status = code;
- /* 'msgid' and 'type' should be in network byte order */
- nm.messageid = msgid;
- nm.type = type;
+ nm.status_code = status_code;
+ /* 'msg_id' and 'msg_type' should be in network byte order */
+ nm.msg_id = msg_id;
+ nm.msg_type = msg_type;
lde_imsg_compose_ldpe(IMSG_NOTIFICATION_SEND, peerid, 0,
&nm, sizeof(nm));
-/* $OpenBSD: lde.h,v 1.42 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: lde.h,v 1.43 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
/* request entries */
struct lde_req {
- struct fec fec;
- uint32_t msgid;
+ struct fec fec;
+ uint32_t msg_id;
};
/* mapping entries */
-/* $OpenBSD: lde_lib.c,v 1.62 2016/07/01 23:29:55 renato Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.63 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
fn = (struct fec_node *)fec_find(&ft, &fec);
if (fn == NULL || LIST_EMPTY(&fn->nexthops)) {
/* LRq.5: send No Route notification */
- lde_send_notification(ln->peerid, S_NO_ROUTE, map->messageid,
+ lde_send_notification(ln->peerid, S_NO_ROUTE, map->msg_id,
htons(MSG_TYPE_LABELREQUEST));
return;
}
/* LRq.4: send Loop Detected notification */
lde_send_notification(ln->peerid, S_LOOP_DETECTED,
- map->messageid, htons(MSG_TYPE_LABELREQUEST));
+ map->msg_id, htons(MSG_TYPE_LABELREQUEST));
return;
default:
break;
/* LRq.8: record label request */
lre = lde_req_add(ln, &fn->fec, 0);
if (lre != NULL)
- lre->msgid = ntohl(map->messageid);
+ lre->msg_id = ntohl(map->msg_id);
/* LRq.9: perform LSR label distribution */
lde_send_labelmapping(ln, fn, 1);
-/* $OpenBSD: ldp.h,v 1.32 2016/07/01 23:22:42 renato Exp $ */
+/* $OpenBSD: ldp.h,v 1.33 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
uint16_t type;
uint16_t length;
};
-#define TLV_HDR_LEN 4
+#define TLV_HDR_SIZE 4
struct ldp_msg {
uint16_t type;
uint16_t length;
- uint32_t msgid;
+ uint32_t id;
/* Mandatory Parameters */
/* Optional Parameters */
} __packed;
uint16_t holdtime;
uint16_t flags;
};
-
#define F_HELLO_TARGETED 0x8000
#define F_HELLO_REQ_TARG 0x4000
#define F_HELLO_GTSM 0x2000
} __packed;
#define SESS_PRMS_SIZE 18
+#define SESS_PRMS_LEN 14
struct status_tlv {
uint16_t type;
uint8_t type;
uint8_t length;
};
-#define SUBTLV_HDR_LEN 2
+#define SUBTLV_HDR_SIZE 2
#define SUBTLV_IFMTU 0x01
#define SUBTLV_VLANID 0x06
-#define FEC_SUBTLV_IFMTU_LEN 4
-#define FEC_SUBTLV_VLANID_LEN 4
+#define FEC_SUBTLV_IFMTU_SIZE 4
+#define FEC_SUBTLV_VLANID_SIZE 4
struct label_tlv {
uint16_t type;
uint16_t length;
uint32_t label;
};
-
-#define LABEL_TLV_LEN 8
+#define LABEL_TLV_SIZE 8
+#define LABEL_TLV_LEN 4
struct reqid_tlv {
uint16_t type;
uint16_t length;
uint32_t reqid;
};
-
-#define REQID_TLV_LEN 8
+#define REQID_TLV_SIZE 8
+#define REQID_TLV_LEN 4
struct pw_status_tlv {
uint16_t type;
uint16_t length;
uint32_t value;
};
-
-#define PW_STATUS_TLV_LEN 8
+#define PW_STATUS_TLV_SIZE 8
+#define PW_STATUS_TLV_LEN 4
#define PW_FORWARDING 0
#define PW_NOT_FORWARDING (1 << 0)
-/* $OpenBSD: ldpd.h,v 1.79 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: ldpd.h,v 1.80 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
struct map {
uint8_t type;
- uint32_t messageid;
+ uint32_t msg_id;
union {
struct {
uint16_t af;
} pwid;
} fec;
struct {
- uint32_t code;
+ uint32_t status_code;
uint32_t msg_id;
uint16_t msg_type;
- } status;
+ } st;
uint32_t label;
uint32_t requestid;
uint32_t pw_status;
#define F_MAP_PW_STATUS 0x20 /* pseudowire status */
struct notify_msg {
- uint32_t status;
- uint32_t messageid; /* network byte order */
- uint16_t type; /* network byte order */
+ uint32_t status_code;
+ uint32_t msg_id; /* network byte order */
+ uint16_t msg_type; /* network byte order */
uint32_t pw_status;
struct map fec;
uint8_t flags;
-/* $OpenBSD: log.c,v 1.27 2016/05/23 19:11:42 renato Exp $ */
+/* $OpenBSD: log.c,v 1.28 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
}
const char *
-notification_name(uint32_t status)
+status_code_name(uint32_t status)
{
static char buf[16];
-/* $OpenBSD: log.h,v 1.11 2016/05/23 19:09:25 renato Exp $ */
+/* $OpenBSD: log.h,v 1.12 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
const char *nbr_state_name(int);
const char *if_state_name(int);
const char *if_type_name(enum iface_type);
-const char *notification_name(uint32_t);
+const char *status_code_name(uint32_t);
const char *pw_type_name(uint16_t);
char *log_hello_src(const struct hello_source *);
const char *log_map(const struct map *);
-/* $OpenBSD: notification.c,v 1.38 2016/07/01 23:33:46 renato Exp $ */
+/* $OpenBSD: notification.c,v 1.39 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
/* calculate size */
size = LDP_HDR_SIZE + LDP_MSG_SIZE + STATUS_SIZE;
if (nm->flags & F_NOTIF_PW_STATUS)
- size += PW_STATUS_TLV_LEN;
+ size += PW_STATUS_TLV_SIZE;
if (nm->flags & F_NOTIF_FEC) {
- size += TLV_HDR_LEN;
+ size += TLV_HDR_SIZE;
switch (nm->fec.type) {
case MAP_TYPE_PWID:
size += FEC_PWID_ELM_MIN_LEN;
err |= gen_ldp_hdr(buf, size);
size -= LDP_HDR_SIZE;
err |= gen_msg_hdr(buf, MSG_TYPE_NOTIFICATION, size);
- err |= gen_status_tlv(buf, nm->status, nm->messageid, nm->type);
+ err |= gen_status_tlv(buf, nm->status_code, nm->msg_id, nm->msg_type);
/* optional tlvs */
if (nm->flags & F_NOTIF_PW_STATUS)
err |= gen_pw_status_tlv(buf, nm->pw_status);
/* send a notification without optional tlvs */
void
-send_notification(uint32_t status, struct tcp_conn *tcp, uint32_t msgid,
- uint16_t type)
+send_notification(uint32_t status_code, struct tcp_conn *tcp, uint32_t msg_id,
+ uint16_t msg_type)
{
struct notify_msg nm;
memset(&nm, 0, sizeof(nm));
- nm.status = status;
- nm.messageid = msgid;
- nm.type = type;
+ nm.status_code = status_code;
+ nm.msg_id = msg_id;
+ nm.msg_type = msg_type;
send_notification_full(tcp, &nm);
}
void
-send_notification_nbr(struct nbr *nbr, uint32_t status, uint32_t msgid,
- uint16_t type)
+send_notification_nbr(struct nbr *nbr, uint32_t status_code, uint32_t msg_id,
+ uint16_t msg_type)
{
log_debug("%s: lsr-id %s, status %s", __func__, inet_ntoa(nbr->id),
- notification_name(status));
+ status_code_name(status_code));
- send_notification(status, nbr->tcp, msgid, type);
+ send_notification(status_code, nbr->tcp, msg_id, msg_type);
nbr_fsm(nbr, NBR_EVT_PDU_SENT);
}
int
recv_notification(struct nbr *nbr, char *buf, uint16_t len)
{
- struct ldp_msg not;
+ struct ldp_msg msg;
struct status_tlv st;
struct notify_msg nm;
int tlen;
- memcpy(¬, buf, sizeof(not));
+ memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
len -= LDP_MSG_SIZE;
if (len < STATUS_SIZE) {
- session_shutdown(nbr, S_BAD_MSG_LEN, not.msgid, not.type);
+ session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
return (-1);
}
memcpy(&st, buf, sizeof(st));
- if (ntohs(st.length) > STATUS_SIZE - TLV_HDR_LEN ||
- ntohs(st.length) > len - TLV_HDR_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, not.msgid, not.type);
+ if (ntohs(st.length) > STATUS_SIZE - TLV_HDR_SIZE ||
+ ntohs(st.length) > len - TLV_HDR_SIZE) {
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
return (-1);
}
buf += STATUS_SIZE;
len -= STATUS_SIZE;
memset(&nm, 0, sizeof(nm));
- nm.status = ntohl(st.status_code);
+ nm.status_code = ntohl(st.status_code);
/* Optional Parameters */
while (len > 0) {
uint16_t tlv_len;
if (len < sizeof(tlv)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, not.msgid,
- not.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id,
+ msg.type);
return (-1);
}
- memcpy(&tlv, buf, TLV_HDR_LEN);
- buf += TLV_HDR_LEN;
- len -= TLV_HDR_LEN;
+ memcpy(&tlv, buf, TLV_HDR_SIZE);
+ buf += TLV_HDR_SIZE;
+ len -= TLV_HDR_SIZE;
tlv_len = ntohs(tlv.length);
switch (ntohs(tlv.type)) {
case TLV_TYPE_PW_STATUS:
if (tlv_len != 4) {
session_shutdown(nbr, S_BAD_TLV_LEN,
- not.msgid, not.type);
+ msg.id, msg.type);
return (-1);
}
nm.flags |= F_NOTIF_PW_STATUS;
break;
case TLV_TYPE_FEC:
- if ((tlen = tlv_decode_fec_elm(nbr, ¬, buf,
+ if ((tlen = tlv_decode_fec_elm(nbr, &msg, buf,
tlv_len, &nm.fec)) == -1)
return (-1);
/* allow only one fec element */
if (tlen != tlv_len) {
session_shutdown(nbr, S_BAD_TLV_VAL,
- not.msgid, not.type);
+ msg.id, msg.type);
return (-1);
}
nm.flags |= F_NOTIF_FEC;
default:
if (!(ntohs(tlv.type) & UNKNOWN_FLAG)) {
send_notification_nbr(nbr, S_UNKNOWN_TLV,
- not.msgid, not.type);
+ msg.id, msg.type);
}
/* ignore unknown tlv */
break;
len -= tlv_len;
}
- if (nm.status == S_PW_STATUS) {
+ if (nm.status_code == S_PW_STATUS) {
if (!(nm.flags & (F_NOTIF_PW_STATUS|F_NOTIF_FEC))) {
send_notification_nbr(nbr, S_MISS_MSG,
- not.msgid, not.type);
+ msg.id, msg.type);
return (-1);
}
break;
default:
send_notification_nbr(nbr, S_BAD_TLV_VAL,
- not.msgid, not.type);
+ msg.id, msg.type);
return (-1);
}
}
if (st.status_code & htonl(STATUS_FATAL))
log_warnx("received notification from lsr-id %s: %s",
inet_ntoa(nbr->id),
- notification_name(ntohl(st.status_code)));
+ status_code_name(ntohl(st.status_code)));
else
log_debug("received non-fatal notification from lsr-id "
"%s: %s", inet_ntoa(nbr->id),
- notification_name(ntohl(st.status_code)));
+ status_code_name(ntohl(st.status_code)));
if (st.status_code & htonl(STATUS_FATAL)) {
if (nbr->state == NBR_STA_OPENSENT)
return (-1);
}
- if (nm.status == S_PW_STATUS)
+ if (nm.status_code == S_PW_STATUS)
ldpe_imsg_compose_lde(IMSG_NOTIFICATION, nbr->peerid, 0,
&nm, sizeof(nm));
}
int
-gen_status_tlv(struct ibuf *buf, uint32_t status, uint32_t msgid, uint16_t type)
+gen_status_tlv(struct ibuf *buf, uint32_t status_code, uint32_t msg_id,
+ uint16_t msg_type)
{
struct status_tlv st;
memset(&st, 0, sizeof(st));
-
st.type = htons(TLV_TYPE_STATUS);
st.length = htons(STATUS_TLV_LEN);
- st.status_code = htonl(status);
-
- /* for convenience, msgid and type are already in network byte order */
- st.msg_id = msgid;
- st.msg_type = type;
+ st.status_code = htonl(status_code);
+ /*
+ * For convenience, msg_id and msg_type are already in network
+ * byte order.
+ */
+ st.msg_id = msg_id;
+ st.msg_type = msg_type;
return (ibuf_add(buf, &st, STATUS_SIZE));
}
-/* $OpenBSD: packet.c,v 1.66 2016/07/01 23:29:55 renato Exp $ */
+/* $OpenBSD: packet.c,v 1.67 2016/07/01 23:36:38 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
msg.type = htons(type);
/* exclude the 'Type' and 'Length' fields from the total */
msg.length = htons(size - LDP_MSG_DEAD_LEN);
- msg.msgid = htonl(++msgcnt);
+ msg.id = htonl(++msgcnt);
return (ibuf_add(buf, &msg, sizeof(msg)));
}
struct cmsghdr hdr;
char buf[CMSG_SPACE(CMSG_MAXLEN)];
} cmsgbuf;
- struct msghdr msg;
+ struct msghdr m;
struct sockaddr_storage from;
struct iovec iov;
char *buf;
uint16_t len;
struct ldp_hdr ldp_hdr;
uint16_t pdu_len;
- struct ldp_msg ldp_msg;
+ struct ldp_msg msg;
uint16_t msg_len;
struct in_addr lsr_id;
return;
/* setup buffer */
- memset(&msg, 0, sizeof(msg));
+ memset(&m, 0, sizeof(m));
iov.iov_base = buf = pkt_ptr;
iov.iov_len = IBUF_READ_SIZE;
- msg.msg_name = &from;
- msg.msg_namelen = sizeof(from);
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
- msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = sizeof(cmsgbuf.buf);
-
- if ((r = recvmsg(fd, &msg, 0)) == -1) {
+ m.msg_name = &from;
+ m.msg_namelen = sizeof(from);
+ m.msg_iov = &iov;
+ m.msg_iovlen = 1;
+ m.msg_control = &cmsgbuf.buf;
+ m.msg_controllen = sizeof(cmsgbuf.buf);
+
+ if ((r = recvmsg(fd, &m, 0)) == -1) {
if (errno != EAGAIN && errno != EINTR)
log_debug("%s: read error: %s", __func__,
strerror(errno));
return;
}
- multicast = (msg.msg_flags & MSG_MCAST) ? 1 : 0;
+ multicast = (m.msg_flags & MSG_MCAST) ? 1 : 0;
sa2addr((struct sockaddr *)&from, &af, &src);
if (bad_addr(af, &src)) {
log_debug("%s: invalid source address: %s", __func__,
return;
}
- for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ for (cmsg = CMSG_FIRSTHDR(&m); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&m, cmsg)) {
if (af == AF_INET && cmsg->cmsg_level == IPPROTO_IP &&
cmsg->cmsg_type == IP_RECVIF) {
ifindex = ((struct sockaddr_dl *)
* not impose any restrictions since LDP uses UDP only for sending Hello
* packets.
*/
- memcpy(&ldp_msg, buf, sizeof(ldp_msg));
+ memcpy(&msg, buf, sizeof(msg));
/* check "Message Length" field */
- msg_len = ntohs(ldp_msg.length);
+ msg_len = ntohs(msg.length);
if (msg_len < LDP_MSG_LEN || ((msg_len + LDP_MSG_DEAD_LEN) > pdu_len)) {
log_debug("%s: invalid LDP message length %u, source %s",
- __func__, ntohs(ldp_msg.length), log_addr(af, &src));
+ __func__, ntohs(msg.length), log_addr(af, &src));
return;
}
buf += LDP_MSG_SIZE;
len -= LDP_MSG_SIZE;
/* switch LDP packet type */
- switch (ntohs(ldp_msg.type)) {
+ switch (ntohs(msg.type)) {
case MSG_TYPE_HELLO:
- recv_hello(lsr_id, &ldp_msg, af, &src, iface, multicast,
- buf, len);
+ recv_hello(lsr_id, &msg, af, &src, iface, multicast, buf, len);
break;
default:
log_debug("%s: unknown LDP packet type, source %s", __func__,
struct nbr *nbr = arg;
struct tcp_conn *tcp = nbr->tcp;
struct ldp_hdr *ldp_hdr;
- struct ldp_msg *ldp_msg;
+ struct ldp_msg *msg;
char *buf, *pdu;
ssize_t n, len;
uint16_t pdu_len, msg_len, msg_size, max_pdu_len;
while (len >= LDP_MSG_SIZE) {
uint16_t type;
- ldp_msg = (struct ldp_msg *)pdu;
- type = ntohs(ldp_msg->type);
- msg_len = ntohs(ldp_msg->length);
+ msg = (struct ldp_msg *)pdu;
+ type = ntohs(msg->type);
+ msg_len = ntohs(msg->length);
msg_size = msg_len + LDP_MSG_DEAD_LEN;
if (msg_len < LDP_MSG_LEN || msg_size > pdu_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- ldp_msg->msgid, ldp_msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ msg->type);
free(buf);
return;
}
if ((nbr->state != NBR_STA_INITIAL) &&
(nbr->state != NBR_STA_OPENSENT)) {
session_shutdown(nbr, S_SHUTDOWN,
- ldp_msg->msgid, ldp_msg->type);
+ msg->id, msg->type);
free(buf);
return;
}
if ((nbr->state == NBR_STA_INITIAL) ||
(nbr->state == NBR_STA_OPENSENT)) {
session_shutdown(nbr, S_SHUTDOWN,
- ldp_msg->msgid, ldp_msg->type);
+ msg->id, msg->type);
free(buf);
return;
}
case MSG_TYPE_LABELABORTREQ:
if (nbr->state != NBR_STA_OPER) {
session_shutdown(nbr, S_SHUTDOWN,
- ldp_msg->msgid, ldp_msg->type);
+ msg->id, msg->type);
free(buf);
return;
}
default:
log_debug("%s: unknown LDP message from nbr %s",
__func__, inet_ntoa(nbr->id));
- if (!(ntohs(ldp_msg->type) & UNKNOWN_FLAG))
+ if (!(ntohs(msg->type) & UNKNOWN_FLAG))
send_notification_nbr(nbr,
- S_UNKNOWN_MSG, ldp_msg->msgid,
- ldp_msg->type);
+ S_UNKNOWN_MSG, msg->id, msg->type);
/* ignore the message */
ret = 0;
break;
}
void
-session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msgid,
- uint32_t type)
+session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id,
+ uint32_t msg_type)
{
switch (nbr->state) {
case NBR_STA_PRESENT:
case NBR_STA_OPER:
log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
- send_notification_nbr(nbr, status, msgid, type);
+ send_notification_nbr(nbr, status, msg_id, msg_type);
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
break;