struct if_addr_head *, unsigned int);
static void address_list_add(struct if_addr_head *, struct if_addr *);
static void address_list_clr(struct if_addr_head *);
+static void log_msg_address(int, uint16_t, struct nbr *, int,
+ union ldpd_addr *);
static void
send_address(struct nbr *nbr, int af, struct if_addr_head *addr_list,
}
while ((if_addr = LIST_FIRST(addr_list)) != NULL) {
- debug_msg_send("%s: lsr-id %s address %s",
- msg_name(msg_type), inet_ntoa(nbr->id),
- log_addr(af, &if_addr->addr));
+ log_msg_address(1, msg_type, nbr, af, &if_addr->addr);
LIST_REMOVE(if_addr, entry);
free(if_addr);
fatalx("recv_address: unknown af");
}
- debug_msg_recv("%s: lsr-id %s address %s", msg_name(msg_type),
- inet_ntoa(nbr->id), log_addr(lde_addr.af, &lde_addr.addr));
+ log_msg_address(0, msg_type, nbr, lde_addr.af, &lde_addr.addr);
ldpe_imsg_compose_lde(type, nbr->peerid, 0, &lde_addr,
sizeof(lde_addr));
free(if_addr);
}
}
+
+static void
+log_msg_address(int out, uint16_t msg_type, struct nbr *nbr, int af,
+ union ldpd_addr *addr)
+{
+ debug_msg(out, "%s: lsr-id %s, address %s", msg_name(msg_type),
+ inet_ntoa(nbr->id), log_addr(af, addr));
+}
static int tlv_decode_label(struct nbr *, struct ldp_msg *, char *,
uint16_t, uint32_t *);
static int gen_reqid_tlv(struct ibuf *, uint32_t);
+static void log_msg_mapping(int, uint16_t, struct nbr *, struct map *);
static void
enqueue_pdu(struct nbr *nbr, struct ibuf *buf, uint16_t size)
return;
}
- debug_msg_send("%s: lsr-id %s fec %s label %s", msg_name(type),
- inet_ntoa(nbr->id), log_map(&me->map),
- log_label(me->map.label));
+ log_msg_mapping(1, type, nbr, &me->map);
TAILQ_REMOVE(mh, me, entry);
free(me);
if (me->map.flags & F_MAP_REQ_ID)
me->map.requestid = reqid;
- debug_msg_recv("%s: lsr-id %s fec %s label %s", msg_name(type),
- inet_ntoa(nbr->id), log_map(&me->map),
- log_label(me->map.label));
+ log_msg_mapping(0, type, nbr, &me->map);
switch (type) {
case MSG_TYPE_LABELMAPPING:
return (-1);
}
+
+static void
+log_msg_mapping(int out, uint16_t msg_type, struct nbr *nbr, struct map *map)
+{
+ debug_msg(out, "%s: lsr-id %s, fec %s, label %s", msg_name(msg_type),
+ inet_ntoa(nbr->id), log_map(map), log_label(map->label));
+}
log_debug("msg[out]: " emsg, __VA_ARGS__); \
} while (0)
+#define debug_msg(out, emsg, ...) \
+do { \
+ if (out) \
+ debug_msg_send(emsg, __VA_ARGS__); \
+ else \
+ debug_msg_recv(emsg, __VA_ARGS__); \
+} while (0)
+
#define debug_kalive_recv(emsg, ...) \
do { \
if (LDP_DEBUG(msg, MSG_RECV_ALL)) \
#include "ldpe.h"
#include "ldp_debug.h"
+static void log_msg_notification(int, struct nbr *, struct notify_msg *);
+
void
send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm)
{
}
if (tcp->nbr) {
- debug_msg_send("notification: lsr-id %s status %s%s",
- inet_ntoa(tcp->nbr->id), status_code_name(nm->status_code),
- (nm->status_code & STATUS_FATAL) ? " (fatal)" : "");
- if (nm->flags & F_NOTIF_FEC)
- debug_msg_send("notification: fec %s",
- log_map(&nm->fec));
- if (nm->flags & F_NOTIF_PW_STATUS)
- debug_msg_send("notification: pw-status %s",
- (nm->pw_status) ? "not forwarding" : "forwarding");
+ log_msg_notification(1, tcp->nbr, nm);
nbr_fsm(tcp->nbr, NBR_EVT_PDU_SENT);
}
}
}
- debug_msg_recv("notification: lsr-id %s: %s%s", inet_ntoa(nbr->id),
- status_code_name(ntohl(st.status_code)),
- (st.status_code & htonl(STATUS_FATAL)) ? " (fatal)" : "");
- if (nm.flags & F_NOTIF_FEC)
- debug_msg_recv("notification: fec %s", log_map(&nm.fec));
- if (nm.flags & F_NOTIF_PW_STATUS)
- debug_msg_recv("notification: pw-status %s",
- (nm.pw_status) ? "not forwarding" : "forwarding");
+ log_msg_notification(0, nbr, &nm);
if (st.status_code & htonl(STATUS_FATAL)) {
if (nbr->state == NBR_STA_OPENSENT)
return (ibuf_add(buf, &st, STATUS_SIZE));
}
+
+void
+log_msg_notification(int out, struct nbr *nbr, struct notify_msg *nm)
+{
+ if (nm->status_code & STATUS_FATAL) {
+ debug_msg(out, "notification: lsr-id %s, status %s "
+ "(fatal error)", inet_ntoa(nbr->id),
+ status_code_name(nm->status_code));
+ return;
+ }
+
+ debug_msg(out, "notification: lsr-id %s, status %s",
+ inet_ntoa(nbr->id), status_code_name(nm->status_code));
+ if (nm->flags & F_NOTIF_FEC)
+ debug_msg(out, "notification: fec %s", log_map(&nm->fec));
+ if (nm->flags & F_NOTIF_PW_STATUS)
+ debug_msg(out, "notification: pw-status %s",
+ (nm->pw_status) ? "not forwarding" : "forwarding");
+}