Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ifwatchd Invoke "ip-up" and "ip-down" script with p...
details: https://anonhg.NetBSD.org/src/rev/ee57aee9e03e
branches: trunk
changeset: 525701:ee57aee9e03e
user: tron <tron%NetBSD.org@localhost>
date: Mon Apr 15 17:32:18 2002 +0000
description:
Invoke "ip-up" and "ip-down" script with parameters exactly matching
those used by pppd(8).
diffstat:
usr.sbin/ifwatchd/ifwatchd.8 | 28 ++++++++++++++++++----------
usr.sbin/ifwatchd/ifwatchd.c | 7 ++++---
2 files changed, 22 insertions(+), 13 deletions(-)
diffs (97 lines):
diff -r 8cd4e057a60c -r ee57aee9e03e usr.sbin/ifwatchd/ifwatchd.8
--- a/usr.sbin/ifwatchd/ifwatchd.8 Mon Apr 15 17:27:39 2002 +0000
+++ b/usr.sbin/ifwatchd/ifwatchd.8 Mon Apr 15 17:32:18 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ifwatchd.8,v 1.8 2002/04/14 11:41:43 martin Exp $
+.\" $NetBSD: ifwatchd.8,v 1.9 2002/04/15 17:32:18 tron Exp $
.\"
.\" Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -106,42 +106,50 @@
.Sh EXAMPLES
.Bd -literal -offset indent
# ifwatchd -u /etc/ppp/ip-up -d /etc/ppp/ip-down pppoe0
+
.Ed
If your pppoe0 interface is your main connection to the internet, the typical
use of the up/down scripts is to add and remove a default route. This is
an example for an up script doing this:
.Bd -literal -offset indent
#! /bin/sh
-/sbin/route add default $4
+/sbin/route add default $5
+
.Ed
As described below the fourth command line parameter will contain the peer
address of the pppoe link. The corresponding ip-down script is:
.Bd -literal -offset indent
#! /bin/sh
-/sbin/route delete default
+/sbin/route delete default $5
+
.Ed
Note that this is not a good idea if you have pppoe0 configured to connect
only on demand (via the link1 flag), but works well for all permanent connected
cases. Use
.Bd -literal -offset indent
! /sbin/route add default -iface 0.0.0.1
+
.Ed
in your
.Pa /etc/ifconfig.pppoe0
file in the on-demand case.
.Sh PARAMETERS PASSED TO SCRIPTS
-The invoked scripts get four parameters passed:
+The invoked scripts get five parameters passed:
.Bl -tag -width destination
.It Ar ifname
The name of the interface this change is for (this allows to share the same
script for multiple interfaces watched and dispatching on the interface name
in the script).
-.It Ar up/down
-Verbatim
-.Em up
-or
-.Em down ,
-which allows for the sharing of up and down scripts.
+.It Ar tty
+Dummy parameter for compatibility with
+.Xr pppd 8
+which will always be
+.Em /dev/null .
+.It Ar speed
+Dummy parameter for compatibility with
+.Xr pppd 8
+which will always be
+.Em 9600 .
.It Ar address
The new address if this is an up event, or the no longer valid old address
if this is a down event.
diff -r 8cd4e057a60c -r ee57aee9e03e usr.sbin/ifwatchd/ifwatchd.c
--- a/usr.sbin/ifwatchd/ifwatchd.c Mon Apr 15 17:27:39 2002 +0000
+++ b/usr.sbin/ifwatchd/ifwatchd.c Mon Apr 15 17:32:18 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ifwatchd.c,v 1.6 2002/04/14 11:41:43 martin Exp $ */
+/* $NetBSD: ifwatchd.c,v 1.7 2002/04/15 17:32:18 tron Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -55,6 +55,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -286,8 +287,8 @@
script = is_up? up_script : down_script;
if (script == NULL) return;
- asprintf(&cmd, "%s \"%s\" %s \"%s\" \"%s\"", script, ifname,
- is_up?"up":"down", addr, daddr);
+ asprintf(&cmd, "%s \"%s\" " _PATH_DEVNULL " 9600 \"%s\" \"%s\"",
+ script, ifname, addr, daddr);
if (cmd == NULL) {
fprintf(stderr, "out of memory\n");
return;
Home |
Main Index |
Thread Index |
Old Index