Project

General

Profile

Bug #2724 ยป snoop-analysis.patch

suggested fix - Milan Jurik, 2012-06-05 04:42 PM

View differences:

new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c Tue Jun 5 18:36:22 2012
21 21
/*
22 22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 23
 * Use is subject to license terms.
24
 * Copyright 2012 Milan Jurik. All rights reserved.
24 25
 */
25 26

  
26 27
#include <stdio.h>
......
603 604
{
604 605
	struct stat st;
605 606
	int cap_vers;
606
	int *word, device_mac_type;
607
	int *word;
608
	int device_mac_type = -1;
607 609
	int capfile_in;
608 610

  
609 611
	capfile_in = open(name, O_RDONLY);
610
-- old/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c	Tue Jun  5 18:36:24 2012
612
++ new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c	Tue Jun  5 18:36:23 2012
......
21 21
/*
22 22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 23
 * Use is subject to license terms.
24
 * Copyright 2012 Milan Jurik. All rights reserved.
24 25
 */
25 26

  
26 27
#include <stdio.h>
......
1049 1050
static void
1050 1051
compare_value_zone(uint_t offset, uint32_t val)
1051 1052
{
1052
	int i;
1053

  
1054
	load_const(ntohl(((uint32_t *)&val)[i]));
1055
	load_value(offset + i * 4, 4);
1053
	load_const(ntohl(val));
1054
	load_value(offset, 4);
1056 1055
	emitop(OP_EQ);
1057 1056
}
1058 1057

  
......
1582 1581
		}
1583 1582
	}
1584 1583

  
1584
	if (hp == NULL)
1585
		return;
1586

  
1585 1587
	switch (which) {
1586 1588
	case TO:
1587 1589
		addr4offset = IPV4_DSTADDR_OFFSET;
......
1600 1602
	/*
1601 1603
	 * The code below generates the filter.
1602 1604
	 */
1603
	if (hp != NULL && hp->h_addrtype == AF_INET) {
1605
	if (hp->h_addrtype == AF_INET) {
1604 1606
		ethertype_match(interface->network_type_ip);
1605 1607
		emitop(OP_BRFL);
1606 1608
		n = chain(n);
1607
-- old/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c	Tue Jun  5 18:36:25 2012
1609
++ new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c	Tue Jun  5 18:36:24 2012
......
21 21
/*
22 22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 23
 * Use is subject to license terms.
24
 * Copyright 2012 Milan Jurik. All rights reserved.
24 25
 */
25 26

  
26 27
#include <stdio.h>
......
1205 1206
	 * Display Classification Level
1206 1207
	 */
1207 1208
	ripso_class = get_pair_byval(ripso_class_tbl, (int)opt[2]);
1208
	if (ripso_class != NULL)
1209
	if (ripso_class == NULL)
1209 1210
		(void) snprintf(get_line(0, 0), get_line_remain(),
1210 1211
		    "Classification = Unknown (0x%02x)", opt[2]);
1211 1212
	else
1212
-- old/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c	Tue Jun  5 18:36:26 2012
1213
++ new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c	Tue Jun  5 18:36:25 2012
......
21 21
/*
22 22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 23
 * Use is subject to license terms.
24
 * Copyright 2012 Milan Jurik. All rights reserved.
24 25
 */
25 26

  
26 27
#include <stdio.h>
......
688 689
		pr_err("unknown token type: %s", hostname);
689 690
	}
690 691

  
692
	if (hp == NULL)
693
		return;
694

  
691 695
	switch (which) {
692 696
	case TO:
693 697
		addr4offset = IPV4_DSTADDR_OFFSET;
......
703 707
		break;
704 708
	}
705 709

  
706
	if (hp != NULL && hp->h_addrtype == AF_INET) {
710
	if (hp->h_addrtype == AF_INET) {
707 711
		pf_matchfn("ip");
708 712
		if (dl.dl_type == DL_ETHER)
709 713
			pf_check_vlan_tag(ENCAP_ETHERTYPE_OFF/2);
......
809 813
		}
810 814
	}
811 815

  
812
	if (hp != NULL) {
813
		freehostent(hp);
814
	}
816
	freehostent(hp);
815 817
}
816 818

  
817 819

  
818
-- old/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c	Tue Jun  5 18:36:27 2012
820
++ new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c	Tue Jun  5 18:36:26 2012
......
22 22
/*
23 23
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24 24
 * Use is subject to license terms.
25
 * Copyright 2012 Milan Jurik. All rights reserved.
25 26
 */
26 27

  
27
#pragma ident	"%Z%%M%	%I%	%E% SMI"
28

  
29 28
#include <sys/types.h>
30 29
#include <sys/errno.h>
31 30
#include <sys/tiuser.h>
......
105 104
	rpcsec_gss_service    = getxdr_enum();
106 105

  
107 106
	(void) sprintf(get_line(pos, getxdr_pos()),
108
		"   version = %u",  rpcsec_gss_ver);
107
	    "   version = %u",  rpcsec_gss_ver);
