set netlinkfh($which.$tr) [set fh [open $pipefp.$tr r+]]
fconfigure $fh -blocking 0 -buffering none -translation binary
}
- fileevent $netlinkfh($which.t) readable [list netlink-readable $which]
+ fileevent $netlinkfh($which.r) readable [list netlink-readable $which]
set fakeuf test/$which.fake-userv
set fakeuh [open $fakeuf w 0755]
puts $fakeuh "#!/bin/sh
set -e
-cat >$pipefp.t &
-exec 3<>$pipefp.r
-exec <$pipefp.r
+exec 3<&0
+cat <&3 3<&- >$pipefp.r &
+exec 3<>$pipefp.t
+exec <$pipefp.t
exec 3<&-
exec cat
"
+ close $fakeuh
set cfg "
netlink userv-ipif {
name \"netlink\";
}
proc spawn-secnet {which} {
+ global netlinkfh
upvar #0 pids($which) pid
set cf test/$which.conf
set ch [open $cf w]
if {!$pid} {
execl ./secnet $argl
}
+ puts -nonewline $netlinkfh($which.t) "\xc0"
+}
+
+proc netlink-readable {which} {
+ global ok
+ upvar #0 netlinkfh($which.r) fh
+ read $fh; # empty the buffer
+ switch -exact $which {
+ outside {
+ puts OK
+ set ok 1; # what a bodge
+ return
+ }
+ inside {
+ error "inside rx'd!"
+ }
+ }
+}
+
+proc bgerror {message} {
+ global errorInfo errorCode
+ catch {
+ puts stderr "
+----------------------------------------
+$errorInfo
+
+$errorCode
+$message
+----------------------------------------
+ "
+ }
+ exit 1
}
spawn-secnet inside
spawn-secnet outside
+
+vwait ok