FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/logsent.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | a1065c17429c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * This module implements the logging of sent packets | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 #include <strings.h> | |
9 #include "../include/pktmux.h" | |
10 #include "../include/limits.h" | |
11 | |
12 static void | |
13 log_sent_ati(pkt, pktlen) | |
14 u_char *pkt; | |
15 { | |
16 char buf[MAX_PKT_TO_TARGET*4+10]; | |
17 int i, c; | |
18 char *dp; | |
19 | |
20 strcpy(buf, "Sent to ATI: "); | |
21 dp = buf + 13; | |
22 for (i = 1; i < pktlen; i++) { | |
23 c = pkt[i]; | |
24 if (c & 0x80) { | |
25 *dp++ = 'M'; | |
26 *dp++ = '-'; | |
27 c &= 0x7F; | |
28 } | |
29 if (c < 0x20) { | |
30 *dp++ = '^'; | |
31 *dp++ = c + '@'; | |
32 } else if (c == 0x7F) { | |
33 *dp++ = '^'; | |
34 *dp++ = '?'; | |
35 } else | |
36 *dp++ = c; | |
37 } | |
38 *dp = '\0'; | |
39 output_line(buf); | |
40 } | |
41 | |
42 static void | |
43 log_sent_gpf(pkt, pktlen) | |
44 u_char *pkt; | |
45 { | |
46 char buf[MAX_PKT_TO_TARGET*4+30]; | |
47 | |
48 strcpy(buf, "Sent "); | |
49 format_g23_packet(pkt, pktlen, buf + 5); | |
50 output_line(buf); | |
51 } | |
52 | |
53 static void | |
54 log_sent_other(pkt, pktlen) | |
55 u_char *pkt; | |
56 { | |
57 char buf[MAX_PKT_TO_TARGET*3+5]; | |
58 int i; | |
59 char *dp; | |
60 | |
61 dp = buf; | |
62 strcpy(dp, "Sent"); | |
63 dp += 4; | |
64 for (i = 0; i < pktlen; i++) { | |
65 sprintf(dp, " %02X", pkt[i]); | |
66 dp += 3; | |
67 } | |
68 *dp = '\0'; | |
69 output_line(buf); | |
70 } | |
71 | |
72 log_sent_packet(pkt, pktlen) | |
73 u_char *pkt; | |
74 { | |
75 switch (pkt[0]) { | |
76 case RVT_L23_HEADER: | |
77 log_sent_gpf(pkt, pktlen); | |
78 return; | |
79 case RVT_AT_HEADER: | |
80 log_sent_ati(pkt, pktlen); | |
81 return; | |
82 default: | |
83 log_sent_other(pkt, pktlen); | |
84 } | |
85 } |