From 688023b7ca650f1a33a6a2ca338244bd64cac358 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Fri, 14 Jun 2013 17:11:56 +0200 Subject: [PATCH] debug: display invalid packet Dump packet info and packet content when packet can not be sent on wire. --- src/source-af-packet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 302e4a7..cd1f867 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -608,6 +608,8 @@ int AFPRead(AFPThreadVars *ptv) SCReturnInt(AFP_READ_OK); } +#include "util-print.h" + TmEcode AFPWritePacket(Packet *p) { struct sockaddr_ll socket_address; @@ -643,6 +645,19 @@ TmEcode AFPWritePacket(Packet *p) SCLogWarning(SC_ERR_SOCKET, "Sending packet failed on socket %d: %s", socket, strerror(errno)); + + if (PKT_IS_IPV4(p)) { + char srcip[16], dstip[16]; + PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); + PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); + SCLogInfo("%s:%" PRIu32 " -> %s:%" PRIu32 " [%d]", srcip, p->sp, dstip, p->dp, GET_PKT_LEN(p)); + } else { + char srcip[46], dstip[46]; + PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); + PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip)); + SCLogInfo("%s:%" PRIu32 " -> %s:%" PRIu32 " [%d]", srcip, p->sp, dstip, p->dp, GET_PKT_LEN(p)); + } + PrintRawDataFp(stdout,GET_PKT_DATA(p),GET_PKT_LEN(p)); if (p->afp_v.peer->flags & AFP_SOCK_PROTECT) SCMutexUnlock(&p->afp_v.peer->sock_protect); return TM_ECODE_FAILED; -- 1.8.3.1