109 108

  
110 109
	(void) sprintf(get_line(pos, getxdr_pos()),
111
		"   gss control procedure = %u (%s)",
112
		rpcsec_gss_proc,
113
		rpcsec_gss_proc_to_string(rpcsec_gss_proc));
110
	    "   gss control procedure = %u (%s)",
111
	    rpcsec_gss_proc,
112
	    rpcsec_gss_proc_to_string(rpcsec_gss_proc));
114 113

  
115 114
	(void) sprintf(get_line(pos, getxdr_pos()),
116
		"   sequence num = %u", seq_num);
115
	    "   sequence num = %u", seq_num);
117 116

  
118 117
	(void) sprintf(get_line(pos, getxdr_pos()),
119 118
	    "   service = %d (%s)", rpcsec_gss_service,
......
123 122
	handle = getxdr_hex(handle_len);
124 123
	line = get_line(pos, getxdr_pos());
125 124
	sprintf(line, "   handle: length = %d, data = [%s]",
126
			handle_len, handle);
125
	    handle_len, handle);
127 126
	x = find_xid(xid);
128 127
	if (x) {
129 128
		x->xid_gss_proc    = rpcsec_gss_proc;
......
159 158
		seq = getxdr_u_long();
160 159
		if (flags & F_ALLSUM) {
161 160
			(void) sprintf(get_sum_line(), "%s %c seq_num = %u",
162
				"RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
163
				seq);
161
			    "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
162
			    seq);
164 163
		} else if (flags & F_DTAIL) {
165 164
			sprintf(get_line(0, 0),
166
				"RPCSEC_GSS data seq_num = %u", seq);
165
			    "RPCSEC_GSS data seq_num = %u", seq);
167 166
			show_space();
168 167
		}
169 168
		/* call args follow */
......
178 177
		}
179 178

  
180 179
		if (flags & F_SUM || flags & F_ALLSUM) {
181
		    (void) sprintf(get_sum_line(),
182
			"%s %c %s ver(%d) proc(%d) (data encrypted) ",
183
			"RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
184
			progname, vers, proc);
180
			(void) sprintf(get_sum_line(),
181
			    "%s %c %s ver(%d) proc(%d) (data encrypted) ",
182
			    "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
183
			    progname, vers, proc);
185 184
		} else if (flags & F_DTAIL) {
186
		    unsigned int args_len;
185
			unsigned int args_len;
187 186

  
188
		    args_len = getxdr_u_long();
189
		    sprintf(get_line(0, 0),
190
			"RPCSEC_GSS %s ver(%d) proc(%d)",
191
			progname, vers, proc);
192
		    sprintf(get_line(0, 0),
193
			"(%s args encrypted, len = %d bytes)",
194
			type == CALL ? "CALL" : "REPLY", args_len);
195
		    show_space();
187
			args_len = getxdr_u_long();
188
			sprintf(get_line(0, 0),
189
			    "RPCSEC_GSS %s ver(%d) proc(%d)",
190
			    progname, vers, proc);
191
			sprintf(get_line(0, 0),
192
			    "(%s args encrypted, len = %d bytes)",
193
			    type == CALL ? "CALL" : "REPLY", args_len);
194
			show_space();
196 195
		}
