view rvinterf/lowlevel/logsent.c @ 928:65953c172f24

rvinterf/lowlevel: new hex dump format
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 05:23:19 +0000
parents 4e243402f453
children 3d1abb9f05ef
line wrap: on
line source

/*
 * This module implements the logging of sent packets
 */

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

extern int no_output, verbose;
extern FILE *logF;

extern void output_cont();

static void
log_sent_ati(pkt, pktlen)
	u_char *pkt;
{
	char buf[MAX_PKT_TO_TARGET*4+10];

	strcpy(buf, "Sent to ATI: ");
	safe_print_trace(pkt + 1, pktlen - 1, buf + 13);
	output_line(buf);
}

static void
log_sent_gpf(pkt, pktlen)
	u_char *pkt;
{
	char buf[MAX_PKT_TO_TARGET*4+30];

	strcpy(buf, "Sent ");
	format_g23_packet(pkt, pktlen, buf + 5);
	output_line(buf);
}

log_sent_packet(pkt, pktlen)
	u_char *pkt;
{
	if (no_output && !logF)
		return;
	switch (pkt[0]) {
	case RVT_L23_HEADER:
		log_sent_gpf(pkt, pktlen);
		return;
	case RVT_TM_HEADER:
		output_line("Sent Test Mode packet");
		packet_hex_dump(pkt, pktlen, output_cont);
		return;
	case RVT_AT_HEADER:
		log_sent_ati(pkt, pktlen);
		return;
	case RVT_TCH_HEADER:
		if (verbose) {
			output_line("Sent TCH packet");
			packet_hex_dump(pkt, pktlen, output_cont);
		} else {
			tch_inc_count_tx();
		}
		return;
	default:
		output_line("Sent misc packet");
		packet_hex_dump(pkt, pktlen, output_cont);
	}
}