Bryan O'Sullivan avatar Bryan O'Sullivan committed 62ecaca

Merge

Comments (0)

Files changed (10)

 This is the README file for netplug, a Linux daemon that responds to
 network link events, such as a network interface losing or acquiring a
-carrier signal.  Netplug is licensed under the GNU General Public
-License, version 2, and is copyright 2003 by Key Research, Inc.
+carrier signal.
+
+Netplug is licensed under the GNU General Public License, version 2.
+Copyright 2003 Pathscale, Inc.
+Copyright 2003, 2004 Bryan O'Sullivan
 
 
 What is netplug?
 /*
  * config.c - manage configuration data
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License,

docs/state-machine.dot

 
   insane -> probing [label="regained\nsanity"];
 
-  probing -> down [label="probe done"];
+  probing -> down [label="probe\ndone"];
   probing -> probing_up [label="up -> 1"];
 
   down -> inactive [label="up -> 1"];
 
-  probing_up -> inactive [label="probe done"];
+  probing_up -> inactive [label="probe\ndone"];
+  probing_up -> probing [label="up -> 0"];
 
   inactive -> inning [label="running -> 1"];
+  inactive -> probing [label="up -> 0"];
 
   inning -> wait_in [label="running -> 0"];
   inning -> active [label="in done OK"];
 /*
  * if_info.c - track network interface information
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  * Copyright 2003 Jeremy Fitzhardinge
  *
  * This program is free software; you can redistribute it and/or
             assert(info->worker == -1);
             info->worker = run_netplug_bg(info->name, "probe");
             info->state = ST_PROBING;
-        }
-        if (info->flags & IFF_RUNNING) {
+        } else if (info->flags & IFF_RUNNING) {
             assert(info->worker == -1);
             info->worker = run_netplug_bg(info->name, "in");
             info->state = ST_INNING;
     case ST_OUTING:
         if (!(info->flags & IFF_UP))
             info->state = ST_DOWNANDOUT;
+	break;
 
     case ST_INSANE:
         break;
                 /* already down */
                 break;
 
+	    case ST_PROBING:
+		/* already probing - don't do anything rash */
+		break;
+
+	    case ST_PROBING_UP:
+		/* well, we were up, but now we're not */
+		info->state = ST_PROBING;
+		break;
+
             default:
                 /* All other states: kill off any scripts currently
                    running, and go into the PROBING state, attempting
 /*
  * lib.c - random library routines
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  * Copyright 2003 Jeremy Fitzhardinge
  *
  * This program is free software; you can redistribute it and/or
 /*
  * main.c - daemon startup and link monitoring
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  * Copyright 2003 Jeremy Fitzhardinge
  *
  * This program is free software; you can redistribute it and/or
 static void
 usage(char *progname, int exitcode)
 {
-    fprintf(stderr, "Usage: %s [-FPcip]\n", progname);
+    fprintf(stderr, "Usage: %s [-DFP] [-c config-file] [-i interface] [-p pid-file]\n", 
+	    progname);
 
+    fprintf(stderr, "\t-D\t\t"
+            "print extra debugging messages\n");
     fprintf(stderr, "\t-F\t\t"
             "run in foreground (don't become a daemon)\n");
     fprintf(stderr, "\t-P\t\t"
             do_log(LOG_ERR, "poll failed: %m");
             exit(1);
         }
-        if (ret == 0)
-            continue;           /* XXX??? */
+        if (ret == 0) {         /* XXX??? */
+            sleep(1);           /* don't spin */
+            continue;
+        }
 
         if (fds[0].revents & POLLIN) {
             /* interface flag state change */
             /* netplug script finished */
             int ret;
             struct child_exit ce;
-
+                
             do {
                 ret = read(child_handler_pipe[0], &ce, sizeof(ce));
 
                 assert(ret == 0 || ret == -1 || ret == sizeof(ce));
-
+                
                 if (ret == sizeof(ce))
                     ifsm_scriptdone(ce.pid, ce.status);
                 else if (ret == -1 && errno != EAGAIN) {

man/man8/netplugd.8

 .It Fl i Ar interface_pattern
 Specify a pattern that will be used to match interface names that
 .Nm
-should manage.  You can probide this option multiple times to specify
+should manage.  You can provide this option multiple times to specify
 multiple patterns.
 .\"
 .It Fl p Ar pid_file
 .Bl -tag -width Ds
 .It in
 A cable was plugged in, or carrier came up.  The command should bring
-the interface up.  The command is run asynchronously, and its exit
-status is ignored.
+the interface up.  The command is run asynchronously, and it should
+exit with status 0 on success.
 .It out
 A cable was plugged out, or carrier went down.  The command should
-bring the interface down.  The command is run asynchronously, and its exit
-status is ignored.
+bring the interface down.  The command is run asynchronously, and it should
+exit with status 0 on success.
 .It probe
 The command should load and initialise the driver for this interface,
 if possible, and bring the interface into the "up" state, so that it
 .\"
 .\"
 .Sh COPYRIGHT AND LICENSE
-Copyright 2003 Key Research, Inc.
+Copyright 2003 PathScale, Inc.
+Copyright 2003, 2004 Bryan O'Sullivan
 .\"
 .Pp
 .Nm
 /*
  * netlink.c - interface with kernel's netlink facility
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License,
 /*
  * netplug.h - common include file
  *
- * Copyright 2003 Key Research, Inc.
+ * Copyright 2003 PathScale, Inc.
+ * Copyright 2003, 2004 Bryan O'Sullivan
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License,
-%define version 1.1
+%define version 1.2
 %define release 1
 %define sysconfig /etc/sysconfig/network-scripts
 
 Group: System Environment/Base
 URL: http://www.red-bean.com/~bos/
 Packager: Bryan O'Sullivan <bos@serpentine.com>
-Vendor: Key Research, Inc. <http://www.keyresearch.com/>
+Vendor: PathScale, Inc. <http://www.pathscale.com/>
 Source: %{name}-%{version}.tar.bz2
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 Requires: iproute >= 2.4.7
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.