aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/libtinytac/lproto.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libtinytac/lproto.c')
-rw-r--r--lib/libtinytac/lproto.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/libtinytac/lproto.c b/lib/libtinytac/lproto.c
index 0ed365e..75ee6ea 100644
--- a/lib/libtinytac/lproto.c
+++ b/lib/libtinytac/lproto.c
@@ -75,6 +75,70 @@
75//------------------// 75//------------------//
76#pragma mark packet functions 76#pragma mark packet functions
77 77
78void
79tinytac_pckt_hexdump(
80 FILE * fs,
81 tinytac_pckt_t * pckt,
82 const char * prefix )
83{
84 uint8_t * bytes;
85 unsigned line;
86 unsigned pos;
87 unsigned pckt_len;
88 const char * str;
89
90 bytes = (void *)pckt;
91 pckt_len = ntohl(pckt->pckt_length) + sizeof(tinytac_pckt_t);
92 prefix = ((prefix)) ? prefix : "";
93
94 fprintf(fs, "%spacket: version: %u.%u;", prefix, (pckt->pckt_version >> 4), (pckt->pckt_version & 0x0f));
95 switch(pckt->pckt_type)
96 {
97 case TAC_PLUS_TYPE_AUTHEN: str = "authen"; break;
98 case TAC_PLUS_TYPE_AUTHOR: str = "author"; break;
99 case TAC_PLUS_TYPE_ACCT: str = "acct"; break;
100 default: str = "unknown"; break;
101 };
102 fprintf(fs, " type: %s;", str);
103 fprintf(fs, " seq_no: %u;", pckt->pckt_seq_no);
104 fprintf(fs, " session_id: %08x;", ntohl(pckt->pckt_session_id));
105 fprintf(fs, "\n%spacket: length: %u (0x%x);", prefix, pckt_len, pckt_len);
106 fprintf(fs, " flags:");
107 if (!(pckt->pckt_flags))
108 fprintf(fs, " NONE");
109 if ((pckt->pckt_flags & TAC_PLUS_FLAG_SINGLE_CONNECT))
110 fprintf(fs, " SINGLE-CONNECT");
111 if ((pckt->pckt_flags & TAC_PLUS_FLAG_UNENCRYPTED))
112 fprintf(fs, " UNENCRYPTED");
113 fprintf(fs, ";");
114 fprintf(fs, "\n");
115
116
117 fprintf(fs, "%s offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef\n", prefix);
118 for(line = 0; (line < pckt_len); line += 0x10)
119 {
120 fprintf(fs, "%s%08x", prefix, line);
121 for(pos = line; (pos < (line+0x10)); pos++)
122 {
123 if ((pos & 0x03) == 0)
124 fprintf(fs, " ");
125 if (pos < pckt_len)
126 fprintf(fs, " %02x", bytes[pos]);
127 else
128 fprintf(fs, " ");
129 };
130 fprintf(fs, " ");
131 for(pos = line; ((pos < (line+0x10)) && (pos < pckt_len)); pos++)
132 fprintf(fs, "%c", ((bytes[pos] < 0x20) || (bytes[pos] > 0x7e)) ? '.' : bytes[pos]);
133 fprintf(fs, "\n");
134 if ((line & 0xf0) == 0xf0)
135 fprintf(fs, "\n");
136 };
137
138 return;
139}
140
141
78int 142int
79tinytac_pckt_md5pad( 143tinytac_pckt_md5pad(
80 tinytac_pckt_t * pckt, 144 tinytac_pckt_t * pckt,