Add a ttyXX.if file in /var/run that points to

the tunX.pid file.  Change the ppp.tunX.pid name
to tunX.pid

Requested by:	Daniel O Callaghan <danny@panda.hilink.com.au>
This commit is contained in:
Brian Somers 1997-05-10 03:39:57 +00:00
parent 9f944c1498
commit 41c6c54314
6 changed files with 38 additions and 24 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.42 1997/05/09 23:34:56 brian Exp $
* $Id: command.c,v 1.43 1997/05/10 01:22:08 brian Exp $
*
*/
#include <sys/types.h>
@ -1025,6 +1025,8 @@ int param;
case VAR_DEVICE:
strncpy(VarDevice, *argv, sizeof(VarDevice)-1);
VarDevice[sizeof(VarDevice)-1] = '\0';
VarBaseDevice = rindex(VarDevice, '/');
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
break;
case VAR_ACCMAP:
sscanf(*argv, "%lx", &map);

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: defs.h,v 1.12 1997/04/21 01:01:41 brian Exp $
* $Id: defs.h,v 1.13 1997/05/04 02:39:03 ache Exp $
*
* TODO:
*/
@ -39,8 +39,10 @@
#define LOGFILE "/var/log/ppp.tun%d.log" /* Name of log file */
#ifdef __FreeBSD__
#define MODEM_DEV "/dev/cuaa1" /* name of tty device */
#define BASE_MODEM_DEV "cuaa1" /* name of base tty device */
#else
#define MODEM_DEV "/dev/tty01" /* name of tty device */
#define BASE_MODEM_DEV "tty01" /* name of base tty device */
#endif
#define MODEM_SPEED B38400 /* tty speed */
#define SERVER_PORT 3000 /* Base server port no. */

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: main.c,v 1.46 1997/05/04 02:39:03 ache Exp $
* $Id: main.c,v 1.47 1997/05/10 01:22:15 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@ -76,7 +76,8 @@ int TermMode;
static int server;
static pid_t BGPid = 0;
struct sockaddr_in ifsin;
char pid_filename[128];
static char pid_filename[MAXPATHLEN];
static char if_filename[MAXPATHLEN];
int tunno;
static void
@ -170,6 +171,7 @@ int excode;
if (mode & (MODE_AUTO | MODE_BACKGROUND)) {
DeleteIfRoutes(1);
unlink(pid_filename);
unlink(if_filename);
}
OsInterfaceDown(1);
if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) {
@ -430,8 +432,7 @@ char **argv;
DupLog();
if (!(mode & MODE_DIRECT)) {
int fd;
char pid[32];
FILE *lockfile;
pid_t bgpid;
bgpid = fork ();
@ -458,15 +459,24 @@ char **argv;
} else if (mode & MODE_BACKGROUND)
close(BGFiledes[0]);
snprintf(pid_filename, sizeof (pid_filename), "%s/ppp.tun%d.pid",
snprintf(pid_filename, sizeof (pid_filename), "%s/tun%d.pid",
_PATH_VARRUN, tunno);
unlink(pid_filename);
snprintf(pid, sizeof(pid), "%d\n", (int)getpid());
if ((fd = open(pid_filename, O_RDWR|O_CREAT, 0666)) != -1)
if ((lockfile = fopen(pid_filename, "w")) != NULL)
{
write(fd, pid, strlen(pid));
close(fd);
fprintf(lockfile, "%d\n", (int)getpid());
fclose(lockfile);
}
snprintf(if_filename, sizeof if_filename, "%s%s.if",
_PATH_VARRUN, VarBaseDevice);
unlink(if_filename);
if ((lockfile = fopen(if_filename, "w")) != NULL)
{
fprintf(lockfile, "tun%d\n", tunno);
fclose(lockfile);
}
}
if (server >= 0)

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: modem.c,v 1.34 1997/04/21 01:01:53 brian Exp $
* $Id: modem.c,v 1.35 1997/05/10 01:22:17 brian Exp $
*
* TODO:
*/
@ -47,7 +47,6 @@ static int mbits; /* Current DCD status */
static int connect_time; /* connection time */
static int connect_count;
static struct pppTimer ModemTimer;
static char uucplock[10];
extern void PacketMode(), TtyTermMode(), TtyCommandMode();
extern int TermMode;
@ -395,10 +394,8 @@ int mode;
} else if (modem < 0)
return(modem);
} else if (modem < 0) {
if (strncmp(VarDevice, "/dev", 4) == 0) {
strncpy(uucplock, rindex(VarDevice, '/')+1,sizeof(uucplock)-1);
uucplock[sizeof(uucplock)-1] = '\0';
if ((res = uu_lock(uucplock)) != UU_LOCK_OK) {
if (strncmp(VarDevice, "/dev/", 5) == 0) {
if ((res = uu_lock(VarBaseDevice)) != UU_LOCK_OK) {
if (res == UU_LOCK_INUSE)
LogPrintf(LOG_PHASE_BIT, "Modem %s is in use\n", VarDevice);
else
@ -409,7 +406,7 @@ int mode;
modem = open(VarDevice, O_RDWR|O_NONBLOCK);
if (modem < 0) {
LogPrintf(LOG_PHASE_BIT, "Open Failed %s\n", VarDevice);
(void) uu_unlock(uucplock);
(void) uu_unlock(VarBaseDevice);
return(modem);
}
} else {
@ -621,7 +618,7 @@ int flag;
close(modem);
}
modem = -1; /* Mark as modem has closed */
(void) uu_unlock(uucplock);
(void) uu_unlock(VarBaseDevice);
} else if (modem >= 0) {
mbits |= TIOCM_DTR;
#ifndef notyet
@ -642,7 +639,7 @@ CloseModem()
close(modem);
modem = -1;
}
(void) uu_unlock(uucplock);
(void) uu_unlock(VarBaseDevice);
}
/*

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.c,v 1.13 1997/04/14 23:48:19 brian Exp $
* $Id: vars.c,v 1.14 1997/04/21 01:02:00 brian Exp $
*
*/
#include "fsm.h"
@ -29,7 +29,7 @@
#include "defs.h"
char VarVersion[] = "Version 0.94";
char VarLocalVersion[] = "$Date: 1997/04/14 23:48:19 $";
char VarLocalVersion[] = "$Date: 1997/04/21 01:02:00 $";
/*
* Order of conf option is important. See vars.h.
@ -51,7 +51,8 @@ struct confdesc pppConfs[] = {
struct pppvars pppVars = {
DEF_MRU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD,
NEXT_REDIAL_PERIOD, 1, MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH,
NEXT_REDIAL_PERIOD, 1, MODEM_DEV, BASE_MODEM_DEV,
OPEN_PASSIVE, LOCAL_NO_AUTH,
};
int

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.h,v 1.11 1997/04/14 23:48:20 brian Exp $
* $Id: vars.h,v 1.12 1997/04/21 01:02:02 brian Exp $
*
* TODO:
*/
@ -68,6 +68,7 @@ struct pppvars {
int redial_next_timeout; /* Redial next timeout value */
int dial_tries; /* Dial attempts before giving up, 0 == forever */
char modem_dev[20]; /* Name of device */
char *base_modem_dev; /* Pointer to base of modem_dev */
int open_mode; /* LCP open mode */
#define LOCAL_AUTH 0x01
#define LOCAL_NO_AUTH 0x02
@ -87,6 +88,7 @@ struct pppvars {
#define VarAccmap pppVars.var_accmap
#define VarMRU pppVars.var_mru
#define VarDevice pppVars.modem_dev
#define VarBaseDevice pppVars.base_modem_dev
#define VarSpeed pppVars.modem_speed
#define VarParity pppVars.modem_parity
#define VarCtsRts pppVars.modem_ctsrts