aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/bundle.c
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1998-04-10 13:19:23 +0000
committerBrian Somers <brian@FreeBSD.org>1998-04-10 13:19:23 +0000
commit565e35e50e2cdac423588a3d18742544bde128b0 (patch)
tree4fd95655022372ca2d6e72fd41d3d7d073afa866 /usr.sbin/ppp/bundle.c
parentc06d604b0351800163c0b058cf6c47e036543c24 (diff)
downloadsrc-565e35e50e2cdac423588a3d18742544bde128b0.tar.gz
src-565e35e50e2cdac423588a3d18742544bde128b0.zip
o Remove the `mode' global - it's now per physical device.
o Shuffle things that live at the datalink level into ``show link'' rather than ``show modem''. o Make both ``show'' commands prettier and more consistent, and display carrier status, link type and our name in ``show modem''. o Show redial and reconnect information in ``show link'' and remove ``show redial'' and ``show reconnect''. o Down the correct link in bundle_LinkLost(). o Remove stale -direct and -background links at the end of our main loop, not when we know they're going. This prevents unexpected pointer-invalidations... o If we ``set server'' with the same values twice, notice and don't moan about failure. o Record dial script despite our link mode. The mode may be changed later (next mod) :-) We never run scripts in -direct and -dedicated modes. o Make ``set server none'' functional again. o Correct datalink state array so that we don't report an ``unknown'' state. o Pass struct ipcp to IpcpCleanInterface, not struct fsm. o Create TUN_PREFIX define rather than hard-coding in main.c o prompt_TtyInit now handles a NULL prompt for -direct mode rather than having to create one then destroy it uncleanly. o Mention our mode in the "PPP Started" LogPHASE message. o Bring all auto links up when we have something to send. o Remove some redundant Physical_*() functions. o Show which connection is running a command when logging commands. o Initialise throughput uptime correctly.
Notes
Notes: svn path=/cvs2svn/branches/MP/; revision=35118
Diffstat (limited to 'usr.sbin/ppp/bundle.c')
-rw-r--r--usr.sbin/ppp/bundle.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 18ec8b4d3ce2..4b5f7c27bed8 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.1.2.42 1998/04/07 01:49:24 brian Exp $
+ * $Id: bundle.c,v 1.1.2.43 1998/04/07 23:45:41 brian Exp $
*/
#include <sys/types.h>
@@ -199,7 +199,7 @@ bundle_LayerUp(struct bundle *bundle, struct fsm *fp)
* The given fsm is now up
* If it's an LCP (including MP initialisation), set our mtu
* (This routine is also called from mp_Init() with it's LCP)
- * If it's an NCP, tell our background mode parent to go away.
+ * If it's an NCP, tell our -background parent to go away.
* If it's the first NCP, start the idle timer.
*/
@@ -422,7 +422,7 @@ bundle_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
* (ENXIO) or the third `No such file or directory' (ENOENT) error.
*/
struct bundle *
-bundle_Create(const char *prefix, struct prompt *prompt)
+bundle_Create(const char *prefix, struct prompt *prompt, int type)
{
int s, enoentcount, err;
struct ifreq ifrq;
@@ -518,8 +518,9 @@ bundle_Create(const char *prefix, struct prompt *prompt)
bundle.fsm.object = &bundle;
bundle.cfg.idle_timeout = NCP_IDLE_TIMEOUT;
+ bundle.phys_type = type;
- bundle.links = datalink_Create("Modem", &bundle, &bundle.fsm);
+ bundle.links = datalink_Create("default", &bundle, &bundle.fsm, type);
if (bundle.links == NULL) {
LogPrintf(LogERROR, "Cannot create data link: %s\n", strerror(errno));
close(bundle.tun_fd);
@@ -601,9 +602,8 @@ bundle_Destroy(struct bundle *bundle)
struct datalink *dl;
struct descriptor *desc, *ndesc;
-
- if (mode & MODE_AUTO) {
- IpcpCleanInterface(&bundle->ncp.ipcp.fsm);
+ if (bundle->phys_type & PHYS_DEMAND) {
+ IpcpCleanInterface(&bundle->ncp.ipcp);
bundle_DownInterface(bundle);
}
@@ -744,7 +744,7 @@ failed:
}
void
-bundle_LinkLost(struct bundle *bundle, struct link *link, int staydown)
+bundle_LinkLost(struct bundle *bundle, struct physical *p, int staydown)
{
/*
* Locate the appropriate datalink, and Down it.
@@ -757,9 +757,9 @@ bundle_LinkLost(struct bundle *bundle, struct link *link, int staydown)
* and MAY cause a program exit.
*/
- if ((mode & MODE_DIRECT) || bundle->CleaningUp)
+ if (p->type == PHYS_STDIN || bundle->CleaningUp)
staydown = 1;
- datalink_Down(bundle->links, staydown);
+ datalink_Down(p->dl, staydown);
}
void
@@ -767,27 +767,20 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
{
/*
* Our datalink has closed.
- * If it's DIRECT or BACKGROUND, delete it.
+ * UpdateSet() will remove 1OFF and STDIN links.
* If it's the last data link, enter phase DEAD.
*/
struct datalink *odl;
int other_links;
- if (mode & (MODE_DIRECT|MODE_BACKGROUND)) {
- struct datalink **dlp;
- for (dlp = &bundle->links; *dlp; dlp = &(*dlp)->next)
- if (*dlp == dl)
- *dlp = datalink_Destroy(*dlp);
- }
-
other_links = 0;
for (odl = bundle->links; odl; odl = odl->next)
if (odl != dl && odl->state != DATALINK_CLOSED)
other_links++;
if (!other_links) {
- if (!(mode & MODE_AUTO))
+ if (dl->physical->type != PHYS_DEMAND)
bundle_DownInterface(bundle);
bundle_NewPhase(bundle, PHASE_DEAD);
bundle_DisplayPrompt(bundle);
@@ -795,18 +788,17 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
}
void
-bundle_Open(struct bundle *bundle, const char *name)
+bundle_Open(struct bundle *bundle, const char *name, int mask)
{
/*
* Please open the given datalink, or all if name == NULL
*/
struct datalink *dl;
- int runscripts;
- runscripts = (mode & (MODE_DIRECT|MODE_DEDICATED)) ? 0 : 1;
for (dl = bundle->links; dl; dl = dl->next)
if (name == NULL || !strcasecmp(dl->name, name)) {
- datalink_Up(dl, runscripts, 1);
+ if (mask & dl->physical->type)
+ datalink_Up(dl, 1, 1);
if (name != NULL)
break;
}
@@ -875,7 +867,8 @@ bundle_IdleTimeout(void *v)
void
bundle_StartIdleTimer(struct bundle *bundle)
{
- if (!(mode & (MODE_DEDICATED | MODE_DDIAL)) && bundle->cfg.idle_timeout) {
+ if (!(bundle->phys_type & (PHYS_DEDICATED|PHYS_PERM)) &&
+ bundle->cfg.idle_timeout) {
StopTimer(&bundle->idle.timer);
bundle->idle.timer.func = bundle_IdleTimeout;
bundle->idle.timer.name = "idle";
@@ -993,6 +986,17 @@ bundle_SetTtyCommandMode(struct bundle *bundle, struct datalink *dl)
prompt_TtyCommandMode(p);
}
}
+
+static void
+bundle_GenPhysType(struct bundle *bundle)
+{
+ struct datalink *dl;
+
+ bundle->phys_type = 0;
+ for (dl = bundle->links; dl; dl = dl->next)
+ bundle->phys_type |= dl->physical->type;
+}
+
void
bundle_DatalinkClone(struct bundle *bundle, struct datalink *dl,
const char *name)
@@ -1001,6 +1005,7 @@ bundle_DatalinkClone(struct bundle *bundle, struct datalink *dl,
ndl->next = dl->next;
dl->next = ndl;
+ bundle_GenPhysType(bundle);
}
void
@@ -1014,4 +1019,19 @@ bundle_DatalinkRemove(struct bundle *bundle, struct datalink *dl)
*dlp = datalink_Destroy(dl);
break;
}
+ bundle_GenPhysType(bundle);
+}
+
+void
+bundle_CleanDatalinks(struct bundle *bundle)
+{
+ struct datalink **dlp = &bundle->links;
+
+ while (*dlp)
+ if ((*dlp)->state == DATALINK_CLOSED &&
+ (*dlp)->physical->type & (PHYS_STDIN|PHYS_1OFF))
+ *dlp = datalink_Destroy(*dlp);
+ else
+ dlp = &(*dlp)->next;
+ bundle_GenPhysType(bundle);
}