1. Bryan O'Sullivan
  2. netplug

Commits

Bryan O'Sullivan  committed 62ecaca

Merge

  • Participants
  • Parent commits dbffc85
  • Branches default

Comments (0)

Files changed (10)

File README

View file
  • Ignore whitespace
 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?

File config.c

View file
  • Ignore whitespace
 /*
  * 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,

File docs/state-machine.dot

View file
  • Ignore whitespace
 
   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"];

File if_info.c

View file
  • Ignore whitespace
 /*
  * 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

File lib.c

View file
  • Ignore whitespace
 /*
  * 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

File main.c

View file
  • Ignore whitespace
 /*
  * 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) {

File man/man8/netplugd.8

View file
  • Ignore whitespace
 .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

File netlink.c

View file
  • Ignore whitespace
 /*
  * 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,

File netplug.h

View file
  • Ignore whitespace
 /*
  * 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,

File netplug.spec

View file
  • Ignore whitespace
-%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