CC:=@CC@
INSTALL:=@INSTALL@
INSTALL_PROGRAM:=@INSTALL_PROGRAM@
+INSTALL_SCRIPT:=@INSTALL_SCRIPT@
prefix:=@prefix@
exec_prefix:=@exec_prefix@
sbindir:=@sbindir@
sysconfdir:=@sysconfdir@
+datarootdir:=@datarootdir@
transform:=@program_transform_name@
mandir:=@mandir@
-Wno-strict-aliasing -fno-strict-aliasing \
-MMD
ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
-CPPFLAGS:=@CPPFLAGS@ $(EXTRA_CPPFLAGS)
+CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
installdirs:
$(INSTALL) -d $(prefix)/share/secnet $(sbindir)
$(INSTALL) -d $(mandir)/man8
+ $(INSTALL) -d $(datarootdir)/secnet
install: installdirs
set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
$(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
$(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
$(INSTALL) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
+ $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
+ $(datarootdir)/secnet/.
$(INSTALL) secnet.8 $(mandir)/man8/secnet.8
install-force:
--- /dev/null
+#!/usr/bin/perl -w
+use strict;
+use IO::Handle;
+
+my $us = $0;
+$us =~ s{.*/}{};
+
+die "$us: no arguments permitted\n" if @ARGV;
+
+our ($monh,$monchild);
+
+our %reported;
+# no entry: not reported, does not exist
+# /ry+/: reported, entry exists
+# during processing only:
+# /r/: reported, may not still exist
+# /y+/: not reported, entry exists
+
+sub killmonitor () {
+ return unless $monchild;
+ kill 9, $monchild
+ or warn "$us: cannot kill monitor child [$monchild]: $!\n";
+ $monchild=undef;
+ close $monh;
+}
+
+END { killmonitor(); }
+
+my $restart;
+
+for (;;) {
+ my $o;
+ eval {
+ if (!$monh) {
+ killmonitor();
+ $monh = new IO::File;
+ $monchild = open $monh, "-|", qw(ip -o monitor addr)
+ or die "spawn monitor: $!\n";
+ sleep(1) if $restart++;
+ } else {
+ my $discard;
+ my $got = sysread $monh, $discard, 4096;
+ die "read monitor: $!\n" unless defined $got;
+ die "monitor failed\n" unless $got;
+ }
+ $_='r' foreach values %reported;
+ foreach my $ip (qw(4 6)) {
+ my $addrh = new IO::File;
+ open $addrh, "-|", qw(ip -o), "-$ip", qw(addr show)
+ or die "spawn addr $ip show: $!\n";
+ my $afstr = $ip==4 ? 'inet' : $ip==6 ? 'inet6' : die;
+ while (<$addrh>) {
+ if (m{^\d+\:\s*(\S+)\s+$afstr\s+([0-9a-z.:]+)(?:/\d+)?\s}) {
+ my $outline = "$ip $1 $2";
+ $reported{$outline} .= "y";
+ } else {
+ chomp;
+ warn "unexpected output from addr $ip show: $_\n";
+ }
+ }
+ my $r = close $addrh;
+ die "addr $ip show failed $!\n" unless $r;
+ $o = '';
+ }
+ foreach my $k (keys %reported) {
+ local $_ = $reported{$k};
+ if (m/^r$/) {
+ $o .= "-$k\n";
+ delete $reported{$k};
+ } elsif (m/^y/) {
+ $o .= "+$k\n";
+ }
+ }
+ };
+ if ($@) {
+ print STDERR "$us: $@";
+ sleep 5;
+ next;
+ }
+ print $o or die $!;
+ STDOUT->flush or die $!;
+}