view rvinterf/lowlevel/rviftmode.c @ 934:0d6be90ae74f

rvinterf -v TM: send hex dump only to log file if we have one
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 06:49:10 +0000
parents bd6dd6120180
children d203a9c7c4e6
line wrap: on
line source

/*
 * This module is for rvinterf only.  Whenever we send or receive Test Mode
 * packets, we should be a little more intelligent about how we display and
 * log them.  By default we only print a one-line summary, and in verbose mode
 * we also emit a full hex dump.
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

extern u_char rxpkt[];
extern size_t rxpkt_len;

extern int verbose;
extern FILE *logF;

static void
hexdump_out(line)
	char *line;
{
	if (logF)
		fprintf(logF, "%s\n", line);
	else
		printf("%s\n", line);
}

void
log_sent_tm(pkt, pktlen)
	u_char *pkt;
{
	output_line("Sent Test Mode packet");
	if (verbose >= 1)
		packet_hex_dump(pkt, pktlen, hexdump_out);
}

void
print_tm_output_new()
{
	output_line("Rx Test Mode packet");
	if (verbose >= 1)
		packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out);
}