View | Details | Raw Unified | Return to bug 649
Collapse All | Expand All

(-)usr/src/usr.sbin/tcpdump/tcpdump/tcpdump.c (-6 / +56 lines)
Lines 39-44 Link Here
39
#include <netinet/in.h>
39
#include <netinet/in.h>
40
40
41
#include <pcap.h>
41
#include <pcap.h>
42
#include <ctype.h>
42
#include <signal.h>
43
#include <signal.h>
43
#include <stdio.h>
44
#include <stdio.h>
44
#ifdef __STDC__
45
#ifdef __STDC__
Lines 351-375 Link Here
351
	exit(0);
352
	exit(0);
352
}
353
}
353
354
355
static void
356
chardump(const char *s_, size_t n)
357
{
358
	register const unsigned char *s;
359
360
	s = s_;
361
	printf(" /");
362
	while (n-- != 0) {
363
		int c = *s++;
364
		if (c < 0x20 || c == 0x7f || c >= 0xfd)
365
			c = '.';
366
		putchar(c);
367
	}/* while */
368
	putchar(' ');
369
}
370
371
354
/* Like default_print() but data need not be aligned */
372
/* Like default_print() but data need not be aligned */
355
void
373
void
356
default_print_unaligned(register const u_char *cp, register int length)
374
default_print_unaligned(register const u_char *cp, register int length)
357
{
375
{
358
	register u_int i, s;
376
	register u_int i, s;
359
	register int nshorts;
377
	register int nshorts;
378
	char *pp;
379
	int out;
360
380
381
	pp = (char *)cp;
382
	out = 0;
361
	nshorts = (u_int) length / sizeof(u_short);
383
	nshorts = (u_int) length / sizeof(u_short);
362
	i = 0;
384
	i = 0;
363
	while (--nshorts >= 0) {
385
	while (--nshorts >= 0) {
364
		if ((i++ % 8) == 0)
386
		if ((i++ % 8) == 0)
365
			(void)printf("\n\t\t\t");
387
			(void)printf("\n\t\t");
366
		s = *cp++;
388
		s = *cp++;
367
		(void)printf(" %02x%02x", s, *cp++);
389
		(void)printf(" %02x%02x", s, *cp++);
390
		if ((xflag & 2) && (out += 2) == 16) {
391
			chardump(pp, out);
392
			pp += out;
393
			out = 0;
394
		}
368
	}
395
	}
369
	if (length & 1) {
396
	if (length & 1) {
370
		if ((i % 8) == 0)
397
		if ((i % 8) == 0)
371
			(void)printf("\n\t\t\t");
398
			(void)printf("\n\t\t");
372
		(void)printf(" %02x", *cp);
399
		(void)printf(" %02x  ", *cp);
400
		out++;
401
	}
402
	if (xflag & 2) {
403
		int j;
404
		for (j = (out + 1) / 2 * 2; j < 16; j += 2)
405
			printf("     ");
406
		chardump(pp, out);
373
	}
407
	}
374
}
408
}
375
409
Lines 379-385 Link Here
379
	register const u_short *sp;
413
	register const u_short *sp;
380
	register u_int i;
414
	register u_int i;
381
	register int nshorts;
415
	register int nshorts;
416
	char *pp;
417
	int out;
382
418
419
	pp = (char *)bp;
420
	out = 0;
