head	1.2;
access;
symbols
	perseant-exfatfs-base-20250801:1.2
	perseant-exfatfs-base-20240630:1.2
	perseant-exfatfs:1.2.0.20
	perseant-exfatfs-base:1.2
	cjep_sun2x:1.2.0.18
	cjep_sun2x-base:1.2
	cjep_staticlib_x-base1:1.2
	cjep_staticlib_x:1.2.0.16
	cjep_staticlib_x-base:1.2
	phil-wifi-20200421:1.2
	phil-wifi-20200411:1.2
	phil-wifi-20200406:1.2
	pgoyette-compat-merge-20190127:1.2
	pgoyette-compat-20190127:1.2
	pgoyette-compat-20190118:1.2
	pgoyette-compat-1226:1.2
	pgoyette-compat-1126:1.2
	pgoyette-compat-1020:1.2
	pgoyette-compat-0930:1.2
	pgoyette-compat-0906:1.2
	pgoyette-compat-0728:1.2
	pgoyette-compat-0625:1.2
	pgoyette-compat-0521:1.2
	pgoyette-compat-0502:1.2
	pgoyette-compat-0422:1.2
	pgoyette-compat-0415:1.2
	pgoyette-compat-0407:1.2
	pgoyette-compat-0330:1.2
	pgoyette-compat-0322:1.2
	pgoyette-compat-0315:1.2
	pgoyette-compat:1.2.0.14
	pgoyette-compat-base:1.2
	perseant-stdc-iso10646:1.2.0.12
	perseant-stdc-iso10646-base:1.2
	prg-localcount2-base3:1.2
	prg-localcount2-base2:1.2
	prg-localcount2-base1:1.2
	prg-localcount2:1.2.0.10
	prg-localcount2-base:1.2
	pgoyette-localcount-20170426:1.2
	bouyer-socketcan-base1:1.2
	pgoyette-localcount-20170320:1.2
	bouyer-socketcan:1.2.0.8
	bouyer-socketcan-base:1.2
	pgoyette-localcount-20170107:1.2
	pgoyette-localcount-20161104:1.2
	localcount-20160914:1.2
	pgoyette-localcount-20160806:1.2
	pgoyette-localcount-20160726:1.2
	pgoyette-localcount:1.2.0.6
	pgoyette-localcount-base:1.2
	yamt-pagecache-base9:1.2
	tls-earlyentropy:1.2.0.2
	tls-earlyentropy-base:1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.2
	riastradh-drm2-base3:1.2
	agc-symver:1.2.0.4
	agc-symver-base:1.2
	tls-maxphys-base:1.2
	yamt-pagecache-base8:1.2
	yamt-pagecache-base7:1.2
	yamt-pagecache-base6:1.2
	yamt-pagecache-base5:1.2
	yamt-pagecache-base4:1.2
	v5-1-1:1.1.1.1
	DARRENR:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2012.03.23.23.14.34;	author christos;	state dead;
branches;
next	1.1;

1.1
date	2012.03.23.21.20.16;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2012.03.23.21.20.16;	author christos;	state Exp;
branches;
next	;


desc
@@


