File: omi_dmp_pkt.c

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (106 lines) | stat: -rw-r--r-- 2,437 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/****************************************************************
 *								*
 *	Copyright 2001, 2012 Fidelity Information Services, Inc	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

/*
 *  omi_dump_pkt.c ---
 *
 *
 *
 */
#include "mdef.h"

#include <errno.h>
#include "gtm_stdio.h"
#include "gtm_unistd.h"

#include "gtm_string.h"
#include "gtmio.h"
#include "have_crit.h"

#include "omi.h"

GBLREF char	*omi_pklog;
GBLREF int	 omi_pkdbg;
GBLREF char	*omi_oprlist[];

#ifndef lint
static char rcsid[] = "$Header:$";
#endif


void omi_dump_pkt(omi_conn *cptr)
{
    char	*ptr, *end, *chr;
    omi_vi	 vi, mlen, xlen;
    omi_li	 li, nx;
    omi_si	 si;
    int		 i, j, len, buf[5];

    if (!omi_pklog || INV_FD_P(cptr->pklog))
	return;

    if (write(cptr->pklog, cptr->bptr, cptr->blen) < 0)
	OMI_DBG((omi_debug, "gtcm_server: write(): %s\n", STRERROR(errno)));

    if (!omi_pkdbg)
	return;

    OMI_DBG((omi_debug, "gtcm_server: connection %d:", cptr->stats.id));

    ptr = cptr->bptr;
    OMI_VI_READ(&mlen, ptr);
    OMI_DBG((omi_debug, " %d bytes", mlen.value));

    if (cptr->exts & OMI_XTF_BUNCH) {
	OMI_LI_READ(&nx, ptr);
	OMI_DBG((omi_debug, " %d transactions in bunch", nx.value));
    }
    else {
	nx.value = 1;
	xlen     = mlen;
    }
    OMI_DBG((omi_debug, "\n"));

    for (i = 0; i < nx.value; i++) {
	if (cptr->exts & OMI_XTF_BUNCH)
	    OMI_VI_READ(&xlen, ptr);
	end  = ptr + xlen.value;
	ptr += 3;
	OMI_SI_READ(&si, ptr);
	ptr += 8;
	OMI_DBG((omi_debug, "    "));
	if (cptr->exts & OMI_XTF_BUNCH)
	    OMI_DBG((omi_debug, "bunch %d, ", i));
	OMI_DBG((omi_debug, "%s (%d bytes)\n", (omi_oprlist[si.value])
		 ? omi_oprlist[si.value] : "unknown", xlen.value));
	chr  = (char *)buf;
	while (ptr < end) {
	    OMI_DBG((omi_debug, "\t"));
	    if ((len = (int)(end - ptr)) > 20)
		len = 20;
	    memcpy(chr, ptr, len);
	    ptr += len;
	    for (j = len; j < 20; j++)
		chr[j] = '\0';
	    for (j = 0; j < 5; j++)
		OMI_DBG((omi_debug, "%08x ", buf[j]));
	    for (j = 0; j < 20; j++)
		if (j >= len)
		    chr[j] = ' ';
		else if (chr[j] < 32 || chr[j] > 126)
		    chr[j] = '.';
	    OMI_DBG((omi_debug, "%20s\n", chr));
	}
    }

    return;

}