From 8298d780be5a5b00c31c10a37a5f3a1353d6e234 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 6 Apr 2009 16:17:47 +0200 Subject: Better OSPF packet tracing log messages. Replaces old OSPF packet tracing messages with uniform messages with packet dumps. --- proto/ospf/lsreq.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'proto/ospf/lsreq.c') diff --git a/proto/ospf/lsreq.c b/proto/ospf/lsreq.c index f43a08f..e179189 100644 --- a/proto/ospf/lsreq.c +++ b/proto/ospf/lsreq.c @@ -8,6 +8,24 @@ #include "ospf.h" +static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt) +{ + struct ospf_packet *op = &pkt->ospf_packet; + + ASSERT(op->type == LSREQ_P); + ospf_dump_common(p, op); + + struct ospf_lsreq_header *plsr = (void *) (pkt + 1); + int i, j; + + j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) / + sizeof(struct ospf_lsreq_header); + + for (i = 0; i < j; i++) + log(L_TRACE "%s: LSR Id: %I, Rt: %I, Type: %u", + p->name, htonl(plsr[i].id), htonl(plsr[i].rt), plsr[i].type); +} + void ospf_lsreq_send(struct ospf_neighbor *n) { @@ -59,8 +77,10 @@ ospf_lsreq_send(struct ospf_neighbor *n) sizeof(struct ospf_lsreq_packet) + (j - i) * sizeof(struct ospf_lsreq_header); op->length = htons(length); + + OSPF_PACKET(ospf_dump_lsreq, (struct ospf_lsreq_packet *) n->ifa->ip_sk->tbuf, + "LSREQ packet sent to %I via %s", n->ip, n->ifa->iface->name); ospf_send_to(n->ifa->ip_sk, n->ip, n->ifa); - OSPF_TRACE(D_PACKETS, "LS request sent to: %I", n->rid); } void @@ -77,10 +97,11 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps, struct proto_ospf *po = oa->po; struct proto *p = &po->proto; + OSPF_PACKET(ospf_dump_lsreq, ps, "LSREQ packet received from %I via %s", n->ip, ifa->iface->name); + if (n->state < NEIGHBOR_EXCHANGE) return; - OSPF_TRACE(D_EVENTS, "Received LS req from neighbor: %I", n->ip); ospf_neigh_sm(n, INM_HELLOREC); lsh = (void *) (ps + 1); -- cgit v1.2.3