383
	if ((int)bp & 1) {
421
	if ((int)bp & 1) {
384
		default_print_unaligned(bp, length);
422
		default_print_unaligned(bp, length);
385
		return;
423
		return;
Lines 389-401 Link Here
389
	i = 0;
427
	i = 0;
390
	while (--nshorts >= 0) {
428
	while (--nshorts >= 0) {
391
		if ((i++ % 8) == 0)
429
		if ((i++ % 8) == 0)
392
			(void)printf("\n\t\t\t");
430
			(void)printf("\n\t\t");
393
		(void)printf(" %04x", ntohs(*sp++));
431
		(void)printf(" %04x", ntohs(*sp++));
432
		if ((xflag & 2) && (out += 2) == 16) {
433
			chardump(pp, out);
434
			pp += out;
435
			out = 0;
436
		}
394
	}
437
	}
395
	if (length & 1) {
438
	if (length & 1) {
396
		if ((i % 8) == 0)
439
		if ((i % 8) == 0)
397
			(void)printf("\n\t\t\t");
440
			(void)printf("\n\t\t");
398
		(void)printf(" %02x", *(u_char *)sp);
441
		(void)printf(" %02x  ", *(u_char *)sp);
442
		out++;
443
	}
444
	if (xflag & 2) {
445
		int j;
446
		for (j = (out + 1) / 2 * 2; j < 16; j += 2)
447
			printf("     ");
448
		chardump(pp, out);
399
	}
449
	}
400
}
450
}
401
451
(-)usr/src/usr.sbin/tcpdump/tcpdump/print-atalk.c (-5 / +12 lines)
Lines 100-108 Link Here
100
	register const struct atShortDDP *sdp;
100
	register const struct atShortDDP *sdp;
101
	u_short snet;
101
	u_short snet;
102
102
103
#if 0
103
	lp = (struct LAP *)bp;
104
	lp = (struct LAP *)bp;
104
	bp += sizeof(*lp);
105
	bp += sizeof(*lp);
105
	length -= sizeof(*lp);
106
	length -= sizeof(*lp);
107
#else
108
	{
109
		static struct LAP lp_ = {0, 0, lapDDP};
110
		lp = &lp_;
111
	}
112
#endif
106
	switch (lp->type) {
113
	switch (lp->type) {
107
114
108
	case lapShortDDP:
115
	case lapShortDDP:
Lines 532-538 Link Here
532
		if (tp2->addr == i) {
539
		if (tp2->addr == i) {
533
			tp->addr = (atnet << 8) | athost;
540
			tp->addr = (atnet << 8) | athost;
534
			tp->nxt = (struct hnamemem *)calloc(1, sizeof(*tp));
541
			tp->nxt = (struct hnamemem *)calloc(1, sizeof(*tp));
535
			(void)sprintf(nambuf, "%s.%d", tp2->name, athost);
542
			(void)sprintf(nambuf, "%s.%02x", tp2->name, athost);
536
			tp->name = savestr(nambuf);
543
			tp->name = savestr(nambuf);
537
			return (tp->name);
544
			return (tp->name);
538
		}
545
		}
Lines 540-549 Link Here
540
	tp->addr = (atnet << 8) | athost;
547
	tp->addr = (atnet << 8) | athost;
541
	tp->nxt = (struct hnamemem *)calloc(1, sizeof(*tp));
548
	tp->nxt = (struct hnamemem *)calloc(1, sizeof(*tp));
542
	if (athost != 255)
549
	if (athost != 255)
543
		(void)sprintf(nambuf, "%d.%d.%d",
550
		(void)sprintf(nambuf, "%02x.%02x.%02x",
544
		    atnet >> 8, atnet & 0xff, athost);
551
		    atnet >> 8, atnet & 0xff, athost);
545
	else
552
	else
546
		(void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff);
553
		(void)sprintf(nambuf, "%02x.%02x", atnet >> 8, atnet & 0xff);
547
	i = strlen(nambuf) + 1;
554
	i = strlen(nambuf) + 1;
548
	tp->name = strcpy(malloc((u_int) i), nambuf);
555
	tp->name = strcpy(malloc((u_int) i), nambuf);
549
556
Lines 564-571 Link Here
564
	static char buf[8];
571
	static char buf[8];
565
572
566
	if (nflag) {
573
	if (nflag) {
567
		(void)sprintf(buf, "%d", skt);
574
		(void)sprintf(buf, "%02x", skt);
568
		return (buf);
575
		return (buf);
569
	}
576
	}
570
	return (tok2str(skt2str, "%d", skt));
577
	return (tok2str(skt2str, "%02x", skt));
571
}
578
}

Return to bug 649