mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-02 08:42:48 +00:00
o Create a new `timer'' log level. This lets us
`set
log debug'' without filling our filesystem/screen with junk that we don't really want to see. o change PHYS_STDIN to PHYS_DIRECT - we can handle incoming connections that aren't on STDIN_FILENO now. o Allow return values from our FSM LayerUp functions. If LayerUp() fails, the FSM does an immediate FsmDown() without calling the fsm_parent's Layer{Up,Down} functions. o Clear the close-on-exec flag of file descriptor 3 when executing chat programs so that our documented ability to communicate with /dev/tty via that descriptor works. Also document it as descriptor 3, not 4 :-O o Allow a ``rm'' command as an alias for ``remove''. o Fix the bind()/connect()/accept() calls made by the MP server. o Create bundle_SendDatalink() and bundle_ReceiveDatalink(). This allows `struct datalink's to flatten themselves, pass through a pipe (read: the eye of a needle !) and come alive at the other end. The donator then fork()s & exec()s pppmpipe, ``passing'' the connection to another ppp instance. *** PPP NOW TALKS MULTILINK :-))) *** Our link utilization is hideous, and lots of code needs tidying still. It's also probably riddled with bugs ! It's been tested against itself only, and has hung once, so confidence isn't high....
This commit is contained in:
parent
9c281ab21b
commit
6f38457323
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35568
@ -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.63 1998/04/27 01:40:37 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.64 1998/04/28 01:25:04 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -41,6 +41,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
@ -192,13 +193,7 @@ bundle_Notify(struct bundle *bundle, char c)
|
||||
}
|
||||
|
||||
static void
|
||||
bundle_vLayerUp(void *v, struct fsm *fp)
|
||||
{
|
||||
bundle_LayerUp((struct bundle *)v, fp);
|
||||
}
|
||||
|
||||
void
|
||||
bundle_LayerUp(struct bundle *bundle, struct fsm *fp)
|
||||
bundle_LayerUp(void *v, struct fsm *fp)
|
||||
{
|
||||
/*
|
||||
* The given fsm is now up
|
||||
@ -207,6 +202,7 @@ bundle_LayerUp(struct bundle *bundle, struct fsm *fp)
|
||||
* If it's an NCP, tell our -background parent to go away.
|
||||
* If it's the first NCP, start the idle timer.
|
||||
*/
|
||||
struct bundle *bundle = (struct bundle *)v;
|
||||
|
||||
if (fp->proto == PROTO_LCP) {
|
||||
if (bundle->ncp.mp.active) {
|
||||
@ -305,8 +301,8 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
{
|
||||
/*
|
||||
* Please close the given datalink.
|
||||
* If name == NULL or name is the last datalink, enter TERMINATE phase
|
||||
* and FsmClose all NCPs (except our MP)
|
||||
* If name == NULL or name is the last datalink, FsmClose all NCPs
|
||||
* (except our MP)
|
||||
* If it isn't the last datalink, just Close that datalink.
|
||||
*/
|
||||
|
||||
@ -511,7 +507,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
bundle.CleaningUp = 0;
|
||||
|
||||
bundle.fsm.LayerStart = bundle_LayerStart;
|
||||
bundle.fsm.LayerUp = bundle_vLayerUp;
|
||||
bundle.fsm.LayerUp = bundle_LayerUp;
|
||||
bundle.fsm.LayerDown = bundle_LayerDown;
|
||||
bundle.fsm.LayerFinish = bundle_LayerFinish;
|
||||
bundle.fsm.object = &bundle;
|
||||
@ -524,7 +520,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
bundle.cfg.mtu = DEF_MTU;
|
||||
bundle.phys_type = type;
|
||||
|
||||
bundle.links = datalink_Create("deflink", &bundle, &bundle.fsm, type);
|
||||
bundle.links = datalink_Create("deflink", &bundle, type);
|
||||
if (bundle.links == NULL) {
|
||||
LogPrintf(LogERROR, "Cannot create data link: %s\n", strerror(errno));
|
||||
close(bundle.tun_fd);
|
||||
@ -1067,7 +1063,7 @@ bundle_CleanDatalinks(struct bundle *bundle)
|
||||
|
||||
while (*dlp)
|
||||
if ((*dlp)->state == DATALINK_CLOSED &&
|
||||
(*dlp)->physical->type & (PHYS_STDIN|PHYS_1OFF))
|
||||
(*dlp)->physical->type & (PHYS_DIRECT|PHYS_1OFF))
|
||||
*dlp = datalink_Destroy(*dlp);
|
||||
else
|
||||
dlp = &(*dlp)->next;
|
||||
@ -1090,15 +1086,128 @@ bundle_GetLabel(struct bundle *bundle)
|
||||
}
|
||||
|
||||
void
|
||||
bundle_SendDatalink(struct datalink *dl, int fd)
|
||||
bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
{
|
||||
LogPrintf(LogERROR, "Can't send link yet !\n");
|
||||
close(fd);
|
||||
struct datalink *dl, *ndl;
|
||||
u_char *buf;
|
||||
int get, got, vlen;
|
||||
|
||||
/*
|
||||
* We expect:
|
||||
* .---------.---------.--------------.
|
||||
* | ver len | Version | datalink len |
|
||||
* `---------'---------'--------------'
|
||||
* We then pass the rest of the stream to datalink.
|
||||
*/
|
||||
|
||||
LogPrintf(LogPHASE, "Receiving datalink\n");
|
||||
|
||||
vlen = strlen(Version);
|
||||
get = sizeof(int) * 2 + vlen;
|
||||
buf = (u_char *)malloc(get);
|
||||
got = fullread(fd, buf, get);
|
||||
if (got != get) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink header"
|
||||
" (got %d bytes, not %d)\n", got, get);
|
||||
close(fd);
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
if (*(int *)buf != vlen || *(int *)(buf + sizeof(int) + vlen) != sizeof *dl ||
|
||||
memcmp(buf + sizeof(int), Version, vlen)) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink, incorrect version\n");
|
||||
close(fd);
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
free(buf);
|
||||
|
||||
ndl = datalink_FromBinary(bundle, fd);
|
||||
if (ndl) {
|
||||
/* Make sure the name is unique ! */
|
||||
do {
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
if (!strcasecmp(ndl->name, dl->name)) {
|
||||
datalink_Rename(ndl);
|
||||
break;
|
||||
}
|
||||
} while (dl);
|
||||
|
||||
ndl->next = bundle->links;
|
||||
bundle->links = ndl;
|
||||
bundle_GenPhysType(bundle);
|
||||
LogPrintf(LogPHASE, "%s: Created in %s state\n",
|
||||
ndl->name, datalink_State(ndl));
|
||||
datalink_AuthOk(ndl);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
bundle_SendDatalink(struct datalink *dl, int fd)
|
||||
{
|
||||
LogPrintf(LogERROR, "Can't receive link yet !\n");
|
||||
close(fd);
|
||||
int len, link_fd, err;
|
||||
struct datalink **pdl;
|
||||
struct bundle *bundle = dl->bundle;
|
||||
char procname[100];
|
||||
|
||||
/*
|
||||
* We send:
|
||||
* .---------.---------.--------------.
|
||||
* | ver len | Version | datalink len |
|
||||
* `---------'---------'--------------'
|
||||
* We then pass the rest of the stream to datalink.
|
||||
*/
|
||||
|
||||
LogPrintf(LogPHASE, "Transmitting datalink %s\n", dl->name);
|
||||
|
||||
/* First, un-hook the datalink */
|
||||
for (pdl = &bundle->links; *pdl; pdl = &(*pdl)->next)
|
||||
if (*pdl == dl) {
|
||||
*pdl = dl->next;
|
||||
dl->next = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write our bit of the data */
|
||||
err = 0;
|
||||
len = strlen(Version);
|
||||
if (write(fd, &len, sizeof len) != sizeof len)
|
||||
err++;
|
||||
if (write(fd, Version, len) != len)
|
||||
err++;
|
||||
len = sizeof(struct datalink);
|
||||
if (write(fd, &len, sizeof len) != sizeof len)
|
||||
err++;
|
||||
|
||||
if (err) {
|
||||
LogPrintf(LogERROR, "Failed sending version\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
link_fd = datalink_ToBinary(dl, fd);
|
||||
|
||||
if (link_fd != -1) {
|
||||
switch (fork()) {
|
||||
case 0:
|
||||
snprintf(procname, sizeof procname, "%s <-> %s",
|
||||
dl->name, *dl->physical->name.base ?
|
||||
dl->physical->name.base : "network");
|
||||
setsid();
|
||||
dup2(link_fd, STDIN_FILENO);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
setuid(geteuid());
|
||||
/* signals are defaulted by the exec */
|
||||
execlp(PPPMPIPE, procname, NULL);
|
||||
LogPrintf(LogERROR, "exec: %s: %s\n", PPPMPIPE, strerror(errno));
|
||||
exit(1);
|
||||
break;
|
||||
case -1:
|
||||
LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
|
||||
/* Fall through */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.h,v 1.1.2.32 1998/04/23 03:22:45 brian Exp $
|
||||
* $Id: bundle.h,v 1.1.2.33 1998/04/28 01:25:05 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHASE_DEAD 0 /* Link is dead */
|
||||
@ -121,7 +121,6 @@ extern void bundle_StartIdleTimer(struct bundle *);
|
||||
extern void bundle_SetIdleTimer(struct bundle *, int);
|
||||
extern void bundle_StopIdleTimer(struct bundle *);
|
||||
extern int bundle_RemainingIdleTime(struct bundle *);
|
||||
extern void bundle_LayerUp(struct bundle *, struct fsm *);
|
||||
extern int bundle_IsDead(struct bundle *);
|
||||
extern struct datalink *bundle2datalink(struct bundle *, const char *);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.c,v 1.30.2.39 1998/04/25 10:48:49 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.40 1998/04/28 01:25:07 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -65,7 +65,7 @@ static void CcpDecodeConfig(struct fsm *, u_char *, int, int,
|
||||
struct fsm_decode *);
|
||||
static void CcpLayerStart(struct fsm *);
|
||||
static void CcpLayerFinish(struct fsm *);
|
||||
static void CcpLayerUp(struct fsm *);
|
||||
static int CcpLayerUp(struct fsm *);
|
||||
static void CcpLayerDown(struct fsm *);
|
||||
static void CcpInitRestartCounter(struct fsm *);
|
||||
static void CcpRecvResetReq(struct fsm *);
|
||||
@ -85,6 +85,9 @@ static struct fsm_callbacks ccp_Callbacks = {
|
||||
CcpRecvResetAck
|
||||
};
|
||||
|
||||
static const char *ccp_TimerNames[] =
|
||||
{"CCP restart", "CCP openmode", "CCP stopped"};
|
||||
|
||||
static char const *cftypes[] = {
|
||||
/* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */
|
||||
"OUI", /* 0: OUI */
|
||||
@ -154,16 +157,23 @@ ccp_ReportStatus(struct cmdargs const *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ccp_SetupCallbacks(struct ccp *ccp)
|
||||
{
|
||||
ccp->fsm.fn = &ccp_Callbacks;
|
||||
ccp->fsm.FsmTimer.name = ccp_TimerNames[0];
|
||||
ccp->fsm.OpenTimer.name = ccp_TimerNames[1];
|
||||
ccp->fsm.StoppedTimer.name = ccp_TimerNames[2];
|
||||
}
|
||||
|
||||
void
|
||||
ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l,
|
||||
const struct fsm_parent *parent)
|
||||
{
|
||||
/* Initialise ourselves */
|
||||
static const char *timer_names[] =
|
||||
{"CCP restart", "CCP openmode", "CCP stopped"};
|
||||
|
||||
fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, 10, LogCCP,
|
||||
bundle, l, parent, &ccp_Callbacks, timer_names);
|
||||
bundle, l, parent, &ccp_Callbacks, ccp_TimerNames);
|
||||
|
||||
ccp->cfg.deflate.in.winsize = 0;
|
||||
ccp->cfg.deflate.out.winsize = 15;
|
||||
@ -328,7 +338,7 @@ CcpLayerDown(struct fsm *fp)
|
||||
/*
|
||||
* Called when CCP has reached the OPEN state
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
CcpLayerUp(struct fsm *fp)
|
||||
{
|
||||
/* We're now up */
|
||||
@ -360,6 +370,7 @@ CcpLayerUp(struct fsm *fp)
|
||||
LogPrintf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
|
||||
fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
|
||||
protoname(ccp->his_proto), ccp->his_proto);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.14.2.17 1998/04/16 00:25:51 brian Exp $
|
||||
* $Id: ccp.h,v 1.14.2.18 1998/04/24 19:15:24 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -124,3 +124,4 @@ extern int ccp_ReportStatus(struct cmdargs const *);
|
||||
extern int ccp_Compress(struct ccp *, struct link *, int, u_short, struct mbuf *);
|
||||
extern struct mbuf *ccp_Decompress(struct ccp *, u_short *, struct mbuf *);
|
||||
extern u_short ccp_Proto(struct ccp *);
|
||||
extern void ccp_SetupCallbacks(struct ccp *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: chat.c,v 1.44.2.25 1998/04/19 15:24:37 brian Exp $
|
||||
* $Id: chat.c,v 1.44.2.26 1998/04/28 01:25:09 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -745,6 +745,7 @@ ExecStr(struct physical *physical, char *command, char *out, int olen)
|
||||
if ((nb = open("/dev/tty", O_RDWR)) > 3) {
|
||||
dup2(nb, 3);
|
||||
close(nb);
|
||||
fcntl(3, F_SETFD, 0); /* Clear close-on-exec flag */
|
||||
}
|
||||
setuid(geteuid());
|
||||
execvp(vector[0], vector);
|
||||
|
@ -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.131.2.72 1998/04/25 10:48:53 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.73 1998/04/27 01:40:38 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -122,6 +122,9 @@
|
||||
#define NEG_VJCOMP 49
|
||||
#define NEG_DNS 50
|
||||
|
||||
const char Version[] = "2.0-beta";
|
||||
const char VersionDate[] = "$Date: 1998/04/27 01:40:38 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
static int QuitCommand(struct cmdargs const *);
|
||||
@ -308,7 +311,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
}
|
||||
|
||||
if ((shpid = fork()) == 0) {
|
||||
int dtablesize, i, fd;
|
||||
int i, fd;
|
||||
|
||||
if ((shell = getenv("SHELL")) == 0)
|
||||
shell = _PATH_BSHELL;
|
||||
@ -329,9 +332,6 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
for (i = 0; i < 3; i++)
|
||||
dup2(fd, i);
|
||||
|
||||
for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
|
||||
close(i);
|
||||
|
||||
setuid(geteuid());
|
||||
if (arg->argc > arg->argn) {
|
||||
/* substitute pseudo args */
|
||||
@ -440,7 +440,7 @@ static struct cmdtab const Commands[] = {
|
||||
"Password for manipulation", "passwd LocalPassword"},
|
||||
{"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
||||
"Quit PPP program", "quit|bye [all]"},
|
||||
{"remove", NULL, RemoveCommand, LOCAL_AUTH | LOCAL_CX,
|
||||
{"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,
|
||||
"Remove a link", "remove"},
|
||||
{"save", NULL, SaveCommand, LOCAL_AUTH,
|
||||
"Save settings", "save"},
|
||||
@ -508,10 +508,7 @@ ShowStopped(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowVersion(struct cmdargs const *arg)
|
||||
{
|
||||
static char VarVersion[] = "PPP Version 2.0-beta";
|
||||
static char VarLocalVersion[] = "$Date: 1998/04/25 10:48:53 $";
|
||||
|
||||
prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
|
||||
prompt_Printf(arg->prompt, "PPP Version %s - %s\n", Version, VersionDate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.h,v 1.12.2.10 1998/04/14 23:17:03 brian Exp $
|
||||
* $Id: command.h,v 1.12.2.11 1998/04/16 00:25:55 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -51,6 +51,9 @@ struct cmdtab {
|
||||
#define IsAccepted(x) ((x) & NEG_ACCEPTED)
|
||||
#define IsEnabled(x) ((x) & NEG_ENABLED)
|
||||
|
||||
extern const char Version[];
|
||||
extern const char VersionDate[];
|
||||
|
||||
extern int IsInteractive(struct prompt *);
|
||||
extern void InterpretCommand(char *, int, int *, char ***);
|
||||
extern void RunCommand(struct bundle *, int, char const *const *,
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.1.2.49 1998/04/28 01:25:11 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.50 1998/04/30 23:52:53 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -32,10 +32,12 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mbuf.h"
|
||||
#include "log.h"
|
||||
@ -113,7 +115,7 @@ datalink_HangupDone(struct datalink *dl)
|
||||
dl->phone.chosen = "N/A";
|
||||
|
||||
if (dl->bundle->CleaningUp ||
|
||||
(dl->physical->type == PHYS_STDIN) ||
|
||||
(dl->physical->type == PHYS_DIRECT) ||
|
||||
((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) &&
|
||||
!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)))) {
|
||||
LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
|
||||
@ -207,7 +209,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
result = 0;
|
||||
switch (dl->state) {
|
||||
case DATALINK_CLOSED:
|
||||
if ((dl->physical->type & (PHYS_STDIN|PHYS_DEDICATED|PHYS_1OFF)) &&
|
||||
if ((dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED|PHYS_1OFF)) &&
|
||||
!bundle_IsDead(dl->bundle))
|
||||
/*
|
||||
* Our first time in - DEDICATED never comes down, and STDIN & 1OFF
|
||||
@ -529,8 +531,7 @@ datalink_LayerFinish(void *v, struct fsm *fp)
|
||||
}
|
||||
|
||||
struct datalink *
|
||||
datalink_Create(const char *name, struct bundle *bundle,
|
||||
const struct fsm_parent *parent, int type)
|
||||
datalink_Create(const char *name, struct bundle *bundle, int type)
|
||||
{
|
||||
struct datalink *dl;
|
||||
|
||||
@ -575,7 +576,7 @@ datalink_Create(const char *name, struct bundle *bundle,
|
||||
|
||||
dl->name = strdup(name);
|
||||
peerid_Init(&dl->peer);
|
||||
dl->parent = parent;
|
||||
dl->parent = &bundle->fsm;
|
||||
dl->fsmp.LayerStart = datalink_LayerStart;
|
||||
dl->fsmp.LayerUp = datalink_LayerUp;
|
||||
dl->fsmp.LayerDown = datalink_LayerDown;
|
||||
@ -685,7 +686,7 @@ datalink_Destroy(struct datalink *dl)
|
||||
void
|
||||
datalink_Up(struct datalink *dl, int runscripts, int packetmode)
|
||||
{
|
||||
if (dl->physical->type & (PHYS_STDIN|PHYS_DEDICATED))
|
||||
if (dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED))
|
||||
/* Ignore scripts */
|
||||
runscripts = 0;
|
||||
|
||||
@ -697,7 +698,7 @@ datalink_Up(struct datalink *dl, int runscripts, int packetmode)
|
||||
bundle_NewPhase(dl->bundle, PHASE_ESTABLISH);
|
||||
dl->state = DATALINK_OPENING;
|
||||
dl->reconnect_tries =
|
||||
dl->physical->type == PHYS_STDIN ? 0 : dl->cfg.reconnect.max;
|
||||
dl->physical->type == PHYS_DIRECT ? 0 : dl->cfg.reconnect.max;
|
||||
dl->dial_tries = dl->cfg.dial.max;
|
||||
dl->script.run = runscripts;
|
||||
dl->script.packetmode = packetmode;
|
||||
@ -913,3 +914,159 @@ datalink_State(struct datalink *dl)
|
||||
return "unknown";
|
||||
return states[dl->state];
|
||||
}
|
||||
|
||||
struct datalink *
|
||||
datalink_FromBinary(struct bundle *bundle, int fd)
|
||||
{
|
||||
struct datalink *dl = (struct datalink *)malloc(sizeof(struct datalink));
|
||||
u_int retry;
|
||||
int got, get;
|
||||
|
||||
/*
|
||||
* We expect:
|
||||
* .----------.----------.------.--------------.
|
||||
* | datalink | name len | name | physical len |
|
||||
* `----------'----------'------'--------------'
|
||||
* We then pass the rest of the stream to physical.
|
||||
*/
|
||||
|
||||
got = fullread(fd, dl, sizeof *dl);
|
||||
if (got != sizeof *dl) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink"
|
||||
" (got %d bytes, not %d)\n", got, sizeof *dl);
|
||||
close(fd);
|
||||
free(dl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
got = fullread(fd, &get, sizeof get);
|
||||
if (got != sizeof get) {
|
||||
LogPrintf(LogWARN, "Cannot receive name length"
|
||||
" (got %d bytes, not %d)\n", got, sizeof get);
|
||||
close(fd);
|
||||
free(dl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dl->name = (char *)malloc(get + 1);
|
||||
got = fullread(fd, dl->name, get);
|
||||
if (got != get) {
|
||||
LogPrintf(LogWARN, "Cannot receive name"
|
||||
" (got %d bytes, not %d)\n", got, get);
|
||||
close(fd);
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
return NULL;
|
||||
}
|
||||
dl->name[get] = '\0';
|
||||
|
||||
dl->desc.type = DATALINK_DESCRIPTOR;
|
||||
dl->desc.next = NULL;
|
||||
dl->desc.UpdateSet = datalink_UpdateSet;
|
||||
dl->desc.IsSet = datalink_IsSet;
|
||||
dl->desc.Read = datalink_Read;
|
||||
dl->desc.Write = datalink_Write;
|
||||
|
||||
mp_linkInit(&dl->mp);
|
||||
*dl->phone.list = '\0';
|
||||
dl->phone.next = NULL;
|
||||
dl->phone.alt = NULL;
|
||||
dl->phone.chosen = "N/A";
|
||||
|
||||
dl->bundle = bundle;
|
||||
dl->next = NULL;
|
||||
memset(&dl->dial_timer, '\0', sizeof dl->dial_timer);
|
||||
dl->dial_tries = 0;
|
||||
dl->reconnect_tries = 0;
|
||||
dl->parent = &bundle->fsm;
|
||||
dl->fsmp.LayerStart = datalink_LayerStart;
|
||||
dl->fsmp.LayerUp = datalink_LayerUp;
|
||||
dl->fsmp.LayerDown = datalink_LayerDown;
|
||||
dl->fsmp.LayerFinish = datalink_LayerFinish;
|
||||
dl->fsmp.object = dl;
|
||||
|
||||
retry = dl->pap.cfg.fsmretry;
|
||||
authinfo_Init(&dl->pap);
|
||||
dl->pap.cfg.fsmretry = retry;
|
||||
|
||||
retry = dl->chap.auth.cfg.fsmretry;
|
||||
authinfo_Init(&dl->chap.auth);
|
||||
dl->chap.auth.cfg.fsmretry = retry;
|
||||
|
||||
got = fullread(fd, &get, sizeof get);
|
||||
if (got != sizeof get) {
|
||||
LogPrintf(LogWARN, "Cannot receive physical length"
|
||||
" (got %d bytes, not %d)\n", got, sizeof get);
|
||||
close(fd);
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
dl = NULL;
|
||||
} else if ((dl->physical = modem_FromBinary(dl, fd)) == NULL) {
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
dl = NULL;
|
||||
} else
|
||||
chat_Init(&dl->chat, dl->physical, NULL, 1, NULL);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
||||
int
|
||||
datalink_ToBinary(struct datalink *dl, int fd)
|
||||
{
|
||||
int len, link_fd;
|
||||
|
||||
/*
|
||||
* We send:
|
||||
* .----------.----------.------.--------------.
|
||||
* | datalink | name len | name | physical len |
|
||||
* `----------'----------'------'--------------'
|
||||
*/
|
||||
|
||||
if (fd != -1) {
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
if (write(fd, dl, sizeof *dl) != sizeof *dl)
|
||||
err++;
|
||||
len = strlen(dl->name);
|
||||
if (write(fd, &len, sizeof(int)) != sizeof(int))
|
||||
err++;
|
||||
if (write(fd, dl->name, len) != len)
|
||||
err++;
|
||||
len = sizeof(struct physical);
|
||||
if (write(fd, &len, sizeof(int)) != sizeof(int))
|
||||
err++;
|
||||
|
||||
if (err) {
|
||||
LogPrintf(LogERROR, "Failed sending datalink\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
link_fd = modem_ToBinary(dl->physical, fd);
|
||||
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
|
||||
return link_fd;
|
||||
}
|
||||
|
||||
void
|
||||
datalink_Rename(struct datalink *dl)
|
||||
{
|
||||
int f, n;
|
||||
char *name;
|
||||
|
||||
n = strlen(dl->name);
|
||||
name = (char *)malloc(n+3);
|
||||
for (f = n - 1; f >= 0; f--)
|
||||
if (!isdigit(dl->name[f]))
|
||||
break;
|
||||
n = sprintf(name, "%.*s-", dl->name[f] == '-' ? f : f + 1, dl->name);
|
||||
sprintf(name + n, "%d", atoi(dl->name + f + 1) + 1);
|
||||
LogPrintf(LogPHASE, "Rename link %s to %s\n", dl->name, name);
|
||||
free(dl->name);
|
||||
dl->physical->link.name = dl->name = name;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.h,v 1.1.2.18 1998/04/18 01:01:20 brian Exp $
|
||||
* $Id: datalink.h,v 1.1.2.19 1998/04/24 19:16:02 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -104,9 +104,10 @@ struct datalink {
|
||||
#define descriptor2datalink(d) \
|
||||
((d)->type == DATALINK_DESCRIPTOR ? (struct datalink *)(d) : NULL)
|
||||
|
||||
extern struct datalink *datalink_Create(const char *name, struct bundle *,
|
||||
const struct fsm_parent *, int);
|
||||
extern struct datalink *datalink_Create(const char *name, struct bundle *, int);
|
||||
extern struct datalink *datalink_Clone(struct datalink *, const char *);
|
||||
extern struct datalink *datalink_FromBinary(struct bundle *, int);
|
||||
extern int datalink_ToBinary(struct datalink *, int);
|
||||
extern struct datalink *datalink_Destroy(struct datalink *);
|
||||
extern void datalink_GotAuthname(struct datalink *, const char *, int);
|
||||
extern void datalink_Up(struct datalink *, int, int);
|
||||
@ -119,3 +120,4 @@ extern int datalink_Show(struct cmdargs const *);
|
||||
extern int datalink_SetRedial(struct cmdargs const *);
|
||||
extern int datalink_SetReconnect(struct cmdargs const *);
|
||||
extern const char *datalink_State(struct datalink *);
|
||||
extern void datalink_Rename(struct datalink *);
|
||||
|
@ -23,11 +23,12 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: defs.c,v 1.11.4.8 1998/04/10 13:19:07 brian Exp $
|
||||
* $Id: defs.c,v 1.11.4.9 1998/04/23 03:22:50 brian Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -47,3 +48,21 @@ randinit()
|
||||
srandom(time(NULL)^getpid());
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t
|
||||
fullread(int fd, void *v, size_t n)
|
||||
{
|
||||
size_t got, total;
|
||||
|
||||
for (total = 0; total < n; total += got)
|
||||
switch ((got = read(fd, (char *)v + total, n - total))) {
|
||||
case 0:
|
||||
return total;
|
||||
case -1:
|
||||
if (errno == EINTR)
|
||||
got = 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
@ -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.29.2.13 1998/04/10 13:19:07 brian Exp $
|
||||
* $Id: defs.h,v 1.29.2.14 1998/04/23 03:22:51 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#define TUN_PREFIX "/dev/tun" /* tunnel device prefix */
|
||||
#define PPPMPIPE "pppmpipe" /* Multilink pipe program name */
|
||||
|
||||
#define MODEM_SPEED B38400 /* tty speed */
|
||||
#define SERVER_PORT 3000 /* Base server port no. */
|
||||
@ -71,10 +72,11 @@
|
||||
/* physical::type values (OR'd in bundle::phys_type) */
|
||||
#define PHYS_MANUAL 1 /* Manual link */
|
||||
#define PHYS_DEMAND 2 /* Dial-on-demand link (-auto) */
|
||||
#define PHYS_STDIN 4 /* Incoming link (-direct) */
|
||||
#define PHYS_DIRECT 4 /* Incoming link (-direct) */
|
||||
#define PHYS_DEDICATED 8 /* Dedicated link (-dedicated) */
|
||||
#define PHYS_PERM 16 /* Dial immediately, stay connected (-ddial) */
|
||||
#define PHYS_1OFF 32 /* Dial immediately, delete when done. (-background) */
|
||||
#define PHYS_ALL 63
|
||||
|
||||
extern void randinit(void);
|
||||
extern ssize_t fullread(int, void *, size_t);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.c,v 1.27.2.32 1998/04/24 19:15:38 brian Exp $
|
||||
* $Id: fsm.c,v 1.27.2.33 1998/04/28 01:25:15 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -507,8 +507,14 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
case ST_ACKRCVD:
|
||||
if (ackaction) {
|
||||
NewState(fp, ST_OPENED);
|
||||
(*fp->fn->LayerUp)(fp);
|
||||
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
||||
if ((*fp->fn->LayerUp)(fp))
|
||||
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
||||
else {
|
||||
(*fp->fn->LayerDown)(fp);
|
||||
FsmInitRestartCounter(fp);
|
||||
FsmSendTerminateReq(fp);
|
||||
NewState(fp, ST_CLOSING);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ST_ACKSENT:
|
||||
@ -542,8 +548,14 @@ FsmRecvConfigAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
case ST_ACKSENT:
|
||||
FsmInitRestartCounter(fp);
|
||||
NewState(fp, ST_OPENED);
|
||||
(*fp->fn->LayerUp)(fp);
|
||||
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
||||
if ((*fp->fn->LayerUp)(fp))
|
||||
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
||||
else {
|
||||
(*fp->fn->LayerDown)(fp);
|
||||
FsmInitRestartCounter(fp);
|
||||
FsmSendTerminateReq(fp);
|
||||
NewState(fp, ST_CLOSING);
|
||||
}
|
||||
break;
|
||||
case ST_OPENED:
|
||||
(*fp->fn->LayerDown)(fp);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.16.2.13 1998/04/03 19:21:21 brian Exp $
|
||||
* $Id: fsm.h,v 1.16.2.14 1998/04/07 00:53:42 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -54,7 +54,7 @@ struct fsm_decode {
|
||||
};
|
||||
|
||||
struct fsm_callbacks {
|
||||
void (*LayerUp) (struct fsm *); /* Layer is now up (tlu) */
|
||||
int (*LayerUp) (struct fsm *); /* Layer is now up (tlu) */
|
||||
void (*LayerDown) (struct fsm *); /* About to come down (tld) */
|
||||
void (*LayerStart) (struct fsm *); /* Layer about to start up (tls) */
|
||||
void (*LayerFinish) (struct fsm *); /* Layer now down (tlf) */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: id.c,v 1.6.4.7 1998/04/25 10:49:01 brian Exp $
|
||||
* $Id: id.c,v 1.6.4.8 1998/04/28 01:25:19 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -215,27 +215,27 @@ ID0logout(const char *device)
|
||||
}
|
||||
|
||||
int
|
||||
ID0bind_un(int s, const struct sockaddr_un *name, int namelen)
|
||||
ID0bind_un(int s, const struct sockaddr_un *name)
|
||||
{
|
||||
int result;
|
||||
|
||||
ID0set0();
|
||||
result = bind(s, (const struct sockaddr *)name, namelen);
|
||||
result = bind(s, (const struct sockaddr *)name, sizeof *name);
|
||||
LogPrintf(LogID0, "%d = bind(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, namelen);
|
||||
result, s, name->sun_path, sizeof *name);
|
||||
ID0setuser();
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
ID0connect_un(int s, const struct sockaddr_un *name, int namelen)
|
||||
ID0connect_un(int s, const struct sockaddr_un *name)
|
||||
{
|
||||
int result;
|
||||
|
||||
ID0set0();
|
||||
result = connect(s, (const struct sockaddr *)name, namelen);
|
||||
result = connect(s, (const struct sockaddr *)name, sizeof *name);
|
||||
LogPrintf(LogID0, "%d = connect(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, namelen);
|
||||
result, s, name->sun_path, sizeof *name);
|
||||
ID0setuser();
|
||||
return result;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: id.h,v 1.3.4.2 1998/04/17 22:05:19 brian Exp $
|
||||
* $Id: id.h,v 1.3.4.3 1998/04/28 01:25:20 brian Exp $
|
||||
*/
|
||||
|
||||
struct utmp;
|
||||
@ -41,5 +41,5 @@ extern int ID0uu_lock(const char *);
|
||||
extern int ID0uu_unlock(const char *);
|
||||
extern void ID0login(struct utmp *);
|
||||
extern void ID0logout(const char *);
|
||||
extern int ID0bind_un(int, const struct sockaddr_un *, int);
|
||||
extern int ID0connect_un(int, const struct sockaddr_un *, int);
|
||||
extern int ID0bind_un(int, const struct sockaddr_un *);
|
||||
extern int ID0connect_un(int, const struct sockaddr_un *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.50.2.46 1998/04/25 10:49:09 brian Exp $
|
||||
* $Id: ipcp.c,v 1.50.2.47 1998/04/28 01:25:26 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -81,7 +81,7 @@ struct compreq {
|
||||
u_char compcid;
|
||||
};
|
||||
|
||||
static void IpcpLayerUp(struct fsm *);
|
||||
static int IpcpLayerUp(struct fsm *);
|
||||
static void IpcpLayerDown(struct fsm *);
|
||||
static void IpcpLayerStart(struct fsm *);
|
||||
static void IpcpLayerFinish(struct fsm *);
|
||||
@ -684,7 +684,7 @@ IpcpLayerDown(struct fsm *fp)
|
||||
IpcpCleanInterface(ipcp);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
IpcpLayerUp(struct fsm *fp)
|
||||
{
|
||||
/* We're now up */
|
||||
@ -700,7 +700,7 @@ IpcpLayerUp(struct fsm *fp)
|
||||
|
||||
if (ipcp_SetIPaddress(fp->bundle, ipcp->my_ip, ipcp->peer_ip, 0) < 0) {
|
||||
LogPrintf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
@ -725,6 +725,7 @@ IpcpLayerUp(struct fsm *fp)
|
||||
throughput_start(&ipcp->throughput, "IPCP throughput",
|
||||
Enabled(fp->bundle, OPT_THROUGHPUT));
|
||||
bundle_DisplayPrompt(fp->bundle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.c,v 1.55.2.49 1998/04/25 10:49:12 brian Exp $
|
||||
* $Id: lcp.c,v 1.55.2.50 1998/04/28 01:25:27 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Limit data field length by MRU
|
||||
@ -71,7 +71,7 @@ struct lqrreq {
|
||||
u_long period; /* Reporting interval */
|
||||
};
|
||||
|
||||
static void LcpLayerUp(struct fsm *);
|
||||
static int LcpLayerUp(struct fsm *);
|
||||
static void LcpLayerDown(struct fsm *);
|
||||
static void LcpLayerStart(struct fsm *);
|
||||
static void LcpLayerFinish(struct fsm *);
|
||||
@ -96,6 +96,9 @@ static struct fsm_callbacks lcp_Callbacks = {
|
||||
NullRecvResetAck
|
||||
};
|
||||
|
||||
static const char *lcp_TimerNames[] =
|
||||
{"LCP restart", "LCP openmode", "LCP stopped"};
|
||||
|
||||
static const char *cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
"???",
|
||||
@ -184,17 +187,24 @@ GenerateMagic(void)
|
||||
return random();
|
||||
}
|
||||
|
||||
void
|
||||
lcp_SetupCallbacks(struct lcp *lcp)
|
||||
{
|
||||
lcp->fsm.fn = &lcp_Callbacks;
|
||||
lcp->fsm.FsmTimer.name = lcp_TimerNames[0];
|
||||
lcp->fsm.OpenTimer.name = lcp_TimerNames[1];
|
||||
lcp->fsm.StoppedTimer.name = lcp_TimerNames[2];
|
||||
}
|
||||
|
||||
void
|
||||
lcp_Init(struct lcp *lcp, struct bundle *bundle, struct link *l,
|
||||
const struct fsm_parent *parent)
|
||||
{
|
||||
/* Initialise ourselves */
|
||||
int mincode = parent ? 1 : LCP_MINMPCODE;
|
||||
static const char *timer_names[] =
|
||||
{"LCP restart", "LCP openmode", "LCP stopped"};
|
||||
|
||||
fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, mincode, LCP_MAXCODE, 10, LogLCP,
|
||||
bundle, l, parent, &lcp_Callbacks, timer_names);
|
||||
bundle, l, parent, &lcp_Callbacks, lcp_TimerNames);
|
||||
|
||||
lcp->cfg.mru = DEF_MRU;
|
||||
lcp->cfg.accmap = 0;
|
||||
@ -377,7 +387,7 @@ LcpLayerFinish(struct fsm *fp)
|
||||
LogPrintf(LogLCP, "%s: LcpLayerFinish\n", fp->link->name);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
LcpLayerUp(struct fsm *fp)
|
||||
{
|
||||
/* We're now up */
|
||||
@ -388,6 +398,7 @@ LcpLayerUp(struct fsm *fp)
|
||||
async_SetLinkParams(&p->async, lcp);
|
||||
StartLqm(lcp);
|
||||
hdlc_StartTimer(&p->hdlc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.16.2.20 1998/04/16 00:26:06 brian Exp $
|
||||
* $Id: lcp.h,v 1.16.2.21 1998/04/23 03:22:56 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -113,3 +113,4 @@ extern void lcp_Setup(struct lcp *, int);
|
||||
extern void lcp_SendProtoRej(struct lcp *, u_char *, int);
|
||||
extern int lcp_ReportStatus(struct cmdargs const *);
|
||||
extern void LcpInput(struct lcp *, struct mbuf *);
|
||||
extern void lcp_SetupCallbacks(struct lcp *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: log.c,v 1.25.2.10 1998/04/24 19:16:05 brian Exp $
|
||||
* $Id: log.c,v 1.25.2.11 1998/04/25 10:49:20 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -47,6 +47,7 @@ static const char *LogNames[] = {
|
||||
"Command",
|
||||
"Connect",
|
||||
"Debug",
|
||||
"Timer",
|
||||
"HDLC",
|
||||
"ID0",
|
||||
"IPCP",
|
||||
@ -107,7 +108,9 @@ static int
|
||||
syslogLevel(int lev)
|
||||
{
|
||||
switch (lev) {
|
||||
case LogDEBUG:return LOG_DEBUG;
|
||||
case LogDEBUG:
|
||||
case LogTIMER:
|
||||
return LOG_DEBUG;
|
||||
case LogWARN:
|
||||
return LOG_WARNING;
|
||||
case LogERROR:
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: log.h,v 1.18.2.4 1998/04/19 23:08:35 brian Exp $
|
||||
* $Id: log.h,v 1.18.2.5 1998/04/24 19:15:44 brian Exp $
|
||||
*/
|
||||
|
||||
#define LogMIN (1)
|
||||
@ -33,19 +33,20 @@
|
||||
#define LogCOMMAND (4)
|
||||
#define LogCONNECT (5)
|
||||
#define LogDEBUG (6) /* syslog(LOG_DEBUG, ....) */
|
||||
#define LogHDLC (7)
|
||||
#define LogID0 (8)
|
||||
#define LogIPCP (9)
|
||||
#define LogLCP (10)
|
||||
#define LogLQM (11)
|
||||
#define LogPHASE (12)
|
||||
#define LogTCPIP (13)
|
||||
#define LogTUN (14) /* If set, tun%d is output with each message */
|
||||
#define LogMAXCONF (14)
|
||||
#define LogWARN (15) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
|
||||
#define LogERROR (16) /* syslog(LOG_ERR, ....), + sent to VarTerm */
|
||||
#define LogALERT (17) /* syslog(LOG_ALERT, ....) */
|
||||
#define LogMAX (17)
|
||||
#define LogTIMER (7) /* syslog(LOG_DEBUG, ....) */
|
||||
#define LogHDLC (8)
|
||||
#define LogID0 (9)
|
||||
#define LogIPCP (10)
|
||||
#define LogLCP (11)
|
||||
#define LogLQM (12)
|
||||
#define LogPHASE (13)
|
||||
#define LogTCPIP (14)
|
||||
#define LogTUN (15) /* If set, tun%d is output with each message */
|
||||
#define LogMAXCONF (15)
|
||||
#define LogWARN (16) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
|
||||
#define LogERROR (17) /* syslog(LOG_ERR, ....), + sent to VarTerm */
|
||||
#define LogALERT (18) /* syslog(LOG_ALERT, ....) */
|
||||
#define LogMAX (18)
|
||||
|
||||
struct mbuf;
|
||||
struct cmdargs;
|
||||
|
@ -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.121.2.51 1998/04/25 10:49:26 brian Exp $
|
||||
* $Id: main.c,v 1.121.2.52 1998/04/28 01:25:30 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -216,7 +216,7 @@ ProcessArgs(int argc, char **argv, int *mode)
|
||||
*mode = PHYS_1OFF;
|
||||
labelrequired = 1;
|
||||
} else if (strcmp(cp, "direct") == 0)
|
||||
*mode = PHYS_STDIN;
|
||||
*mode = PHYS_DIRECT;
|
||||
else if (strcmp(cp, "dedicated") == 0)
|
||||
*mode = PHYS_DEDICATED;
|
||||
else if (strcmp(cp, "ddial") == 0) {
|
||||
@ -297,7 +297,7 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Allow output for the moment (except in direct mode) */
|
||||
if (mode == PHYS_STDIN)
|
||||
if (mode == PHYS_DIRECT)
|
||||
prompt = NULL;
|
||||
else {
|
||||
const char *m;
|
||||
@ -338,7 +338,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (!ValidSystem(label, prompt, mode)) {
|
||||
fprintf(stderr, "You may not use ppp in this mode with this label\n");
|
||||
if (mode == PHYS_STDIN) {
|
||||
if (mode == PHYS_DIRECT) {
|
||||
const char *l;
|
||||
l = label ? label : "default";
|
||||
LogPrintf(LogWARN, "Label %s rejected -direct connection\n", l);
|
||||
@ -393,7 +393,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (mode != PHYS_MANUAL) {
|
||||
if (mode != PHYS_STDIN) {
|
||||
if (mode != PHYS_DIRECT) {
|
||||
int bgpipe[2];
|
||||
pid_t bgpid;
|
||||
|
||||
@ -498,10 +498,11 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
|
||||
handle_signals();
|
||||
|
||||
descriptor_UpdateSet(&bundle->desc, &rfds, &wfds, &efds, &nfds);
|
||||
descriptor_UpdateSet(&server.desc, &rfds, &wfds, &efds, &nfds);
|
||||
/* This one comes first 'cos it may nuke a datalink */
|
||||
descriptor_UpdateSet(&bundle->ncp.mp.server.desc, &rfds, &wfds,
|
||||
&efds, &nfds);
|
||||
descriptor_UpdateSet(&bundle->desc, &rfds, &wfds, &efds, &nfds);
|
||||
descriptor_UpdateSet(&server.desc, &rfds, &wfds, &efds, &nfds);
|
||||
|
||||
/* If there are aren't many packets queued, look for some more. */
|
||||
if (qlen < 20 && bundle->tun_fd >= 0) {
|
||||
|
@ -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.77.2.58 1998/04/25 10:49:31 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.59 1998/04/28 01:25:31 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -418,7 +418,7 @@ modem_lock(struct physical *modem, int tunno)
|
||||
if (*modem->name.full != '/')
|
||||
return 0;
|
||||
|
||||
if (modem->type != PHYS_STDIN &&
|
||||
if (modem->type != PHYS_DIRECT &&
|
||||
(res = ID0uu_lock(modem->name.base)) != UU_LOCK_OK) {
|
||||
if (res == UU_LOCK_INUSE)
|
||||
LogPrintf(LogPHASE, "%s: %s is in use\n",
|
||||
@ -461,7 +461,7 @@ modem_Unlock(struct physical *modem)
|
||||
ID0unlink(fn);
|
||||
#endif
|
||||
|
||||
if (modem->type != PHYS_STDIN && ID0uu_unlock(modem->name.base) == -1)
|
||||
if (modem->type != PHYS_DIRECT && ID0uu_unlock(modem->name.base) == -1)
|
||||
LogPrintf(LogALERT, "%s: Can't uu_unlock %s\n", modem->link.name, fn);
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
if (modem->fd >= 0)
|
||||
LogPrintf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
||||
/* We're going back into "term" mode */
|
||||
else if (modem->type == PHYS_STDIN) {
|
||||
else if (modem->type == PHYS_DIRECT) {
|
||||
if (isatty(STDIN_FILENO)) {
|
||||
LogPrintf(LogDEBUG, "%s: Open(direct): Modem is a tty\n",
|
||||
modem->link.name);
|
||||
@ -591,7 +591,7 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
if (modem->type != PHYS_DEDICATED)
|
||||
rstio.c_cflag |= HUPCL;
|
||||
|
||||
if (modem->type != PHYS_STDIN) {
|
||||
if (modem->type != PHYS_DIRECT) {
|
||||
/* Change tty speed when we're not in -direct mode */
|
||||
rstio.c_cflag &= ~(CSIZE | PARODD | PARENB);
|
||||
rstio.c_cflag |= modem->cfg.parity;
|
||||
@ -605,7 +605,7 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
(u_long)rstio.c_oflag, (u_long)rstio.c_cflag);
|
||||
|
||||
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) == -1) {
|
||||
if (modem->type != PHYS_STDIN) {
|
||||
if (modem->type != PHYS_DIRECT) {
|
||||
LogPrintf(LogERROR, "%s: Open: Cannot get modem status: %s\n",
|
||||
modem->link.name, strerror(errno));
|
||||
modem_LogicalClose(modem);
|
||||
@ -655,7 +655,7 @@ modem_Raw(struct physical *modem, struct bundle *bundle)
|
||||
if (!isatty(modem->fd) || Physical_IsSync(modem))
|
||||
return 0;
|
||||
|
||||
if (modem->type != PHYS_STDIN && modem->fd >= 0 && !Online(modem))
|
||||
if (modem->type != PHYS_DIRECT && modem->fd >= 0 && !Online(modem))
|
||||
LogPrintf(LogDEBUG, "%s: Raw: modem = %d, mbits = %x\n",
|
||||
modem->link.name, modem->fd, modem->mbits);
|
||||
|
||||
@ -818,7 +818,7 @@ modem_ShowStatus(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "closed\n");
|
||||
prompt_Printf(arg->prompt, " Device: %s\n",
|
||||
*modem->name.full ? modem->name.full :
|
||||
modem->type == PHYS_STDIN ? "stdin" : "N/A");
|
||||
modem->type == PHYS_DIRECT ? "stdin" : "N/A");
|
||||
|
||||
prompt_Printf(arg->prompt, " Link Type: %s\n", mode2Nam(modem->type));
|
||||
prompt_Printf(arg->prompt, " Connect Count: %d\n",
|
||||
@ -879,7 +879,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
nointr_usleep(10000);
|
||||
|
||||
n = Physical_Read(p, rbuff, sizeof rbuff);
|
||||
if (p->type == PHYS_STDIN && n <= 0)
|
||||
if (p->type == PHYS_DIRECT && n <= 0)
|
||||
datalink_Down(p->dl, 0);
|
||||
else
|
||||
LogDumpBuff(LogASYNC, "ReadFromModem", rbuff, n);
|
||||
@ -908,3 +908,104 @@ modem_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
{
|
||||
return Physical_UpdateSet(d, r, w, e, n, 0);
|
||||
}
|
||||
|
||||
struct physical *
|
||||
modem_FromBinary(struct datalink *dl, int fd)
|
||||
{
|
||||
struct physical *p = (struct physical *)malloc(sizeof(struct physical));
|
||||
int got;
|
||||
|
||||
/*
|
||||
* We expect:
|
||||
* .----------.
|
||||
* | physical |
|
||||
* `----------'
|
||||
*/
|
||||
|
||||
got = fullread(fd, p, sizeof *p);
|
||||
if (got != sizeof *p) {
|
||||
LogPrintf(LogWARN, "Cannot receive physical"
|
||||
" (got %d bytes, not %d)\n", got, sizeof *p);
|
||||
close(fd);
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
p->link.name = dl->name;
|
||||
throughput_init(&p->link.throughput);
|
||||
memset(&p->Timer, '\0', sizeof p->Timer);
|
||||
memset(p->link.Queue, '\0', sizeof p->link.Queue);
|
||||
|
||||
p->desc.UpdateSet = modem_UpdateSet;
|
||||
p->desc.IsSet = Physical_IsSet;
|
||||
p->desc.Read = modem_DescriptorRead;
|
||||
p->desc.Write = modem_DescriptorWrite;
|
||||
p->desc.next = NULL;
|
||||
p->type = PHYS_DIRECT;
|
||||
p->dl = dl;
|
||||
p->name.base = strrchr(p->name.full, '/');
|
||||
p->mbits = 0;
|
||||
p->dev_is_modem = 1;
|
||||
p->out = NULL;
|
||||
p->connect_count = 1;
|
||||
|
||||
p->link.lcp.fsm.bundle = dl->bundle;
|
||||
p->link.lcp.fsm.link = &p->link;
|
||||
memset(&p->link.lcp.fsm.FsmTimer, '\0', sizeof p->link.lcp.fsm.FsmTimer);
|
||||
memset(&p->link.lcp.fsm.OpenTimer, '\0', sizeof p->link.lcp.fsm.OpenTimer);
|
||||
memset(&p->link.lcp.fsm.StoppedTimer, '\0',
|
||||
sizeof p->link.lcp.fsm.StoppedTimer);
|
||||
p->link.lcp.fsm.parent = &dl->fsmp;
|
||||
lcp_SetupCallbacks(&p->link.lcp);
|
||||
|
||||
p->link.ccp.fsm.bundle = dl->bundle;
|
||||
p->link.ccp.fsm.link = &p->link;
|
||||
/* Our in.state & out.state are NULL (no link-level ccp yet) */
|
||||
memset(&p->link.ccp.fsm.FsmTimer, '\0', sizeof p->link.ccp.fsm.FsmTimer);
|
||||
memset(&p->link.ccp.fsm.OpenTimer, '\0', sizeof p->link.ccp.fsm.OpenTimer);
|
||||
memset(&p->link.ccp.fsm.StoppedTimer, '\0',
|
||||
sizeof p->link.ccp.fsm.StoppedTimer);
|
||||
p->link.ccp.fsm.parent = &dl->fsmp;
|
||||
ccp_SetupCallbacks(&p->link.ccp);
|
||||
|
||||
p->hdlc.lqm.owner = &p->link.lcp;
|
||||
p->hdlc.ReportTimer.state = TIMER_STOPPED;
|
||||
p->hdlc.lqm.timer.state = TIMER_STOPPED;
|
||||
if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load)
|
||||
StartLqm(&p->link.lcp);
|
||||
hdlc_StartTimer(&p->hdlc);
|
||||
|
||||
p->fd = fd; /* Now talk down it :-) */
|
||||
throughput_start(&p->link.throughput, "modem throughput",
|
||||
Enabled(dl->bundle, OPT_THROUGHPUT));
|
||||
/* Don't need a modem timer.... */
|
||||
/* Don't need to lock the device in -direct mode */
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
int
|
||||
modem_ToBinary(struct physical *p, int fd)
|
||||
{
|
||||
int link_fd;
|
||||
|
||||
/*
|
||||
* We send:
|
||||
* .----------.
|
||||
* | physical |
|
||||
* `----------'
|
||||
*/
|
||||
|
||||
hdlc_StopTimer(&p->hdlc);
|
||||
StopLqrTimer(p);
|
||||
|
||||
if (fd != -1 && write(fd, p, sizeof *p) != sizeof *p) {
|
||||
LogPrintf(LogERROR, "Failed sending physical\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
link_fd = p->fd;
|
||||
free(p);
|
||||
|
||||
return link_fd;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.h,v 1.16.2.14 1998/04/07 00:54:10 brian Exp $
|
||||
* $Id: modem.h,v 1.16.2.15 1998/04/10 13:19:14 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -36,3 +36,5 @@ extern int modem_ShowStatus(struct cmdargs const *);
|
||||
extern void modem_Close(struct physical *);
|
||||
extern void modem_Offline(struct physical *);
|
||||
extern void modem_Destroy(struct physical *);
|
||||
extern struct physical *modem_FromBinary(struct datalink *, int);
|
||||
extern int modem_ToBinary(struct physical *, int fd);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.c,v 1.1.2.16 1998/04/25 10:49:35 brian Exp $
|
||||
* $Id: mp.c,v 1.1.2.17 1998/04/28 01:25:33 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -241,13 +241,15 @@ mp_Up(struct mp *mp, struct datalink *dl)
|
||||
*/
|
||||
fd = mpserver_Open(&mp->server, &mp->peer);
|
||||
if (fd >= 0) {
|
||||
LogPrintf(LogPHASE, "mp: Transfer link %s\n", mp->server.ifsun.sun_path);
|
||||
bundle_SendDatalink(dl, fd);
|
||||
LogPrintf(LogPHASE, "mp: Transfer link on %s\n",
|
||||
mp->server.socket.sun_path);
|
||||
mp->server.send.dl = dl;
|
||||
mp->server.send.fd = fd;
|
||||
return MP_LINKSENT;
|
||||
} else if (!mpserver_IsOpen(&mp->server))
|
||||
return MP_FAILED;
|
||||
else {
|
||||
LogPrintf(LogPHASE, "mp: Listening on %s\n", mp->server.ifsun.sun_path);
|
||||
LogPrintf(LogPHASE, "mp: Listening on %s\n", mp->server.socket.sun_path);
|
||||
LogPrintf(LogPHASE, " First link: %s\n", dl->name);
|
||||
|
||||
/* Re-point our IPCP layer at our MP link */
|
||||
@ -529,6 +531,8 @@ mp_FillQueues(struct bundle *bundle)
|
||||
|
||||
total = 0;
|
||||
for (dl = bundle->links; dl; dl = dl->next) {
|
||||
if (dl->state != DATALINK_OPEN)
|
||||
continue;
|
||||
if (dl->physical->out)
|
||||
/* this link has suffered a short write. Let it continue */
|
||||
continue;
|
||||
@ -554,6 +558,8 @@ mp_FillQueues(struct bundle *bundle)
|
||||
looped = 1;
|
||||
dl = bundle->links;
|
||||
}
|
||||
if (dl->state != DATALINK_OPEN)
|
||||
continue;
|
||||
if (len <= dl->mp.weight + LINK_MINWEIGHT) {
|
||||
mo = m;
|
||||
end = 1;
|
||||
@ -599,7 +605,7 @@ mp_ShowStatus(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "Multilink is %sactive\n", mp->active ? "" : "in");
|
||||
if (mp->active)
|
||||
prompt_Printf(arg->prompt, "Socket: %s\n",
|
||||
mp->server.ifsun.sun_path);
|
||||
mp->server.socket.sun_path);
|
||||
|
||||
prompt_Printf(arg->prompt, "\nMy Side:\n");
|
||||
if (mp->active) {
|
||||
@ -780,6 +786,12 @@ mpserver_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
{
|
||||
struct mpserver *s = descriptor2mpserver(d);
|
||||
|
||||
if (s->send.dl != NULL) {
|
||||
bundle_SendDatalink(s->send.dl, s->send.fd);
|
||||
s->send.dl = NULL;
|
||||
s->send.fd = -1;
|
||||
}
|
||||
|
||||
if (r && s->fd >= 0) {
|
||||
if (*n < s->fd + 1)
|
||||
*n = s->fd + 1;
|
||||
@ -800,21 +812,20 @@ static void
|
||||
mpserver_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
struct mpserver *s = descriptor2mpserver(d);
|
||||
struct sockaddr in;
|
||||
int fd, size;
|
||||
|
||||
size = sizeof s->ifsun;
|
||||
fd = accept(s->fd, (struct sockaddr *)&s->ifsun, &size);
|
||||
size = sizeof in;
|
||||
fd = accept(s->fd, &in, &size);
|
||||
if (fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->ifsun.sun_family != AF_LOCAL) { /* ??? */
|
||||
if (in.sa_family != AF_LOCAL) /* ??? */
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
bundle_ReceiveDatalink(bundle, fd);
|
||||
else
|
||||
bundle_ReceiveDatalink(bundle, fd);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -833,67 +844,74 @@ mpserver_Init(struct mpserver *s)
|
||||
s->desc.IsSet = mpserver_IsSet;
|
||||
s->desc.Read = mpserver_Read;
|
||||
s->desc.Write = mpserver_Write;
|
||||
s->send.dl = NULL;
|
||||
s->send.fd = -1;
|
||||
s->fd = -1;
|
||||
memset(&s->ifsun, '\0', sizeof s->ifsun);
|
||||
memset(&s->socket, '\0', sizeof s->socket);
|
||||
}
|
||||
|
||||
int
|
||||
mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
{
|
||||
int f, l, fd;
|
||||
mode_t mask;
|
||||
int f;
|
||||
|
||||
if (s->fd != -1) {
|
||||
LogPrintf(LogERROR, "Internal error ! mpserver already open\n");
|
||||
close(s->fd);
|
||||
memset(&s->ifsun, '\0', sizeof s->ifsun);
|
||||
mpserver_Close(s);
|
||||
}
|
||||
|
||||
s->ifsun.sun_len = snprintf(s->ifsun.sun_path, sizeof s->ifsun.sun_path,
|
||||
"%sppp-%s-%02x-", _PATH_VARRUN,
|
||||
peer->authname, peer->enddisc.class);
|
||||
l = snprintf(s->socket.sun_path, sizeof s->socket.sun_path, "%sppp-%s-%02x-",
|
||||
_PATH_VARRUN, peer->authname, peer->enddisc.class);
|
||||
|
||||
for (f = 0; f < peer->enddisc.len; f++) {
|
||||
snprintf(s->ifsun.sun_path + s->ifsun.sun_len,
|
||||
sizeof s->ifsun.sun_path - s->ifsun.sun_len,
|
||||
for (f = 0; f < peer->enddisc.len && l < sizeof s->socket.sun_path - 2; f++) {
|
||||
snprintf(s->socket.sun_path + l, sizeof s->socket.sun_path - l,
|
||||
"%02x", *(u_char *)(peer->enddisc.address+f));
|
||||
s->ifsun.sun_len += 2;
|
||||
l += 2;
|
||||
}
|
||||
|
||||
s->ifsun.sun_family = AF_LOCAL;
|
||||
s->socket.sun_family = AF_LOCAL;
|
||||
s->socket.sun_len = sizeof s->socket;
|
||||
s->fd = ID0socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
if (s->fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver: socket: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
setsockopt(s->fd, SOL_SOCKET, SO_REUSEADDR, (struct sockaddr *)&s->ifsun,
|
||||
sizeof s->ifsun);
|
||||
|
||||
setsockopt(s->fd, SOL_SOCKET, SO_REUSEADDR, (struct sockaddr *)&s->socket,
|
||||
sizeof s->socket);
|
||||
mask = umask(0177);
|
||||
|
||||
if (ID0bind_un(s->fd, &s->ifsun, sizeof s->ifsun) < 0) {
|
||||
umask(mask);
|
||||
f = sizeof s->ifsun;
|
||||
getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (struct sockaddr *)&s->ifsun, &f);
|
||||
if (ID0connect_un(s->fd, &s->ifsun, sizeof s->ifsun) < 0) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't open bundle socket (%s)\n",
|
||||
strerror(errno));
|
||||
if (ID0bind_un(s->fd, &s->socket) < 0) {
|
||||
if (errno != EADDRINUSE) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't create bundle socket %s (%s)\n",
|
||||
s->socket.sun_path, strerror(errno));
|
||||
umask(mask);
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
return -1;
|
||||
} else {
|
||||
/* We wanna donate our link to the other guy */
|
||||
int fd = s->fd;
|
||||
s->fd = -1;
|
||||
return fd;
|
||||
}
|
||||
} else {
|
||||
umask(mask);
|
||||
if (listen(s->fd, 5) != 0) {
|
||||
LogPrintf(LogERROR, "mpserver: Unable to listen to socket"
|
||||
" - BUNDLE overload?\n");
|
||||
mpserver_Close(s);
|
||||
if (ID0connect_un(s->fd, &s->socket) < 0) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't connect to bundle socket %s (%s)\n",
|
||||
s->socket.sun_path, strerror(errno));
|
||||
if (errno == ECONNREFUSED)
|
||||
LogPrintf(LogPHASE, " Has the previous server died badly ?\n");
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Donate our link to the other guy */
|
||||
fd = s->fd;
|
||||
s->fd = -1;
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Listen for other ppp invocations that want to donate links */
|
||||
if (listen(s->fd, 5) != 0) {
|
||||
LogPrintf(LogERROR, "mpserver: Unable to listen to socket"
|
||||
" - BUNDLE overload?\n");
|
||||
mpserver_Close(s);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -902,9 +920,18 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
void
|
||||
mpserver_Close(struct mpserver *s)
|
||||
{
|
||||
if (s->send.dl != NULL) {
|
||||
bundle_SendDatalink(s->send.dl, s->send.fd);
|
||||
s->send.dl = NULL;
|
||||
s->send.fd = -1;
|
||||
}
|
||||
|
||||
if (s->fd >= 0) {
|
||||
close(s->fd);
|
||||
ID0unlink(s->ifsun.sun_path);
|
||||
if (ID0unlink(s->socket.sun_path) == -1)
|
||||
LogPrintf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path,
|
||||
strerror(errno));
|
||||
memset(&s->socket, '\0', sizeof s->socket);
|
||||
s->fd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.h,v 1.1.2.7 1998/04/25 00:09:22 brian Exp $
|
||||
* $Id: mp.h,v 1.1.2.8 1998/04/28 01:25:34 brian Exp $
|
||||
*/
|
||||
|
||||
struct mbuf;
|
||||
@ -58,7 +58,12 @@ struct peerid {
|
||||
struct mpserver {
|
||||
struct descriptor desc;
|
||||
int fd; /* listen()ing here */
|
||||
struct sockaddr_un ifsun; /* On this socket */
|
||||
struct sockaddr_un socket; /* On this socket */
|
||||
|
||||
struct {
|
||||
struct datalink *dl; /* Send this datalink through */
|
||||
int fd; /* this descriptor when it's safe */
|
||||
} send; /* (in UpdateSet()) */
|
||||
};
|
||||
|
||||
struct mp {
|
||||
|
@ -16,29 +16,23 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.c,v 1.1.2.26 1998/04/25 10:49:39 brian Exp $
|
||||
* $Id: physical.c,v 1.1.2.27 1998/04/28 01:25:37 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <sys/tty.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <utmp.h>
|
||||
|
||||
#include <sys/tty.h>
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
/* XXX Name space pollution from hdlc.h */
|
||||
#include "mbuf.h"
|
||||
|
||||
/* Name space pollution for physical.h */
|
||||
#include "timer.h"
|
||||
#include "lqr.h"
|
||||
#include "hdlc.h"
|
||||
@ -48,10 +42,8 @@
|
||||
#include "async.h"
|
||||
#include "ccp.h"
|
||||
#include "link.h"
|
||||
|
||||
#include "descriptor.h"
|
||||
#include "physical.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "id.h"
|
||||
|
||||
@ -177,7 +169,7 @@ Physical_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
void
|
||||
Physical_Login(struct physical *phys, const char *name)
|
||||
{
|
||||
if (phys->type == PHYS_STDIN && Physical_IsATTY(phys)) {
|
||||
if (phys->type == PHYS_DIRECT && Physical_IsATTY(phys)) {
|
||||
if (phys->Utmp)
|
||||
LogPrintf(LogERROR, "Oops, already logged in on %s\n", phys->name.base);
|
||||
else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.97.2.23 1998/04/24 19:15:48 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.97.2.24 1998/04/24 19:16:15 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -2101,10 +2101,14 @@ Clone the specified link, creating one or more new links according to the
|
||||
.Ar name
|
||||
argument(s). This command must be used from the
|
||||
.Dq link
|
||||
command below. It is only available in multilink mode. Links may
|
||||
be removed using the
|
||||
command below unless you've only got a single link (in which case that
|
||||
link becomes the default). This command is only available in multilink
|
||||
mode. Links may be removed using the
|
||||
.Dq remove
|
||||
command below.
|
||||
.Pp
|
||||
The default link name is
|
||||
.Dq deflink .
|
||||
.It close Op lcp|ccp
|
||||
If no arguments are given, or if
|
||||
.Dq lcp
|
||||
@ -2218,10 +2222,9 @@ all argument is given,
|
||||
.Nm
|
||||
will exit despite the source of the command after closing all existing
|
||||
connections.
|
||||
.It remove
|
||||
This command removes the given link (specified via the
|
||||
.Dq link
|
||||
command). It is only available in multilink mode. A link must be
|
||||
.It remove|rm
|
||||
This command removes the given link. It is only really useful in
|
||||
multilink mode. A link must be
|
||||
in the
|
||||
.Dv CLOSED
|
||||
state before it is removed.
|
||||
@ -2374,7 +2377,7 @@ command), and standard error is read by
|
||||
.Nm
|
||||
and substituted as the expect or send string. If
|
||||
.Nm
|
||||
is running in interactive mode, file descriptor 4 is attached to
|
||||
is running in interactive mode, file descriptor 3 is attached to
|
||||
.Pa /dev/tty .
|
||||
.Pp
|
||||
For example (wrapped for readability);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.c,v 1.35.2.6 1998/04/10 13:19:21 brian Exp $
|
||||
* $Id: systems.c,v 1.35.2.7 1998/04/14 23:17:11 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -187,7 +187,7 @@ static struct {
|
||||
} modes[] = {
|
||||
{ PHYS_MANUAL, "interactive" },
|
||||
{ PHYS_DEMAND, "auto" },
|
||||
{ PHYS_STDIN, "direct" },
|
||||
{ PHYS_DIRECT, "direct" },
|
||||
{ PHYS_DEDICATED, "dedicated" },
|
||||
{ PHYS_PERM, "ddial" },
|
||||
{ PHYS_1OFF, "background" },
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: timer.c,v 1.27.2.7 1998/04/19 23:09:03 brian Exp $
|
||||
* $Id: timer.c,v 1.27.2.8 1998/04/21 01:02:32 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -73,7 +73,7 @@ StartTimer(struct pppTimer * tp)
|
||||
StopTimerNoBlock(tp);
|
||||
|
||||
if (tp->load == 0) {
|
||||
LogPrintf(LogDEBUG, "%s timer[%p] has 0 load!\n", tp->name, tp);
|
||||
LogPrintf(LogTIMER, "%s timer[%p] has 0 load!\n", tp->name, tp);
|
||||
sigsetmask(omask);
|
||||
return;
|
||||
}
|
||||
@ -89,10 +89,10 @@ StartTimer(struct pppTimer * tp)
|
||||
tp->rest = tp->load - ticks;
|
||||
|
||||
if (t)
|
||||
LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p] before %s "
|
||||
LogPrintf(LogTIMER, "StartTimer: Inserting %s timer[%p] before %s "
|
||||
"timer[%p], delta = %ld\n", tp->name, tp, t->name, t, tp->rest);
|
||||
else
|
||||
LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p]\n", tp->name, tp);
|
||||
LogPrintf(LogTIMER, "StartTimer: Inserting %s timer[%p]\n", tp->name, tp);
|
||||
|
||||
/* Insert given *tp just before *t */
|
||||
tp->next = t;
|
||||
@ -148,12 +148,12 @@ TimerService(void)
|
||||
{
|
||||
struct pppTimer *tp, *exp, *wt;
|
||||
|
||||
if (LogIsKept(LogDEBUG)) {
|
||||
if (LogIsKept(LogTIMER)) {
|
||||
static time_t t;
|
||||
time_t n = time(NULL); /* Only show timers every second */
|
||||
|
||||
if (n > t)
|
||||
ShowTimers(LogDEBUG, NULL);
|
||||
ShowTimers(LogTIMER, NULL);
|
||||
t = n;
|
||||
}
|
||||
tp = TimerList;
|
||||
|
Loading…
Reference in New Issue
Block a user