1.2
log
@deal with tests
@
text
@@@P=();
$line = 0;
while (<>) {
	s/\=192.168.1.188/\=c0a8:0100::bc/g;
	s/\=192.168.1.188/\=c0a8:0100::bc/g;
	@@F = split;
	if (/^#/) {
		@@P[$nline++] = join(" ",@@F);
		next;
	}
	$line = 0 if (/^\[/);
	if ($line == 1) {
		$len = hex($F[1]) - 20;
		$pr = hex($F[4]) & 0xff;
		$pr = 58 if ($pr == 1);
		$ttl = hex($F[4]) >> 8;
		&replaceip($_, $len, $pr, $ttl);
		$ipline = $nline;
		$err = 0;
	} elsif ($line == 2) {
		if ($pr == 58) {
			#
			# Map the ICMP type codes from IPv4 to IPv6
			# and update the checksum to compensate.
			#
			if ($F[0] =~ /^0800/) {
				$F[0] =~ s/^0800/8000/;
				$d = 0x7800;
			}
			if ($F[0] =~ /^0000/) {
				$F[0] =~ s/^0000/8100/;
				$d = 0x8100;
			}
			if ($F[0] =~ /^0304/) {
				$F[0] =~ s/^0304/0200/;
				$d = 0xfefc;
				$err = 1;
			}
			if ($F[0] =~ /^03/) {
				$F[0] =~ s/^03/01/;
				$d = 0xfe00;
				$err = 1;
			}
			if ($F[0] =~ /^0b/) {
				$F[0] =~ s/^0b/03/;
				$d = 0xf800;
				$err = 1;
			}
			if ($F[0] =~ /^0c/) {
				$F[0] =~ s/^0c/04/;
				$d = 0xf800;
				$err = 1;
			}
			$F[1] = sprintf "%04x", hex($F[1]) - $d;
		}
		@@P[$nline++] = join(" ",@@F);
	} elsif ($line == 3) {
		if ($pr == 58 && $err == 1 && $F[0] =~ /^45/) {
			local($l) = hex($F[1]) - 20;
			local($p) = hex($F[4]) & 0xff;
			$p = 58 if ($p == 1);
			local($t) = hex($F[4]) >> 8;
			&replaceip(join(" ", @@F), $l, $p, $t);
			@@H = split(/ /, $P[$ipline]);
			$H[2] += 20;
			$P[$ipline] = join(" ",@@H);
		} else {
			@@P[$nline++] = join(" ",@@F);
		}
	} else {
		@@P[$nline++] = join(" ",@@F);
	}
	$line++;
}

for ($li = 0; $li < $nline; $li++) {
	print "$P[$li]\n";
}

exit(0);

sub replaceip {
	local(@@G) = split(/\s/,$_[0]);
	local($p) = "";

	$p = sprintf "6000 0000 %04x %02x%02x", $_[1], $_[2], $_[3];
	if ($G[6] =~ /^c0a8/) {
		$fmt = " %02x%02x %02x00 0000 0000 0000 0000 0000 00%02x";
	} else {
		if ($G[6] =~ /^0[4a]../) {
			$fmt = " 00%02x 00%02x 00%02x 0000 0000 0000 0000 00%02x";
		} else {
			$fmt = " 00%02x 0000 0000 0000 0000 00%02x 00%02x 00%02x";
		}
		if ($G[6] =~ /^0a/) {
			$G[6] =~ s/^0a/10/;
		}
		if ($G[6] =~ /0a$/) {
			$G[6] =~ s/0a$/10/;
		}
		if ($G[7] =~ /^0a/) {
			$G[7] =~ s/^0a/10/;
		}
		if ($G[7] =~ /0a$/) {
			$G[7] =~ s/0a$/10/;
		}
	}
	$p = $p.sprintf $fmt, hex($G[6]) >> 8, hex($G[6]) & 0xff,
		     hex($G[7]) >> 8, hex($G[7]) & 0xff;

	if ($G[6] =~ /^c0a8/) {
		$fmt = " %02x%02x %02x00 0000 0000 0000 0000 0000 00%02x";
	} else {
		if ($G[8] =~ /^0[4a]../) {
			$fmt = " 00%02x 00%02x 00%02x 0000 0000 0000 0000 00%02x";
		} else {
			$fmt = " 00%02x 0000 0000 0000 0000 00%02x 00%02x 00%02x";
		}
		if ($G[8] =~ /^0a/) {
			$G[8] =~ s/^0a/10/;
		}
		if ($G[8] =~ /0a$/) {
			$G[8] =~ s/0a$/10/;
		}
		if ($G[9] =~ /^0a/) {
			$G[9] =~ s/^0a/10/;
		}
		if ($G[9] =~ /0a$/) {
			$G[9] =~ s/0a$/10/;
		}
	}
	$p = $p.sprintf $fmt, hex($G[8]) >> 8, hex($G[8]) & 0xff,
		     hex($G[9]) >> 8, hex($G[9]) & 0xff;
	$P[$nline++] = $p;
}
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@import 5.1.1
@
text
@@
