Deglobalise `struct prompt':
o Our diagnostic socket has its password set in the `set socket' line only (not in ppp.secret). o Passwords are per server socket (*VarAuthKey are gone) o Authority is per prompt (VarLocalAuth is gone). o Local logging is per prompt. o Add a `show who' command to see who's connected. No identd routine - just a `where the connection came from' display. o SIGUSR1 is disabled for now - we have no way of choosing a password for the socket created :-( Prompts are attached as a list of `struct descriptor's in struct bundle, and serviced under the bundles descriptor service routines. Ultimately, everything should be done like this. Cosmetic: o alphabeticalise SRCS in Makefile. o Add a few comments in command.h TODO: Start checking that we don't overflow the descriptor sets in select() now that we can have any number of descriptors.
This commit is contained in:
parent
8390b57662
commit
b6217683dc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35016
@ -1,8 +1,8 @@
|
||||
# $Id: Makefile,v 1.36.2.7 1998/02/15 23:59:34 brian Exp $
|
||||
# $Id: Makefile,v 1.36.2.8 1998/04/03 19:21:03 brian Exp $
|
||||
|
||||
PROG= ppp
|
||||
SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c \
|
||||
deflate.c datalink.c defs.c filter.c fsm.c hdlc.c id.c ip.c \
|
||||
datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c ip.c \
|
||||
ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c mbuf.c modem.c \
|
||||
mp.c pap.c physical.c pred.c prompt.c route.c server.c sig.c \
|
||||
slcompress.c systems.c throughput.c timer.c tun.c vars.c vjcomp.c
|
||||
|
@ -2,7 +2,7 @@
|
||||
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
|
||||
* who places it in the public domain without restriction.
|
||||
*
|
||||
* $Id: alias_cmd.c,v 1.12.2.1 1998/01/29 23:11:30 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.12.2.2 1998/02/10 03:23:05 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -36,7 +36,7 @@ int
|
||||
AliasRedirectPort(struct cmdargs const *arg)
|
||||
{
|
||||
if (!(mode & MODE_ALIAS)) {
|
||||
prompt_Printf(&prompt, "Alias not enabled\n");
|
||||
prompt_Printf(arg->prompt, "Alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == 3) {
|
||||
char proto_constant;
|
||||
@ -54,23 +54,25 @@ AliasRedirectPort(struct cmdargs const *arg)
|
||||
} else if (strcmp(proto, "udp") == 0) {
|
||||
proto_constant = IPPROTO_UDP;
|
||||
} else {
|
||||
prompt_Printf(&prompt, "port redirect: protocol must be tcp or udp\n");
|
||||
prompt_Printf(&prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
prompt_Printf(arg->prompt, "port redirect: protocol must be"
|
||||
" tcp or udp\n");
|
||||
prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = StrToAddrAndPort(arg->argv[1], &local_addr, &local_port, proto);
|
||||
if (error) {
|
||||
prompt_Printf(&prompt, "port redirect: error reading local addr:port\n");
|
||||
prompt_Printf(&prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
prompt_Printf(arg->prompt, "port redirect: error reading"
|
||||
" local addr:port\n");
|
||||
prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
error = StrToPort(arg->argv[2], &alias_port, proto);
|
||||
if (error) {
|
||||
prompt_Printf(&prompt, "port redirect: error reading alias port\n");
|
||||
prompt_Printf(&prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
prompt_Printf(arg->prompt, "port redirect: error reading alias port\n");
|
||||
prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
@ -82,7 +84,7 @@ AliasRedirectPort(struct cmdargs const *arg)
|
||||
proto_constant);
|
||||
|
||||
if (link == NULL)
|
||||
prompt_Printf(&prompt, "port redirect: error returned by packed"
|
||||
prompt_Printf(arg->prompt, "port redirect: error returned by packed"
|
||||
" aliasing engine (code=%d)\n", error);
|
||||
} else
|
||||
return -1;
|
||||
@ -95,7 +97,7 @@ int
|
||||
AliasRedirectAddr(struct cmdargs const *arg)
|
||||
{
|
||||
if (!(mode & MODE_ALIAS)) {
|
||||
prompt_Printf(&prompt, "alias not enabled\n");
|
||||
prompt_Printf(arg->prompt, "alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == 2) {
|
||||
int error;
|
||||
@ -105,21 +107,21 @@ AliasRedirectAddr(struct cmdargs const *arg)
|
||||
|
||||
error = StrToAddr(arg->argv[0], &local_addr);
|
||||
if (error) {
|
||||
prompt_Printf(&prompt, "address redirect: invalid local address\n");
|
||||
prompt_Printf(arg->prompt, "address redirect: invalid local address\n");
|
||||
return 1;
|
||||
}
|
||||
error = StrToAddr(arg->argv[1], &alias_addr);
|
||||
if (error) {
|
||||
prompt_Printf(&prompt, "address redirect: invalid alias address\n");
|
||||
prompt_Printf(&prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
prompt_Printf(arg->prompt, "address redirect: invalid alias address\n");
|
||||
prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
link = VarPacketAliasRedirectAddr(local_addr, alias_addr);
|
||||
if (link == NULL) {
|
||||
prompt_Printf(&prompt, "address redirect: packet aliasing"
|
||||
prompt_Printf(arg->prompt, "address redirect: packet aliasing"
|
||||
" engine error\n");
|
||||
prompt_Printf(&prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name,
|
||||
arg->cmd->syntax);
|
||||
}
|
||||
} else
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.c,v 1.27.2.16 1998/04/03 19:21:06 brian Exp $
|
||||
* $Id: auth.c,v 1.27.2.17 1998/04/03 19:23:52 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Implement check against with registered IP addresses.
|
||||
@ -75,63 +75,6 @@ Auth2Nam(u_short auth)
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void
|
||||
LocalAuthInit()
|
||||
{
|
||||
if (!(mode&MODE_DAEMON))
|
||||
/* We're allowed in interactive mode */
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
else if (VarHaveLocalAuthKey)
|
||||
VarLocalAuth = *VarLocalAuthKey == '\0' ? LOCAL_AUTH : LOCAL_NO_AUTH;
|
||||
else
|
||||
switch (LocalAuthValidate(SECRETFILE, VarShortHost, "")) {
|
||||
case NOT_FOUND:
|
||||
VarLocalAuth = LOCAL_DENY;
|
||||
break;
|
||||
case VALID:
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
break;
|
||||
case INVALID:
|
||||
VarLocalAuth = LOCAL_NO_AUTH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOCAL_AUTH_VALID
|
||||
LocalAuthValidate(const char *fname, const char *system, const char *key)
|
||||
{
|
||||
FILE *fp;
|
||||
int n;
|
||||
char *vector[3];
|
||||
char buff[LINE_LEN];
|
||||
LOCAL_AUTH_VALID rc;
|
||||
|
||||
rc = NOT_FOUND; /* No system entry */
|
||||
fp = OpenSecret(fname);
|
||||
if (fp == NULL)
|
||||
return (rc);
|
||||
while (fgets(buff, sizeof buff, fp)) {
|
||||
if (buff[0] == '#')
|
||||
continue;
|
||||
buff[strlen(buff) - 1] = 0;
|
||||
memset(vector, '\0', sizeof vector);
|
||||
n = MakeArgs(buff, vector, VECSIZE(vector));
|
||||
if (n < 1)
|
||||
continue;
|
||||
if (strcmp(vector[0], system) == 0) {
|
||||
if ((vector[1] == (char *) NULL && (key == NULL || *key == '\0')) ||
|
||||
(vector[1] != (char *) NULL && strcmp(vector[1], key) == 0)) {
|
||||
rc = VALID; /* Valid */
|
||||
} else {
|
||||
rc = INVALID; /* Invalid */
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
CloseSecret(fp);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
auth_CheckPasswd(const char *name, const char *data, const char *key)
|
||||
{
|
||||
|
@ -15,19 +15,13 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.h,v 1.10.2.4 1998/03/01 01:07:38 brian Exp $
|
||||
* $Id: auth.h,v 1.10.2.5 1998/04/03 19:23:52 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
struct physical;
|
||||
|
||||
typedef enum {
|
||||
VALID,
|
||||
INVALID,
|
||||
NOT_FOUND
|
||||
} LOCAL_AUTH_VALID;
|
||||
|
||||
struct authinfo {
|
||||
void (*ChallengeFunc)(struct authinfo *, int, struct physical *);
|
||||
struct pppTimer authtimer;
|
||||
@ -42,11 +36,9 @@ struct authinfo {
|
||||
extern void authinfo_Init(struct authinfo *);
|
||||
|
||||
extern const char *Auth2Nam(u_short);
|
||||
extern LOCAL_AUTH_VALID LocalAuthValidate(const char *, const char *, const char *);
|
||||
extern void StopAuthTimer(struct authinfo *);
|
||||
extern void StartAuthChallenge(struct authinfo *, struct physical *,
|
||||
void (*fn)(struct authinfo *, int, struct physical *));
|
||||
extern void LocalAuthInit(void);
|
||||
extern int AuthValidate(struct bundle *, const char *, const char *,
|
||||
const char *, struct physical *);
|
||||
extern char *AuthGetSecret(struct bundle *, const char *, const char *, int,
|
||||
|
@ -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.34 1998/04/03 19:21:06 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.35 1998/04/03 19:24:56 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -115,7 +115,7 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
|
||||
|
||||
case PHASE_AUTHENTICATE:
|
||||
bundle->phase = new;
|
||||
prompt_Display(&prompt, bundle);
|
||||
bundle_DisplayPrompt(bundle);
|
||||
break;
|
||||
|
||||
case PHASE_NETWORK:
|
||||
@ -126,7 +126,7 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
|
||||
|
||||
case PHASE_TERMINATE:
|
||||
bundle->phase = new;
|
||||
prompt_Display(&prompt, bundle);
|
||||
bundle_DisplayPrompt(bundle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -359,12 +359,16 @@ bundle_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
{
|
||||
struct bundle *bundle = descriptor2bundle(d);
|
||||
struct datalink *dl;
|
||||
struct descriptor *desc;
|
||||
int result;
|
||||
|
||||
result = 0;
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
result += descriptor_UpdateSet(&dl->desc, r, w, e, n);
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
result += descriptor_UpdateSet(desc, r, w, e, n);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -373,11 +377,16 @@ bundle_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
{
|
||||
struct bundle *bundle = descriptor2bundle(d);
|
||||
struct datalink *dl;
|
||||
struct descriptor *desc;
|
||||
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
if (descriptor_IsSet(&dl->desc, fdset))
|
||||
return 1;
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
if (descriptor_IsSet(desc, fdset))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -386,10 +395,15 @@ bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
const fd_set *fdset)
|
||||
{
|
||||
struct datalink *dl;
|
||||
struct descriptor *desc;
|
||||
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
if (descriptor_IsSet(&dl->desc, fdset))
|
||||
descriptor_Read(&dl->desc, bundle, fdset);
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
if (descriptor_IsSet(desc, fdset))
|
||||
descriptor_Read(desc, bundle, fdset);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -397,10 +411,15 @@ bundle_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
|
||||
const fd_set *fdset)
|
||||
{
|
||||
struct datalink *dl;
|
||||
struct descriptor *desc;
|
||||
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
if (descriptor_IsSet(&dl->desc, fdset))
|
||||
descriptor_Write(&dl->desc, bundle, fdset);
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
if (descriptor_IsSet(desc, fdset))
|
||||
descriptor_Write(desc, bundle, fdset);
|
||||
}
|
||||
|
||||
|
||||
@ -412,7 +431,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)
|
||||
bundle_Create(const char *prefix, struct prompt *prompt)
|
||||
{
|
||||
int s, enoentcount, err;
|
||||
struct ifreq ifrq;
|
||||
@ -441,7 +460,7 @@ bundle_Create(const char *prefix)
|
||||
}
|
||||
|
||||
if (bundle.unit > MAX_TUN) {
|
||||
prompt_Printf(&prompt, "No tunnel device is available (%s).\n",
|
||||
prompt_Printf(prompt, "No tunnel device is available (%s).\n",
|
||||
strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
@ -494,7 +513,7 @@ bundle_Create(const char *prefix)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prompt_Printf(&prompt, "Using interface: %s\n", bundle.ifname);
|
||||
prompt_Printf(prompt, "Using interface: %s\n", bundle.ifname);
|
||||
LogPrintf(LogPHASE, "Using interface: %s\n", bundle.ifname);
|
||||
|
||||
bundle.routing_seq = 0;
|
||||
@ -583,6 +602,8 @@ void
|
||||
bundle_Destroy(struct bundle *bundle)
|
||||
{
|
||||
struct datalink *dl;
|
||||
struct descriptor *desc, *ndesc;
|
||||
|
||||
|
||||
if (mode & MODE_AUTO) {
|
||||
IpcpCleanInterface(&bundle->ncp.ipcp.fsm);
|
||||
@ -594,6 +615,18 @@ bundle_Destroy(struct bundle *bundle)
|
||||
dl = datalink_Destroy(dl);
|
||||
|
||||
bundle_Notify(bundle, EX_ERRDEAD);
|
||||
|
||||
desc = bundle->desc.next;
|
||||
while (desc) {
|
||||
ndesc = desc->next;
|
||||
if (desc->type == PROMPT_DESCRIPTOR)
|
||||
prompt_Destroy((struct prompt *)desc, 1);
|
||||
else
|
||||
LogPrintf(LogERROR, "bundle_Destroy: Don't know how to delete descriptor"
|
||||
" type %d\n", desc->type);
|
||||
desc = ndesc;
|
||||
}
|
||||
bundle->desc.next = NULL;
|
||||
bundle->ifname = NULL;
|
||||
}
|
||||
|
||||
@ -760,7 +793,7 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
|
||||
if (!(mode & MODE_AUTO))
|
||||
bundle_DownInterface(bundle);
|
||||
bundle_NewPhase(bundle, PHASE_DEAD);
|
||||
prompt_Display(&prompt, bundle);
|
||||
bundle_DisplayPrompt(bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -845,12 +878,12 @@ int
|
||||
bundle_ShowLinks(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->cx)
|
||||
datalink_Show(arg->cx);
|
||||
datalink_Show(arg->cx, arg->prompt);
|
||||
else {
|
||||
struct datalink *dl;
|
||||
|
||||
for (dl = arg->bundle->links; dl; dl = dl->next)
|
||||
datalink_Show(dl);
|
||||
datalink_Show(dl, arg->prompt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -912,3 +945,81 @@ bundle_IsDead(struct bundle *bundle)
|
||||
{
|
||||
return !bundle->links || (bundle->phase == PHASE_DEAD && bundle->CleaningUp);
|
||||
}
|
||||
|
||||
void
|
||||
bundle_RegisterDescriptor(struct bundle *bundle, struct descriptor *d)
|
||||
{
|
||||
d->next = bundle->desc.next;
|
||||
bundle->desc.next = d;
|
||||
}
|
||||
|
||||
void
|
||||
bundle_UnRegisterDescriptor(struct bundle *bundle, struct descriptor *d)
|
||||
{
|
||||
struct descriptor **desc;
|
||||
|
||||
for (desc = &bundle->desc.next; *desc; desc = &(*desc)->next)
|
||||
if (*desc == d) {
|
||||
*desc = d->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bundle_DelPromptDescriptors(struct bundle *bundle, struct server *s)
|
||||
{
|
||||
struct descriptor **desc;
|
||||
struct prompt *p;
|
||||
|
||||
desc = &bundle->desc.next;
|
||||
while (*desc) {
|
||||
if ((*desc)->type == PROMPT_DESCRIPTOR) {
|
||||
p = (struct prompt *)*desc;
|
||||
if (p->owner == s) {
|
||||
prompt_Destroy(p, 1);
|
||||
desc = &bundle->desc.next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
desc = &(*desc)->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bundle_DisplayPrompt(struct bundle *bundle)
|
||||
{
|
||||
struct descriptor **desc;
|
||||
|
||||
for (desc = &bundle->desc.next; *desc; desc = &(*desc)->next)
|
||||
if ((*desc)->type == PROMPT_DESCRIPTOR)
|
||||
prompt_Required((struct prompt *)*desc);
|
||||
}
|
||||
|
||||
void
|
||||
bundle_WriteTermPrompt(struct bundle *bundle, struct datalink *dl,
|
||||
const char *data, int len)
|
||||
{
|
||||
struct descriptor *desc;
|
||||
struct prompt *p;
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
if (desc->type == PROMPT_DESCRIPTOR) {
|
||||
p = (struct prompt *)desc;
|
||||
if (prompt_IsTermMode(p, dl))
|
||||
prompt_Printf(p, ".*s", len, data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bundle_SetTtyCommandMode(struct bundle *bundle, struct datalink *dl)
|
||||
{
|
||||
struct descriptor *desc;
|
||||
struct prompt *p;
|
||||
|
||||
for (desc = bundle->desc.next; desc; desc = desc->next)
|
||||
if (desc->type == PROMPT_DESCRIPTOR) {
|
||||
p = (struct prompt *)desc;
|
||||
if (prompt_IsTermMode(p, dl))
|
||||
prompt_TtyCommandMode(p);
|
||||
}
|
||||
}
|
||||
|
@ -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.22 1998/04/03 19:21:07 brian Exp $
|
||||
* $Id: bundle.h,v 1.1.2.23 1998/04/03 19:24:41 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHASE_DEAD 0 /* Link is dead */
|
||||
@ -36,6 +36,8 @@
|
||||
struct datalink;
|
||||
struct physical;
|
||||
struct link;
|
||||
struct server;
|
||||
struct prompt;
|
||||
|
||||
struct bundle {
|
||||
struct descriptor desc; /* really all our datalinks */
|
||||
@ -85,7 +87,7 @@ struct bundle {
|
||||
#define descriptor2bundle(d) \
|
||||
((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL)
|
||||
|
||||
extern struct bundle *bundle_Create(const char *);
|
||||
extern struct bundle *bundle_Create(const char *, struct prompt *);
|
||||
extern void bundle_Destroy(struct bundle *);
|
||||
extern const char *bundle_PhaseName(struct bundle *);
|
||||
#define bundle_Phase(b) ((b)->phase)
|
||||
@ -111,3 +113,12 @@ extern struct physical *bundle2physical(struct bundle *, const char *);
|
||||
extern struct datalink *bundle2datalink(struct bundle *, const char *);
|
||||
extern struct authinfo *bundle2pap(struct bundle *, const char *);
|
||||
extern struct chap *bundle2chap(struct bundle *, const char *);
|
||||
|
||||
extern void bundle_RegisterDescriptor(struct bundle *, struct descriptor *);
|
||||
extern void bundle_UnRegisterDescriptor(struct bundle *, struct descriptor *);
|
||||
|
||||
extern void bundle_DelPromptDescriptors(struct bundle *, struct server *);
|
||||
extern void bundle_DisplayPrompt(struct bundle *);
|
||||
extern void bundle_WriteTermPrompt(struct bundle *, struct datalink *,
|
||||
const char *, int);
|
||||
extern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *);
|
||||
|
@ -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.29 1998/04/03 19:21:08 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.30 1998/04/03 19:23:53 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -138,19 +138,19 @@ ccp_ReportStatus(struct cmdargs const *arg)
|
||||
struct link *l = ChooseLink(arg);
|
||||
struct ccp *ccp = &l->ccp;
|
||||
|
||||
prompt_Printf(&prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
|
||||
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
|
||||
State2Nam(ccp->fsm.state));
|
||||
prompt_Printf(&prompt, " My protocol = %s, His protocol = %s\n",
|
||||
prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n",
|
||||
protoname(ccp->my_proto), protoname(ccp->his_proto));
|
||||
prompt_Printf(&prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n",
|
||||
prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n",
|
||||
ccp->uncompout, ccp->compout,
|
||||
ccp->compin, ccp->uncompin);
|
||||
|
||||
prompt_Printf(&prompt, "\n Defaults: ");
|
||||
prompt_Printf(&prompt, "deflate windows: ");
|
||||
prompt_Printf(&prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize);
|
||||
prompt_Printf(&prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize);
|
||||
prompt_Printf(&prompt, " FSM retry = %us\n", ccp->cfg.fsmretry);
|
||||
prompt_Printf(arg->prompt, "\n Defaults: ");
|
||||
prompt_Printf(arg->prompt, "deflate windows: ");
|
||||
prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize);
|
||||
prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize);
|
||||
prompt_Printf(arg->prompt, " FSM retry = %us\n", ccp->cfg.fsmretry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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.48 1998/04/03 19:24:45 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.49 1998/04/03 19:24:58 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -109,19 +109,25 @@ HelpCommand(struct cmdargs const *arg)
|
||||
struct cmdtab const *cmd;
|
||||
int n, cmax, dmax, cols;
|
||||
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "help: Cannot help without a prompt\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg->argc > 0) {
|
||||
for (cmd = arg->cmdtab; cmd->name || cmd->alias; cmd++)
|
||||
if ((cmd->lauth & VarLocalAuth) &&
|
||||
if ((cmd->lauth & arg->prompt->auth) &&
|
||||
((cmd->name && !strcasecmp(cmd->name, *arg->argv)) ||
|
||||
(cmd->alias && !strcasecmp(cmd->alias, *arg->argv)))) {
|
||||
prompt_Printf(&prompt, "%s\n", cmd->syntax);
|
||||
prompt_Printf(arg->prompt, "%s\n", cmd->syntax);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmax = dmax = 0;
|
||||
for (cmd = arg->cmdtab; cmd->func; cmd++)
|
||||
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
|
||||
if (cmd->name && (cmd->lauth & arg->prompt->auth)) {
|
||||
if ((n = strlen(cmd->name)) > cmax)
|
||||
cmax = n;
|
||||
if ((n = strlen(cmd->helpmes)) > dmax)
|
||||
@ -131,20 +137,20 @@ HelpCommand(struct cmdargs const *arg)
|
||||
cols = 80 / (dmax + cmax + 3);
|
||||
n = 0;
|
||||
for (cmd = arg->cmdtab; cmd->func; cmd++)
|
||||
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
|
||||
prompt_Printf(&prompt, " %-*.*s: %-*.*s",
|
||||
if (cmd->name && (cmd->lauth & arg->prompt->auth)) {
|
||||
prompt_Printf(arg->prompt, " %-*.*s: %-*.*s",
|
||||
cmax, cmax, cmd->name, dmax, dmax, cmd->helpmes);
|
||||
if (++n % cols == 0)
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
}
|
||||
if (n % cols != 0)
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
IsInteractive(int Display)
|
||||
IsInteractive(struct prompt *prompt)
|
||||
{
|
||||
const char *m = NULL;
|
||||
|
||||
@ -154,16 +160,14 @@ IsInteractive(int Display)
|
||||
m = "background";
|
||||
else if (mode & MODE_AUTO)
|
||||
m = "auto";
|
||||
else if (mode & MODE_DIRECT)
|
||||
m = "direct";
|
||||
else if (mode & MODE_DEDICATED)
|
||||
m = "dedicated";
|
||||
else if (mode & MODE_INTER)
|
||||
m = "interactive";
|
||||
if (m) {
|
||||
if (Display)
|
||||
prompt_Printf(&prompt, "Working in %s mode\n", m);
|
||||
}
|
||||
|
||||
if (m)
|
||||
prompt_Printf(prompt, "Working in %s mode\n", m);
|
||||
|
||||
return mode & MODE_INTER;
|
||||
}
|
||||
|
||||
@ -207,7 +211,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
* we want to stop shell commands when we've got a telnet connection to an
|
||||
* auto mode ppp
|
||||
*/
|
||||
if (prompt_Active(&prompt) && !(mode & MODE_INTER)) {
|
||||
if (arg->prompt && !(mode & MODE_INTER)) {
|
||||
LogPrintf(LogWARN, "Shell is not allowed interactively in auto mode\n");
|
||||
return 1;
|
||||
}
|
||||
@ -215,7 +219,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
|
||||
if (arg->argc == 0)
|
||||
if (!(mode & MODE_INTER)) {
|
||||
if (prompt_Active(&prompt))
|
||||
if (arg->prompt)
|
||||
LogPrintf(LogWARN, "Can't start an interactive shell from"
|
||||
" a telnet session\n");
|
||||
else
|
||||
@ -240,8 +244,8 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
signal(SIGALRM, SIG_DFL);
|
||||
|
||||
if (prompt_Active(&prompt))
|
||||
fd = prompt.fd_out;
|
||||
if (arg->prompt)
|
||||
fd = arg->prompt->fd_out;
|
||||
else if ((fd = open("/dev/null", O_RDWR)) == -1) {
|
||||
LogPrintf(LogALERT, "Failed to open /dev/null: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
@ -252,7 +256,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
|
||||
close(i);
|
||||
|
||||
prompt_TtyOldMode(&prompt);
|
||||
prompt_TtyOldMode(arg->prompt);
|
||||
setuid(geteuid());
|
||||
if (arg->argc > 0) {
|
||||
/* substitute pseudo args */
|
||||
@ -276,11 +280,11 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
LogPrintf(LogERROR, "%d: daemon: %s\n", p, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
} else if (prompt_Active(&prompt))
|
||||
} else if (arg->prompt)
|
||||
printf("ppp: Pausing until %s finishes\n", arg->argv[0]);
|
||||
execvp(argv[0], argv);
|
||||
} else {
|
||||
if (prompt_Active(&prompt))
|
||||
if (arg->prompt)
|
||||
printf("ppp: Pausing until %s finishes\n", shell);
|
||||
execl(shell, shell, NULL);
|
||||
}
|
||||
@ -297,7 +301,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
waitpid(shpid, &status, 0);
|
||||
}
|
||||
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_TtyCommandMode(arg->prompt);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -353,7 +357,7 @@ static struct cmdtab const Commands[] = {
|
||||
"Link specific commands", "link name command ..."},
|
||||
{"load", NULL, LoadCommand, LOCAL_AUTH,
|
||||
"Load settings", "load [remote]"},
|
||||
{"passwd", NULL, LocalAuthCommand, LOCAL_NO_AUTH,
|
||||
{"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
|
||||
"Password for manipulation", "passwd LocalPassword"},
|
||||
{"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
||||
"Quit PPP program", "quit|bye [all]"},
|
||||
@ -372,26 +376,6 @@ static struct cmdtab const Commands[] = {
|
||||
{NULL, NULL, NULL},
|
||||
};
|
||||
|
||||
static int
|
||||
ShowLogLevel(struct cmdargs const *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
prompt_Printf(&prompt, "Log: ");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKept(i) & LOG_KEPT_SYSLOG)
|
||||
prompt_Printf(&prompt, " %s", LogName(i));
|
||||
|
||||
prompt_Printf(&prompt, "\nLocal:");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKept(i) & LOG_KEPT_LOCAL)
|
||||
prompt_Printf(&prompt, " %s", LogName(i));
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ShowEscape(struct cmdargs const *arg)
|
||||
{
|
||||
@ -403,10 +387,10 @@ ShowEscape(struct cmdargs const *arg)
|
||||
if (arg->cx->physical->async.cfg.EscMap[code])
|
||||
for (bit = 0; bit < 8; bit++)
|
||||
if (arg->cx->physical->async.cfg.EscMap[code] & (1 << bit)) {
|
||||
prompt_Printf(&prompt, "%s0x%02x", sep, (code << 3) + bit);
|
||||
prompt_Printf(arg->prompt, "%s0x%02x", sep, (code << 3) + bit);
|
||||
sep = ", ";
|
||||
}
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -416,10 +400,11 @@ ShowTimeout(struct cmdargs const *arg)
|
||||
{
|
||||
int remaining;
|
||||
|
||||
prompt_Printf(&prompt, "Idle Timer: %ds\n", arg->bundle->cfg.idle_timeout);
|
||||
prompt_Printf(arg->prompt, "Idle Timer: %ds\n",
|
||||
arg->bundle->cfg.idle_timeout);
|
||||
remaining = bundle_RemainingIdleTime(arg->bundle);
|
||||
if (remaining != -1)
|
||||
prompt_Printf(&prompt, "Remaining: %ds\n", remaining);
|
||||
prompt_Printf(arg->prompt, "Remaining: %ds\n", remaining);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -427,28 +412,28 @@ ShowTimeout(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowTimerList(struct cmdargs const *arg)
|
||||
{
|
||||
ShowTimers(0);
|
||||
ShowTimers(0, arg->prompt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ShowStopped(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, " Stopped Timer: LCP: ");
|
||||
prompt_Printf(arg->prompt, " Stopped Timer: LCP: ");
|
||||
if (!arg->cx->physical->link.lcp.fsm.StoppedTimer.load)
|
||||
prompt_Printf(&prompt, "Disabled");
|
||||
prompt_Printf(arg->prompt, "Disabled");
|
||||
else
|
||||
prompt_Printf(&prompt, "%ld secs",
|
||||
prompt_Printf(arg->prompt, "%ld secs",
|
||||
arg->cx->physical->link.lcp.fsm.StoppedTimer.load / SECTICKS);
|
||||
|
||||
prompt_Printf(&prompt, ", CCP: ");
|
||||
prompt_Printf(arg->prompt, ", CCP: ");
|
||||
if (!arg->cx->physical->link.ccp.fsm.StoppedTimer.load)
|
||||
prompt_Printf(&prompt, "Disabled");
|
||||
prompt_Printf(arg->prompt, "Disabled");
|
||||
else
|
||||
prompt_Printf(&prompt, "%ld secs",
|
||||
prompt_Printf(arg->prompt, "%ld secs",
|
||||
arg->cx->physical->link.ccp.fsm.StoppedTimer.load / SECTICKS);
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -456,10 +441,10 @@ ShowStopped(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowAuthKey(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "AuthName = %s\n", arg->bundle->cfg.auth.name);
|
||||
prompt_Printf(&prompt, "AuthKey = %s\n", HIDDEN);
|
||||
prompt_Printf(arg->prompt, "AuthName = %s\n", arg->bundle->cfg.auth.name);
|
||||
prompt_Printf(arg->prompt, "AuthKey = %s\n", HIDDEN);
|
||||
#ifdef HAVE_DES
|
||||
prompt_Printf(&prompt, "Encrypt = %s\n", VarMSChap ? "MSChap" : "MD5" );
|
||||
prompt_Printf(arg->prompt, "Encrypt = %s\n", VarMSChap ? "MSChap" : "MD5" );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -467,7 +452,7 @@ ShowAuthKey(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowVersion(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "%s - %s \n", VarVersion, VarLocalVersion);
|
||||
prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -476,8 +461,8 @@ ShowProtocolStats(struct cmdargs const *arg)
|
||||
{
|
||||
struct link *l = ChooseLink(arg);
|
||||
|
||||
prompt_Printf(&prompt, "%s:\n", l->name);
|
||||
link_ReportProtocolStatus(l);
|
||||
prompt_Printf(arg->prompt, "%s:\n", l->name);
|
||||
link_ReportProtocolStatus(l, arg->prompt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -485,7 +470,7 @@ ShowProtocolStats(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowReconnect(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "%s: Reconnect Timer: %d, %d tries\n",
|
||||
prompt_Printf(arg->prompt, "%s: Reconnect Timer: %d, %d tries\n",
|
||||
arg->cx->name, arg->cx->cfg.reconnect_timeout,
|
||||
arg->cx->cfg.max_reconnect);
|
||||
return 0;
|
||||
@ -494,24 +479,24 @@ ShowReconnect(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowRedial(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, " Redial Timer: ");
|
||||
prompt_Printf(arg->prompt, " Redial Timer: ");
|
||||
|
||||
if (arg->cx->cfg.dial_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->cfg.dial_timeout);
|
||||
prompt_Printf(arg->prompt, " %d seconds, ", arg->cx->cfg.dial_timeout);
|
||||
else
|
||||
prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
prompt_Printf(arg->prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
|
||||
prompt_Printf(&prompt, " Redial Next Timer: ");
|
||||
prompt_Printf(arg->prompt, " Redial Next Timer: ");
|
||||
|
||||
if (arg->cx->cfg.dial_next_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->cfg.dial_next_timeout);
|
||||
prompt_Printf(arg->prompt, " %d seconds, ", arg->cx->cfg.dial_next_timeout);
|
||||
else
|
||||
prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
prompt_Printf(arg->prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
|
||||
if (arg->cx->cfg.max_dial)
|
||||
prompt_Printf(&prompt, "%d dial tries", arg->cx->cfg.max_dial);
|
||||
prompt_Printf(arg->prompt, "%d dial tries", arg->cx->cfg.max_dial);
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -520,14 +505,14 @@ ShowRedial(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowMSExt(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, " MS PPP extention values \n");
|
||||
prompt_Printf(&prompt, " Primary NS : %s\n",
|
||||
prompt_Printf(arg->prompt, " MS PPP extention values \n");
|
||||
prompt_Printf(arg->prompt, " Primary NS : %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[0]));
|
||||
prompt_Printf(&prompt, " Secondary NS : %s\n",
|
||||
prompt_Printf(arg->prompt, " Secondary NS : %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[1]));
|
||||
prompt_Printf(&prompt, " Primary NBNS : %s\n",
|
||||
prompt_Printf(arg->prompt, " Primary NBNS : %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.nbns_entries[0]));
|
||||
prompt_Printf(&prompt, " Secondary NBNS : %s\n",
|
||||
prompt_Printf(arg->prompt, " Secondary NBNS : %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.nbns_entries[1]));
|
||||
|
||||
return 0;
|
||||
@ -554,7 +539,7 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show LCP status", "show lcp"},
|
||||
{"links", "link", bundle_ShowLinks, LOCAL_AUTH,
|
||||
"Show available link names", "show links"},
|
||||
{"log", NULL, ShowLogLevel, LOCAL_AUTH,
|
||||
{"log", NULL, log_ShowLevel, LOCAL_AUTH,
|
||||
"Show log levels", "show log"},
|
||||
{"mem", NULL, ShowMemMap, LOCAL_AUTH,
|
||||
"Show memory map", "show mem"},
|
||||
@ -580,6 +565,8 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show alarm timers", "show timers"},
|
||||
{"version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
|
||||
"Show version string", "show version"},
|
||||
{"who", NULL, log_ShowWho, LOCAL_AUTH,
|
||||
"Show client list", "show who"},
|
||||
{"help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
|
||||
"Display this message", "show help|? [command]", ShowCommands},
|
||||
{NULL, NULL, NULL},
|
||||
@ -619,7 +606,8 @@ FindCommand(struct cmdtab const *cmds, const char *str, int *pmatch)
|
||||
|
||||
static int
|
||||
FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc,
|
||||
char const *const *argv, const char *prefix, struct datalink *cx)
|
||||
char const *const *argv, const char *prefix, struct prompt *prompt,
|
||||
struct datalink *cx)
|
||||
{
|
||||
struct cmdtab const *cmd;
|
||||
int val = 1;
|
||||
@ -629,7 +617,7 @@ FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc,
|
||||
cmd = FindCommand(cmds, *argv, &nmatch);
|
||||
if (nmatch > 1)
|
||||
LogPrintf(LogWARN, "%s%s: Ambiguous command\n", prefix, *argv);
|
||||
else if (cmd && (cmd->lauth & VarLocalAuth)) {
|
||||
else if (cmd && (!prompt || (cmd->lauth & prompt->auth))) {
|
||||
if ((cmd->lauth & LOCAL_CX) && !cx)
|
||||
/* We've got no context, but we require it */
|
||||
cx = bundle2datalink(bundle, NULL);
|
||||
@ -649,6 +637,7 @@ FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc,
|
||||
arg.argv = argv+1;
|
||||
arg.bundle = bundle;
|
||||
arg.cx = cx;
|
||||
arg.prompt = prompt;
|
||||
val = (cmd->func) (&arg);
|
||||
}
|
||||
} else
|
||||
@ -698,7 +687,7 @@ arghidden(int argc, char const *const *argv, int n)
|
||||
|
||||
void
|
||||
RunCommand(struct bundle *bundle, int argc, char const *const *argv,
|
||||
const char *label)
|
||||
struct prompt *prompt, const char *label)
|
||||
{
|
||||
if (argc > 0) {
|
||||
if (LogIsKept(LogCOMMAND)) {
|
||||
@ -723,31 +712,31 @@ RunCommand(struct bundle *bundle, int argc, char const *const *argv,
|
||||
}
|
||||
LogPrintf(LogCOMMAND, "%s\n", buf);
|
||||
}
|
||||
FindExec(bundle, Commands, argc, argv, "", NULL);
|
||||
FindExec(bundle, Commands, argc, argv, "", prompt, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DecodeCommand(struct bundle *bundle, char *buff, int nb, const char *label)
|
||||
DecodeCommand(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
|
||||
const char *label)
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
InterpretCommand(buff, nb, &argc, &argv);
|
||||
RunCommand(bundle, argc, (char const *const *)argv, label);
|
||||
RunCommand(bundle, argc, (char const *const *)argv, prompt, label);
|
||||
}
|
||||
|
||||
static int
|
||||
ShowCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (!prompt_Active(&prompt))
|
||||
if (!arg->prompt)
|
||||
LogPrintf(LogWARN, "show: Cannot show without a prompt\n");
|
||||
else if (arg->argc > 0)
|
||||
FindExec(arg->bundle, ShowCommands, arg->argc, arg->argv, "show ", arg->cx);
|
||||
else if (prompt_Active(&prompt))
|
||||
prompt_Printf(&prompt, "Use ``show ?'' to get a list.\n");
|
||||
FindExec(arg->bundle, ShowCommands, arg->argc, arg->argv, "show ",
|
||||
arg->prompt, arg->cx);
|
||||
else
|
||||
LogPrintf(LogWARN, "show command must have arguments\n");
|
||||
prompt_Printf(arg->prompt, "Use ``show ?'' to get a list.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -755,32 +744,34 @@ ShowCommand(struct cmdargs const *arg)
|
||||
static int
|
||||
TerminalCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "term: Need a prompt\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arg->cx->physical->link.lcp.fsm.state > ST_CLOSED) {
|
||||
prompt_Printf(&prompt, "LCP state is [%s]\n",
|
||||
prompt_Printf(arg->prompt, "LCP state is [%s]\n",
|
||||
State2Nam(arg->cx->physical->link.lcp.fsm.state));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!IsInteractive(1))
|
||||
if (!IsInteractive(arg->prompt))
|
||||
return (1);
|
||||
|
||||
datalink_Up(arg->cx, 0, 0);
|
||||
prompt_Printf(&prompt, "Entering terminal mode.\n");
|
||||
prompt_Printf(&prompt, "Type `~?' for help.\n");
|
||||
prompt_TtyTermMode(&prompt, arg->cx);
|
||||
prompt_TtyTermMode(arg->prompt, arg->cx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
QuitCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (prompt_Active(&prompt)) {
|
||||
prompt_Drop(&prompt, 1);
|
||||
if ((mode & MODE_INTER) ||
|
||||
(arg->argc > 0 && !strcasecmp(*arg->argv, "all") &&
|
||||
(VarLocalAuth & LOCAL_AUTH)))
|
||||
Cleanup(EX_NORMAL);
|
||||
}
|
||||
if (!arg->prompt || prompt_IsController(arg->prompt) ||
|
||||
(arg->argc > 0 && !strcasecmp(*arg->argv, "all") &&
|
||||
(arg->prompt->auth & LOCAL_AUTH)))
|
||||
Cleanup(EX_NORMAL);
|
||||
if (arg->prompt)
|
||||
prompt_Destroy(arg->prompt, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -927,39 +918,28 @@ SetServer(struct cmdargs const *arg)
|
||||
|
||||
/* What's what ? */
|
||||
port = arg->argv[0];
|
||||
if (arg->argc == 2)
|
||||
if (ismask(arg->argv[1])) {
|
||||
passwd = NULL;
|
||||
mask = arg->argv[1];
|
||||
} else {
|
||||
passwd = arg->argv[1];
|
||||
mask = NULL;
|
||||
}
|
||||
else if (arg->argc == 3) {
|
||||
if (arg->argc == 2) {
|
||||
passwd = arg->argv[1];
|
||||
mask = NULL;
|
||||
} else if (arg->argc == 3) {
|
||||
passwd = arg->argv[1];
|
||||
mask = arg->argv[2];
|
||||
if (!ismask(mask))
|
||||
return -1;
|
||||
} else
|
||||
passwd = mask = NULL;
|
||||
|
||||
if (passwd == NULL)
|
||||
VarHaveLocalAuthKey = 0;
|
||||
else {
|
||||
strncpy(VarLocalAuthKey, passwd, sizeof VarLocalAuthKey - 1);
|
||||
VarLocalAuthKey[sizeof VarLocalAuthKey - 1] = '\0';
|
||||
VarHaveLocalAuthKey = 1;
|
||||
}
|
||||
LocalAuthInit();
|
||||
|
||||
if (strcasecmp(port, "none") == 0) {
|
||||
} else if (strcasecmp(port, "none") == 0) {
|
||||
if (mask != NULL || passwd != NULL)
|
||||
return -1;
|
||||
|
||||
if (ServerClose())
|
||||
if (ServerClose(arg->bundle))
|
||||
LogPrintf(LogPHASE, "Disabled server port.\n");
|
||||
res = 0;
|
||||
} else if (*port == '/') {
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
strncpy(server.passwd, passwd, sizeof server.passwd - 1);
|
||||
server.passwd[sizeof server.passwd - 1] = '\0';
|
||||
|
||||
if (*port == '/') {
|
||||
mode_t imask;
|
||||
|
||||
if (mask != NULL) {
|
||||
@ -971,7 +951,7 @@ SetServer(struct cmdargs const *arg)
|
||||
return -1;
|
||||
} else
|
||||
imask = (mode_t)-1;
|
||||
res = ServerLocalOpen(port, imask);
|
||||
res = ServerLocalOpen(arg->bundle, port, imask);
|
||||
} else {
|
||||
int iport;
|
||||
|
||||
@ -988,7 +968,7 @@ SetServer(struct cmdargs const *arg)
|
||||
iport = ntohs(s->s_port);
|
||||
} else
|
||||
iport = atoi(port);
|
||||
res = iport ? ServerTcpOpen(iport) : -1;
|
||||
res = iport ? ServerTcpOpen(arg->bundle, iport) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1001,52 +981,6 @@ SetModemParity(struct cmdargs const *arg)
|
||||
return arg->argc > 0 ? modem_SetParity(arg->cx->physical, *arg->argv) : -1;
|
||||
}
|
||||
|
||||
static int
|
||||
SetLogLevel(struct cmdargs const *arg)
|
||||
{
|
||||
int i;
|
||||
int res;
|
||||
int argc;
|
||||
char const *const *argv, *argp;
|
||||
void (*Discard)(int), (*Keep)(int);
|
||||
void (*DiscardAll)(void);
|
||||
|
||||
argc = arg->argc;
|
||||
argv = arg->argv;
|
||||
res = 0;
|
||||
if (argc == 0 || strcasecmp(argv[0], "local")) {
|
||||
Discard = LogDiscard;
|
||||
Keep = LogKeep;
|
||||
DiscardAll = LogDiscardAll;
|
||||
} else {
|
||||
argc--;
|
||||
argv++;
|
||||
Discard = LogDiscardLocal;
|
||||
Keep = LogKeepLocal;
|
||||
DiscardAll = LogDiscardAllLocal;
|
||||
}
|
||||
|
||||
if (argc == 0 || (argv[0][0] != '+' && argv[0][0] != '-'))
|
||||
DiscardAll();
|
||||
while (argc--) {
|
||||
argp = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (strcasecmp(argp, LogName(i)) == 0) {
|
||||
if (**argv == '-')
|
||||
(*Discard)(i);
|
||||
else
|
||||
(*Keep)(i);
|
||||
break;
|
||||
}
|
||||
if (i > LogMAX) {
|
||||
LogPrintf(LogWARN, "%s: Invalid log value\n", argp);
|
||||
res = -1;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
SetEscape(struct cmdargs const *arg)
|
||||
{
|
||||
@ -1449,7 +1383,7 @@ static struct cmdtab const SetCommands[] = {
|
||||
"Set FSM retry period", "set ipcpretry value", (const void *)VAR_IPCPRETRY},
|
||||
{"lcpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
||||
"Set FSM retry period", "set lcpretry value", (const void *)VAR_LCPRETRY},
|
||||
{"log", NULL, SetLogLevel, LOCAL_AUTH,
|
||||
{"log", NULL, log_SetLevel, LOCAL_AUTH,
|
||||
"Set log level", "set log [local] [+|-]value..."},
|
||||
{"login", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
||||
"Set login script", "set login chat-script", (const void *) VAR_LOGIN},
|
||||
@ -1498,9 +1432,10 @@ static int
|
||||
SetCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc > 0)
|
||||
FindExec(arg->bundle, SetCommands, arg->argc, arg->argv, "set ", arg->cx);
|
||||
else if (prompt_Active(&prompt))
|
||||
prompt_Printf(&prompt, "Use `set ?' to get a list or `set ? <var>' for"
|
||||
FindExec(arg->bundle, SetCommands, arg->argc, arg->argv, "set ",
|
||||
arg->prompt, arg->cx);
|
||||
else if (arg->prompt)
|
||||
prompt_Printf(arg->prompt, "Use `set ?' to get a list or `set ? <var>' for"
|
||||
" syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "set command must have arguments\n");
|
||||
@ -1606,9 +1541,10 @@ static int
|
||||
AliasCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc > 0)
|
||||
FindExec(arg->bundle, AliasCommands, arg->argc, arg->argv, "alias ", arg->cx);
|
||||
else if (prompt_Active(&prompt))
|
||||
prompt_Printf(&prompt, "Use `alias help' to get a list or `alias help"
|
||||
FindExec(arg->bundle, AliasCommands, arg->argc, arg->argv, "alias ",
|
||||
arg->prompt, arg->cx);
|
||||
else if (arg->prompt)
|
||||
prompt_Printf(arg->prompt, "Use `alias help' to get a list or `alias help"
|
||||
" <option>' for syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "alias command must have arguments\n");
|
||||
@ -1678,10 +1614,11 @@ AllowCommand(struct cmdargs const *arg)
|
||||
{
|
||||
/* arg->bundle may be NULL (see ValidSystem()) ! */
|
||||
if (arg->argc > 0)
|
||||
FindExec(arg->bundle, AllowCommands, arg->argc, arg->argv, "allow ", arg->cx);
|
||||
else if (prompt_Active(&prompt))
|
||||
prompt_Printf(&prompt, "Use `allow ?' to get a list or `allow ? <cmd>' for"
|
||||
" syntax help.\n");
|
||||
FindExec(arg->bundle, AllowCommands, arg->argc, arg->argv, "allow ",
|
||||
arg->prompt, arg->cx);
|
||||
else if (arg->prompt)
|
||||
prompt_Printf(arg->prompt, "Use `allow ?' to get a list or `allow ? <cmd>'"
|
||||
" for syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "allow command must have arguments\n");
|
||||
|
||||
@ -1694,7 +1631,8 @@ LinkCommand(struct cmdargs const *arg)
|
||||
if (arg->argc > 1) {
|
||||
struct datalink *cx = bundle2datalink(arg->bundle, arg->argv[0]);
|
||||
if (cx)
|
||||
FindExec(arg->bundle, Commands, arg->argc - 1, arg->argv + 1, "", cx);
|
||||
FindExec(arg->bundle, Commands, arg->argc - 1, arg->argv + 1, "",
|
||||
arg->prompt, cx);
|
||||
else {
|
||||
LogPrintf(LogWARN, "link: %s: Invalid link name\n", arg->argv[0]);
|
||||
return 1;
|
||||
|
@ -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.6 1998/04/03 19:21:15 brian Exp $
|
||||
* $Id: command.h,v 1.12.2.7 1998/04/03 19:23:55 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -25,10 +25,11 @@ struct cmdtab;
|
||||
struct cmdargs {
|
||||
struct cmdtab const *cmdtab; /* The entire command table */
|
||||
struct cmdtab const *cmd; /* This command entry */
|
||||
int argc;
|
||||
char const *const *argv;
|
||||
struct bundle *bundle;
|
||||
struct datalink *cx;
|
||||
int argc; /* Number of arguments (excluding cmd */
|
||||
char const *const *argv; /* Arguments */
|
||||
struct bundle *bundle; /* Our bundle */
|
||||
struct datalink *cx; /* Our context */
|
||||
struct prompt *prompt; /* Who executed us */
|
||||
};
|
||||
|
||||
struct cmdtab {
|
||||
@ -65,8 +66,10 @@ struct cmdtab {
|
||||
extern struct in_addr ifnetmask;
|
||||
extern int aft_cmd;
|
||||
|
||||
extern int IsInteractive(int);
|
||||
extern int IsInteractive(struct prompt *);
|
||||
extern void InterpretCommand(char *, int, int *, char ***);
|
||||
extern void RunCommand(struct bundle *, int, char const *const *, const char *);
|
||||
extern void DecodeCommand(struct bundle *, char *, int, const char *);
|
||||
extern void RunCommand(struct bundle *, int, char const *const *,
|
||||
struct prompt *, const char *);
|
||||
extern void DecodeCommand(struct bundle *, char *, int, struct prompt *,
|
||||
const char *);
|
||||
extern struct link *ChooseLink(struct cmdargs 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.29 1998/04/03 19:21:17 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.30 1998/04/03 19:23:56 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -645,9 +645,9 @@ datalink_StayDown(struct datalink *dl)
|
||||
}
|
||||
|
||||
void
|
||||
datalink_Show(struct datalink *dl)
|
||||
datalink_Show(struct datalink *dl, struct prompt *prompt)
|
||||
{
|
||||
prompt_Printf(&prompt, "Link %s: State %s\n", dl->name, datalink_State(dl));
|
||||
prompt_Printf(prompt, "Link %s: State %s\n", dl->name, datalink_State(dl));
|
||||
}
|
||||
|
||||
static char *states[] = {
|
||||
|
@ -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.12 1998/03/13 21:07:03 brian Exp $
|
||||
* $Id: datalink.h,v 1.1.2.13 1998/04/03 19:21:18 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -94,6 +94,8 @@ struct datalink {
|
||||
#define descriptor2datalink(d) \
|
||||
((d)->type == DATALINK_DESCRIPTOR ? (struct datalink *)(d) : NULL)
|
||||
|
||||
struct prompt;
|
||||
|
||||
extern struct datalink *datalink_Create(const char *name, struct bundle *,
|
||||
const struct fsm_parent *);
|
||||
extern struct datalink *datalink_Destroy(struct datalink *);
|
||||
@ -101,6 +103,6 @@ extern void datalink_Up(struct datalink *, int, int);
|
||||
extern void datalink_Close(struct datalink *, int);
|
||||
extern void datalink_Down(struct datalink *, int);
|
||||
extern void datalink_StayDown(struct datalink *);
|
||||
extern void datalink_Show(struct datalink *);
|
||||
extern void datalink_Show(struct datalink *, struct prompt *);
|
||||
extern void datalink_AuthOk(struct datalink *);
|
||||
extern void datalink_AuthNotOk(struct datalink *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: defs.c,v 1.11.4.4 1998/03/24 18:46:49 brian Exp $
|
||||
* $Id: defs.c,v 1.11.4.5 1998/03/25 18:38:44 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -75,20 +75,3 @@ randinit()
|
||||
srandom(time(NULL)^getpid());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
GetShortHost()
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (gethostname(VarShortHost, sizeof VarShortHost)) {
|
||||
LogPrintf(LogERROR, "GetShortHost: gethostname: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((p = strchr(VarShortHost, '.')))
|
||||
*p = '\0';
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -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.8 1998/04/03 19:21:19 brian Exp $
|
||||
* $Id: defs.h,v 1.29.2.9 1998/04/03 19:23:58 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -85,4 +85,3 @@ extern int mode;
|
||||
extern void SetLabel(const char *);
|
||||
extern const char *GetLabel(void);
|
||||
extern void randinit(void);
|
||||
extern int GetShortHost(void);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: filter.c,v 1.22.2.10 1998/04/03 19:21:19 brian Exp $
|
||||
* $Id: filter.c,v 1.22.2.11 1998/04/03 19:25:00 brian Exp $
|
||||
*
|
||||
* TODO: Shoud send ICMP error message when we discard packets.
|
||||
*/
|
||||
@ -402,35 +402,35 @@ filter_Action2Nam(int act)
|
||||
}
|
||||
|
||||
static void
|
||||
doShowFilter(struct filterent *fp)
|
||||
doShowFilter(struct filterent *fp, struct prompt *prompt)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < MAXFILTERS; n++, fp++) {
|
||||
if (fp->action != A_NONE) {
|
||||
prompt_Printf(&prompt, " %2d %s", n, filter_Action2Nam(fp->action));
|
||||
prompt_Printf(prompt, " %2d %s", n, filter_Action2Nam(fp->action));
|
||||
if (fp->action & A_UHOST)
|
||||
prompt_Printf(&prompt, "host ");
|
||||
prompt_Printf(prompt, "host ");
|
||||
else if (fp->action & A_UPORT)
|
||||
prompt_Printf(&prompt, "port ");
|
||||
prompt_Printf(prompt, "port ");
|
||||
else
|
||||
prompt_Printf(&prompt, " ");
|
||||
prompt_Printf(&prompt, "%s/%d ", inet_ntoa(fp->saddr), fp->swidth);
|
||||
prompt_Printf(&prompt, "%s/%d ", inet_ntoa(fp->daddr), fp->dwidth);
|
||||
prompt_Printf(prompt, " ");
|
||||
prompt_Printf(prompt, "%s/%d ", inet_ntoa(fp->saddr), fp->swidth);
|
||||
prompt_Printf(prompt, "%s/%d ", inet_ntoa(fp->daddr), fp->dwidth);
|
||||
if (fp->proto) {
|
||||
prompt_Printf(&prompt, "%s", filter_Proto2Nam(fp->proto));
|
||||
prompt_Printf(prompt, "%s", filter_Proto2Nam(fp->proto));
|
||||
|
||||
if (fp->opt.srcop)
|
||||
prompt_Printf(&prompt, " src %s %d", filter_Op2Nam(fp->opt.srcop),
|
||||
prompt_Printf(prompt, " src %s %d", filter_Op2Nam(fp->opt.srcop),
|
||||
fp->opt.srcport);
|
||||
if (fp->opt.dstop)
|
||||
prompt_Printf(&prompt, " dst %s %d", filter_Op2Nam(fp->opt.dstop),
|
||||
prompt_Printf(prompt, " dst %s %d", filter_Op2Nam(fp->opt.dstop),
|
||||
fp->opt.dstport);
|
||||
if (fp->opt.estab)
|
||||
prompt_Printf(&prompt, " estab");
|
||||
prompt_Printf(prompt, " estab");
|
||||
|
||||
}
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(prompt, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -454,7 +454,7 @@ ShowFilter(struct cmdargs const *arg)
|
||||
filter = &arg->bundle->filter.alive;
|
||||
else
|
||||
return -1;
|
||||
doShowFilter(filter->rule);
|
||||
doShowFilter(filter->rule, arg->prompt);
|
||||
} else {
|
||||
struct filter *filter[4];
|
||||
int f;
|
||||
@ -465,9 +465,9 @@ ShowFilter(struct cmdargs const *arg)
|
||||
filter[3] = &arg->bundle->filter.alive;
|
||||
for (f = 0; f < 4; f++) {
|
||||
if (f)
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(&prompt, "%s:\n", filter[f]->name);
|
||||
doShowFilter(filter[f]->rule);
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
prompt_Printf(arg->prompt, "%s:\n", filter[f]->name);
|
||||
doShowFilter(filter[f]->rule, arg->prompt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.c,v 1.28.2.21 1998/03/16 22:53:50 brian Exp $
|
||||
* $Id: hdlc.c,v 1.28.2.22 1998/04/03 19:21:22 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -574,15 +574,17 @@ HdlcDetect(struct physical *physical, u_char *cp, int n)
|
||||
int
|
||||
hdlc_ReportStatus(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "HDLC level errors:\n");
|
||||
prompt_Printf(&prompt, " Bad Frame Check Sequence fields: %u\n",
|
||||
arg->cx->physical->hdlc.stats.badfcs);
|
||||
prompt_Printf(&prompt, " Bad address (!= 0x%02x) fields: %u\n",
|
||||
HDLC_ADDR, arg->cx->physical->hdlc.stats.badaddr);
|
||||
prompt_Printf(&prompt, " Bad command (!= 0x%02x) fields: %u\n",
|
||||
HDLC_UI, arg->cx->physical->hdlc.stats.badcommand);
|
||||
prompt_Printf(&prompt, " Unrecognised protocol fields: %u\n",
|
||||
arg->cx->physical->hdlc.stats.unknownproto);
|
||||
struct hdlc *hdlc = &arg->cx->physical->hdlc;
|
||||
|
||||
prompt_Printf(arg->prompt, "HDLC level errors:\n");
|
||||
prompt_Printf(arg->prompt, " Bad Frame Check Sequence fields: %u\n",
|
||||
hdlc->stats.badfcs);
|
||||
prompt_Printf(arg->prompt, " Bad address (!= 0x%02x) fields: %u\n",
|
||||
HDLC_ADDR, hdlc->stats.badaddr);
|
||||
prompt_Printf(arg->prompt, " Bad command (!= 0x%02x) fields: %u\n",
|
||||
HDLC_UI, hdlc->stats.badcommand);
|
||||
prompt_Printf(arg->prompt, " Unrecognised protocol fields: %u\n",
|
||||
hdlc->stats.unknownproto);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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.29 1998/04/03 19:23:59 brian Exp $
|
||||
* $Id: ipcp.c,v 1.50.2.30 1998/04/03 19:25:04 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -142,40 +142,40 @@ ipcp_AddOutOctets(struct ipcp *ipcp, int n)
|
||||
int
|
||||
ReportIpcpStatus(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "%s [%s]\n", arg->bundle->ncp.ipcp.fsm.name,
|
||||
prompt_Printf(arg->prompt, "%s [%s]\n", arg->bundle->ncp.ipcp.fsm.name,
|
||||
State2Nam(arg->bundle->ncp.ipcp.fsm.state));
|
||||
if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED) {
|
||||
prompt_Printf(&prompt, " His side: %s, %s\n",
|
||||
prompt_Printf(arg->prompt, " His side: %s, %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.peer_ip),
|
||||
vj2asc(arg->bundle->ncp.ipcp.peer_compproto));
|
||||
prompt_Printf(&prompt, " My side: %s, %s\n",
|
||||
prompt_Printf(arg->prompt, " My side: %s, %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.my_ip),
|
||||
vj2asc(arg->bundle->ncp.ipcp.my_compproto));
|
||||
}
|
||||
|
||||
prompt_Printf(&prompt, "\nDefaults:\n");
|
||||
prompt_Printf(&prompt, " My Address: %s/%d\n",
|
||||
prompt_Printf(arg->prompt, "\nDefaults:\n");
|
||||
prompt_Printf(arg->prompt, " My Address: %s/%d\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.my_range.ipaddr),
|
||||
arg->bundle->ncp.ipcp.cfg.my_range.width);
|
||||
if (iplist_isvalid(&arg->bundle->ncp.ipcp.cfg.peer_list))
|
||||
prompt_Printf(&prompt, " His Address: %s\n",
|
||||
prompt_Printf(arg->prompt, " His Address: %s\n",
|
||||
arg->bundle->ncp.ipcp.cfg.peer_list.src);
|
||||
else
|
||||
prompt_Printf(&prompt, " His Address: %s/%d\n",
|
||||
prompt_Printf(arg->prompt, " His Address: %s/%d\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.peer_range.ipaddr),
|
||||
arg->bundle->ncp.ipcp.cfg.peer_range.width);
|
||||
if (arg->bundle->ncp.ipcp.cfg.HaveTriggerAddress)
|
||||
prompt_Printf(&prompt, " Negotiation(trigger): %s\n",
|
||||
prompt_Printf(arg->prompt, " Negotiation(trigger): %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.TriggerAddress));
|
||||
else
|
||||
prompt_Printf(&prompt, " Negotiation(trigger): MYADDR\n");
|
||||
prompt_Printf(&prompt, " Initial VJ slots: %d\n",
|
||||
prompt_Printf(arg->prompt, " Negotiation(trigger): MYADDR\n");
|
||||
prompt_Printf(arg->prompt, " Initial VJ slots: %d\n",
|
||||
arg->bundle->ncp.ipcp.cfg.VJInitSlots);
|
||||
prompt_Printf(&prompt, " Initial VJ compression: %s\n",
|
||||
prompt_Printf(arg->prompt, " Initial VJ compression: %s\n",
|
||||
arg->bundle->ncp.ipcp.cfg.VJInitComp ? "on" : "off");
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
throughput_disp(&arg->bundle->ncp.ipcp.throughput);
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
throughput_disp(&arg->bundle->ncp.ipcp.throughput, arg->prompt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -529,12 +529,12 @@ IpcpLayerDown(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (SelectSystem(fp->bundle, s, LINKDOWNFILE) < 0)
|
||||
if (SelectSystem(fp->bundle, s, LINKDOWNFILE, NULL) < 0)
|
||||
if (GetLabel()) {
|
||||
if (SelectSystem(fp->bundle, GetLabel(), LINKDOWNFILE) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE);
|
||||
if (SelectSystem(fp->bundle, GetLabel(), LINKDOWNFILE, NULL) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
} else
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE);
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
|
||||
if (!(mode & MODE_AUTO))
|
||||
IpcpCleanInterface(fp);
|
||||
@ -573,15 +573,15 @@ IpcpLayerUp(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (SelectSystem(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE) < 0)
|
||||
if (SelectSystem(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE, NULL) < 0)
|
||||
if (GetLabel()) {
|
||||
if (SelectSystem(fp->bundle, GetLabel(), LINKUPFILE) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE);
|
||||
if (SelectSystem(fp->bundle, GetLabel(), LINKUPFILE, NULL) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
} else
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE);
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
|
||||
throughput_start(&ipcp->throughput, "IPCP throughput");
|
||||
prompt_Display(&prompt, fp->bundle);
|
||||
bundle_DisplayPrompt(fp->bundle);
|
||||
}
|
||||
|
||||
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.34 1998/04/03 19:21:29 brian Exp $
|
||||
* $Id: lcp.c,v 1.55.2.35 1998/04/03 19:24:01 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Limit data field length by MRU
|
||||
@ -146,31 +146,33 @@ lcp_ReportStatus(struct cmdargs const *arg)
|
||||
struct link *l = ChooseLink(arg);
|
||||
struct lcp *lcp = &l->lcp;
|
||||
|
||||
prompt_Printf(&prompt, "%s: %s [%s]\n", l->name, lcp->fsm.name,
|
||||
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, lcp->fsm.name,
|
||||
State2Nam(lcp->fsm.state));
|
||||
prompt_Printf(&prompt,
|
||||
prompt_Printf(arg->prompt,
|
||||
" his side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n"
|
||||
" MAGIC %08lx, REJECT %04x\n",
|
||||
lcp->his_mru, (u_long)lcp->his_accmap,
|
||||
lcp->his_protocomp, lcp->his_acfcomp,
|
||||
(u_long)lcp->his_magic, lcp->his_reject);
|
||||
prompt_Printf(&prompt,
|
||||
prompt_Printf(arg->prompt,
|
||||
" my side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n"
|
||||
" MAGIC %08lx, REJECT %04x\n",
|
||||
lcp->want_mru, (u_long)lcp->want_accmap,
|
||||
lcp->want_protocomp, lcp->want_acfcomp,
|
||||
(u_long)lcp->want_magic, lcp->my_reject);
|
||||
|
||||
prompt_Printf(&prompt, "\n Defaults: MRU = %d, ", lcp->cfg.mru);
|
||||
prompt_Printf(arg->prompt, "\n Defaults: MRU = %d, ", lcp->cfg.mru);
|
||||
if (l->lcp.cfg.mtu)
|
||||
prompt_Printf(&prompt, "MTU = %d, ", lcp->cfg.mtu);
|
||||
prompt_Printf(&prompt, "ACCMAP = %08lx\n", (u_long)lcp->cfg.accmap);
|
||||
prompt_Printf(&prompt, " LQR period = %us, ", lcp->cfg.lqrperiod);
|
||||
prompt_Printf(&prompt, "Open Mode = %s",
|
||||
prompt_Printf(arg->prompt, "MTU = %d, ", lcp->cfg.mtu);
|
||||
prompt_Printf(arg->prompt, "ACCMAP = %08lx\n", (u_long)lcp->cfg.accmap);
|
||||
prompt_Printf(arg->prompt, " LQR period = %us, ",
|
||||
lcp->cfg.lqrperiod);
|
||||
prompt_Printf(arg->prompt, "Open Mode = %s",
|
||||
lcp->cfg.openmode == OPEN_PASSIVE ? "passive" : "active");
|
||||
if (lcp->cfg.openmode > 0)
|
||||
prompt_Printf(&prompt, " (delay %ds)", lcp->cfg.openmode);
|
||||
prompt_Printf(&prompt, "\n FSM retry = %us\n", lcp->cfg.fsmretry);
|
||||
prompt_Printf(arg->prompt, " (delay %ds)", lcp->cfg.openmode);
|
||||
prompt_Printf(arg->prompt, "\n FSM retry = %us\n",
|
||||
lcp->cfg.fsmretry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: link.c,v 1.1.2.14 1998/03/20 19:48:08 brian Exp $
|
||||
* $Id: link.c,v 1.1.2.15 1998/04/03 19:21:33 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -194,18 +194,18 @@ link_ProtocolRecord(struct link *l, u_short proto, int type)
|
||||
}
|
||||
|
||||
void
|
||||
link_ReportProtocolStatus(struct link *l)
|
||||
link_ReportProtocolStatus(struct link *l, struct prompt *prompt)
|
||||
{
|
||||
int i;
|
||||
|
||||
prompt_Printf(&prompt, " Protocol in out "
|
||||
prompt_Printf(prompt, " Protocol in out "
|
||||
"Protocol in out\n");
|
||||
for (i = 0; i < NPROTOSTAT; i++) {
|
||||
prompt_Printf(&prompt, " %-9s: %8lu, %8lu",
|
||||
prompt_Printf(prompt, " %-9s: %8lu, %8lu",
|
||||
ProtocolStat[i].name, l->proto_in[i], l->proto_out[i]);
|
||||
if ((i % 2) == 0)
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(prompt, "\n");
|
||||
}
|
||||
if (!(i % 2))
|
||||
prompt_Printf(&prompt, "\n");
|
||||
prompt_Printf(prompt, "\n");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: link.h,v 1.1.2.6 1998/02/23 00:38:34 brian Exp $
|
||||
* $Id: link.h,v 1.1.2.7 1998/04/03 19:21:33 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#define NPROTOSTAT 12
|
||||
|
||||
struct bundle;
|
||||
struct prompt;
|
||||
|
||||
struct link {
|
||||
int type; /* _LINK type */
|
||||
@ -65,4 +66,4 @@ extern void link_Output(struct link *, int, struct mbuf *);
|
||||
#define PROTO_IN 1 /* third arg to link_ProtocolRecord */
|
||||
#define PROTO_OUT 2
|
||||
extern void link_ProtocolRecord(struct link *, u_short, int);
|
||||
extern void link_ReportProtocolStatus(struct link *);
|
||||
extern void link_ReportProtocolStatus(struct link *, struct prompt *);
|
||||
|
@ -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 1998/01/21 02:15:18 brian Exp $
|
||||
* $Id: log.c,v 1.25.2.1 1998/02/10 03:23:25 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <termios.h>
|
||||
|
||||
@ -70,6 +71,36 @@ static const char *LogNames[] = {
|
||||
static u_long LogMask = MSK(LogLINK) | MSK(LogCARRIER) | MSK(LogPHASE);
|
||||
static u_long LogMaskLocal = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN);
|
||||
static int LogTunno = -1;
|
||||
static struct prompt *logprompt; /* Where to log local stuff */
|
||||
|
||||
void
|
||||
log_RegisterPrompt(struct prompt *prompt)
|
||||
{
|
||||
if (prompt) {
|
||||
prompt->lognext = logprompt;
|
||||
logprompt = prompt;
|
||||
LogMaskLocal |= prompt->logmask;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
log_UnRegisterPrompt(struct prompt *prompt)
|
||||
{
|
||||
if (prompt) {
|
||||
struct prompt **p;
|
||||
|
||||
LogMaskLocal = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN);
|
||||
for (p = &logprompt; *p; p = &(*p)->lognext) {
|
||||
if (*p == prompt) {
|
||||
*p = (*p)->lognext;
|
||||
prompt->lognext = NULL;
|
||||
if (!*p)
|
||||
break;
|
||||
}
|
||||
LogMaskLocal |= (*p)->logmask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
syslogLevel(int lev)
|
||||
@ -100,10 +131,12 @@ LogKeep(int id)
|
||||
}
|
||||
|
||||
void
|
||||
LogKeepLocal(int id)
|
||||
LogKeepLocal(int id, u_long *mask)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF)
|
||||
if (id >= LogMIN && id <= LogMAXCONF) {
|
||||
LogMaskLocal |= MSK(id);
|
||||
*mask |= MSK(id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -114,10 +147,12 @@ LogDiscard(int id)
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscardLocal(int id)
|
||||
LogDiscardLocal(int id, u_long *mask)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF)
|
||||
if (id >= LogMIN && id <= LogMAXCONF) {
|
||||
LogMaskLocal &= ~MSK(id);
|
||||
*mask &= ~MSK(id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -127,9 +162,9 @@ LogDiscardAll()
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscardAllLocal()
|
||||
LogDiscardAllLocal(u_long *mask)
|
||||
{
|
||||
LogMaskLocal = 0;
|
||||
LogMaskLocal = *mask = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN);
|
||||
}
|
||||
|
||||
int
|
||||
@ -144,6 +179,18 @@ LogIsKept(int id)
|
||||
((LogMask & MSK(id)) ? LOG_KEPT_SYSLOG : 0);
|
||||
}
|
||||
|
||||
int
|
||||
LogIsKeptLocal(int id, u_long mask)
|
||||
{
|
||||
if (id < LogMIN || id > LogMAX)
|
||||
return 0;
|
||||
if (id > LogMAXCONF)
|
||||
return LOG_KEPT_LOCAL | LOG_KEPT_SYSLOG;
|
||||
|
||||
return ((mask & MSK(id)) ? LOG_KEPT_LOCAL : 0) |
|
||||
((LogMask & MSK(id)) ? LOG_KEPT_SYSLOG : 0);
|
||||
}
|
||||
|
||||
void
|
||||
LogOpen(const char *Name)
|
||||
{
|
||||
@ -167,22 +214,25 @@ void
|
||||
LogPrintf(int lev, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
struct prompt *prompt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (LogIsKept(lev)) {
|
||||
static char nfmt[200];
|
||||
|
||||
if ((LogIsKept(lev) & LOG_KEPT_LOCAL) && prompt_Active(&prompt)) {
|
||||
if ((LogIsKept(lev) & LOG_KEPT_LOCAL) && logprompt) {
|
||||
if ((LogIsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1)
|
||||
snprintf(nfmt, sizeof nfmt, "tun%d: %s: %s",
|
||||
LogTunno, LogName(lev), fmt);
|
||||
else
|
||||
snprintf(nfmt, sizeof nfmt, "%s: %s", LogName(lev), fmt);
|
||||
prompt_vPrintf(&prompt, nfmt, ap);
|
||||
|
||||
for (prompt = logprompt; prompt; prompt = prompt->lognext)
|
||||
if (lev > LogMAXCONF || (prompt->logmask & MSK(lev)))
|
||||
prompt_vPrintf(prompt, nfmt, ap);
|
||||
}
|
||||
|
||||
if ((LogIsKept(lev) & LOG_KEPT_SYSLOG) && (lev != LogWARN ||
|
||||
!prompt_Active(&prompt))) {
|
||||
if ((LogIsKept(lev) & LOG_KEPT_SYSLOG) && (lev != LogWARN || !logprompt)) {
|
||||
if ((LogIsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1)
|
||||
snprintf(nfmt, sizeof nfmt, "tun%d: %s: %s",
|
||||
LogTunno, LogName(lev), fmt);
|
||||
@ -246,3 +296,86 @@ LogDumpBuff(int lev, const char *hdr, const u_char * ptr, int n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
log_ShowLevel(struct cmdargs const *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
prompt_Printf(arg->prompt, "Log: ");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKept(i) & LOG_KEPT_SYSLOG)
|
||||
prompt_Printf(arg->prompt, " %s", LogName(i));
|
||||
|
||||
prompt_Printf(arg->prompt, "\nLocal:");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKeptLocal(i, arg->prompt->logmask) & LOG_KEPT_LOCAL)
|
||||
prompt_Printf(arg->prompt, " %s", LogName(i));
|
||||
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
log_SetLevel(struct cmdargs const *arg)
|
||||
{
|
||||
int i, res, argc, local;
|
||||
char const *const *argv, *argp;
|
||||
|
||||
argc = arg->argc;
|
||||
argv = arg->argv;
|
||||
res = 0;
|
||||
|
||||
if (argc == 0 || strcasecmp(argv[0], "local"))
|
||||
local = 0;
|
||||
else {
|
||||
if (arg->prompt == NULL) {
|
||||
LogPrintf(LogWARN, "set log local: Only available on the command line\n");
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
local = 1;
|
||||
}
|
||||
|
||||
if (argc == 0 || (argv[0][0] != '+' && argv[0][0] != '-'))
|
||||
if (local)
|
||||
LogDiscardAllLocal(&arg->prompt->logmask);
|
||||
else
|
||||
LogDiscardAll();
|
||||
|
||||
while (argc--) {
|
||||
argp = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (strcasecmp(argp, LogName(i)) == 0) {
|
||||
if (**argv == '-')
|
||||
if (local)
|
||||
LogDiscardLocal(i, &arg->prompt->logmask);
|
||||
else
|
||||
LogDiscard(i);
|
||||
else if (local)
|
||||
LogKeepLocal(i, &arg->prompt->logmask);
|
||||
else
|
||||
LogKeep(i);
|
||||
break;
|
||||
}
|
||||
if (i > LogMAX) {
|
||||
LogPrintf(LogWARN, "%s: Invalid log value\n", argp);
|
||||
res = -1;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
log_ShowWho(struct cmdargs const *arg)
|
||||
{
|
||||
struct prompt *p;
|
||||
|
||||
for (p = logprompt; p; p = p->lognext)
|
||||
prompt_Printf(arg->prompt, "%s%s\n", p->who, p == arg->prompt ? " *" : "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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 1997/12/21 12:11:07 brian Exp $
|
||||
* $Id: log.h,v 1.18.2.1 1998/02/10 03:23:27 brian Exp $
|
||||
*/
|
||||
|
||||
#define LogMIN (1)
|
||||
@ -54,17 +54,23 @@ struct mbuf;
|
||||
/* The first int arg for all of the following is one of the above values */
|
||||
extern const char *LogName(int);
|
||||
extern void LogKeep(int);
|
||||
extern void LogKeepLocal(int);
|
||||
extern void LogKeepLocal(int, u_long *);
|
||||
extern void LogDiscard(int);
|
||||
extern void LogDiscardLocal(int);
|
||||
extern void LogDiscardLocal(int, u_long *);
|
||||
extern void LogDiscardAll(void);
|
||||
extern void LogDiscardAllLocal(void);
|
||||
extern void LogDiscardAllLocal(u_long *);
|
||||
#define LOG_KEPT_SYSLOG (1) /* Results of LogIsKept() */
|
||||
#define LOG_KEPT_LOCAL (2) /* Results of LogIsKept() */
|
||||
extern int LogIsKept(int);
|
||||
extern int LogIsKeptLocal(int, u_long);
|
||||
extern void LogOpen(const char *);
|
||||
extern void LogSetTun(int);
|
||||
extern void LogClose(void);
|
||||
extern void LogPrintf(int, const char *,...);
|
||||
extern void LogDumpBp(int, const char *, const struct mbuf *);
|
||||
extern void LogDumpBuff(int, const char *, const u_char *, int);
|
||||
extern void log_RegisterPrompt(struct prompt *);
|
||||
extern void log_UnRegisterPrompt(struct prompt *);
|
||||
extern int log_ShowLevel(struct cmdargs const *);
|
||||
extern int log_SetLevel(struct cmdargs const *);
|
||||
extern int log_ShowWho(struct cmdargs const *);
|
||||
|
@ -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.41 1998/04/03 19:24:17 brian Exp $
|
||||
* $Id: main.c,v 1.121.2.42 1998/04/03 19:25:07 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Add commands for traffic summary, version display, etc.
|
||||
@ -94,11 +94,12 @@
|
||||
|
||||
static char pid_filename[MAXPATHLEN];
|
||||
|
||||
static void DoLoop(struct bundle *);
|
||||
static void DoLoop(struct bundle *, struct prompt *);
|
||||
static void TerminalStop(int);
|
||||
static const char *ex_desc(int);
|
||||
|
||||
static struct bundle *SignalBundle;
|
||||
static struct prompt *SignalPrompt;
|
||||
|
||||
void
|
||||
Cleanup(int excode)
|
||||
@ -111,11 +112,9 @@ Cleanup(int excode)
|
||||
void
|
||||
AbortProgram(int excode)
|
||||
{
|
||||
prompt_Drop(&prompt, 1);
|
||||
ServerClose();
|
||||
ServerClose(SignalBundle);
|
||||
ID0unlink(pid_filename);
|
||||
LogPrintf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode));
|
||||
prompt_TtyOldMode(&prompt);
|
||||
bundle_Close(SignalBundle, NULL, 1);
|
||||
bundle_Destroy(SignalBundle);
|
||||
LogClose();
|
||||
@ -156,20 +155,27 @@ TerminalCont(int signo)
|
||||
{
|
||||
pending_signal(SIGCONT, SIG_DFL);
|
||||
pending_signal(SIGTSTP, TerminalStop);
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
if (getpgrp() == prompt_pgrp(&prompt))
|
||||
prompt_Display(&prompt, SignalBundle);
|
||||
if (getpgrp() == prompt_pgrp(SignalPrompt)) {
|
||||
prompt_TtyCommandMode(SignalPrompt);
|
||||
log_RegisterPrompt(SignalPrompt);
|
||||
SignalPrompt->nonewline = 1;
|
||||
prompt_Required(SignalPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
TerminalStop(int signo)
|
||||
{
|
||||
pending_signal(SIGCONT, TerminalCont);
|
||||
prompt_TtyOldMode(&prompt);
|
||||
if (getpgrp() == prompt_pgrp(SignalPrompt)) {
|
||||
prompt_TtyOldMode(SignalPrompt);
|
||||
log_UnRegisterPrompt(SignalPrompt);
|
||||
}
|
||||
pending_signal(SIGTSTP, SIG_DFL);
|
||||
kill(getpid(), signo);
|
||||
}
|
||||
|
||||
#if 0 /* What's our passwd :-O */
|
||||
static void
|
||||
SetUpServer(int signo)
|
||||
{
|
||||
@ -181,13 +187,13 @@ SetUpServer(int signo)
|
||||
LogPrintf(LogERROR, "SIGUSR1: Failed %d to open port %d\n",
|
||||
res, SERVER_PORT + SignalBundle->unit);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
BringDownServer(int signo)
|
||||
{
|
||||
VarHaveLocalAuthKey = 0;
|
||||
LocalAuthInit();
|
||||
ServerClose();
|
||||
/* Drops all child prompts too ! */
|
||||
ServerClose(SignalBundle);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -276,6 +282,7 @@ main(int argc, char **argv)
|
||||
char *name, *label;
|
||||
int nfds;
|
||||
struct bundle *bundle;
|
||||
struct prompt *prompt;
|
||||
|
||||
nfds = getdtablesize();
|
||||
if (nfds >= FD_SETSIZE)
|
||||
@ -311,7 +318,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
prompt_Init(&prompt, (mode & MODE_DIRECT) ? PROMPT_NONE : PROMPT_STD);
|
||||
/* Allow output for the moment (except in direct mode) */
|
||||
if (mode & MODE_DIRECT)
|
||||
prompt = NULL;
|
||||
else
|
||||
SignalPrompt = prompt = prompt_Create(NULL, NULL, PROMPT_STD);
|
||||
|
||||
ID0init();
|
||||
if (ID0realuid() != 0) {
|
||||
@ -329,7 +340,7 @@ main(int argc, char **argv)
|
||||
} while (ptr >= conf);
|
||||
}
|
||||
|
||||
if (!ValidSystem(label)) {
|
||||
if (!ValidSystem(label, prompt)) {
|
||||
fprintf(stderr, "You may not use ppp in this mode with this label\n");
|
||||
if (mode & MODE_DIRECT) {
|
||||
const char *l;
|
||||
@ -340,27 +351,25 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mode & MODE_INTER)
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
|
||||
if ((bundle = bundle_Create("/dev/tun")) == NULL) {
|
||||
if ((bundle = bundle_Create("/dev/tun", prompt)) == NULL) {
|
||||
LogPrintf(LogWARN, "bundle_Create: %s\n", strerror(errno));
|
||||
return EX_START;
|
||||
}
|
||||
|
||||
if (!GetShortHost())
|
||||
return 1;
|
||||
IsInteractive(1);
|
||||
|
||||
SignalBundle = bundle;
|
||||
if (prompt) {
|
||||
prompt->bundle = bundle;
|
||||
bundle_RegisterDescriptor(bundle, &prompt->desc);
|
||||
IsInteractive(prompt);
|
||||
}
|
||||
|
||||
if (SelectSystem(bundle, "default", CONFFILE) < 0)
|
||||
prompt_Printf(&prompt,
|
||||
if (SelectSystem(bundle, "default", CONFFILE, prompt) < 0)
|
||||
prompt_Printf(prompt,
|
||||
"Warning: No default entry is given in config file.\n");
|
||||
|
||||
if ((mode & MODE_OUTGOING_DAEMON) && !(mode & MODE_DEDICATED))
|
||||
if (label == NULL) {
|
||||
prompt_Printf(&prompt, "Destination system must be specified in"
|
||||
prompt_Printf(prompt, "Destination system must be specified in"
|
||||
" auto, background or ddial mode.\n");
|
||||
return EX_START;
|
||||
}
|
||||
@ -385,17 +394,19 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
if (!(mode & MODE_INTER)) {
|
||||
#if 0 /* What's our passwd :-O */
|
||||
#ifdef SIGUSR1
|
||||
pending_signal(SIGUSR1, SetUpServer);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
pending_signal(SIGUSR2, BringDownServer);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (label) {
|
||||
if (SelectSystem(bundle, label, CONFFILE) < 0) {
|
||||
prompt_Printf(&prompt, "Destination system (%s) not found.\n", label);
|
||||
if (SelectSystem(bundle, label, CONFFILE, prompt) < 0) {
|
||||
prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
|
||||
AbortProgram(EX_START);
|
||||
}
|
||||
/*
|
||||
@ -405,7 +416,7 @@ main(int argc, char **argv)
|
||||
SetLabel(label);
|
||||
if (mode & MODE_AUTO &&
|
||||
bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
|
||||
prompt_Printf(&prompt, "You must \"set ifaddr\" in label %s for "
|
||||
prompt_Printf(prompt, "You must \"set ifaddr\" in label %s for "
|
||||
"auto mode.\n", label);
|
||||
AbortProgram(EX_START);
|
||||
}
|
||||
@ -441,13 +452,13 @@ main(int argc, char **argv)
|
||||
|
||||
/* Wait for our child to close its pipe before we exit */
|
||||
if (read(bgpipe[0], &c, 1) != 1) {
|
||||
prompt_Printf(&prompt, "Child exit, no status.\n");
|
||||
prompt_Printf(prompt, "Child exit, no status.\n");
|
||||
LogPrintf(LogPHASE, "Parent: Child exit, no status.\n");
|
||||
} else if (c == EX_NORMAL) {
|
||||
prompt_Printf(&prompt, "PPP enabled.\n");
|
||||
prompt_Printf(prompt, "PPP enabled.\n");
|
||||
LogPrintf(LogPHASE, "Parent: PPP enabled.\n");
|
||||
} else {
|
||||
prompt_Printf(&prompt, "Child failed (%s).\n", ex_desc((int) c));
|
||||
prompt_Printf(prompt, "Child failed (%s).\n", ex_desc((int) c));
|
||||
LogPrintf(LogPHASE, "Parent: Child failed (%s).\n",
|
||||
ex_desc((int) c));
|
||||
}
|
||||
@ -460,22 +471,25 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
prompt_Init(&prompt, PROMPT_NONE);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
if (mode & MODE_DIRECT)
|
||||
if (mode & MODE_DIRECT) {
|
||||
/* STDIN_FILENO gets used by modem_Open in DIRECT mode */
|
||||
prompt_TtyInit(&prompt, PROMPT_DONT_WANT_INT);
|
||||
else if (mode & MODE_DAEMON) {
|
||||
setsid();
|
||||
prompt = prompt_Create(NULL, bundle, PROMPT_STD);
|
||||
prompt_TtyInit(prompt, PROMPT_DONT_WANT_INT);
|
||||
prompt_DestroyUnclean(prompt);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
} else if (mode & MODE_DAEMON) {
|
||||
prompt_Destroy(prompt, 0);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
close(STDIN_FILENO);
|
||||
setsid();
|
||||
}
|
||||
} else {
|
||||
close(STDERR_FILENO);
|
||||
prompt_TtyInit(&prompt, PROMPT_WANT_INT);
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_Display(&prompt, bundle);
|
||||
prompt_TtyInit(prompt, PROMPT_WANT_INT);
|
||||
prompt_TtyCommandMode(prompt);
|
||||
prompt_Required(prompt);
|
||||
}
|
||||
|
||||
snprintf(pid_filename, sizeof pid_filename, "%stun%d.pid",
|
||||
@ -495,7 +509,7 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
do
|
||||
DoLoop(bundle);
|
||||
DoLoop(bundle, prompt);
|
||||
while (mode & MODE_DEDICATED);
|
||||
|
||||
AbortProgram(EX_NORMAL);
|
||||
@ -504,7 +518,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
static void
|
||||
DoLoop(struct bundle *bundle)
|
||||
DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
{
|
||||
fd_set rfds, wfds, efds;
|
||||
int pri, i, n, nfds;
|
||||
@ -534,8 +548,6 @@ DoLoop(struct bundle *bundle)
|
||||
FD_SET(bundle->tun_fd, &rfds);
|
||||
}
|
||||
|
||||
descriptor_UpdateSet(&prompt.desc, &rfds, &wfds, &efds, &nfds);
|
||||
|
||||
if (bundle_IsDead(bundle))
|
||||
/* Don't select - we'll be here forever */
|
||||
break;
|
||||
@ -563,9 +575,6 @@ DoLoop(struct bundle *bundle)
|
||||
if (descriptor_IsSet(&server.desc, &rfds))
|
||||
descriptor_Read(&server.desc, bundle, &rfds);
|
||||
|
||||
if (descriptor_IsSet(&prompt.desc, &rfds))
|
||||
descriptor_Read(&prompt.desc, bundle, &rfds);
|
||||
|
||||
if (descriptor_IsSet(&bundle->desc, &wfds))
|
||||
descriptor_Write(&bundle->desc, bundle, &wfds);
|
||||
|
||||
@ -644,6 +653,5 @@ DoLoop(struct bundle *bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
prompt_Printf(&prompt, "\n");
|
||||
LogPrintf(LogDEBUG, "Job (DoLoop) done.\n");
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: mbuf.c,v 1.13.2.5 1998/02/16 00:00:42 brian Exp $
|
||||
* $Id: mbuf.c,v 1.13.2.6 1998/04/03 19:21:38 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -158,7 +158,7 @@ ShowMemMap(struct cmdargs const *arg)
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= MB_MAX; i += 2)
|
||||
prompt_Printf(&prompt, "%d: %d %d: %d\n",
|
||||
prompt_Printf(arg->prompt, "%d: %d %d: %d\n",
|
||||
i, MemMap[i].count, i + 1, MemMap[i + 1].count);
|
||||
|
||||
return 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.41 1998/03/21 22:58:43 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.42 1998/04/03 19:21:40 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -777,9 +777,7 @@ modem_Hangup(struct physical *modem, int dedicated_force)
|
||||
if (modem->fd >= 0) {
|
||||
StopTimer(&modem->link.Timer);
|
||||
throughput_stop(&modem->link.throughput);
|
||||
|
||||
if (prompt_IsTermMode(&prompt))
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
bundle_SetTtyCommandMode(modem->dl->bundle, modem->dl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -893,61 +891,62 @@ int
|
||||
modem_ShowStatus(struct cmdargs const *arg)
|
||||
{
|
||||
const char *dev;
|
||||
struct physical *modem = arg->cx->physical;
|
||||
#ifdef TIOCOUTQ
|
||||
int nb;
|
||||
#endif
|
||||
|
||||
dev = *arg->cx->physical->name.full ?
|
||||
arg->cx->physical->name.full : "stdin";
|
||||
dev = *modem->name.full ?
|
||||
modem->name.full : "stdin";
|
||||
|
||||
prompt_Printf(&prompt, "device list: %s\n", arg->cx->physical->cfg.devlist);
|
||||
prompt_Printf(&prompt, "device: %s\n ", dev);
|
||||
prompt_Printf(arg->prompt, "device list: %s\n", modem->cfg.devlist);
|
||||
prompt_Printf(arg->prompt, "device: %s\n ", dev);
|
||||
if (Physical_IsSync(arg->cx->physical))
|
||||
prompt_Printf(&prompt, "sync");
|
||||
prompt_Printf(arg->prompt, "sync");
|
||||
else
|
||||
prompt_Printf(&prompt, "%dbps", arg->cx->physical->cfg.speed);
|
||||
prompt_Printf(arg->prompt, "%dbps", modem->cfg.speed);
|
||||
|
||||
switch (arg->cx->physical->cfg.parity & CSIZE) {
|
||||
switch (modem->cfg.parity & CSIZE) {
|
||||
case CS7:
|
||||
prompt_Printf(&prompt, ", cs7");
|
||||
prompt_Printf(arg->prompt, ", cs7");
|
||||
break;
|
||||
case CS8:
|
||||
prompt_Printf(&prompt, ", cs8");
|
||||
prompt_Printf(arg->prompt, ", cs8");
|
||||
break;
|
||||
}
|
||||
if (arg->cx->physical->cfg.parity & PARENB) {
|
||||
if (arg->cx->physical->cfg.parity & PARODD)
|
||||
prompt_Printf(&prompt, ", odd parity");
|
||||
if (modem->cfg.parity & PARENB) {
|
||||
if (modem->cfg.parity & PARODD)
|
||||
prompt_Printf(arg->prompt, ", odd parity");
|
||||
else
|
||||
prompt_Printf(&prompt, ", even parity");
|
||||
prompt_Printf(arg->prompt, ", even parity");
|
||||
} else
|
||||
prompt_Printf(&prompt, ", no parity");
|
||||
prompt_Printf(arg->prompt, ", no parity");
|
||||
|
||||
prompt_Printf(&prompt, ", CTS/RTS %s\n",
|
||||
(arg->cx->physical->cfg.rts_cts ? "on" : "off"));
|
||||
prompt_Printf(arg->prompt, ", CTS/RTS %s\n",
|
||||
(modem->cfg.rts_cts ? "on" : "off"));
|
||||
|
||||
if (LogIsKept(LogDEBUG))
|
||||
prompt_Printf(&prompt, "fd = %d, modem control = %o\n",
|
||||
arg->cx->physical->fd, arg->cx->physical->mbits);
|
||||
prompt_Printf(&prompt, "connect count: %d\n",
|
||||
arg->cx->physical->connect_count);
|
||||
prompt_Printf(arg->prompt, "fd = %d, modem control = %o\n",
|
||||
modem->fd, modem->mbits);
|
||||
prompt_Printf(arg->prompt, "connect count: %d\n",
|
||||
modem->connect_count);
|
||||
#ifdef TIOCOUTQ
|
||||
if (arg->cx->physical->fd >= 0)
|
||||
if (ioctl(arg->cx->physical->fd, TIOCOUTQ, &nb) >= 0)
|
||||
prompt_Printf(&prompt, "outq: %d\n", nb);
|
||||
if (modem->fd >= 0)
|
||||
if (ioctl(modem->fd, TIOCOUTQ, &nb) >= 0)
|
||||
prompt_Printf(arg->prompt, "outq: %d\n", nb);
|
||||
else
|
||||
prompt_Printf(&prompt, "outq: ioctl probe failed: %s\n", strerror(errno));
|
||||
prompt_Printf(arg->prompt, "outq: ioctl probe failed: %s\n", strerror(errno));
|
||||
#endif
|
||||
prompt_Printf(&prompt, "outq packets: %d\n",
|
||||
link_QueueLen(&arg->cx->physical->link));
|
||||
prompt_Printf(&prompt, "Dial Script: %s\n", arg->cx->cfg.script.dial);
|
||||
prompt_Printf(&prompt, "Login Script: %s\n", arg->cx->cfg.script.login);
|
||||
prompt_Printf(&prompt, "Hangup Script: %s\n", arg->cx->cfg.script.hangup);
|
||||
prompt_Printf(&prompt, "Phone List: %s\n", arg->cx->cfg.phone.list);
|
||||
prompt_Printf(&prompt, "Phone Number: %s\n", arg->cx->phone.chosen);
|
||||
prompt_Printf(arg->prompt, "outq packets: %d\n",
|
||||
link_QueueLen(&modem->link));
|
||||
prompt_Printf(arg->prompt, "Dial Script: %s\n", arg->cx->cfg.script.dial);
|
||||
prompt_Printf(arg->prompt, "Login Script: %s\n", arg->cx->cfg.script.login);
|
||||
prompt_Printf(arg->prompt, "Hangup Script: %s\n", arg->cx->cfg.script.hangup);
|
||||
prompt_Printf(arg->prompt, "Phone List: %s\n", arg->cx->cfg.phone.list);
|
||||
prompt_Printf(arg->prompt, "Phone Number: %s\n", arg->cx->phone.chosen);
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
throughput_disp(&arg->cx->physical->link.throughput);
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
throughput_disp(&modem->link.throughput, arg->prompt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1000,7 +999,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
}
|
||||
datalink_Up(bundle2datalink(bundle, p->link.name), 0, 1);
|
||||
} else
|
||||
prompt_Printf(&prompt, "%.*s", n, rbuff);
|
||||
bundle_WriteTermPrompt(p->dl->bundle, p->dl, rbuff, n);
|
||||
}
|
||||
} else if (n > 0)
|
||||
async_Input(bundle, rbuff, n, p);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.97.2.9 1998/04/03 19:24:21 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.97.2.10 1998/04/03 19:24:31 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -2460,7 +2460,7 @@ or
|
||||
packets are sent. The default is 30 seconds. You must also use the
|
||||
.Dq enable lqr
|
||||
command if you wish to send LQR requests to the peer.
|
||||
.It set server|socket TcpPort|LocalName|none [password] [mask]
|
||||
.It set server|socket TcpPort|LocalName|none password [mask]
|
||||
This command tells
|
||||
.Nm
|
||||
to listen on the given socket or
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: prompt.c,v 1.1.2.16 1998/03/20 19:48:19 brian Exp $
|
||||
* $Id: prompt.c,v 1.1.2.17 1998/04/03 19:21:50 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -33,6 +33,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <termios.h>
|
||||
@ -67,8 +69,50 @@
|
||||
#include "chat.h"
|
||||
#include "chap.h"
|
||||
#include "datalink.h"
|
||||
#include "server.h"
|
||||
|
||||
static int prompt_nonewline = 1;
|
||||
static void
|
||||
prompt_Display(struct prompt *p)
|
||||
{
|
||||
static char shostname[MAXHOSTNAMELEN];
|
||||
const char *pconnect, *pauth;
|
||||
|
||||
if (p->TermMode || !p->needprompt)
|
||||
return;
|
||||
|
||||
p->needprompt = 0;
|
||||
|
||||
if (p->nonewline)
|
||||
p->nonewline = 0;
|
||||
else
|
||||
fprintf(p->Term, "\n");
|
||||
|
||||
if (p->auth == LOCAL_AUTH)
|
||||
pauth = " ON ";
|
||||
else
|
||||
pauth = " on ";
|
||||
|
||||
if (p->bundle->ncp.ipcp.fsm.state == ST_OPENED)
|
||||
pconnect = "PPP";
|
||||
else if (bundle_Phase(p->bundle) == PHASE_NETWORK)
|
||||
pconnect = "PPp";
|
||||
else if (bundle_Phase(p->bundle) == PHASE_AUTHENTICATE)
|
||||
pconnect = "Ppp";
|
||||
else
|
||||
pconnect = "ppp";
|
||||
|
||||
if (*shostname == '\0') {
|
||||
char *p;
|
||||
|
||||
if (gethostname(shostname, sizeof shostname))
|
||||
strcpy(shostname, "localhost");
|
||||
else if ((p = strchr(shostname, '.')))
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
fprintf(p->Term, "%s%s%s> ", pconnect, pauth, shostname);
|
||||
fflush(p->Term);
|
||||
}
|
||||
|
||||
static int
|
||||
prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
@ -90,6 +134,8 @@ prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
*n = p->fd_in + 1;
|
||||
}
|
||||
|
||||
prompt_Display(p);
|
||||
|
||||
return sets;
|
||||
}
|
||||
|
||||
@ -133,13 +179,14 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
linebuff[--n] = '\0';
|
||||
else
|
||||
linebuff[n] = '\0';
|
||||
prompt_nonewline = 1; /* In case DecodeCommand does a prompt */
|
||||
p->nonewline = 1; /* Maybe DecodeCommand does a prompt */
|
||||
prompt_Required(p);
|
||||
if (n)
|
||||
DecodeCommand(bundle, linebuff, n, IsInteractive(0) ? NULL : "Client");
|
||||
prompt_Display(&prompt, bundle);
|
||||
DecodeCommand(bundle, linebuff, n, p,
|
||||
IsInteractive(NULL) ? NULL : "Client");
|
||||
} else if (n <= 0) {
|
||||
LogPrintf(LogPHASE, "Client connection closed.\n");
|
||||
prompt_Drop(&prompt, 0);
|
||||
prompt_Destroy(p, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -147,9 +194,9 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
switch (p->TermMode->state) {
|
||||
case DATALINK_CLOSED:
|
||||
prompt_Printf(p, "Link lost, terminal mode.\n");
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_nonewline = 0;
|
||||
prompt_Display(&prompt, bundle);
|
||||
prompt_TtyCommandMode(p);
|
||||
p->nonewline = 0;
|
||||
prompt_Required(p);
|
||||
return;
|
||||
|
||||
case DATALINK_READY:
|
||||
@ -157,8 +204,8 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
|
||||
case DATALINK_OPEN:
|
||||
prompt_Printf(p, "\nPacket mode detected.\n");
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_nonewline = 0;
|
||||
prompt_TtyCommandMode(p);
|
||||
p->nonewline = 0;
|
||||
/* We'll get a prompt because of our status change */
|
||||
/* Fall through */
|
||||
|
||||
@ -190,15 +237,15 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
case 'p':
|
||||
datalink_Up(p->TermMode, 0, 1);
|
||||
prompt_Printf(p, "\nPacket mode.\n");
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_TtyCommandMode(p);
|
||||
break;
|
||||
case '.':
|
||||
prompt_TtyCommandMode(&prompt);
|
||||
prompt_nonewline = 0;
|
||||
prompt_Display(&prompt, bundle);
|
||||
prompt_TtyCommandMode(p);
|
||||
p->nonewline = 0;
|
||||
prompt_Required(p);
|
||||
break;
|
||||
case 't':
|
||||
ShowTimers(0);
|
||||
ShowTimers(0, p);
|
||||
break;
|
||||
case 'm':
|
||||
ShowMemMap(NULL);
|
||||
@ -221,97 +268,74 @@ prompt_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
LogPrintf(LogERROR, "prompt_Write: Internal error: Bad call !\n");
|
||||
}
|
||||
|
||||
struct prompt prompt = {
|
||||
{
|
||||
PROMPT_DESCRIPTOR,
|
||||
NULL,
|
||||
prompt_UpdateSet,
|
||||
prompt_IsSet,
|
||||
prompt_Read,
|
||||
prompt_Write
|
||||
},
|
||||
-1,
|
||||
-1,
|
||||
NULL
|
||||
};
|
||||
|
||||
int
|
||||
prompt_Init(struct prompt *p, int fd)
|
||||
struct prompt *
|
||||
prompt_Create(struct server *s, struct bundle *bundle, int fd)
|
||||
{
|
||||
if (p->Term && p->Term != stdout)
|
||||
return 0; /* must prompt_Drop() first */
|
||||
struct prompt *p = (struct prompt *)malloc(sizeof(struct prompt));
|
||||
|
||||
if (fd == PROMPT_NONE) {
|
||||
p->fd_in = p->fd_out = -1;
|
||||
p->Term = NULL;
|
||||
} else if (fd == PROMPT_STD) {
|
||||
p->fd_in = STDIN_FILENO;
|
||||
p->fd_out = STDOUT_FILENO;
|
||||
p->Term = stdout;
|
||||
} else {
|
||||
p->fd_in = p->fd_out = fd;
|
||||
p->Term = fdopen(fd, "a+");
|
||||
if (p != NULL) {
|
||||
p->desc.type = PROMPT_DESCRIPTOR;
|
||||
p->desc.next = NULL;
|
||||
p->desc.UpdateSet = prompt_UpdateSet;
|
||||
p->desc.IsSet = prompt_IsSet;
|
||||
p->desc.Read = prompt_Read;
|
||||
p->desc.Write = prompt_Write;
|
||||
|
||||
if (fd == PROMPT_STD) {
|
||||
p->fd_in = STDIN_FILENO;
|
||||
p->fd_out = STDOUT_FILENO;
|
||||
p->Term = stdout;
|
||||
p->owner = NULL;
|
||||
p->auth = LOCAL_AUTH;
|
||||
snprintf(p->who, sizeof p->who, "Controller (%s)", ttyname(p->fd_out));
|
||||
tcgetattr(p->fd_in, &p->oldtio); /* Save original tty mode */
|
||||
} else {
|
||||
p->fd_in = p->fd_out = fd;
|
||||
p->Term = fdopen(fd, "a+");
|
||||
p->owner = s;
|
||||
p->auth = *s->passwd ? LOCAL_NO_AUTH : LOCAL_AUTH;
|
||||
*p->who = '\0';
|
||||
}
|
||||
p->TermMode = NULL;
|
||||
p->nonewline = 1;
|
||||
p->needprompt = 1;
|
||||
p->bundle = bundle;
|
||||
if (p->bundle)
|
||||
bundle_RegisterDescriptor(p->bundle, &p->desc);
|
||||
log_RegisterPrompt(p);
|
||||
}
|
||||
p->TermMode = NULL;
|
||||
tcgetattr(STDIN_FILENO, &p->oldtio); /* Save original tty mode */
|
||||
|
||||
return 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
prompt_Display(struct prompt *p, struct bundle *bundle)
|
||||
prompt_DestroyUnclean(struct prompt *p)
|
||||
{
|
||||
const char *pconnect, *pauth;
|
||||
|
||||
if (!p->Term || p->TermMode != NULL)
|
||||
return;
|
||||
|
||||
if (prompt_nonewline)
|
||||
prompt_nonewline = 0;
|
||||
else
|
||||
fprintf(p->Term, "\n");
|
||||
|
||||
if (VarLocalAuth == LOCAL_AUTH)
|
||||
pauth = " ON ";
|
||||
else
|
||||
pauth = " on ";
|
||||
|
||||
if (bundle->ncp.ipcp.fsm.state == ST_OPENED)
|
||||
pconnect = "PPP";
|
||||
else if (bundle_Phase(bundle) == PHASE_NETWORK)
|
||||
pconnect = "PPp";
|
||||
else if (bundle_Phase(bundle) == PHASE_AUTHENTICATE)
|
||||
pconnect = "Ppp";
|
||||
else
|
||||
pconnect = "ppp";
|
||||
|
||||
fprintf(p->Term, "%s%s%s> ", pconnect, pauth, VarShortHost);
|
||||
fflush(p->Term);
|
||||
log_UnRegisterPrompt(p);
|
||||
bundle_UnRegisterDescriptor(p->bundle, &p->desc);
|
||||
free(p);
|
||||
}
|
||||
|
||||
void
|
||||
prompt_Drop(struct prompt *p, int verbose)
|
||||
prompt_Destroy(struct prompt *p, int verbose)
|
||||
{
|
||||
if (p->Term && p->Term != stdout) {
|
||||
FILE *oVarTerm;
|
||||
|
||||
oVarTerm = p->Term;
|
||||
p->Term = NULL;
|
||||
if (oVarTerm)
|
||||
fclose(oVarTerm);
|
||||
if (p->Term != stdout) {
|
||||
fclose(p->Term);
|
||||
close(p->fd_in);
|
||||
if (p->fd_out != p->fd_in)
|
||||
close(p->fd_out);
|
||||
p->fd_in = p->fd_out = -1;
|
||||
if (verbose)
|
||||
LogPrintf(LogPHASE, "Client connection dropped.\n");
|
||||
}
|
||||
} else
|
||||
prompt_TtyOldMode(p);
|
||||
|
||||
prompt_DestroyUnclean(p);
|
||||
}
|
||||
|
||||
void
|
||||
prompt_Printf(struct prompt *p, const char *fmt,...)
|
||||
{
|
||||
if (p->Term) {
|
||||
if (p) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@ -324,7 +348,7 @@ prompt_Printf(struct prompt *p, const char *fmt,...)
|
||||
void
|
||||
prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
|
||||
{
|
||||
if (p->Term) {
|
||||
if (p) {
|
||||
vfprintf(p->Term, fmt, ap);
|
||||
fflush(p->Term);
|
||||
}
|
||||
@ -333,26 +357,30 @@ prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
|
||||
void
|
||||
prompt_TtyInit(struct prompt *p, int DontWantInt)
|
||||
{
|
||||
struct termios newtio;
|
||||
int stat;
|
||||
|
||||
stat = fcntl(p->fd_in, F_GETFL, 0);
|
||||
if (stat > 0) {
|
||||
stat |= O_NONBLOCK;
|
||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||
fcntl(p->fd_in, F_SETFL, stat);
|
||||
}
|
||||
|
||||
if (p->Term == stdout) {
|
||||
struct termios newtio;
|
||||
|
||||
newtio = p->oldtio;
|
||||
newtio.c_lflag &= ~(ECHO | ISIG | ICANON);
|
||||
newtio.c_iflag = 0;
|
||||
newtio.c_oflag &= ~OPOST;
|
||||
newtio.c_cc[VEOF] = _POSIX_VDISABLE;
|
||||
if (DontWantInt)
|
||||
newtio.c_cc[VINTR] = _POSIX_VDISABLE;
|
||||
newtio.c_cc[VMIN] = 1;
|
||||
newtio.c_cc[VTIME] = 0;
|
||||
newtio.c_cflag |= CS8;
|
||||
tcsetattr(p->fd_in, TCSANOW, &newtio);
|
||||
p->comtio = newtio;
|
||||
}
|
||||
newtio = p->oldtio;
|
||||
newtio.c_lflag &= ~(ECHO | ISIG | ICANON);
|
||||
newtio.c_iflag = 0;
|
||||
newtio.c_oflag &= ~OPOST;
|
||||
newtio.c_cc[VEOF] = _POSIX_VDISABLE;
|
||||
if (DontWantInt)
|
||||
newtio.c_cc[VINTR] = _POSIX_VDISABLE;
|
||||
newtio.c_cc[VMIN] = 1;
|
||||
newtio.c_cc[VTIME] = 0;
|
||||
newtio.c_cflag |= CS8;
|
||||
tcsetattr(p->fd_in, TCSANOW, &newtio);
|
||||
p->comtio = newtio;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -364,19 +392,18 @@ prompt_TtyCommandMode(struct prompt *p)
|
||||
struct termios newtio;
|
||||
int stat;
|
||||
|
||||
if (!(mode & MODE_INTER))
|
||||
return;
|
||||
|
||||
tcgetattr(p->fd_in, &newtio);
|
||||
newtio.c_lflag |= (ECHO | ISIG | ICANON);
|
||||
newtio.c_iflag = p->oldtio.c_iflag;
|
||||
newtio.c_oflag |= OPOST;
|
||||
tcsetattr(p->fd_in, TCSADRAIN, &newtio);
|
||||
|
||||
stat = fcntl(p->fd_in, F_GETFL, 0);
|
||||
if (stat > 0) {
|
||||
stat |= O_NONBLOCK;
|
||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||
fcntl(p->fd_in, F_SETFL, stat);
|
||||
}
|
||||
|
||||
p->TermMode = NULL;
|
||||
}
|
||||
|
||||
@ -388,11 +415,16 @@ prompt_TtyTermMode(struct prompt *p, struct datalink *dl)
|
||||
{
|
||||
int stat;
|
||||
|
||||
tcsetattr(p->fd_in, TCSADRAIN, &p->comtio);
|
||||
prompt_Printf(p, "Entering terminal mode on %s.\n", dl->name);
|
||||
prompt_Printf(p, "Type `~?' for help.\n");
|
||||
|
||||
if (p->Term == stdout)
|
||||
tcsetattr(p->fd_in, TCSADRAIN, &p->comtio);
|
||||
|
||||
stat = fcntl(p->fd_in, F_GETFL, 0);
|
||||
if (stat > 0) {
|
||||
stat &= ~O_NONBLOCK;
|
||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||
fcntl(p->fd_in, F_SETFL, stat);
|
||||
}
|
||||
p->TermMode = dl;
|
||||
}
|
||||
@ -405,13 +437,45 @@ prompt_TtyOldMode(struct prompt *p)
|
||||
stat = fcntl(p->fd_in, F_GETFL, 0);
|
||||
if (stat > 0) {
|
||||
stat &= ~O_NONBLOCK;
|
||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||
fcntl(p->fd_in, F_SETFL, stat);
|
||||
}
|
||||
tcsetattr(p->fd_in, TCSADRAIN, &p->oldtio);
|
||||
|
||||
if (p->Term == stdout)
|
||||
tcsetattr(p->fd_in, TCSADRAIN, &p->oldtio);
|
||||
}
|
||||
|
||||
pid_t
|
||||
prompt_pgrp(struct prompt *p)
|
||||
{
|
||||
return p->Term ? tcgetpgrp(p->fd_in) : -1;
|
||||
return tcgetpgrp(p->fd_in);
|
||||
}
|
||||
|
||||
int
|
||||
PasswdCommand(struct cmdargs const *arg)
|
||||
{
|
||||
const char *pass;
|
||||
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "passwd: Cannot specify without a prompt\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg->prompt->owner == NULL) {
|
||||
LogPrintf(LogWARN, "passwd: Not required\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg->argc == 0)
|
||||
pass = "";
|
||||
else if (arg->argc > 1)
|
||||
return -1;
|
||||
else
|
||||
pass = *arg->argv;
|
||||
|
||||
if (!strcmp(arg->prompt->owner->passwd, pass))
|
||||
arg->prompt->auth = LOCAL_AUTH;
|
||||
else
|
||||
arg->prompt->auth = LOCAL_NO_AUTH;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -23,14 +23,33 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: prompt.h,v 1.1.2.2 1998/02/16 00:01:00 brian Exp $
|
||||
* $Id: prompt.h,v 1.1.2.3 1998/02/17 19:28:13 brian Exp $
|
||||
*/
|
||||
|
||||
#define LOCAL_AUTH 0x01
|
||||
#define LOCAL_NO_AUTH 0x02
|
||||
#define LOCAL_DENY 0x03
|
||||
#define LOCAL_CX 0x04 /* OR'd value - require a context */
|
||||
#define LOCAL_CX_OPT 0x08 /* OR'd value - optional context */
|
||||
|
||||
struct server;
|
||||
struct bundle;
|
||||
|
||||
struct prompt {
|
||||
struct descriptor desc;
|
||||
int fd_in, fd_out;
|
||||
struct datalink *TermMode; /* The modem we're talking directly to */
|
||||
FILE *Term; /* sits on top of fd_out */
|
||||
u_char auth; /* Local Authorized status */
|
||||
struct server *owner; /* who created me */
|
||||
struct bundle *bundle; /* who I'm controlling */
|
||||
unsigned nonewline : 1; /* need a newline before our prompt ? */
|
||||
unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */
|
||||
|
||||
char who[40]; /* Where do I come from */
|
||||
|
||||
struct prompt *lognext; /* Maintained in log.c */
|
||||
u_long logmask; /* Maintained in log.c */
|
||||
|
||||
struct termios oldtio; /* Original tty mode */
|
||||
struct termios comtio; /* Command level tty mode */
|
||||
@ -40,14 +59,11 @@ struct prompt {
|
||||
#define descriptor2prompt(d) \
|
||||
((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL)
|
||||
|
||||
extern struct prompt prompt;
|
||||
|
||||
#define prompt_Active(p) ((p)->Term ? 1 : 0)
|
||||
#define PROMPT_NONE -2
|
||||
#define PROMPT_STD -1
|
||||
extern int prompt_Init(struct prompt *, int);
|
||||
extern void prompt_Display(struct prompt *, struct bundle *);
|
||||
extern void prompt_Drop(struct prompt *, int);
|
||||
#define PROMPT_STD (-1)
|
||||
extern struct prompt *prompt_Create(struct server *, struct bundle *, int);
|
||||
extern void prompt_Destroy(struct prompt *, int);
|
||||
extern void prompt_DestroyUnclean(struct prompt *);
|
||||
extern void prompt_Required(struct prompt *);
|
||||
extern void prompt_Printf(struct prompt *, const char *, ...);
|
||||
extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_);
|
||||
#define PROMPT_DONT_WANT_INT 1
|
||||
@ -57,4 +73,7 @@ extern void prompt_TtyCommandMode(struct prompt *);
|
||||
extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
|
||||
extern void prompt_TtyOldMode(struct prompt *);
|
||||
extern pid_t prompt_pgrp(struct prompt *);
|
||||
#define prompt_IsTermMode(p) ((p)->TermMode ? 1 : 0)
|
||||
extern int PasswdCommand(struct cmdargs const *);
|
||||
#define prompt_IsTermMode(p, dl) ((p)->TermMode == (dl) ? 1 : 0)
|
||||
#define prompt_IsController(p) (!(p) || (p)->owner ? 0 : 1)
|
||||
#define prompt_Required(p) ((p)->needprompt = 1)
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: route.c,v 1.42.2.13 1998/03/20 19:48:21 brian Exp $
|
||||
* $Id: route.c,v 1.42.2.14 1998/04/03 19:21:51 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -70,7 +70,8 @@
|
||||
#include "prompt.h"
|
||||
|
||||
static void
|
||||
p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width)
|
||||
p_sockaddr(struct prompt *prompt, struct sockaddr *phost,
|
||||
struct sockaddr *pmask, int width)
|
||||
{
|
||||
char buf[29];
|
||||
struct sockaddr_in *ihost = (struct sockaddr_in *)phost;
|
||||
@ -141,7 +142,7 @@ p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width)
|
||||
break;
|
||||
}
|
||||
|
||||
prompt_Printf(&prompt, "%-*s ", width-1, buf);
|
||||
prompt_Printf(prompt, "%-*s ", width-1, buf);
|
||||
}
|
||||
|
||||
static struct bits {
|
||||
@ -182,7 +183,7 @@ static struct bits {
|
||||
#endif
|
||||
|
||||
static void
|
||||
p_flags(u_long f, int max)
|
||||
p_flags(struct prompt *prompt, u_long f, int max)
|
||||
{
|
||||
char name[33], *flags;
|
||||
register struct bits *p = bits;
|
||||
@ -194,7 +195,7 @@ p_flags(u_long f, int max)
|
||||
if (p->b_mask & f)
|
||||
*flags++ = p->b_val;
|
||||
*flags = '\0';
|
||||
prompt_Printf(&prompt, "%-*.*s", max, max, name);
|
||||
prompt_Printf(prompt, "%-*.*s", max, max, name);
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -309,7 +310,8 @@ ShowRoute(struct cmdargs const *arg)
|
||||
}
|
||||
ep = sp + needed;
|
||||
|
||||
prompt_Printf(&prompt, "%-20s%-20sFlags Netif\n", "Destination", "Gateway");
|
||||
prompt_Printf(arg->prompt, "%-20s%-20sFlags Netif\n",
|
||||
"Destination", "Gateway");
|
||||
for (cp = sp; cp < ep; cp += rtm->rtm_msglen) {
|
||||
rtm = (struct rt_msghdr *) cp;
|
||||
wp = (char *)(rtm+1);
|
||||
@ -332,11 +334,11 @@ ShowRoute(struct cmdargs const *arg)
|
||||
} else
|
||||
sa_mask = NULL;
|
||||
|
||||
p_sockaddr(sa_dst, sa_mask, 20);
|
||||
p_sockaddr(sa_gw, NULL, 20);
|
||||
p_sockaddr(arg->prompt, sa_dst, sa_mask, 20);
|
||||
p_sockaddr(arg->prompt, sa_gw, NULL, 20);
|
||||
|
||||
p_flags(rtm->rtm_flags, 6);
|
||||
prompt_Printf(&prompt, " %s\n", Index2Nam(rtm->rtm_index));
|
||||
p_flags(arg->prompt, rtm->rtm_flags, 6);
|
||||
prompt_Printf(arg->prompt, " %s\n", Index2Nam(rtm->rtm_index));
|
||||
}
|
||||
free(sp);
|
||||
return 0;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: server.c,v 1.16.2.9 1998/03/20 19:48:23 brian Exp $
|
||||
* $Id: server.c,v 1.16.2.10 1998/04/03 19:21:51 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -31,6 +31,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@ -52,6 +53,19 @@
|
||||
#include "prompt.h"
|
||||
#include "timer.h"
|
||||
#include "auth.h"
|
||||
#include "lqr.h"
|
||||
#include "hdlc.h"
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#include "ccp.h"
|
||||
#include "throughput.h"
|
||||
#include "link.h"
|
||||
#include "mp.h"
|
||||
#include "iplist.h"
|
||||
#include "slcompress.h"
|
||||
#include "ipcp.h"
|
||||
#include "filter.h"
|
||||
#include "bundle.h"
|
||||
|
||||
static int
|
||||
server_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
@ -78,6 +92,8 @@ server_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
#define UN_SIZE sizeof(struct sockaddr_in)
|
||||
#define ADDRSZ (IN_SIZE > UN_SIZE ? IN_SIZE : UN_SIZE)
|
||||
|
||||
static char *rm;
|
||||
|
||||
static void
|
||||
server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
@ -86,6 +102,7 @@ server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
struct sockaddr *sa = (struct sockaddr *)hisaddr;
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)hisaddr;
|
||||
int ssize = ADDRSZ, wfd;
|
||||
struct prompt *p;
|
||||
|
||||
wfd = accept(s->fd, sa, &ssize);
|
||||
if (wfd < 0) {
|
||||
@ -116,13 +133,22 @@ server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!prompt_Init(&prompt, wfd)) {
|
||||
write(wfd, "Connection already in use.\n", 27);
|
||||
if ((p = prompt_Create(s, bundle, wfd)) == NULL) {
|
||||
write(wfd, "Connection refused.\n", 20);
|
||||
close(wfd);
|
||||
} else {
|
||||
LocalAuthInit();
|
||||
IsInteractive(1);
|
||||
prompt_Display(&prompt, bundle);
|
||||
switch (sa->sa_family) {
|
||||
case AF_LOCAL:
|
||||
snprintf(p->who, sizeof p->who, "local (%s)", rm);
|
||||
break;
|
||||
case AF_INET:
|
||||
snprintf(p->who, sizeof p->who, "TCP (%s:%u)",
|
||||
inet_ntoa(sin->sin_addr), sin->sin_port);
|
||||
break;
|
||||
}
|
||||
IsInteractive(p);
|
||||
prompt_TtyCommandMode(p);
|
||||
prompt_Required(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,24 +172,12 @@ struct server server = {
|
||||
};
|
||||
|
||||
static struct sockaddr_un ifsun;
|
||||
static char *rm;
|
||||
|
||||
int
|
||||
ServerLocalOpen(const char *name, mode_t mask)
|
||||
ServerLocalOpen(struct bundle *bundle, const char *name, mode_t mask)
|
||||
{
|
||||
int s;
|
||||
|
||||
if (VarLocalAuth == LOCAL_DENY) {
|
||||
LogPrintf(LogWARN, "Local: Can't open socket %s: No password "
|
||||
"in ppp.secret\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mode & MODE_INTER) {
|
||||
LogPrintf(LogWARN, "Local: Can't open socket in interactive mode\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&ifsun, '\0', sizeof ifsun);
|
||||
ifsun.sun_len = strlen(name);
|
||||
if (ifsun.sun_len > sizeof ifsun.sun_path - 1) {
|
||||
@ -184,9 +198,7 @@ ServerLocalOpen(const char *name, mode_t mask)
|
||||
if (bind(s, (struct sockaddr *)&ifsun, sizeof ifsun) < 0) {
|
||||
if (mask != (mode_t)-1)
|
||||
umask(mask);
|
||||
LogPrintf(LogERROR, "Local: bind: %s\n", strerror(errno));
|
||||
if (errno == EADDRINUSE)
|
||||
prompt_Printf(&prompt, "Wait for a while, then try again.\n");
|
||||
LogPrintf(LogWARN, "Local: bind: %s\n", strerror(errno));
|
||||
close(s);
|
||||
return 4;
|
||||
}
|
||||
@ -198,7 +210,7 @@ ServerLocalOpen(const char *name, mode_t mask)
|
||||
ID0unlink(name);
|
||||
return 5;
|
||||
}
|
||||
ServerClose();
|
||||
ServerClose(bundle);
|
||||
server.fd = s;
|
||||
rm = ifsun.sun_path;
|
||||
LogPrintf(LogPHASE, "Listening at local socket %s.\n", name);
|
||||
@ -206,22 +218,11 @@ ServerLocalOpen(const char *name, mode_t mask)
|
||||
}
|
||||
|
||||
int
|
||||
ServerTcpOpen(int port)
|
||||
ServerTcpOpen(struct bundle *bundle, int port)
|
||||
{
|
||||
struct sockaddr_in ifsin;
|
||||
int s;
|
||||
|
||||
if (VarLocalAuth == LOCAL_DENY) {
|
||||
LogPrintf(LogWARN, "Tcp: Can't open socket %d: No password "
|
||||
"in ppp.secret\n", port);
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (mode & MODE_INTER) {
|
||||
LogPrintf(LogWARN, "Tcp: Can't open socket in interactive mode\n");
|
||||
return 6;
|
||||
}
|
||||
|
||||
s = ID0socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "Tcp: socket: %s\n", strerror(errno));
|
||||
@ -233,9 +234,7 @@ ServerTcpOpen(int port)
|
||||
ifsin.sin_port = htons(port);
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
|
||||
if (bind(s, (struct sockaddr *)&ifsin, sizeof ifsin) < 0) {
|
||||
LogPrintf(LogERROR, "Tcp: bind: %s\n", strerror(errno));
|
||||
if (errno == EADDRINUSE)
|
||||
prompt_Printf(&prompt, "Wait for a while, then try again.\n");
|
||||
LogPrintf(LogWARN, "Tcp: bind: %s\n", strerror(errno));
|
||||
close(s);
|
||||
return 8;
|
||||
}
|
||||
@ -244,14 +243,14 @@ ServerTcpOpen(int port)
|
||||
close(s);
|
||||
return 9;
|
||||
}
|
||||
ServerClose();
|
||||
ServerClose(bundle);
|
||||
server.fd = s;
|
||||
LogPrintf(LogPHASE, "Listening at port %d.\n", port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ServerClose()
|
||||
ServerClose(struct bundle *bundle)
|
||||
{
|
||||
if (server.fd >= 0) {
|
||||
close(server.fd);
|
||||
@ -260,6 +259,8 @@ ServerClose()
|
||||
rm = 0;
|
||||
}
|
||||
server.fd = -1;
|
||||
/* Drop associated prompts */
|
||||
bundle_DelPromptDescriptors(bundle, &server);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -23,12 +23,13 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: server.h,v 1.4 1997/12/21 12:11:08 brian Exp $
|
||||
* $Id: server.h,v 1.4.2.1 1998/02/09 19:24:02 brian Exp $
|
||||
*/
|
||||
|
||||
struct server {
|
||||
struct descriptor desc;
|
||||
int fd;
|
||||
char passwd[50];
|
||||
};
|
||||
|
||||
#define server2descriptor(s) (&(s)->desc)
|
||||
@ -37,6 +38,6 @@ struct server {
|
||||
|
||||
extern struct server server;
|
||||
|
||||
extern int ServerLocalOpen(const char *, mode_t);
|
||||
extern int ServerTcpOpen(int);
|
||||
extern int ServerClose(void);
|
||||
extern int ServerLocalOpen(struct bundle *, const char *, mode_t);
|
||||
extern int ServerTcpOpen(struct bundle *, int);
|
||||
extern int ServerClose(struct bundle *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: slcompress.c,v 1.15.2.3 1998/03/16 22:54:25 brian Exp $
|
||||
* $Id: slcompress.c,v 1.15.2.4 1998/04/03 19:21:52 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
@ -574,17 +574,17 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type,
|
||||
int
|
||||
ReportCompress(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "VJ compression statistics:\n");
|
||||
prompt_Printf(&prompt, " Out: %d (compress) / %d (total)",
|
||||
prompt_Printf(arg->prompt, "VJ compression statistics:\n");
|
||||
prompt_Printf(arg->prompt, " Out: %d (compress) / %d (total)",
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_compressed,
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_packets);
|
||||
prompt_Printf(&prompt, " %d (miss) / %d (search)\n",
|
||||
prompt_Printf(arg->prompt, " %d (miss) / %d (search)\n",
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_misses,
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_searches);
|
||||
prompt_Printf(&prompt, " In: %d (compress), %d (uncompress)",
|
||||
prompt_Printf(arg->prompt, " In: %d (compress), %d (uncompress)",
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_compressedin,
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_uncompressedin);
|
||||
prompt_Printf(&prompt, " %d (error), %d (tossed)\n",
|
||||
prompt_Printf(arg->prompt, " %d (error), %d (tossed)\n",
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_errorin,
|
||||
arg->bundle->ncp.ipcp.vj.slstat.sls_tossed);
|
||||
return 0;
|
||||
|
@ -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.2 1998/02/04 01:03:36 brian Exp $
|
||||
* $Id: systems.c,v 1.35.2.3 1998/02/09 19:24:03 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -269,12 +269,11 @@ xgets(char *buf, int buflen, FILE *fp)
|
||||
|
||||
static int
|
||||
ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
int doexec)
|
||||
int doexec, struct prompt *prompt)
|
||||
{
|
||||
FILE *fp;
|
||||
char *cp, *wp;
|
||||
int n, len;
|
||||
u_char olauth;
|
||||
char line[LINE_LEN];
|
||||
char filename[MAXPATHLEN];
|
||||
int linenum;
|
||||
@ -311,7 +310,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
switch (DecodeCtrlCommand(cp+1, arg)) {
|
||||
case CTRL_INCLUDE:
|
||||
LogPrintf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
|
||||
n = ReadSystem(bundle, name, arg, doexec);
|
||||
n = ReadSystem(bundle, name, arg, doexec, prompt);
|
||||
LogPrintf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
|
||||
if (!n)
|
||||
return 0; /* got it */
|
||||
@ -348,13 +347,8 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
len = strlen(cp);
|
||||
InterpretCommand(cp, len, &argc, &argv);
|
||||
allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
|
||||
if ((!doexec && allowcmd) || (doexec && !allowcmd)) {
|
||||
olauth = VarLocalAuth;
|
||||
if (VarLocalAuth == LOCAL_NO_AUTH)
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
RunCommand(bundle, argc, (char const *const *)argv, name);
|
||||
VarLocalAuth = olauth;
|
||||
}
|
||||
if ((!doexec && allowcmd) || (doexec && !allowcmd))
|
||||
RunCommand(bundle, argc, (char const *const *)argv, prompt, name);
|
||||
}
|
||||
|
||||
fclose(fp); /* everything read - get out */
|
||||
@ -368,7 +362,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
}
|
||||
|
||||
int
|
||||
ValidSystem(const char *name)
|
||||
ValidSystem(const char *name, struct prompt *prompt)
|
||||
{
|
||||
/*
|
||||
* Note: The ReadSystem() calls only result in calls to the Allow*
|
||||
@ -378,17 +372,18 @@ ValidSystem(const char *name)
|
||||
return userok = modeok = 1;
|
||||
userok = 0;
|
||||
modeok = 1;
|
||||
ReadSystem(NULL, "default", CONFFILE, 0);
|
||||
ReadSystem(NULL, "default", CONFFILE, 0, prompt);
|
||||
if (name != NULL)
|
||||
ReadSystem(NULL, name, CONFFILE, 0);
|
||||
ReadSystem(NULL, name, CONFFILE, 0, prompt);
|
||||
return userok && modeok;
|
||||
}
|
||||
|
||||
int
|
||||
SelectSystem(struct bundle *bundle, const char *name, const char *file)
|
||||
SelectSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
struct prompt *prompt)
|
||||
{
|
||||
userok = modeok = 1;
|
||||
return ReadSystem(bundle, name, file, 1);
|
||||
return ReadSystem(bundle, name, file, 1, prompt);
|
||||
}
|
||||
|
||||
int
|
||||
@ -401,10 +396,10 @@ LoadCommand(struct cmdargs const *arg)
|
||||
else
|
||||
name = "default";
|
||||
|
||||
if (!ValidSystem(name)) {
|
||||
if (!ValidSystem(name, arg->prompt)) {
|
||||
LogPrintf(LogERROR, "%s: Label not allowed\n", name);
|
||||
return 1;
|
||||
} else if (SelectSystem(arg->bundle, name, CONFFILE) < 0) {
|
||||
} else if (SelectSystem(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
|
||||
LogPrintf(LogWARN, "%s: label not found.\n", name);
|
||||
return -1;
|
||||
} else
|
||||
|
@ -17,12 +17,15 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.h,v 1.10 1997/11/22 03:37:51 brian Exp $
|
||||
* $Id: systems.h,v 1.10.2.1 1998/02/02 19:32:15 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
extern int SelectSystem(struct bundle *bundle, const char *, const char *);
|
||||
extern int ValidSystem(const char *);
|
||||
struct prompt;
|
||||
|
||||
extern int SelectSystem(struct bundle *bundle, const char *, const char *,
|
||||
struct prompt *);
|
||||
extern int ValidSystem(const char *, struct prompt *);
|
||||
extern FILE *OpenSecret(const char *);
|
||||
extern void CloseSecret(FILE *);
|
||||
extern int AllowUsers(struct cmdargs const *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: throughput.c,v 1.4.4.1 1998/02/10 03:23:43 brian Exp $
|
||||
* $Id: throughput.c,v 1.4.4.2 1998/04/03 19:21:53 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -58,24 +58,24 @@ throughput_init(struct pppThroughput *t)
|
||||
}
|
||||
|
||||
void
|
||||
throughput_disp(struct pppThroughput *t)
|
||||
throughput_disp(struct pppThroughput *t, struct prompt *prompt)
|
||||
{
|
||||
int secs_up;
|
||||
|
||||
secs_up = t->uptime ? time(NULL) - t->uptime : 0;
|
||||
prompt_Printf(&prompt, "Connect time: %d secs\n", secs_up);
|
||||
prompt_Printf(prompt, "Connect time: %d secs\n", secs_up);
|
||||
if (secs_up == 0)
|
||||
secs_up = 1;
|
||||
prompt_Printf(&prompt, "%ld octets in, %ld octets out\n",
|
||||
prompt_Printf(prompt, "%ld octets in, %ld octets out\n",
|
||||
t->OctetsIn, t->OctetsOut);
|
||||
if (Enabled(ConfThroughput)) {
|
||||
prompt_Printf(&prompt, " overall %5ld bytes/sec\n",
|
||||
prompt_Printf(prompt, " overall %5ld bytes/sec\n",
|
||||
(t->OctetsIn+t->OctetsOut)/secs_up);
|
||||
prompt_Printf(&prompt, " currently %5d bytes/sec\n", t->OctetsPerSecond);
|
||||
prompt_Printf(&prompt, " peak %5d bytes/sec\n",
|
||||
prompt_Printf(prompt, " currently %5d bytes/sec\n", t->OctetsPerSecond);
|
||||
prompt_Printf(prompt, " peak %5d bytes/sec\n",
|
||||
t->BestOctetsPerSecond);
|
||||
} else
|
||||
prompt_Printf(&prompt, "Overall %ld bytes/sec\n",
|
||||
prompt_Printf(prompt, "Overall %ld bytes/sec\n",
|
||||
(t->OctetsIn+t->OctetsOut)/secs_up);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: throughput.h,v 1.2.4.1 1998/02/10 03:23:48 brian Exp $
|
||||
* $Id: throughput.h,v 1.2.4.2 1998/04/03 19:21:53 brian Exp $
|
||||
*/
|
||||
|
||||
#define SAMPLE_PERIOD 5
|
||||
@ -40,7 +40,7 @@ struct pppThroughput {
|
||||
};
|
||||
|
||||
extern void throughput_init(struct pppThroughput *);
|
||||
extern void throughput_disp(struct pppThroughput *);
|
||||
extern void throughput_disp(struct pppThroughput *, struct prompt *);
|
||||
extern void throughput_log(struct pppThroughput *, int, const char *);
|
||||
extern void throughput_start(struct pppThroughput *, const char *);
|
||||
extern void throughput_stop(struct pppThroughput *);
|
||||
|
@ -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 1998/01/21 02:15:29 brian Exp $
|
||||
* $Id: timer.c,v 1.27.2.1 1998/04/03 19:21:54 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -155,7 +155,7 @@ TimerService()
|
||||
time_t n = time(NULL); /* Only show timers every second */
|
||||
|
||||
if (n > t)
|
||||
ShowTimers(LogDEBUG);
|
||||
ShowTimers(LogDEBUG, NULL);
|
||||
t = n;
|
||||
}
|
||||
tp = TimerList;
|
||||
@ -200,7 +200,7 @@ TimerService()
|
||||
}
|
||||
|
||||
void
|
||||
ShowTimers(int LogLevel)
|
||||
ShowTimers(int LogLevel, struct prompt *prompt)
|
||||
{
|
||||
struct pppTimer *pt;
|
||||
int rest = 0;
|
||||
@ -212,18 +212,18 @@ ShowTimers(int LogLevel)
|
||||
pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \
|
||||
HSECS(rest), tState2Nam(pt->state)
|
||||
|
||||
if (LogIsKept(LogLevel))
|
||||
if (!prompt)
|
||||
LogPrintf(LogLevel, "---- Begin of Timer Service List---\n");
|
||||
|
||||
for (pt = TimerList; pt; pt = pt->next) {
|
||||
rest += pt->rest;
|
||||
if (LogIsKept(LogLevel))
|
||||
if (prompt)
|
||||
prompt_Printf(prompt, DISP);
|
||||
else
|
||||
LogPrintf(LogLevel, DISP);
|
||||
else if (LogLevel < LogMIN)
|
||||
prompt_Printf(&prompt, DISP);
|
||||
}
|
||||
|
||||
if (LogIsKept(LogLevel))
|
||||
if (!prompt)
|
||||
LogPrintf(LogLevel, "---- End of Timer Service List ---\n");
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: timer.h,v 1.5 1998/01/21 02:15:30 brian Exp $
|
||||
* $Id: timer.h,v 1.5.4.1 1998/04/03 19:21:54 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -38,10 +38,12 @@ struct pppTimer {
|
||||
#define TIMER_RUNNING 1
|
||||
#define TIMER_EXPIRED 2
|
||||
|
||||
struct prompt;
|
||||
|
||||
extern void StartTimer(struct pppTimer *);
|
||||
extern void StopTimer(struct pppTimer *);
|
||||
extern void TermTimerService(void);
|
||||
extern void ShowTimers(int LogLevel);
|
||||
extern void ShowTimers(int LogLevel, struct prompt *);
|
||||
|
||||
#ifdef SIGALRM
|
||||
extern void nointr_sleep(u_int);
|
||||
|
@ -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.45.2.21 1998/04/03 19:24:36 brian Exp $
|
||||
* $Id: vars.c,v 1.45.2.22 1998/04/03 19:24:48 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -48,7 +48,7 @@
|
||||
#include "prompt.h"
|
||||
|
||||
char VarVersion[] = "PPP Version 2.0-beta";
|
||||
char VarLocalVersion[] = "$Date: 1998/04/03 19:24:36 $";
|
||||
char VarLocalVersion[] = "$Date: 1998/04/03 19:24:48 $";
|
||||
|
||||
/*
|
||||
* Order of conf option is important. See vars.h.
|
||||
@ -72,20 +72,18 @@ struct confdesc pppConfs[NCONFS] = {
|
||||
{"loopback", CONF_ENABLE, CONF_NONE}
|
||||
};
|
||||
|
||||
struct pppvars pppVars = {
|
||||
LOCAL_NO_AUTH
|
||||
};
|
||||
struct pppvars pppVars;
|
||||
|
||||
int
|
||||
DisplayCommand(struct cmdargs const *arg)
|
||||
{
|
||||
int f;
|
||||
|
||||
prompt_Printf(&prompt, "Current configuration option settings..\n\n");
|
||||
prompt_Printf(&prompt, "Name\t\tMy Side\t\tHis Side\n");
|
||||
prompt_Printf(&prompt, "----------------------------------------\n");
|
||||
prompt_Printf(arg->prompt, "Current configuration option settings..\n\n");
|
||||
prompt_Printf(arg->prompt, "Name\t\tMy Side\t\tHis Side\n");
|
||||
prompt_Printf(arg->prompt, "----------------------------------------\n");
|
||||
for (f = 0; f < NCONFS; f++)
|
||||
prompt_Printf(&prompt, "%-10s\t%s\t\t%s\n", pppConfs[f].name,
|
||||
prompt_Printf(arg->prompt, "%-10s\t%s\t\t%s\n", pppConfs[f].name,
|
||||
(pppConfs[f].myside == CONF_ENABLE) ? "enable" :
|
||||
(pppConfs[f].myside == CONF_DISABLE ? "disable" : "N/A"),
|
||||
(pppConfs[f].hisside == CONF_ACCEPT) ? "accept" :
|
||||
@ -157,36 +155,3 @@ DenyCommand(struct cmdargs const *arg)
|
||||
{
|
||||
return ConfigCommand(arg, 0, CONF_DENY);
|
||||
}
|
||||
|
||||
int
|
||||
LocalAuthCommand(struct cmdargs const *arg)
|
||||
{
|
||||
const char *pass;
|
||||
if (arg->argc == 0)
|
||||
pass = "";
|
||||
else if (arg->argc > 1)
|
||||
return -1;
|
||||
else
|
||||
pass = *arg->argv;
|
||||
|
||||
if (VarHaveLocalAuthKey)
|
||||
VarLocalAuth = strcmp(VarLocalAuthKey, pass) ? LOCAL_NO_AUTH : LOCAL_AUTH;
|
||||
else
|
||||
switch (LocalAuthValidate(SECRETFILE, VarShortHost, pass)) {
|
||||
case INVALID:
|
||||
VarLocalAuth = LOCAL_NO_AUTH;
|
||||
break;
|
||||
case VALID:
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
break;
|
||||
case NOT_FOUND:
|
||||
VarLocalAuth = LOCAL_AUTH;
|
||||
LogPrintf(LogWARN, "WARNING: No Entry for this system\n");
|
||||
break;
|
||||
default:
|
||||
VarLocalAuth = LOCAL_NO_AUTH;
|
||||
LogPrintf(LogERROR, "LocalAuthCommand: Ooops?\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -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.42.2.18 1998/04/03 19:24:36 brian Exp $
|
||||
* $Id: vars.h,v 1.42.2.19 1998/04/03 19:24:49 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -57,27 +57,12 @@ struct confdesc {
|
||||
extern struct confdesc pppConfs[NCONFS];
|
||||
|
||||
struct pppvars {
|
||||
#define LOCAL_AUTH 0x01
|
||||
#define LOCAL_NO_AUTH 0x02
|
||||
#define LOCAL_DENY 0x03
|
||||
#define LOCAL_CX 0x04 /* OR'd value - require a context */
|
||||
#define LOCAL_CX_OPT 0x08 /* OR'd value - optional context */
|
||||
u_char lauth; /* Local Authorized status */
|
||||
|
||||
/* The rest are just default initialized in vars.c */
|
||||
char local_auth_key[50]; /* Local auth passwd */
|
||||
int have_local_auth_key; /* Local auth passwd specified ? */
|
||||
int use_MSChap; /* Use MSCHAP encryption */
|
||||
char shostname[MAXHOSTNAMELEN]; /* Local short Host Name */
|
||||
struct aliasHandlers handler; /* Alias function pointers */
|
||||
};
|
||||
|
||||
#define VarLocalAuth pppVars.lauth
|
||||
|
||||
#define VarLocalAuthKey pppVars.local_auth_key
|
||||
#define VarHaveLocalAuthKey pppVars.have_local_auth_key
|
||||
#define VarMSChap pppVars.use_MSChap
|
||||
#define VarShortHost pppVars.shostname
|
||||
|
||||
#define VarAliasHandlers pppVars.handler
|
||||
#define VarPacketAliasGetFragment (*pppVars.handler.PacketAliasGetFragment)
|
||||
@ -100,5 +85,4 @@ extern int EnableCommand(struct cmdargs const *);
|
||||
extern int DisableCommand(struct cmdargs const *);
|
||||
extern int AcceptCommand(struct cmdargs const *);
|
||||
extern int DenyCommand(struct cmdargs const *);
|
||||
extern int LocalAuthCommand(struct cmdargs const *);
|
||||
extern int DisplayCommand(struct cmdargs const *);
|
||||
|
Loading…
Reference in New Issue
Block a user