Check-in [eda3d468e1]
Overview
Comment:Cleaned up
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: eda3d468e1e2650e6c4bc3212a46d28bc823df87
User & Date: rkeene on 2014-01-25 06:40:22
Other Links: manifest | tags
Context
2014-01-25
06:57
Updated to cleanup at any exit point check-in: 1384012f07 user: rkeene tags: trunk
06:40
Cleaned up check-in: eda3d468e1 user: rkeene tags: trunk
06:27
Updated to name service we create "npf", which is what winpcap expects to find and creates if not present check-in: 8f671ec548 user: rkeene tags: trunk
Changes

Modified main.tcl from [836be22022] to [2ed373a5f2].

1
2
3
4
5
6
7
8
9

10

11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18









+
-
+







#! /usr/bin/env tclsh

package require starkit
starkit::startup

lappend auto_path [file join $::starkit::topdir twapi]

package require twapi

# Determine platform to install driver for
# http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx
## http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx
if {[info exists ::env(PROCESSOR_ARCHITEW6432)]} {
	set arch $::env(PROCESSOR_ARCHITEW6432)
} else {
	if {[info exists ::env(PROCESSOR_ARCHITECTURE)]} {
		set arch $::env(PROCESSOR_ARCHITECTURE)
	} else {
		set arch "x86"
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75

76
77
78
79
80
81
82
83

84

85
86


87
88
89
90
91
92
93
62
63
64
65
66
67
68

69
70
71
72
73
74
75

76


77
78
79

80
81
82

83
84
85
86
87
88
89
90
91
92
93
94







-
+






-
+
-
-



-


+
-
+


+
+







		set iface_adapter [lindex [::twapi::get_netif_info $iface_idx -adaptername] 1]
		set iface_npf "\\Device\\NPF_${iface_adapter}"

		set argv [lreplace $argv $dest_parm_idx $dest_parm_idx $iface_npf]
	}
}

# Copy files neeed to temporary directory
# Determine name of temporary directory
for {set i 0} {$i < 20} {incr i} {
	append random_bin [format %c [expr {int(rand() * 256)}]]
}
binary scan $random_bin H* random

set srcdir [file join $::starkit::topdir files]
set dstdir [file join $tmpdir tcpdmp-$random]
set dstdir [file join $tmpdir tcpdump-temp-$random]

file delete -force -- $dstdir

# Run tcpdump
set exit 1
set start_npf_service 0
set npf_failed 0
if {[catch {
	## Create directory
	set filesdir [file join $dstdir files]
	file delete -force -- $dstdir
	file mkdir $dstdir

	## Copy files to directory
	set filesdir [file join $dstdir files]
	file copy -- $srcdir $filesdir

	## Delete extraneous service
	catch {
		::twapi::stop_service npf
	}

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
106
107
108
109
110
111
112


113

114
115
116
117
118
119
120







-
-

-







		if {!$started} {
			error "npf did not start"
		}
	} npf_err]} {
		set npf_failed 1
	}

	after 5000

	## Launch tcpdump with the apropriate parameters
	#puts [list exec -- [file join $filesdir tcpdump.exe] {*}$argv]
	exec -- [file join $filesdir tcpdump.exe] {*}$argv >&@ stdout

	set exit 0
} err]} {
	if {$npf_failed} {
		puts "NPF Failed: $npf_err"
	}