This is the original post on the ip-goingdown patch.

Thought it might be of interest, given recent posts.

  -- Michael

Forwarded by Michael Hutchinson <[EMAIL PROTECTED]>
---------------- Original message follows ----------------
 From: Erv Walter <[EMAIL PROTECTED]>
 To: [EMAIL PROTECTED]
 Date: Sat, 7 Mar 1998 19:21:26 -0600 (CST)
 Subject: ip-goingdown patch
--

I have patched diald to add ip-goingdown functionality.  I thought
other people might be interested in this.  ip-goingdown is like ip-down
except that it is run immediatly *before* the connection is taken down.
This is useful for people who use services like ml.org that need to
send a quick packet to deactivate their dynamic DNS resolution.  The
patch addes a ip-goingdown configfile option that works just like
ip-down.  ip-goingdown is called with the same options as ip-down.  I
believe that I have it so activity in ip-goingdown will not make the
link non-idle again (it shouldn't restart right away).  In anycase, I
added ignore lines to prevent the specific site I connect to from
affecting the connection.

NOTE: ip-goingdown is not called in the background.  diald waits for
this to return so don't put things in here that take a long time. 
There is a 1 second delay after the script returns before diald closes
the link to allow trafic to make it out.

ip-goingdown is not called if the link dies on it's own (HANGUP or
direct pppd killing).  Therefore, I have also added a line in my
personal ip-down to kill my dynamic-ip client in cases where this
happens.

Modify this at will, ignore it, or add it to the offical sources :)

Erv Walter
-- 
Graduate Student                                [EMAIL PROTECTED]
Department of Chemistry                       [EMAIL PROTECTED]
Univ of Wisconsin-Madison               [EMAIL PROTECTED]
       <PGP Public Key: finger [EMAIL PROTECTED]>

Whaddya mean you don't STAPLE diskette labels on.
 -- tagline 1.00 by xopy

----------------------------------------------------------------
Only in diald-0.16.5.new/: core
diff -rwu diald-0.16.5/diald.h diald-0.16.5.new/diald.h
--- diald-0.16.5/diald.h        Fri Mar  6 09:20:04 1998
+++ diald-0.16.5.new/diald.h    Thu Mar  5 22:48:45 1998
@@ -211,6 +211,7 @@
 char *delroute;
 char *ip_up;
 char *ip_down;
+char *ip_goingdown;
 char *acctlog;
 char *pidlog;
 char *fifoname;
@@ -430,6 +431,7 @@
 void forward_buffer(void);
 void run_ip_up(void);
 void run_ip_down(void);
+void run_ip_goingdown(void);
 void set_ptp(char *, int, char *, int);
 void add_routes(char *, int, char *, char *, int);
 void del_routes(char *, int, char *, char *, int);
diff -rwu diald-0.16.5/fsm.c diald-0.16.5.new/fsm.c
--- diald-0.16.5/fsm.c  Sun Jan 25 18:51:48 1998
+++ diald-0.16.5.new/fsm.c      Thu Mar  5 23:03:41 1998
@@ -295,6 +295,7 @@
     if (!forced && queue_empty() && state_timeout == -1) {
        syslog(LOG_INFO,"Closing down idle link.");
 take_link_down:
+       run_ip_goingdown();
        current_retry_count = 0;
        flush_timeout_queue();
        /* WARNING: You MUST do this before calling idle_filter_proxy(),
diff -rwu diald-0.16.5/options.c diald-0.16.5.new/options.c
--- diald-0.16.5/options.c      Sun Jan 25 18:51:48 1998
+++ diald-0.16.5.new/options.c  Thu Mar  5 22:47:50 1998
@@ -34,6 +34,7 @@
 char *delroute = 0;
 char *ip_up = 0;
 char *ip_down = 0;
+char *ip_goingdown = 0;
 char *acctlog = 0;
 char *pidlog = "diald.pid";
 char *fifoname = 0;
@@ -125,6 +126,7 @@
     {"proxyarp","",0,&proxyarp,set_flag},
     {"ip-up","<script>",1,&ip_up,set_str},
     {"ip-down","<script>",1,&ip_down,set_str},
+    {"ip-goingdown","<script>",1,&ip_goingdown,set_str},
     {"reroute","",0,&do_reroute,set_flag},
     {"-reroute","",0,&do_reroute,clear_flag},
 #ifdef SIOCSKEEPALIVE
@@ -213,6 +215,7 @@
     delroute = 0;
     ip_up = 0;
     ip_down = 0;
+    ip_goingdown = 0;
     acctlog = 0;
     pidlog = "diald.pid";
     fifoname = 0;
diff -rwu diald-0.16.5/proxy.c diald-0.16.5.new/proxy.c
--- diald-0.16.5/proxy.c        Sun Jan 25 18:51:49 1998
+++ diald-0.16.5.new/proxy.c    Thu Mar  5 23:25:27 1998
@@ -264,3 +264,24 @@
         background_system(buf);
     }
 }
+
+void run_ip_goingdown()
+{
+    char buf[128];
+    int res;
+
+    if (ip_goingdown) {
+       sprintf(buf,"%s %s %s %s %s",
+           ip_goingdown,
+           snoop_dev,
+           (netmask)?netmask:"255.255.255.255",
+           local_ip,
+           remote_ip);
+       if (debug&DEBUG_VERBOSE)
+           syslog(LOG_INFO,"running ip-goingdown script '%s'",buf);
+        res = system(buf);
+       report_system_result(res,buf);
+       usleep(1000000);
+    }
+}
+

-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]


-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]

Reply via email to