Deleted Added
full compact
print-krb.c (26180) print-krb.c (39297)
1/*
1/*
2 * Copyright (c) 1995, 1996
2 * Copyright (c) 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning

--- 7 unchanged lines hidden (view full) ---

18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Initial contribution from John Hawkinson (jhawk@mit.edu).
22 */
23
24#ifndef lint
25static const char rcsid[] =
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning

--- 7 unchanged lines hidden (view full) ---

18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Initial contribution from John Hawkinson (jhawk@mit.edu).
22 */
23
24#ifndef lint
25static const char rcsid[] =
26 "@(#) $Header: print-krb.c,v 1.8 96/12/10 23:17:39 leres Exp $";
26 "@(#) $Header: print-krb.c,v 1.9 97/04/26 14:01:45 leres Exp $";
27#endif
28
29#include <sys/param.h>
30#include <sys/time.h>
31#include <sys/socket.h>
32
33#include <netinet/in.h>
34#include <netinet/in_systm.h>

--- 33 unchanged lines hidden (view full) ---

68#define KERB_ERR_NAME_MAST_KEY_VER 5
69#define KERB_ERR_SERV_MAST_KEY_VER 6
70#define KERB_ERR_BYTE_ORDER 7
71#define KERB_ERR_PRINCIPAL_UNKNOWN 8
72#define KERB_ERR_PRINCIPAL_NOT_UNIQUE 9
73#define KERB_ERR_NULL_KEY 10
74
75struct krb {
27#endif
28
29#include <sys/param.h>
30#include <sys/time.h>
31#include <sys/socket.h>
32
33#include <netinet/in.h>
34#include <netinet/in_systm.h>

--- 33 unchanged lines hidden (view full) ---

68#define KERB_ERR_NAME_MAST_KEY_VER 5
69#define KERB_ERR_SERV_MAST_KEY_VER 6
70#define KERB_ERR_BYTE_ORDER 7
71#define KERB_ERR_PRINCIPAL_UNKNOWN 8
72#define KERB_ERR_PRINCIPAL_NOT_UNIQUE 9
73#define KERB_ERR_NULL_KEY 10
74
75struct krb {
76 u_char pvno; /* Protocol Version */
77 u_char type; /* Type+B */
76 u_char pvno; /* Protocol Version */
77 u_char type; /* Type+B */
78};
79
80static char tstr[] = " [|kerberos]";
81
82static struct tok type2str[] = {
78};
79
80static char tstr[] = " [|kerberos]";
81
82static struct tok type2str[] = {
83 { AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" },
84 { AUTH_MSG_KDC_REPLY, "KDC_REPLY" },
85 { AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" },
86 { AUTH_MSG_APPL_REQUEST_MUTUAL, "APPL_REQUEST_MUTUAL" },
87 { AUTH_MSG_ERR_REPLY, "ERR_REPLY" },
88 { AUTH_MSG_PRIVATE, "PRIVATE" },
89 { AUTH_MSG_SAFE, "SAFE" },
90 { AUTH_MSG_APPL_ERR, "APPL_ERR" },
91 { AUTH_MSG_DIE, "DIE" },
92 { 0, NULL }
83 { AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" },
84 { AUTH_MSG_KDC_REPLY, "KDC_REPLY" },
85 { AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" },
86 { AUTH_MSG_APPL_REQUEST_MUTUAL, "APPL_REQUEST_MUTUAL" },
87 { AUTH_MSG_ERR_REPLY, "ERR_REPLY" },
88 { AUTH_MSG_PRIVATE, "PRIVATE" },
89 { AUTH_MSG_SAFE, "SAFE" },
90 { AUTH_MSG_APPL_ERR, "APPL_ERR" },
91 { AUTH_MSG_DIE, "DIE" },
92 { 0, NULL }
93};
94
95static struct tok kerr2str[] = {
93};
94
95static struct tok kerr2str[] = {
96 { KERB_ERR_OK, "OK" },
97 { KERB_ERR_NAME_EXP, "NAME_EXP" },
98 { KERB_ERR_SERVICE_EXP, "SERVICE_EXP" },
99 { KERB_ERR_AUTH_EXP, "AUTH_EXP" },
100 { KERB_ERR_PKT_VER, "PKT_VER" },
101 { KERB_ERR_NAME_MAST_KEY_VER, "NAME_MAST_KEY_VER" },
102 { KERB_ERR_SERV_MAST_KEY_VER, "SERV_MAST_KEY_VER" },
103 { KERB_ERR_BYTE_ORDER, "BYTE_ORDER" },
104 { KERB_ERR_PRINCIPAL_UNKNOWN, "PRINCIPAL_UNKNOWN" },
105 { KERB_ERR_PRINCIPAL_NOT_UNIQUE, "PRINCIPAL_NOT_UNIQUE" },
106 { KERB_ERR_NULL_KEY, "NULL_KEY"},
107 { 0, NULL}
96 { KERB_ERR_OK, "OK" },
97 { KERB_ERR_NAME_EXP, "NAME_EXP" },
98 { KERB_ERR_SERVICE_EXP, "SERVICE_EXP" },
99 { KERB_ERR_AUTH_EXP, "AUTH_EXP" },
100 { KERB_ERR_PKT_VER, "PKT_VER" },
101 { KERB_ERR_NAME_MAST_KEY_VER, "NAME_MAST_KEY_VER" },
102 { KERB_ERR_SERV_MAST_KEY_VER, "SERV_MAST_KEY_VER" },
103 { KERB_ERR_BYTE_ORDER, "BYTE_ORDER" },
104 { KERB_ERR_PRINCIPAL_UNKNOWN, "PRINCIPAL_UNKNOWN" },
105 { KERB_ERR_PRINCIPAL_NOT_UNIQUE,"PRINCIPAL_NOT_UNIQUE" },
106 { KERB_ERR_NULL_KEY, "NULL_KEY"},
107 { 0, NULL}
108};
109
110
111/* little endian (unaligned) to host byte order */
112/* XXX need to look at this... */
113#define vtohlp(x) ((( ((char *)(x))[0] ) ) | \
114 (( ((char *)(x))[1] ) << 8) | \
115 (( ((char *)(x))[2] ) << 16) | \

--- 12 unchanged lines hidden (view full) ---

128
129const u_char *
130c_print(register const u_char *s, register const u_char *ep)
131{
132 register u_char c;
133 register int flag;
134
135 flag = 1;
108};
109
110
111/* little endian (unaligned) to host byte order */
112/* XXX need to look at this... */
113#define vtohlp(x) ((( ((char *)(x))[0] ) ) | \
114 (( ((char *)(x))[1] ) << 8) | \
115 (( ((char *)(x))[2] ) << 16) | \

--- 12 unchanged lines hidden (view full) ---

128
129const u_char *
130c_print(register const u_char *s, register const u_char *ep)
131{
132 register u_char c;
133 register int flag;
134
135 flag = 1;
136 while (ep == NULL || s < ep) {
136 while (s < ep) {
137 c = *s++;
138 if (c == '\0') {
139 flag = 0;
140 break;
141 }
142 if (!isascii(c)) {
143 c = toascii(c);
144 putchar('M');
145 putchar('-');
146 }
147 if (!isprint(c)) {
148 c ^= 0x40; /* DEL to ?, others to alpha */
149 putchar('^');
150 }
151 putchar(c);
152 }
153 if (flag)
154 return NULL;
137 c = *s++;
138 if (c == '\0') {
139 flag = 0;
140 break;
141 }
142 if (!isascii(c)) {
143 c = toascii(c);
144 putchar('M');
145 putchar('-');
146 }
147 if (!isprint(c)) {
148 c ^= 0x40; /* DEL to ?, others to alpha */
149 putchar('^');
150 }
151 putchar(c);
152 }
153 if (flag)
154 return NULL;
155 return(s);
155 return (s);
156}
157
158const u_char *
159krb4_print_hdr(const u_char *cp)
160{
156}
157
158const u_char *
159krb4_print_hdr(const u_char *cp)
160{
161 cp+=2;
161 cp += 2;
162
162
163#define PRINT if ((cp=c_print(cp, snapend))==NULL) goto trunc
163#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
164
164
165 TCHECK2(cp, 0);
166 PRINT;
165 PRINT;
167 TCHECK2(cp, 0);
168 putchar('.'); PRINT;
169 TCHECK2(cp, 0);
170 putchar('@'); PRINT;
171 return(cp);
166 putchar('.');
167 PRINT;
168 putchar('@');
169 PRINT;
170 return (cp);
172
173trunc:
174 fputs(tstr, stdout);
171
172trunc:
173 fputs(tstr, stdout);
175 return(NULL);
174 return (NULL);
176
177#undef PRINT
178}
179
180void
181krb4_print(const u_char *cp)
182{
183 register const struct krb *kp;
184 u_char type;
185 u_short len;
186
175
176#undef PRINT
177}
178
179void
180krb4_print(const u_char *cp)
181{
182 register const struct krb *kp;
183 u_char type;
184 u_short len;
185
187#define PRINT if ((cp=c_print(cp, snapend))==NULL) goto trunc
186#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
188/* True if struct krb is little endian */
189#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
190#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp))
191
192 kp = (struct krb *)cp;
193
194 if ((&kp->type) >= snapend) {
195 fputs(tstr, stdout);

--- 5 unchanged lines hidden (view full) ---

201 printf(" %s %s: ",
202 IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
203
204 switch (type) {
205
206 case AUTH_MSG_KDC_REQUEST:
207 if ((cp = krb4_print_hdr(cp)) == NULL)
208 return;
187/* True if struct krb is little endian */
188#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
189#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp))
190
191 kp = (struct krb *)cp;
192
193 if ((&kp->type) >= snapend) {
194 fputs(tstr, stdout);

--- 5 unchanged lines hidden (view full) ---

200 printf(" %s %s: ",
201 IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
202
203 switch (type) {
204
205 case AUTH_MSG_KDC_REQUEST:
206 if ((cp = krb4_print_hdr(cp)) == NULL)
207 return;
209 cp += 4; /* ctime */
210 TCHECK2(cp, 0);
211 printf(" %dmin ", *cp++ * 5);
212 TCHECK2(cp, 0);
213 PRINT;
214 TCHECK2(cp, 0);
215 putchar('.'); PRINT;
216 break;
208 cp += 4; /* ctime */
209 TCHECK(*cp);
210 printf(" %dmin ", *cp++ * 5);
211 PRINT;
212 putchar('.');
213 PRINT;
214 break;
217
218 case AUTH_MSG_APPL_REQUEST:
219 cp += 2;
215
216 case AUTH_MSG_APPL_REQUEST:
217 cp += 2;
220 TCHECK2(cp, 0);
218 TCHECK(*cp);
221 printf("v%d ", *cp++);
219 printf("v%d ", *cp++);
222 TCHECK2(cp, 0);
223 PRINT;
220 PRINT;
224 TCHECK2(cp, 0);
221 TCHECK(*cp);
225 printf(" (%d)", *cp++);
222 printf(" (%d)", *cp++);
226 TCHECK2(cp, 0);
223 TCHECK(*cp);
227 printf(" (%d)", *cp);
224 printf(" (%d)", *cp);
228 TCHECK2(cp, 0);
229 break;
230
231 case AUTH_MSG_KDC_REPLY:
232 if ((cp = krb4_print_hdr(cp)) == NULL)
233 return;
234 cp += 10; /* timestamp + n + exp + kvno */
225 break;
226
227 case AUTH_MSG_KDC_REPLY:
228 if ((cp = krb4_print_hdr(cp)) == NULL)
229 return;
230 cp += 10; /* timestamp + n + exp + kvno */
235 TCHECK2(cp, 0);
231 TCHECK2(*cp, sizeof(short));
236 len = KTOHSP(kp, cp);
237 printf(" (%d)", len);
232 len = KTOHSP(kp, cp);
233 printf(" (%d)", len);
238 TCHECK2(cp, 0);
239 break;
240
241 case AUTH_MSG_ERR_REPLY:
242 if ((cp = krb4_print_hdr(cp)) == NULL)
243 return;
244 cp += 4; /* timestamp */
234 break;
235
236 case AUTH_MSG_ERR_REPLY:
237 if ((cp = krb4_print_hdr(cp)) == NULL)
238 return;
239 cp += 4; /* timestamp */
245 TCHECK2(cp, 0);
240 TCHECK2(*cp, sizeof(short));
246 printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
247 cp += 4;
241 printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
242 cp += 4;
248 TCHECK2(cp, 0);
249 PRINT;
250 break;
251
252 default:
253 fputs("(unknown)", stdout);
254 break;
255 }
256

--- 38 unchanged lines hidden ---
243 PRINT;
244 break;
245
246 default:
247 fputs("(unknown)", stdout);
248 break;
249 }
250

--- 38 unchanged lines hidden ---