diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2017-03-03 23:50:46 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2017-03-03 23:50:46 +0000 |
commit | 56f5d45cf1489d075f76f9893c96f663184204ec (patch) | |
tree | cfd570c2565b0b25440802c4610c567d220de52d /usr.sbin/ldpd/labelmapping.c | |
parent | cf98b5cef64de505b5a9deda78ff0b71bff6ceb2 (diff) |
Create helper functions to log sent/received messages.
Diffstat (limited to 'usr.sbin/ldpd/labelmapping.c')
-rw-r--r-- | usr.sbin/ldpd/labelmapping.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c index 61a6a8ae75f..964cc44286e 100644 --- a/usr.sbin/ldpd/labelmapping.c +++ b/usr.sbin/ldpd/labelmapping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: labelmapping.c,v 1.63 2017/03/03 23:44:35 renato Exp $ */ +/* $OpenBSD: labelmapping.c,v 1.64 2017/03/03 23:50:45 renato Exp $ */ /* * Copyright (c) 2014, 2015 Renato Westphal <renato@openbsd.org> @@ -34,6 +34,7 @@ static int gen_label_tlv(struct ibuf *, uint32_t); 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) @@ -127,9 +128,7 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh) return; } - log_debug("msg-out: %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); @@ -399,9 +398,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) if (me->map.flags & F_MAP_REQ_ID) me->map.requestid = reqid; - log_debug("msg-in: %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: @@ -762,3 +759,11 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf, return (-1); } + +static void +log_msg_mapping(int out, uint16_t msg_type, struct nbr *nbr, struct map *map) +{ + log_debug("msg-%s: %s: lsr-id %s, fec %s, label %s", + (out) ? "out" : "in", msg_name(msg_type), inet_ntoa(nbr->id), + log_map(map), log_label(map->label)); +} |