197 196
		}
198 197
		return (1);
......
238 237
			checksum_len = getxdr_u_long();
239 238
			checksum = getxdr_hex(checksum_len);
240 239
			sprintf(get_line(0, 0),
241
				"checksum: len = %d", checksum_len);
240
			    "checksum: len = %d", checksum_len);
242 241
			sprintf(get_line(0, 0), "[%s]", checksum);
243 242
			show_trailer();
244 243
		}
......
266 265
		if (flags & F_SUM) {
267 266
			if (type == CALL) {
268 267
				(void) sprintf(get_sum_line(), "%s %c %u (%s)",
269
				"RPC RPCSEC_GSS",
270
				type == CALL ? 'C' : 'R',
271
				x->xid_gss_proc,
272
				rpcsec_gss_proc_to_string(x->xid_gss_proc));
268
				    "RPC RPCSEC_GSS",
269
				    type == CALL ? 'C' : 'R',
270
				    x->xid_gss_proc,
271
				    rpcsec_gss_proc_to_string(x->xid_gss_proc));
273 272
			}
274 273
		} else if (flags & F_DTAIL) {
275 274
			if (x->xid_gss_proc == RPCSEC_GSS_INIT ||
......
330 329

  
331 330
	char *token, *line;
332 331
	unsigned int token_len;
333
	int pos;
332
	int pos = 0;
334 333

  
335 334
	/*
336 335
	 *  see if we need to print out the rpc_gss_init_arg structure
......
338 337
	 */
339 338

  
340 339
	if (x->xid_gss_proc != RPCSEC_GSS_INIT &&
341
		x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
340
	    x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
342 341
		return;
343 342
	}
344 343

  
345 344
	/* print it */
346 345

  
347 346
	(void) sprintf(get_line(pos, getxdr_pos()),
348
		"RPCSEC_GSS_INIT args:");
347
	    "RPCSEC_GSS_INIT args:");
349 348

  
350 349
	pos = getxdr_pos();
351 350
	token_len = getxdr_u_long();
352 351
	token = getxdr_hex(token_len);
353 352
	line = get_line(pos, getxdr_pos());
354
		sprintf(line, "   gss token: length = %d, data = [%d bytes]",
355
			token_len, token_len);
353
	sprintf(line, "   gss token: length = %d, data = [%d bytes]",
354
	    token_len, token_len);
356 355

  
357 356
	show_trailer();
358 357
}
......
368 367
	unsigned int token_len, handle_len;
369 368
	unsigned int major, minor, seq_window;
370 369

  
371
	int pos;
370
	int pos = 0;
372 371
	struct cache_struct *x;
373 372

  
374 373
	/* print it */
......
380 379
	handle = getxdr_hex(handle_len);
381 380
	line = get_line(pos, getxdr_pos());
382 381
	sprintf(line, "   handle: length = %d, data = [%s]",
383
		handle_len, handle);
382
	    handle_len, handle);
384 383
	pos = getxdr_pos();
385 384
	major = getxdr_u_long();
386 385
	minor = getxdr_u_long();
387 386
	seq_window = getxdr_u_long();
388 387

  
389 388
	(void) sprintf(get_line(pos, getxdr_pos()),
390
				"   gss_major status = %u", major);
389
	    "   gss_major status = %u", major);
391 390

  
392 391
	(void) sprintf(get_line(pos, getxdr_pos()),
393
				"   gss_minor status = %u", minor);
392
	    "   gss_minor status = %u", minor);
394 393

  
395 394
	(void) sprintf(get_line(pos, getxdr_pos()),
396
				"   sequence window  = %u", seq_window);
395
	    "   sequence window  = %u", seq_window);
397 396
	pos = getxdr_pos();
398 397
	token_len = getxdr_u_long();
399 398
	token = getxdr_hex(token_len);
400 399
	line = get_line(pos, getxdr_pos());
401 400
	sprintf(line, "   gss token: length = %d, data = [%d bytes]",
402
		token_len, token_len);
401
	    token_len, token_len);
403 402
	show_trailer();
404 403
}
    (1-1/1)