changes in IPX routing-protocol negotiation
'pidfile' option set_userip feature minor bug fixes and changes
This commit is contained in:
parent
f7b8a9fa78
commit
e6d231a11a
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# ipppd makefile for Linux
|
||||
# $Id: Makefile.in,v 1.2 1997/03/24 03:12:12 fritz Exp $
|
||||
# $Id: Makefile.in,v 1.3 1997/05/19 10:15:24 hipp Exp $
|
||||
#
|
||||
|
||||
HAVE_LIBBSD := @HAVE_LIBBSD@
|
||||
|
@ -18,7 +18,7 @@ ifeq (../.config,$(wildcard ../.config))
|
|||
include ../.config
|
||||
SBINDIR = $(CONFIG_SBINDIR)
|
||||
MANDIR = $(CONFIG_MANDIR)
|
||||
ifeq ($(CONFIG_IPPD_MSCHAP),y)
|
||||
ifeq ($(CONFIG_IPPPD_MSCHAP),y)
|
||||
USE_MSCHAP = 1
|
||||
endif
|
||||
else
|
||||
|
@ -63,7 +63,7 @@ HEADERS := $(HEADERS) .depend
|
|||
endif
|
||||
|
||||
DEBUG_FLAGS = -DDEBUGALL
|
||||
COMPILE_FLAGS = -Dlint
|
||||
COMPILE_FLAGS =
|
||||
COPTS =
|
||||
CFLAGS = -O2 -fomit-frame-pointer -m486 -Wall
|
||||
VER = 2.2.0
|
||||
|
|
|
@ -49,6 +49,9 @@ I added a few new options:
|
|||
- IPX and MS_DNS are now compiled into the binary without additional option
|
||||
Applied Hartwig Felgers MS-DNS (re)patch for this
|
||||
- added Markus Hofmann's <markus@tower.de> maxconnect patches
|
||||
- added 'pidfile <own pidfilename>' option ..
|
||||
- added 'set_userip' .. you may define valid IPs in /etc/ppp/useriptab
|
||||
(it's a patch from: Meno Abels <Meno.Abels@Technical.Adviser.com>)
|
||||
|
||||
The ipppd can handle multiple devices. This is necessary to
|
||||
link several connections together to one bundle.
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
Report bugs, problems etc. to: i4l-ippp@franken.de
|
||||
--------------------------------------------------
|
||||
|
||||
Introduction.
|
||||
*************
|
||||
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: auth.c,v 1.5 1997/05/07 14:51:34 hipp Exp $";
|
||||
#endif
|
||||
char auth_rcsid[] = "$Id: auth.c,v 1.6 1997/05/19 10:15:28 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -42,9 +42,7 @@ in the developr/rfc directory.
|
|||
|
||||
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: cbcp.c,v 1.3 1997/05/06 13:04:02 hipp Exp $";
|
||||
#endif
|
||||
char cbcp_rcsid[] = "$Id: cbcp.c,v 1.4 1997/05/19 10:15:31 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -25,15 +25,15 @@
|
|||
* OR MODIFICATIONS.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: ccp.c,v 1.2 1997/04/26 17:17:21 hipp Exp $";
|
||||
#endif
|
||||
char ccp_rcsid[] = "$Id: ccp.c,v 1.3 1997/05/19 10:15:34 hipp Exp $";
|
||||
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#if 0
|
||||
#include <net/ppp_defs.h>
|
||||
#endif
|
||||
#include <linux/ppp-comp.h>
|
||||
|
||||
#include "fsm.h"
|
||||
|
@ -138,6 +138,8 @@ static void ccp_init(int unit)
|
|||
{
|
||||
fsm *f = &ccp_fsm[unit];
|
||||
|
||||
memset(f,0,sizeof(fsm));
|
||||
|
||||
f->unit = -1;
|
||||
f->protocol = PPP_CCP;
|
||||
f->callbacks = &ccp_callbacks;
|
||||
|
|
55
ipppd/chap.c
55
ipppd/chap.c
|
@ -18,9 +18,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: chap.c,v 1.2 1997/04/26 17:17:22 hipp Exp $";
|
||||
#endif
|
||||
char chap_rcsid[] = "$Id: chap.c,v 1.3 1997/05/19 10:15:38 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -456,19 +454,14 @@ ChapReceiveChallenge(cstate, inp, id, len)
|
|||
/*
|
||||
* ChapReceiveResponse - Receive and process response.
|
||||
*/
|
||||
static void
|
||||
ChapReceiveResponse(cstate, inp, id, len)
|
||||
chap_state *cstate;
|
||||
u_char *inp;
|
||||
int id;
|
||||
int len;
|
||||
static void ChapReceiveResponse(chap_state *cstate,u_char *inp,int id,int len)
|
||||
{
|
||||
u_char *remmd, remmd_len;
|
||||
int secret_len, old_state;
|
||||
int code;
|
||||
char rhostname[256];
|
||||
MD5_CTX mdContext;
|
||||
char secret[MAXSECRETLEN];
|
||||
u_char *remmd, remmd_len;
|
||||
int secret_len, old_state;
|
||||
int code;
|
||||
char rhostname[256];
|
||||
MD5_CTX mdContext;
|
||||
char secret[MAXSECRETLEN];
|
||||
|
||||
CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: Rcvd id %d.", id));
|
||||
|
||||
|
@ -551,24 +544,24 @@ ChapReceiveResponse(cstate, inp, id, len)
|
|||
default:
|
||||
CHAPDEBUG((LOG_INFO, "unknown digest type %d", cstate->chal_type));
|
||||
}
|
||||
}
|
||||
|
||||
ChapSendStatus(cstate, code);
|
||||
|
||||
if (code == CHAP_SUCCESS) {
|
||||
old_state = cstate->serverstate;
|
||||
cstate->serverstate = CHAPSS_OPEN;
|
||||
if (old_state == CHAPSS_INITIAL_CHAL) {
|
||||
auth_peer_success(cstate->unit, PPP_CHAP);
|
||||
}
|
||||
if (cstate->chal_interval != 0)
|
||||
TIMEOUT(ChapRechallenge, (caddr_t) cstate, cstate->chal_interval);
|
||||
|
||||
} else {
|
||||
syslog(LOG_ERR, "CHAP peer authentication failed");
|
||||
cstate->serverstate = CHAPSS_BADAUTH;
|
||||
auth_peer_fail(cstate->unit, PPP_CHAP);
|
||||
}
|
||||
ChapSendStatus(cstate, code);
|
||||
|
||||
if (code == CHAP_SUCCESS) {
|
||||
set_userip(rhostname, 0);
|
||||
old_state = cstate->serverstate;
|
||||
cstate->serverstate = CHAPSS_OPEN;
|
||||
if (old_state == CHAPSS_INITIAL_CHAL) {
|
||||
auth_peer_success(cstate->unit, PPP_CHAP);
|
||||
}
|
||||
if (cstate->chal_interval != 0)
|
||||
TIMEOUT(ChapRechallenge, (caddr_t) cstate, cstate->chal_interval);
|
||||
} else {
|
||||
syslog(LOG_ERR, "CHAP peer authentication failed");
|
||||
cstate->serverstate = CHAPSS_BADAUTH;
|
||||
auth_peer_fail(cstate->unit, PPP_CHAP);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
*/
|
||||
|
||||
#ifdef USE_MSCHAP
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: chap_ms.c,v 1.2 1997/04/26 17:17:24 hipp Exp $";
|
||||
#endif
|
||||
char chap_ms_rcsid[] = "$Id: chap_ms.c,v 1.3 1997/05/19 10:15:41 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: fsm.c,v 1.2 1997/04/26 17:17:25 hipp Exp $";
|
||||
#endif
|
||||
char fsm_rcsid[] = "$Id: fsm.c,v 1.3 1997/05/19 10:15:43 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: ipcp.c,v 1.2 1997/04/26 17:17:26 hipp Exp $";
|
||||
#endif
|
||||
char ipcp_rcsid[] = "$Id: ipcp.c,v 1.3 1997/05/19 10:15:46 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -152,11 +150,13 @@ void ipcp_init(int unit)
|
|||
ipcp_options *wo = &ipcp_wantoptions[unit];
|
||||
ipcp_options *ao = &ipcp_allowoptions[unit];
|
||||
|
||||
memset(f,0,sizeof(fsm));
|
||||
|
||||
f->unit = -1;
|
||||
f->protocol = PPP_IPCP;
|
||||
f->callbacks = &ipcp_callbacks;
|
||||
f->inuse = 0;
|
||||
fsm_init(&ipcp_fsm[unit]);
|
||||
fsm_init(f);
|
||||
|
||||
memset(wo, 0, sizeof(*wo));
|
||||
memset(ao, 0, sizeof(*ao));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" manual page [] for pppd 2.0
|
||||
.\" $Id: ipppd.8,v 1.2 1997/04/26 17:17:28 hipp Exp $
|
||||
.\" $Id: ipppd.8,v 1.3 1997/05/19 10:15:50 hipp Exp $
|
||||
.\" SH section heading
|
||||
.\" SS subsection heading
|
||||
.\" LP paragraph
|
||||
|
@ -341,8 +341,10 @@ Set the name of the router. This is a string and is sent to the peer
|
|||
as information data.
|
||||
.TP
|
||||
.B ipx-routing \fI<n>
|
||||
Set the routing protocol to be received by this option. More than one
|
||||
instance of \fIipx-routing\fR may be specified. The '\fInone\fR'
|
||||
Set the routing protocol to be received by this option. Use a
|
||||
comma-serperated list if you want to specify more than one
|
||||
protocol.
|
||||
The '\fInone\fR'
|
||||
option (0) may be specified as the only instance of ipx-routing. The
|
||||
values may be \fI0\fR for \fINONE\fR, \fI2\fR for \fIRIP/SAP\fR, and
|
||||
\fI4\fR for \fINLSP\fR.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* pppd.h - PPP daemon global declarations.
|
||||
* ipppd.h - PPP daemon global declarations.
|
||||
*
|
||||
* Copyright (c) 1989 Carnegie Mellon University.
|
||||
* All rights reserved.
|
||||
|
@ -16,7 +16,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipppd.h,v 1.5 1997/05/07 14:51:35 hipp Exp $
|
||||
* $Id: ipppd.h,v 1.6 1997/05/19 10:15:55 hipp Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -25,8 +25,8 @@
|
|||
|
||||
#define ISDN4LINUX_PATCH
|
||||
|
||||
#ifndef __PPPD_H__
|
||||
#define __PPPD_H__
|
||||
#ifndef __IPPPD_H__
|
||||
#define __IPPPD_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
||||
|
@ -94,6 +94,26 @@ extern char hostname[]; /* Our hostname */
|
|||
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||
extern int baud_rate; /* Current link speed in bits/sec */
|
||||
extern char *progname; /* Name of this program */
|
||||
extern char pidfilename[MAXPATHLEN];
|
||||
|
||||
extern void set_userip(char *ruser,int ruserlen);
|
||||
|
||||
extern char options_rcsid[];
|
||||
extern char auth_rcsid[];
|
||||
extern char lcp_rcsid[];
|
||||
extern char ipcp_rcsid[];
|
||||
extern char ipxcp_rcsid[];
|
||||
extern char cbcp_rcsid[];
|
||||
extern char main_rcsid[];
|
||||
extern char chap_rcsid[];
|
||||
#ifdef USE_MSCHAP
|
||||
extern char chap_ms_rcsid[];
|
||||
#endif
|
||||
extern char upap_rcsid[];
|
||||
extern char ccp_rcsid[];
|
||||
extern char fsm_rcsid[];
|
||||
extern char magic_rcsid[];
|
||||
extern char sys_rcsid[];
|
||||
|
||||
/*
|
||||
* Variables set by command-line options.
|
||||
|
@ -439,4 +459,5 @@ extern struct option_info devnam_info;
|
|||
#define MAX(a, b) ((a) > (b)? (a): (b))
|
||||
#endif
|
||||
|
||||
#endif /* __PPP_H__ */
|
||||
#endif /* __IPPP_H__ */
|
||||
|
||||
|
|
734
ipppd/ipxcp.c
734
ipppd/ipxcp.c
|
@ -17,9 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: ipxcp.c,v 1.2 1997/04/26 17:17:31 hipp Exp $";
|
||||
#endif
|
||||
char ipxcp_rcsid[] = "$Id: ipxcp.c,v 1.3 1997/05/19 10:15:57 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -114,6 +112,22 @@ struct protent ipxcp_protent = {
|
|||
* Lengths of configuration options.
|
||||
*/
|
||||
|
||||
/*
|
||||
IPX-ROUTING-PROTOCOL OPTIONS
|
||||
|
||||
Value Protocol Reference
|
||||
----- -------- ---------
|
||||
0 No routing protocol required [RFC1552]
|
||||
1 RESERVED [RFC1552]
|
||||
2 Novell RIP/SAP required [RFC1552]
|
||||
4 Novell NLSP required [RFC1552]
|
||||
5 Novell Demand RIP required [RFC1582]
|
||||
6 Novell Demand SAP required [RFC1582]
|
||||
7 Novell Triggered RIP required [Edmonstone]
|
||||
8 Novell Triggered SAP required [Edmonstone]
|
||||
*/
|
||||
|
||||
|
||||
#define CILEN_VOID 2
|
||||
#define CILEN_COMPLETE 2 /* length of complete option */
|
||||
#define CILEN_NETN 6 /* network number length option */
|
||||
|
@ -155,11 +169,13 @@ static void ipxcp_init(int unit)
|
|||
ipxcp_options *wo = &ipxcp_wantoptions[unit];
|
||||
ipxcp_options *ao = &ipxcp_allowoptions[unit];
|
||||
|
||||
memset(f,0,sizeof(fsm));
|
||||
|
||||
f->unit = -1;
|
||||
f->protocol = PPP_IPXCP;
|
||||
f->callbacks = &ipxcp_callbacks;
|
||||
f->inuse = 0;
|
||||
fsm_init(&ipxcp_fsm[unit]);
|
||||
fsm_init(f);
|
||||
|
||||
memset (wo->name, 0, sizeof (wo->name));
|
||||
memset (wo->our_node, 0, sizeof (wo->our_node));
|
||||
|
@ -341,33 +357,16 @@ static void ipxcp_resetci(fsm *f)
|
|||
inc_node (wo->his_node);
|
||||
ao->accept_remote = 1;
|
||||
}
|
||||
/*
|
||||
* Unless router protocol is suppressed then assume that we can do RIP.
|
||||
*/
|
||||
#if 0
|
||||
if (! (wo->router & BIT(0)))
|
||||
#else
|
||||
if (wo->router == 0)
|
||||
#endif
|
||||
wo->router = 2;
|
||||
/*
|
||||
* Router protocol is only negotiated if requested. Others force the
|
||||
* negotiation.
|
||||
*/
|
||||
if (wo->router & 6 )
|
||||
wo->neg_router = 1;
|
||||
/*
|
||||
* Start with these default values
|
||||
*/
|
||||
|
||||
if (wo->num_router)
|
||||
wo->neg_router = 1;
|
||||
*go = *wo;
|
||||
}
|
||||
|
||||
/*
|
||||
* ipxcp_cilen - Return length of our CI.
|
||||
*/
|
||||
static int
|
||||
ipxcp_cilen(f)
|
||||
fsm *f;
|
||||
static int ipxcp_cilen(fsm *f)
|
||||
{
|
||||
int linkunit = f->unit;
|
||||
int unit = lns[linkunit].ipxcp_unit;
|
||||
|
@ -378,18 +377,25 @@ ipxcp_cilen(f)
|
|||
len += go->neg_node ? CILEN_NODEN : 0;
|
||||
len += go->neg_name ? CILEN_NAME + strlen (go->name) - 1 : 0;
|
||||
len += go->neg_complete ? CILEN_COMPLETE : 0;
|
||||
|
||||
/*
|
||||
* Router protocol 0 is mutually exclusive with the others.
|
||||
*/
|
||||
if (go->neg_router) {
|
||||
if (go->router == 0)
|
||||
len += CILEN_PROTOCOL;
|
||||
else {
|
||||
if (go->router & 2 )
|
||||
len += CILEN_PROTOCOL;
|
||||
if (go->router & 4 )
|
||||
len += CILEN_PROTOCOL;
|
||||
}
|
||||
if (go->neg_router) {
|
||||
int i,nonnull=0;
|
||||
for(i=0;i<go->num_router;i++) {
|
||||
if (go->router[i] == 0) {
|
||||
if(nonnull || go->num_router > 1) {
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp_cilen ignored router proto 0"));
|
||||
continue;
|
||||
}
|
||||
len += CILEN_PROTOCOL;
|
||||
}
|
||||
else {
|
||||
nonnull = 1;
|
||||
len += CILEN_PROTOCOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (len);
|
||||
|
@ -404,46 +410,57 @@ static void ipxcp_addci(fsm *f,u_char *ucp,int *lenp)
|
|||
int linkunit = f->unit;
|
||||
int unit = lns[linkunit].ipxcp_unit;
|
||||
ipxcp_options *go = &ipxcp_gotoptions[unit];
|
||||
/* int len = *lenp; */
|
||||
u_char *ucp1 = ucp;
|
||||
|
||||
/*
|
||||
* Add the options to the record.
|
||||
*/
|
||||
if (go->neg_nn) {
|
||||
PUTCHAR (IPX_NETWORK_NUMBER, ucp);
|
||||
PUTCHAR (CILEN_NETN, ucp);
|
||||
PUTLONG (go->our_network, ucp);
|
||||
|
||||
if (go->neg_nn) {
|
||||
PUTCHAR (IPX_NETWORK_NUMBER, ucp);
|
||||
PUTCHAR (CILEN_NETN, ucp);
|
||||
PUTLONG (go->our_network, ucp);
|
||||
}
|
||||
|
||||
if (go->neg_node) {
|
||||
int indx;
|
||||
PUTCHAR (IPX_NODE_NUMBER, ucp);
|
||||
PUTCHAR (CILEN_NODEN, ucp);
|
||||
for (indx = 0; indx < sizeof (go->our_node); ++indx)
|
||||
PUTCHAR (go->our_node[indx], ucp);
|
||||
}
|
||||
|
||||
if (go->neg_name) {
|
||||
int cilen = strlen (go->name);
|
||||
int indx;
|
||||
PUTCHAR (IPX_ROUTER_NAME, ucp);
|
||||
PUTCHAR (CILEN_NAME + cilen - 1, ucp);
|
||||
for (indx = 0; indx < cilen; ++indx)
|
||||
PUTCHAR (go->name [indx], ucp);
|
||||
}
|
||||
|
||||
if (go->neg_router) {
|
||||
int i,nonnull=0;
|
||||
for(i=0;i<go->num_router;i++) {
|
||||
if(go->router[i] == 0) {
|
||||
if(nonnull || go->num_router > 1)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
nonnull = 1;
|
||||
PUTCHAR (IPX_ROUTER_PROTOCOL, ucp);
|
||||
PUTCHAR (CILEN_PROTOCOL, ucp);
|
||||
PUTSHORT (go->router[i], ucp);
|
||||
}
|
||||
}
|
||||
|
||||
if (go->neg_node) {
|
||||
int indx;
|
||||
PUTCHAR (IPX_NODE_NUMBER, ucp);
|
||||
PUTCHAR (CILEN_NODEN, ucp);
|
||||
for (indx = 0; indx < sizeof (go->our_node); ++indx)
|
||||
PUTCHAR (go->our_node[indx], ucp);
|
||||
}
|
||||
if (go->neg_complete) {
|
||||
PUTCHAR (IPX_COMPLETE, ucp);
|
||||
PUTCHAR (CILEN_COMPLETE, ucp);
|
||||
}
|
||||
|
||||
if (go->neg_name) {
|
||||
int cilen = strlen (go->name);
|
||||
int indx;
|
||||
PUTCHAR (IPX_ROUTER_NAME, ucp);
|
||||
PUTCHAR (CILEN_NAME + cilen - 1, ucp);
|
||||
for (indx = 0; indx < cilen; ++indx)
|
||||
PUTCHAR (go->name [indx], ucp);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (go->neg_router && (go->router & (BIT(0) | BIT(2) | BIT(4)))) {
|
||||
#else
|
||||
if (go->neg_router) {
|
||||
#endif
|
||||
PUTCHAR (IPX_ROUTER_PROTOCOL, ucp);
|
||||
PUTCHAR (CILEN_PROTOCOL, ucp);
|
||||
PUTSHORT (go->router, ucp);
|
||||
}
|
||||
|
||||
if (go->neg_complete) {
|
||||
PUTCHAR (IPX_COMPLETE, ucp);
|
||||
PUTCHAR (CILEN_COMPLETE, ucp);
|
||||
if (ucp - ucp1 != *lenp) {
|
||||
syslog(LOG_ERR, "Bug in ipxcp_addci: wrong length");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,30 +534,33 @@ ipxcp_ackci(f, p, len)
|
|||
break; \
|
||||
}
|
||||
|
||||
#define ACKCIPROTO(opt, neg, val) \
|
||||
if (neg && p[1] == CILEN_PROTOCOL && len >= p[1] && p[0] == opt) \
|
||||
{ \
|
||||
INCPTR(2, p); \
|
||||
len -= CILEN_PROTOCOL; \
|
||||
GETSHORT(cishort, p); \
|
||||
if (cishort != (val)) \
|
||||
break; \
|
||||
}
|
||||
/*
|
||||
* Process the ACK frame in the order in which the frame was assembled
|
||||
*/
|
||||
do {
|
||||
ACKCINETWORK (IPX_NETWORK_NUMBER, go->neg_nn, go->our_network);
|
||||
ACKCINODE (IPX_NODE_NUMBER, go->neg_node, go->our_node);
|
||||
ACKCINAME (IPX_ROUTER_NAME, go->neg_name, go->name);
|
||||
ACKCIPROTO (IPX_ROUTER_PROTOCOL, go->neg_router, go->router);
|
||||
ACKCICOMPLETE (IPX_COMPLETE, go->neg_complete);
|
||||
/*
|
||||
* This is the end of the record.
|
||||
*/
|
||||
if (len == 0)
|
||||
return (1);
|
||||
} while (0);
|
||||
do {
|
||||
ACKCINETWORK (IPX_NETWORK_NUMBER, go->neg_nn, go->our_network);
|
||||
ACKCINODE (IPX_NODE_NUMBER, go->neg_node, go->our_node);
|
||||
ACKCINAME (IPX_ROUTER_NAME, go->neg_name, go->name);
|
||||
if(p[0] == IPX_ROUTER_PROTOCOL && go->neg_router && p[1] == CILEN_PROTOCOL && len >= p[1]) {
|
||||
int i;
|
||||
INCPTR(2, p);
|
||||
len -= CILEN_PROTOCOL;
|
||||
GETSHORT(cishort, p);
|
||||
for(i=0;i<go->num_router;i++) {
|
||||
if(cishort == go->router[i]) {
|
||||
go->router[0] = go->router[i];
|
||||
go->num_router = 1;
|
||||
i = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == go->num_router)
|
||||
break;
|
||||
}
|
||||
ACKCICOMPLETE (IPX_COMPLETE, go->neg_complete);
|
||||
if (len == 0)
|
||||
return (1);
|
||||
} while (0);
|
||||
/*
|
||||
* The frame is invalid
|
||||
*/
|
||||
|
@ -566,6 +586,7 @@ ipxcp_nakci(f, p, len)
|
|||
{
|
||||
int linkunit = f->unit;
|
||||
int unit = lns[linkunit].ipxcp_unit;
|
||||
int i;
|
||||
ipxcp_options *go = &ipxcp_gotoptions[unit];
|
||||
ipxcp_options *ao = &ipxcp_allowoptions[unit];
|
||||
ipxcp_options *ho = &ipxcp_hisoptions[unit];
|
||||
|
@ -618,24 +639,24 @@ ipxcp_nakci(f, p, len)
|
|||
goto bad;
|
||||
|
||||
case IPX_ROUTER_PROTOCOL:
|
||||
if (!go->neg_router || (cilen < CILEN_PROTOCOL))
|
||||
goto bad;
|
||||
|
||||
GETSHORT (s, p);
|
||||
if ((s != 0) && (s != 2) && (s != 4))
|
||||
goto bad;
|
||||
|
||||
if (no.router & s)
|
||||
goto bad;
|
||||
|
||||
if (no.router == 0) /* Reset on first NAK only */
|
||||
try.router = 0;
|
||||
no.router |= s;
|
||||
try.router |= s;
|
||||
try.neg_router = 1;
|
||||
|
||||
IPXCPDEBUG((LOG_INFO, "Router protocol number %d", s));
|
||||
break;
|
||||
if (!go->neg_router || (cilen < CILEN_PROTOCOL))
|
||||
goto bad;
|
||||
GETSHORT (s, p);
|
||||
for(i=0;i<go->num_router;i++) {
|
||||
if(go->router[i] == s) {
|
||||
go->router[0] = s;
|
||||
go->num_router = 1;
|
||||
i = 0;
|
||||
IPXCPDEBUG((LOG_INFO, "Router protocol number %d", s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == go->num_router) {
|
||||
go->router[0] = 0;
|
||||
go->num_router = 1;
|
||||
IPXCPDEBUG((LOG_INFO, "try Router protocol number %d", s));
|
||||
}
|
||||
break;
|
||||
|
||||
/* These, according to the RFC, must never be NAKed. */
|
||||
case IPX_ROUTER_NAME:
|
||||
|
@ -651,19 +672,8 @@ ipxcp_nakci(f, p, len)
|
|||
|
||||
/* If there is still anything left, this packet is bad. */
|
||||
if (len != 0)
|
||||
goto bad;
|
||||
goto bad;
|
||||
|
||||
/*
|
||||
* Do not permit the peer to force a router protocol which we do not
|
||||
* support.
|
||||
*/
|
||||
try.router &= go->router;
|
||||
if (try.router == 0 && go->router != 0) {
|
||||
try.neg_router = 1;
|
||||
/* try.router = BIT(0); */
|
||||
/* grrr: who has done the whole BIT(blabla) stuff? this will never work! */
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, the Nak is good. Now we can update state.
|
||||
*/
|
||||
|
@ -729,20 +739,6 @@ static int ipxcp_rejci(fsm *f,u_char *p,int len)
|
|||
IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected void opt %d", opt)); \
|
||||
}
|
||||
|
||||
#define REJCIPROTO(opt, neg, val) \
|
||||
if (neg && p[1] == CILEN_PROTOCOL && len >= p[1] && p[0] == opt) \
|
||||
{ \
|
||||
INCPTR(2, p); \
|
||||
len -= CILEN_PROTOCOL; \
|
||||
GETSHORT(cishort, p); \
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected router proto 0x%04x", cishort)); \
|
||||
if ((cishort & val) == 0) \
|
||||
break; \
|
||||
val &= ~cishort; \
|
||||
if (val == 0) \
|
||||
neg = 0; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Any Rejected CIs must be in exactly the same order that we sent.
|
||||
* Check packet length and CI length at each step.
|
||||
|
@ -750,20 +746,32 @@ static int ipxcp_rejci(fsm *f,u_char *p,int len)
|
|||
*/
|
||||
try = *go;
|
||||
|
||||
do {
|
||||
REJCINETWORK (IPX_NETWORK_NUMBER, try.neg_nn, try.our_network);
|
||||
REJCINODE (IPX_NODE_NUMBER, try.neg_node, try.our_node);
|
||||
REJCIPROTO (IPX_ROUTER_PROTOCOL, try.neg_router, try.router);
|
||||
REJCINAME (IPX_ROUTER_NAME, try.neg_name, try.name);
|
||||
REJCIVOID (IPX_COMPLETE, try.neg_complete);
|
||||
/*
|
||||
* This is the end of the record.
|
||||
*/
|
||||
if (len == 0) {
|
||||
if (f->state != OPENED)
|
||||
*go = try;
|
||||
return (1);
|
||||
}
|
||||
do {
|
||||
REJCINETWORK (IPX_NETWORK_NUMBER, try.neg_nn, try.our_network);
|
||||
REJCINODE (IPX_NODE_NUMBER, try.neg_node, try.our_node);
|
||||
if(p[0] == IPX_ROUTER_PROTOCOL && try.neg_router && p[1] == CILEN_PROTOCOL && len >= p[1]) {
|
||||
int i;
|
||||
INCPTR(2, p);
|
||||
len -= CILEN_PROTOCOL;
|
||||
GETSHORT(cishort, p);
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected router proto 0x%04x", cishort));
|
||||
for(i=0;i<try.num_router;i++) {
|
||||
if(try.router[i] == cishort)
|
||||
break;
|
||||
}
|
||||
if(i == try.num_router)
|
||||
break;
|
||||
try.num_router--;
|
||||
try.router[i] = try.router[try.num_router];
|
||||
}
|
||||
REJCINAME (IPX_ROUTER_NAME, try.neg_name, try.name);
|
||||
REJCIVOID (IPX_COMPLETE, try.neg_complete);
|
||||
|
||||
if (len == 0) {
|
||||
if (f->state != OPENED)
|
||||
*go = try;
|
||||
return (1);
|
||||
}
|
||||
} while (0);
|
||||
/*
|
||||
* The frame is invalid at this point.
|
||||
|
@ -944,79 +952,56 @@ ipxcp_reqci(f, inp, len, reject_if_disagree)
|
|||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Compression Protocol request "));
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
/*
|
||||
* The routing protocol is a bitmask of various types. Any combination
|
||||
* of the values 2 and 4 are permissible. '0' for no routing protocol must
|
||||
* be specified only once.
|
||||
*/
|
||||
case IPX_ROUTER_PROTOCOL:
|
||||
if ( !ao->neg_router || cilen < CILEN_PROTOCOL ) {
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !ao->neg_router || cilen < CILEN_PROTOCOL ) {
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
GETSHORT (cishort, p);
|
||||
IPXCPDEBUG((LOG_INFO,
|
||||
"Remote router protocol number %d",
|
||||
cishort));
|
||||
IPXCPDEBUG((LOG_INFO, "Remote router protocol number %d", cishort));
|
||||
|
||||
#if 0
|
||||
if ((cishort == 0 && ho->router != 0) || (ho->router & BIT(0))) {
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (cishort != 0 && cishort != 2 && cishort != 4) {
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cishort != 0 && cishort != 2 && cishort != 4) {
|
||||
orc = CONFREJ;
|
||||
ho->router[ho->num_router] = cishort;
|
||||
ho->num_router++;
|
||||
if(ho->num_router > 31)
|
||||
ho->num_router = 31;
|
||||
ho->neg_router = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ho->router & cishort) {
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
|
||||
ho->router |= cishort;
|
||||
ho->neg_router = 1;
|
||||
break;
|
||||
/*
|
||||
* The router name is advisorary. Just accept it if it is not too large.
|
||||
*/
|
||||
case IPX_ROUTER_NAME:
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Router Name request"));
|
||||
if (cilen >= CILEN_NAME) {
|
||||
int name_size = cilen - CILEN_NAME;
|
||||
if (name_size > sizeof (ho->name))
|
||||
name_size = sizeof (ho->name) - 1;
|
||||
memset (ho->name, 0, sizeof (ho->name));
|
||||
memcpy (ho->name, p, name_size);
|
||||
ho->name [name_size] = '\0';
|
||||
ho->neg_name = 1;
|
||||
orc = CONFACK;
|
||||
break;
|
||||
}
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
/*
|
||||
* This is advisorary.
|
||||
*/
|
||||
case IPX_COMPLETE:
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request"));
|
||||
if (cilen != CILEN_COMPLETE)
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Router Name request"));
|
||||
if (cilen >= CILEN_NAME) {
|
||||
int name_size = cilen - CILEN_NAME;
|
||||
if (name_size > sizeof (ho->name))
|
||||
name_size = sizeof (ho->name) - 1;
|
||||
memset (ho->name, 0, sizeof (ho->name));
|
||||
memcpy (ho->name, p, name_size);
|
||||
ho->name [name_size] = '\0';
|
||||
ho->neg_name = 1;
|
||||
orc = CONFACK;
|
||||
break;
|
||||
}
|
||||
orc = CONFREJ;
|
||||
else {
|
||||
ho->neg_complete = 1;
|
||||
orc = CONFACK;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
* All other entries are not known at this time.
|
||||
*/
|
||||
break;
|
||||
|
||||
case IPX_COMPLETE:
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request"));
|
||||
if (cilen != CILEN_COMPLETE)
|
||||
orc = CONFREJ;
|
||||
else {
|
||||
ho->neg_complete = 1;
|
||||
orc = CONFACK;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request"));
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request"));
|
||||
orc = CONFREJ;
|
||||
break;
|
||||
}
|
||||
|
||||
endswitch:
|
||||
|
@ -1174,69 +1159,65 @@ static void ipxcp_down(fsm *f)
|
|||
*/
|
||||
static void ipxcp_script(fsm *f,char *script)
|
||||
{
|
||||
int linkunit = f->unit;
|
||||
int unit = lns[linkunit].ipxcp_unit;
|
||||
ipxcp_options *ho = &ipxcp_hisoptions[unit];
|
||||
ipxcp_options *go = &ipxcp_gotoptions[unit];
|
||||
int linkunit = f->unit;
|
||||
int unit = lns[linkunit].ipxcp_unit;
|
||||
ipxcp_options *ho = &ipxcp_hisoptions[unit];
|
||||
ipxcp_options *go = &ipxcp_gotoptions[unit];
|
||||
|
||||
char strspeed[32], strlocal[32], strremote[32];
|
||||
char strnetwork[32], strpid[32];
|
||||
char *argv[14], strproto_lcl[32], strproto_rmt[32];
|
||||
char strspeed[32], strlocal[32], strremote[32];
|
||||
char strnetwork[32], strpid[32];
|
||||
char *argv[14];
|
||||
char strproto_lcl[32], strproto_rmt[32];
|
||||
|
||||
sprintf (strpid, "%d", getpid());
|
||||
sprintf (strspeed, "%d", baud_rate);
|
||||
sprintf (strpid, "%d", getpid());
|
||||
sprintf (strspeed, "%d", baud_rate);
|
||||
|
||||
strproto_lcl[0] = '\0';
|
||||
if (go->neg_router) {
|
||||
if (go->router & 2 )
|
||||
strcpy (strproto_lcl, "RIP ");
|
||||
if (go->router & 4 )
|
||||
strcpy (strproto_lcl, "NLSP ");
|
||||
strproto_lcl[0] = '\0';
|
||||
if (go->neg_router) {
|
||||
if (go->router[0] == 2 )
|
||||
strcpy (strproto_lcl, "RIP ");
|
||||
if (go->router[0] == 4 )
|
||||
strcpy (strproto_lcl, "NLSP ");
|
||||
}
|
||||
|
||||
if (strproto_lcl[0] == '\0')
|
||||
strcpy (strproto_lcl, "NONE ");
|
||||
if (strproto_lcl[0] == '\0')
|
||||
strcpy (strproto_lcl, "NONE ");
|
||||
|
||||
strproto_lcl[strlen (strproto_lcl)-1] = '\0';
|
||||
strproto_lcl[strlen (strproto_lcl)-1] = '\0';
|
||||
|
||||
strproto_rmt[0] = '\0';
|
||||
if (ho->neg_router) {
|
||||
if (ho->router & 2 )
|
||||
strcpy (strproto_rmt, "RIP ");
|
||||
if (ho->router & 4 )
|
||||
strcpy (strproto_rmt, "NLSP ");
|
||||
}
|
||||
strproto_rmt[0] = '\0';
|
||||
if (ho->neg_router) {
|
||||
if (ho->router[0] == 2 )
|
||||
strcpy (strproto_rmt, "RIP ");
|
||||
if (ho->router[0] == 4 )
|
||||
strcpy (strproto_rmt, "NLSP ");
|
||||
}
|
||||
|
||||
if (strproto_rmt[0] == '\0')
|
||||
strcpy (strproto_rmt, "NONE ");
|
||||
if (strproto_rmt[0] == '\0')
|
||||
strcpy (strproto_rmt, "NONE ");
|
||||
|
||||
strproto_rmt[strlen (strproto_rmt)-1] = '\0';
|
||||
strproto_rmt[strlen (strproto_rmt)-1] = '\0';
|
||||
|
||||
strcpy (strnetwork, ipx_ntoa (go->network));
|
||||
strcpy (strnetwork, ipx_ntoa (go->network));
|
||||
|
||||
sprintf (strlocal,
|
||||
"%02X%02X%02X%02X%02X%02X",
|
||||
NODE(go->our_node));
|
||||
sprintf (strlocal, "%02X%02X%02X%02X%02X%02X", NODE(go->our_node));
|
||||
sprintf (strremote, "%02X%02X%02X%02X%02X%02X", NODE(ho->his_node));
|
||||
|
||||
sprintf (strremote,
|
||||
"%02X%02X%02X%02X%02X%02X",
|
||||
NODE(ho->his_node));
|
||||
|
||||
argv[0] = script;
|
||||
argv[1] = lns[linkunit].ifname;
|
||||
argv[2] = lns[linkunit].devnam;
|
||||
argv[3] = strspeed;
|
||||
argv[4] = strnetwork;
|
||||
argv[5] = strlocal;
|
||||
argv[6] = strremote;
|
||||
argv[7] = strproto_lcl;
|
||||
argv[8] = strproto_rmt;
|
||||
argv[9] = go->name;
|
||||
argv[10] = ho->name;
|
||||
argv[11] = ipparam;
|
||||
argv[12] = strpid;
|
||||
argv[13] = NULL;
|
||||
run_program(script, argv, 0 , linkunit);
|
||||
argv[0] = script;
|
||||
argv[1] = lns[linkunit].ifname;
|
||||
argv[2] = lns[linkunit].devnam;
|
||||
argv[3] = strspeed;
|
||||
argv[4] = strnetwork;
|
||||
argv[5] = strlocal;
|
||||
argv[6] = strremote;
|
||||
argv[7] = strproto_lcl;
|
||||
argv[8] = strproto_rmt;
|
||||
argv[9] = go->name;
|
||||
argv[10] = ho->name;
|
||||
argv[11] = ipparam;
|
||||
argv[12] = strpid;
|
||||
argv[13] = NULL;
|
||||
run_program(script, argv, 0 , linkunit);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1249,122 +1230,135 @@ static char *ipxcp_codenames[] = {
|
|||
|
||||
static int ipxcp_printpkt(u_char *p,int plen,void (*printer) __P((void *, char *, ...)),void *arg)
|
||||
{
|
||||
int code, id, len, olen;
|
||||
u_char *pstart, *optend;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
int code, id, len, olen;
|
||||
u_char *pstart, *optend;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
|
||||
if (plen < HEADERLEN)
|
||||
return 0;
|
||||
pstart = p;
|
||||
GETCHAR(code, p);
|
||||
GETCHAR(id, p);
|
||||
GETSHORT(len, p);
|
||||
if (len < HEADERLEN || len > plen)
|
||||
return 0;
|
||||
if (plen < HEADERLEN)
|
||||
return 0;
|
||||
pstart = p;
|
||||
GETCHAR(code, p);
|
||||
GETCHAR(id, p);
|
||||
GETSHORT(len, p);
|
||||
if (len < HEADERLEN || len > plen)
|
||||
return 0;
|
||||
|
||||
if (code >= 1 && code <= sizeof(ipxcp_codenames) / sizeof(char *))
|
||||
printer(arg, " %s", ipxcp_codenames[code-1]);
|
||||
else
|
||||
printer(arg, " code=0x%x", code);
|
||||
printer(arg, " id=0x%x", id);
|
||||
len -= HEADERLEN;
|
||||
switch (code) {
|
||||
case CONFREQ:
|
||||
case CONFACK:
|
||||
case CONFNAK:
|
||||
case CONFREJ:
|
||||
if (code >= 1 && code <= sizeof(ipxcp_codenames) / sizeof(char *))
|
||||
printer(arg, " %s", ipxcp_codenames[code-1]);
|
||||
else
|
||||
printer(arg, " code=0x%x", code);
|
||||
printer(arg, " id=0x%x", id);
|
||||
len -= HEADERLEN;
|
||||
switch (code) {
|
||||
case CONFREQ:
|
||||
case CONFACK:
|
||||
case CONFNAK:
|
||||
case CONFREJ:
|
||||
/* print option list */
|
||||
while (len >= 2) {
|
||||
GETCHAR(code, p);
|
||||
GETCHAR(olen, p);
|
||||
p -= 2;
|
||||
if (olen < CILEN_VOID || olen > len) {
|
||||
break;
|
||||
}
|
||||
printer(arg, " <");
|
||||
len -= olen;
|
||||
optend = p + olen;
|
||||
switch (code) {
|
||||
case IPX_NETWORK_NUMBER:
|
||||
if (olen == CILEN_NETN) {
|
||||
p += CILEN_VOID;
|
||||
GETLONG(cilong, p);
|
||||
printer (arg, "network %s", ipx_ntoa (cilong));
|
||||
}
|
||||
break;
|
||||
case IPX_NODE_NUMBER:
|
||||
if (olen == CILEN_NODEN) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "node ");
|
||||
while (p < optend) {
|
||||
while (len >= 2) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, "%.2x", code);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPX_COMPRESSION_PROTOCOL:
|
||||
if (olen == CILEN_COMPRESS) {
|
||||
p += CILEN_VOID;
|
||||
GETSHORT (cishort, p);
|
||||
printer (arg, "compression %d", cishort);
|
||||
}
|
||||
break;
|
||||
case IPX_ROUTER_PROTOCOL:
|
||||
if (olen == CILEN_PROTOCOL) {
|
||||
p += CILEN_VOID;
|
||||
GETSHORT (cishort, p);
|
||||
printer (arg, "router proto %d", cishort);
|
||||
}
|
||||
break;
|
||||
case IPX_ROUTER_NAME:
|
||||
if (olen >= CILEN_NAME) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "router name \"");
|
||||
while (p < optend) {
|
||||
GETCHAR(code, p);
|
||||
if (code >= 0x20 && code < 0x7E)
|
||||
printer (arg, "%c", code);
|
||||
else
|
||||
printer (arg, " \\%.2x", code);
|
||||
}
|
||||
printer (arg, "\"");
|
||||
}
|
||||
break;
|
||||
case IPX_COMPLETE:
|
||||
if (olen == CILEN_COMPLETE) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "complete");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GETCHAR(olen, p);
|
||||
p -= 2;
|
||||
if (olen < CILEN_VOID || olen > len)
|
||||
break;
|
||||
printer(arg, " <");
|
||||
len -= olen;
|
||||
optend = p + olen;
|
||||
switch (code) {
|
||||
case IPX_NETWORK_NUMBER:
|
||||
if (olen == CILEN_NETN) {
|
||||
p += CILEN_VOID;
|
||||
GETLONG(cilong, p);
|
||||
printer (arg, "network %s", ipx_ntoa (cilong));
|
||||
}
|
||||
break;
|
||||
case IPX_NODE_NUMBER:
|
||||
if (olen == CILEN_NODEN) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "node ");
|
||||
while (p < optend) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, "%.2x", code);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPX_COMPRESSION_PROTOCOL:
|
||||
if (olen >= CILEN_COMPRESS) {
|
||||
int i;
|
||||
p += CILEN_VOID;
|
||||
GETSHORT (cishort, p);
|
||||
printer (arg, "compression %d", cishort);
|
||||
for(i=0;i<(olen-CILEN_COMPRESS);i++) {
|
||||
unsigned char ccode;
|
||||
GETCHAR(ccode, p);
|
||||
printer (arg, "%#02x ",(int)ccode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPX_ROUTER_PROTOCOL:
|
||||
if (olen >= CILEN_PROTOCOL) {
|
||||
int i;
|
||||
p += CILEN_VOID;
|
||||
GETSHORT (cishort, p);
|
||||
printer (arg, "router proto %d", cishort);
|
||||
for(i=0;i<(olen-CILEN_PROTOCOL);i++) {
|
||||
unsigned char ccode;
|
||||
GETCHAR(ccode, p);
|
||||
printer (arg, "%#02x ",(int)ccode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPX_ROUTER_NAME:
|
||||
if (olen >= CILEN_NAME) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "router name \"");
|
||||
while (p < optend) {
|
||||
GETCHAR(code, p);
|
||||
if (code >= 0x20 && code < 0x7E)
|
||||
printer (arg, "%c", code);
|
||||
else
|
||||
printer (arg, " \\%.2x", code);
|
||||
}
|
||||
printer (arg, "\"");
|
||||
}
|
||||
break;
|
||||
case IPX_COMPLETE:
|
||||
if (olen == CILEN_COMPLETE) {
|
||||
p += CILEN_VOID;
|
||||
printer (arg, "complete");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
while (p < optend) {
|
||||
while (p < optend) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, " %.2x", code);
|
||||
}
|
||||
printer(arg, ">");
|
||||
}
|
||||
break;
|
||||
|
||||
case TERMACK:
|
||||
case TERMREQ:
|
||||
if (len > 0 && *p >= ' ' && *p < 0x7f) {
|
||||
printer(arg, " ");
|
||||
print_string(p, len, printer, arg);
|
||||
p += len;
|
||||
len = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* print the rest of the bytes in the packet
|
||||
*/
|
||||
for (; len > 0; --len) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, " %.2x", code);
|
||||
}
|
||||
printer(arg, ">");
|
||||
}
|
||||
break;
|
||||
|
||||
case TERMACK:
|
||||
case TERMREQ:
|
||||
if (len > 0 && *p >= ' ' && *p < 0x7f) {
|
||||
printer(arg, " ");
|
||||
print_string(p, len, printer, arg);
|
||||
p += len;
|
||||
len = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* print the rest of the bytes in the packet */
|
||||
for (; len > 0; --len) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, " %.2x", code);
|
||||
}
|
||||
|
||||
return p - pstart;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipxcp.h,v 1.1 1997/03/07 16:01:22 hipp Exp $
|
||||
* $Id: ipxcp.h,v 1.2 1997/05/19 10:16:01 hipp Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -52,7 +52,8 @@ typedef struct ipxcp_options {
|
|||
u_char his_node[6]; /* peer's node number */
|
||||
u_char our_node[6]; /* our node number */
|
||||
u_char name [48]; /* name of the router */
|
||||
int router; /* routing protocol */
|
||||
int router[32]; /* routing protocol */
|
||||
int num_router;
|
||||
} ipxcp_options;
|
||||
|
||||
extern fsm ipxcp_fsm[];
|
||||
|
@ -66,3 +67,4 @@ extern struct protent ipxcp_protent;
|
|||
int ipxcp_getunit __P((int));
|
||||
void ipxcp_freeunit __P((int));
|
||||
|
||||
|
||||
|
|
12
ipppd/lcp.c
12
ipppd/lcp.c
|
@ -21,9 +21,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: lcp.c,v 1.2 1997/04/26 17:17:34 hipp Exp $";
|
||||
#endif
|
||||
char lcp_rcsid[] = "$Id: lcp.c,v 1.3 1997/05/19 10:16:04 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -171,7 +169,7 @@ int lcp_loopbackfail = DEFLOOPBACKFAIL;
|
|||
/*
|
||||
* lcp_init - Initialize LCP.
|
||||
*/
|
||||
void lcp_init(int unit)
|
||||
static void lcp_init(int unit)
|
||||
{
|
||||
static int first_call=1;
|
||||
|
||||
|
@ -186,6 +184,8 @@ void lcp_init(int unit)
|
|||
first_call = 0;
|
||||
}
|
||||
|
||||
memset(f,0,sizeof(fsm));
|
||||
|
||||
f->unit = -1;
|
||||
f->protocol = PPP_LCP;
|
||||
f->callbacks = &lcp_callbacks;
|
||||
|
@ -324,7 +324,7 @@ static void RestartIdleTimer(fsm *f)
|
|||
*/
|
||||
if (ioctl (tlns->fd, PPPIOCGIDLE, &ddinfo) < 0) {
|
||||
syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m");
|
||||
die (1);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Compute the time since the last packet was received. If the timer
|
||||
|
@ -2005,7 +2005,7 @@ static void LcpEchoCheck (fsm *f)
|
|||
*/
|
||||
if (ioctl (lns[f->unit].fd, PPPIOCGIDLE, &ddinfo) < 0) {
|
||||
syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m");
|
||||
die (1);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Compute the time since the last packet was received. If the timer
|
||||
|
|
|
@ -17,12 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: magic.c,v 1.2 1997/04/26 17:17:37 hipp Exp $";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char magic_rcsid[] = "$Id: magic.c,v 1.3 1997/05/19 10:16:11 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
|
313
ipppd/main.c
313
ipppd/main.c
|
@ -25,9 +25,7 @@
|
|||
* PATCHLEVEL 9
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: main.c,v 1.4 1997/05/07 14:51:36 hipp Exp $";
|
||||
#endif
|
||||
char main_rcsid[] = "$Id: main.c,v 1.5 1997/05/19 10:16:13 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -77,7 +75,7 @@ static char rcsid[] = "$Id: main.c,v 1.4 1997/05/07 14:51:36 hipp Exp $";
|
|||
/* interface vars */
|
||||
|
||||
extern void make_options_global(int slot);
|
||||
static char pidfilename[MAXPATHLEN]; /* name of pid file */
|
||||
char pidfilename[MAXPATHLEN]; /* name of pid file */
|
||||
char *progname; /* Name of this program */
|
||||
char hostname[MAXNAMELEN]; /* Our hostname */
|
||||
static pid_t pid; /* Our pid */
|
||||
|
@ -148,6 +146,17 @@ void main(int argc,char **argv)
|
|||
sigset_t mask;
|
||||
struct protent *protp;
|
||||
|
||||
if(argc > 1 && !strcmp(argv[1],"-version")) {
|
||||
fprintf(stderr,"ipppd %s.%d (isdn4linux version of pppd by MH) started\n", VERSION, PATCHLEVEL);
|
||||
fprintf(stderr,"%s\n%s\n%s\n%s\n%s\n",lcp_rcsid,ipcp_rcsid,ipxcp_rcsid,ccp_rcsid,magic_rcsid);
|
||||
fprintf(stderr,"%s\n%s\n%s\n%s\n",chap_rcsid,upap_rcsid,main_rcsid,options_rcsid);
|
||||
fprintf(stderr,"%s\n%s\n%s\n",fsm_rcsid,cbcp_rcsid,sys_rcsid);
|
||||
#ifdef USE_MSCHAP
|
||||
fprintf(stderr,"%s\n",chap_ms_rcsid);
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(i=0;i<NUM_PPP;i++) {
|
||||
lns[i].openfails = 0;
|
||||
lns[i].initfdflags = -1;
|
||||
|
@ -174,6 +183,7 @@ void main(int argc,char **argv)
|
|||
}
|
||||
hostname[MAXNAMELEN-1] = 0;
|
||||
|
||||
pidfilename[0] = 0;
|
||||
uid = getuid();
|
||||
|
||||
/*
|
||||
|
@ -183,16 +193,12 @@ void main(int argc,char **argv)
|
|||
*/
|
||||
progname = *argv;
|
||||
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
for (i = 0; (protp = protocols[i]) != NULL; i++)
|
||||
for(j=0;j<NUM_PPP;j++)
|
||||
(*protp->init)(j); /* modifies our options .. !!!! */
|
||||
|
||||
if (!options_from_file(_PATH_SYSOPTIONS, REQ_SYSOPTIONS, 0 , 0) ||
|
||||
#if 0
|
||||
!options_from_user() ||
|
||||
#endif
|
||||
!parse_args(argc-1, argv+1) ||
|
||||
!options_for_tty() )
|
||||
!parse_args(argc-1, argv+1) || !options_for_tty() )
|
||||
die(1);
|
||||
|
||||
/*
|
||||
|
@ -245,13 +251,15 @@ void main(int argc,char **argv)
|
|||
pid = getpid();
|
||||
|
||||
/* write pid to file */
|
||||
sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, "ipppd" );
|
||||
if ((pidfile = fopen(pidfilename, "w")) != NULL) {
|
||||
fprintf(pidfile, "%d\n", pid);
|
||||
fclose(pidfile);
|
||||
} else {
|
||||
syslog(LOG_ERR, "Failed to create pid file %s: %m", pidfilename);
|
||||
pidfilename[0] = 0;
|
||||
if(!strlen(pidfilename)) {
|
||||
sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, "ipppd" );
|
||||
if ((pidfile = fopen(pidfilename, "w")) != NULL) {
|
||||
fprintf(pidfile, "%d\n", pid);
|
||||
fclose(pidfile);
|
||||
} else {
|
||||
syslog(LOG_ERR, "Failed to create pid file %s: %m", pidfilename);
|
||||
pidfilename[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
syslog(LOG_NOTICE, "ipppd %s.%d (isdn4linux version of pppd by MH) started", VERSION, PATCHLEVEL);
|
||||
|
@ -628,23 +636,12 @@ void demuxprotrej(int linkunit,u_short protocol)
|
|||
/*
|
||||
* bad_signal - We've caught a fatal signal. Clean up state and exit.
|
||||
*/
|
||||
static void
|
||||
bad_signal(sig)
|
||||
int sig;
|
||||
static void bad_signal(int sig)
|
||||
{
|
||||
syslog(LOG_ERR, "Fatal signal %d", sig);
|
||||
die(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* quit - Clean up state and exit (with an error indication).
|
||||
*/
|
||||
void
|
||||
quit()
|
||||
{
|
||||
die(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* die - like quit, except we can specify an exit status.
|
||||
*/
|
||||
|
@ -716,62 +713,55 @@ void timeout(void (*func)(),caddr_t arg,int time)
|
|||
/*
|
||||
* Allocate timeout.
|
||||
*/
|
||||
if ((newp = (struct callout *) malloc(sizeof(struct callout))) == NULL) {
|
||||
syslog(LOG_ERR, "Out of memory in timeout()!");
|
||||
die(1);
|
||||
}
|
||||
newp->c_arg = arg;
|
||||
newp->c_func = func;
|
||||
gettimeofday(&timenow, NULL);
|
||||
newp->c_time.tv_sec = timenow.tv_sec + time;
|
||||
newp->c_time.tv_usec = timenow.tv_usec;
|
||||
if ((newp = (struct callout *) malloc(sizeof(struct callout))) == NULL) {
|
||||
syslog(LOG_ERR, "Out of memory in timeout()!");
|
||||
die(1);
|
||||
}
|
||||
newp->c_arg = arg;
|
||||
newp->c_func = func;
|
||||
gettimeofday(&timenow, NULL);
|
||||
newp->c_time.tv_sec = timenow.tv_sec + time;
|
||||
newp->c_time.tv_usec = timenow.tv_usec;
|
||||
|
||||
/*
|
||||
* Find correct place and link it in.
|
||||
*/
|
||||
for (pp = &callout; (p = *pp); pp = &p->c_next)
|
||||
if (newp->c_time.tv_sec < p->c_time.tv_sec
|
||||
|| (newp->c_time.tv_sec == p->c_time.tv_sec
|
||||
&& newp->c_time.tv_usec < p->c_time.tv_sec))
|
||||
break;
|
||||
newp->c_next = p;
|
||||
*pp = newp;
|
||||
for (pp = &callout; (p = *pp); pp = &p->c_next) {
|
||||
if (newp->c_time.tv_sec < p->c_time.tv_sec
|
||||
|| (newp->c_time.tv_sec == p->c_time.tv_sec
|
||||
&& newp->c_time.tv_usec < p->c_time.tv_sec))
|
||||
break;
|
||||
}
|
||||
newp->c_next = p;
|
||||
*pp = newp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* untimeout - Unschedule a timeout.
|
||||
*/
|
||||
void
|
||||
untimeout(func, arg)
|
||||
void (*func)();
|
||||
caddr_t arg;
|
||||
void untimeout(void (*func)(),caddr_t arg)
|
||||
{
|
||||
#if 0
|
||||
struct itimerval itv;
|
||||
int reschedule = 0;
|
||||
#endif
|
||||
struct callout **copp, *freep;
|
||||
struct callout **copp, *freep;
|
||||
|
||||
MAINDEBUG((LOG_DEBUG, "Untimeout %lx:%lx.", (long) func, (long) arg));
|
||||
MAINDEBUG((LOG_DEBUG, "Untimeout %lx:%lx.", (long) func, (long) arg));
|
||||
|
||||
/*
|
||||
* Find first matching timeout and remove it from the list.
|
||||
*/
|
||||
for (copp = &callout; (freep = *copp); copp = &freep->c_next)
|
||||
if (freep->c_func == func && freep->c_arg == arg) {
|
||||
*copp = freep->c_next;
|
||||
(void) free((char *) freep);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Find first matching timeout and remove it from the list.
|
||||
*/
|
||||
for (copp = &callout; (freep = *copp); copp = &freep->c_next)
|
||||
if (freep->c_func == func && freep->c_arg == arg) {
|
||||
*copp = freep->c_next;
|
||||
free((char *) freep);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* calltimeout - Call any timeout routines which are now due.
|
||||
*/
|
||||
void
|
||||
calltimeout()
|
||||
void calltimeout()
|
||||
{
|
||||
struct callout *p;
|
||||
|
||||
|
@ -938,56 +928,44 @@ int run_program(char *prog,char **args,int must_exist,int unit)
|
|||
int pid;
|
||||
char *nullenv[1];
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
syslog(LOG_ERR, "Failed to create child process for %s: %m", prog);
|
||||
return -1;
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
syslog(LOG_ERR, "Failed to create child process for %s: %m", prog);
|
||||
return -1;
|
||||
}
|
||||
if (pid == 0) {
|
||||
int new_fd;
|
||||
if (pid == 0) {
|
||||
int new_fd;
|
||||
|
||||
/* Leave the current location */
|
||||
(void) setsid(); /* No controlling tty. */
|
||||
(void) umask (S_IRWXG|S_IRWXO);
|
||||
(void) chdir ("/"); /* no current directory. */
|
||||
setuid(geteuid());
|
||||
setgid(getegid());
|
||||
setsid();
|
||||
umask (S_IRWXG|S_IRWXO);
|
||||
chdir ("/");
|
||||
setuid(geteuid());
|
||||
setgid(getegid());
|
||||
|
||||
/* Ensure that nothing of our device environment is inherited. */
|
||||
close (0);
|
||||
close (1);
|
||||
close (2);
|
||||
close (lns[unit].fd); /* tty interface to the ppp device */
|
||||
/* XXX should call sysdep cleanup procedure here */
|
||||
close (0);
|
||||
close (1);
|
||||
close (2);
|
||||
close (lns[unit].fd);
|
||||
|
||||
/* Don't pass handles to the PPP device, even by accident. */
|
||||
new_fd = open (_PATH_DEVNULL, O_RDWR);
|
||||
if (new_fd >= 0) {
|
||||
if (new_fd != 0) {
|
||||
dup2 (new_fd, 0); /* stdin <- /dev/null */
|
||||
close (new_fd);
|
||||
}
|
||||
dup2 (0, 1); /* stdout -> /dev/null */
|
||||
dup2 (0, 2); /* stderr -> /dev/null */
|
||||
new_fd = open (_PATH_DEVNULL, O_RDWR);
|
||||
if (new_fd >= 0) {
|
||||
if (new_fd != 0) {
|
||||
dup2 (new_fd, 0); /* stdin <- /dev/null */
|
||||
close (new_fd);
|
||||
}
|
||||
dup2 (0, 1); /* stdout -> /dev/null */
|
||||
dup2 (0, 2); /* stderr -> /dev/null */
|
||||
}
|
||||
|
||||
nullenv[0] = NULL;
|
||||
execve(prog, args, nullenv);
|
||||
if (must_exist || errno != ENOENT)
|
||||
syslog(LOG_WARNING, "Can't execute %s: %m", prog);
|
||||
return -1;
|
||||
}
|
||||
MAINDEBUG((LOG_DEBUG, "Script %s started; pid = %d", prog, pid));
|
||||
++n_children;
|
||||
|
||||
#ifdef BSD
|
||||
/* Force the priority back to zero if pppd is running higher. */
|
||||
if (setpriority (PRIO_PROCESS, 0, 0) < 0)
|
||||
syslog (LOG_WARNING, "can't reset priority to 0: %m");
|
||||
#endif
|
||||
|
||||
/* SysV recommends a second fork at this point. */
|
||||
|
||||
/* run the program; give it a null environment */
|
||||
nullenv[0] = NULL;
|
||||
execve(prog, args, nullenv);
|
||||
if (must_exist || errno != ENOENT)
|
||||
syslog(LOG_WARNING, "Can't execute %s: %m", prog);
|
||||
_exit(-1);
|
||||
}
|
||||
MAINDEBUG((LOG_DEBUG, "Script %s started; pid = %d", prog, pid));
|
||||
++n_children;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -996,25 +974,24 @@ int run_program(char *prog,char **args,int must_exist,int unit)
|
|||
* reap_kids - get status from any dead child processes,
|
||||
* and log a message for abnormal terminations.
|
||||
*/
|
||||
void
|
||||
reap_kids()
|
||||
void reap_kids()
|
||||
{
|
||||
int pid, status;
|
||||
int pid, status;
|
||||
|
||||
if (n_children == 0)
|
||||
return;
|
||||
if ((pid = waitpid(-1, &status, WNOHANG)) == -1) {
|
||||
if (errno != ECHILD)
|
||||
syslog(LOG_ERR, "Error waiting for child process: %m");
|
||||
return;
|
||||
}
|
||||
if (pid > 0) {
|
||||
--n_children;
|
||||
if (WIFSIGNALED(status)) {
|
||||
syslog(LOG_WARNING, "Child process %d terminated with signal %d",
|
||||
pid, WTERMSIG(status));
|
||||
if (n_children == 0)
|
||||
return;
|
||||
if ((pid = waitpid(-1, &status, WNOHANG)) == -1) {
|
||||
if (errno != ECHILD)
|
||||
syslog(LOG_ERR, "Error waiting for child process: %m");
|
||||
return;
|
||||
}
|
||||
if (pid > 0) {
|
||||
--n_children;
|
||||
if (WIFSIGNALED(status)) {
|
||||
syslog(LOG_WARNING, "Child process %d terminated with signal %d",
|
||||
pid, WTERMSIG(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1025,59 +1002,57 @@ reap_kids()
|
|||
char line[256]; /* line to be logged accumulated here */
|
||||
char *linep;
|
||||
|
||||
void
|
||||
log_packet(u_char *p,int len,char *prefix,int linkunit)
|
||||
void log_packet(u_char *p,int len,char *prefix,int linkunit)
|
||||
{
|
||||
strcpy(line, prefix);
|
||||
linep = line + strlen(line);
|
||||
format_packet(p, len, pr_log, NULL,linkunit);
|
||||
strcpy(line, prefix);
|
||||
linep = line + strlen(line);
|
||||
format_packet(p, len, pr_log, NULL,linkunit);
|
||||
if (linep != line)
|
||||
syslog(LOG_DEBUG, "%s", line);
|
||||
syslog(LOG_DEBUG, "%s", line);
|
||||
}
|
||||
|
||||
/*
|
||||
* format_packet - make a readable representation of a packet,
|
||||
* calling `printer(arg, format, ...)' to output it.
|
||||
*/
|
||||
void
|
||||
format_packet(u_char *p,int len,void (*printer)(void*,char*,...),void *arg,int linkunit)
|
||||
void format_packet(u_char *p,int len,void (*printer)(void*,char*,...),void *arg,int linkunit)
|
||||
{
|
||||
int i, n;
|
||||
u_short proto;
|
||||
u_char x;
|
||||
int i, n;
|
||||
u_short proto;
|
||||
u_char x;
|
||||
struct protent *protp;
|
||||
|
||||
if (len >= PPP_HDRLEN && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) {
|
||||
p += 2;
|
||||
GETSHORT(proto, p);
|
||||
len -= PPP_HDRLEN;
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
|
||||
if (proto == protp->protocol)
|
||||
break;
|
||||
}
|
||||
printer(arg,"[%d]",linkunit);
|
||||
if (protp) {
|
||||
printer(arg, "[%s", protp->name);
|
||||
n = (*protp->printpkt)(p, len, printer, arg);
|
||||
printer(arg, "]");
|
||||
p += n;
|
||||
len -= n;
|
||||
} else {
|
||||
printer(arg, "[proto=0x%x]", proto);
|
||||
}
|
||||
}
|
||||
if (len >= PPP_HDRLEN && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) {
|
||||
p += 2;
|
||||
GETSHORT(proto, p);
|
||||
len -= PPP_HDRLEN;
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
|
||||
if (proto == protp->protocol)
|
||||
break;
|
||||
}
|
||||
|
||||
for (; len > 0; --len) {
|
||||
GETCHAR(x, p);
|
||||
printer(arg, " %.2x", x);
|
||||
}
|
||||
printer(arg,"[%d]",linkunit);
|
||||
if (protp) {
|
||||
printer(arg, "[%s", protp->name);
|
||||
n = (*protp->printpkt)(p, len, printer, arg);
|
||||
printer(arg, "]");
|
||||
p += n;
|
||||
len -= n;
|
||||
} else {
|
||||
printer(arg, "[proto=0x%x]", proto);
|
||||
}
|
||||
}
|
||||
|
||||
for (; len > 0; --len) {
|
||||
GETCHAR(x, p);
|
||||
printer(arg, " %.2x", x);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
|
||||
void
|
||||
pr_log(void *arg, char *fmt, ...)
|
||||
void pr_log(void *arg, char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
va_list pvar;
|
||||
|
@ -1099,8 +1074,7 @@ pr_log(void *arg, char *fmt, ...)
|
|||
#else /* __STDC__ */
|
||||
#include <varargs.h>
|
||||
|
||||
void
|
||||
pr_log(arg, fmt, va_alist)
|
||||
void pr_log(arg, fmt, va_alist)
|
||||
void *arg;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
|
@ -1127,12 +1101,7 @@ va_dcl
|
|||
* print_string - print a readable representation of a string using
|
||||
* printer.
|
||||
*/
|
||||
void
|
||||
print_string(p, len, printer, arg)
|
||||
char *p;
|
||||
int len;
|
||||
void (*printer) __P((void *, char *, ...));
|
||||
void *arg;
|
||||
void print_string(char *p,int len,void (*printer) __P((void *, char *, ...)),void *arg)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -1150,9 +1119,7 @@ print_string(p, len, printer, arg)
|
|||
/*
|
||||
* novm - log an error message saying we ran out of memory, and die.
|
||||
*/
|
||||
void
|
||||
novm(msg)
|
||||
char *msg;
|
||||
void novm(char *msg)
|
||||
{
|
||||
syslog(LOG_ERR, "Virtual memory exhausted allocating %s\n", msg);
|
||||
die(1);
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: options.c,v 1.3 1997/05/06 13:04:06 hipp Exp $";
|
||||
#endif
|
||||
char options_rcsid[] = "$Id: options.c,v 1.4 1997/05/19 10:16:18 hipp Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
@ -168,6 +166,7 @@ static int setremote __P((int,char **));
|
|||
static int setauth __P((int));
|
||||
static int setnoauth __P((int));
|
||||
static int readfile __P((int,char **));
|
||||
static int pidfile __P((int,char **));
|
||||
static int callfile __P((int,char **));
|
||||
static int setdefaultroute __P((int));
|
||||
static int setnodefaultroute __P((int));
|
||||
|
@ -306,6 +305,7 @@ static struct cmd {
|
|||
{"auth", 0, setauth}, /* Require authentication from peer */
|
||||
{"noauth", 0, setnoauth}, /* Don't require peer to authenticate */
|
||||
{"file", 1, readfile}, /* Take options from a file */
|
||||
{"pidfile",1,pidfile},
|
||||
{"call", 1, callfile}, /* Take options from a privileged file */
|
||||
{"defaultroute", 0, setdefaultroute}, /* Add default route */
|
||||
{"nodefaultroute", 0, setnodefaultroute}, /* disable defaultroute option */
|
||||
|
@ -990,6 +990,13 @@ int_option(str, valp)
|
|||
* The following procedures execute commands.
|
||||
*/
|
||||
|
||||
static int pidfile(int slot,char **argv)
|
||||
{
|
||||
strncpy(pidfilename,argv[0],MAXPATHLEN-1);
|
||||
pidfilename[MAXPATHLEN-1] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* readfile - take commands from a file.
|
||||
*/
|
||||
|
@ -2081,9 +2088,27 @@ static int setwinsaddr(int ipcp_slot,char **argv)
|
|||
|
||||
static int setipxrouter (int slot,char **argv)
|
||||
{
|
||||
char *val,arg[1024],*endp;
|
||||
int num = 0;
|
||||
|
||||
ipxcp_wantoptions[slot].neg_router = 1;
|
||||
ipxcp_allowoptions[slot].neg_router = 1;
|
||||
return int_option(*argv, &ipxcp_wantoptions[slot].router);
|
||||
ipxcp_allowoptions[slot].num_router = 0;
|
||||
ipxcp_wantoptions[slot].num_router = 0;
|
||||
|
||||
strncpy(arg,argv[0],1023);
|
||||
val = strtok(arg,",");
|
||||
while(val) {
|
||||
ipxcp_wantoptions[slot].router[num] = strtol(val,&endp,10);
|
||||
if(*endp)
|
||||
return 0;
|
||||
num++;
|
||||
if(num == 32)
|
||||
break;
|
||||
}
|
||||
|
||||
ipxcp_wantoptions[slot].num_router = num;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setipxname (int slot,char **argv)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* define path names
|
||||
*
|
||||
* $Id: pathnames.h,v 1.2 1997/03/24 01:18:01 fritz Exp $
|
||||
* $Id: pathnames.h,v 1.3 1997/05/19 10:16:24 hipp Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -13,15 +13,15 @@
|
|||
# define _PATH_DEVNULL "/dev/null"
|
||||
#endif
|
||||
|
||||
#define _PATH_UPAPFILE "/etc/ppp/pap-secrets"
|
||||
#define _PATH_CHAPFILE "/etc/ppp/chap-secrets"
|
||||
#define _PATH_SYSOPTIONS "/etc/ppp/ioptions"
|
||||
#define _PATH_IPUP "/etc/ppp/ip-up"
|
||||
#define _PATH_IPDOWN "/etc/ppp/ip-down"
|
||||
#define _PATH_TTYOPT "/etc/ppp/ioptions."
|
||||
#define _PATH_CONNERRS "/etc/ppp/connect-errors"
|
||||
#define _PATH_PEERFILES "/etc/ppp/peers/"
|
||||
#define _PATH_USEROPT ".ippprc"
|
||||
#define _PATH_UPAPFILE "/etc/ppp/pap-secrets"
|
||||
#define _PATH_CHAPFILE "/etc/ppp/chap-secrets"
|
||||
#define _PATH_SYSOPTIONS "/etc/ppp/ioptions"
|
||||
#define _PATH_IPUP "/etc/ppp/ip-up"
|
||||
#define _PATH_IPDOWN "/etc/ppp/ip-down"
|
||||
#define _PATH_TTYOPT "/etc/ppp/ioptions."
|
||||
#define _PATH_CONNERRS "/etc/ppp/connect-errors"
|
||||
#define _PATH_USERIPTAB "/etc/ppp/useriptab"
|
||||
#define _PATH_PEERFILES "/etc/ppp/peers/"
|
||||
|
||||
/* Programs for processing authenticated logins */
|
||||
#define _PATH_AUTHUP "/etc/ppp/auth-up"
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
char sys_rcsid[] = "$Id: sys-linux.c,v 1.3 1997/05/19 10:16:26 hipp Exp $";
|
||||
|
||||
#define _LINUX_STRING_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -120,36 +122,38 @@ void enable_mp(int linkunit,int flags)
|
|||
* Functions to read and set the flags value in the device driver
|
||||
*/
|
||||
|
||||
static int get_flags (int tu)
|
||||
{
|
||||
int flags;
|
||||
static int get_flags (int tu,int *error)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if(lns[tu].fd < 0)
|
||||
return 0;
|
||||
*error = 0;
|
||||
|
||||
if (ioctl(lns[tu].fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCGFLAGS): %m");
|
||||
quit();
|
||||
}
|
||||
if(lns[tu].fd < 0) {
|
||||
*error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
MAINDEBUG ((LOG_DEBUG, "get flags = %x\n", flags));
|
||||
return flags;
|
||||
}
|
||||
if (ioctl(lns[tu].fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) {
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCGFLAGS): %m");
|
||||
*error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
MAINDEBUG ((LOG_DEBUG, "get flags = %x\n", flags));
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void set_flags (int flags,int tu)
|
||||
{
|
||||
MAINDEBUG ((LOG_DEBUG, "set flags = %x\n", flags));
|
||||
{
|
||||
MAINDEBUG ((LOG_DEBUG, "set flags = %x\n", flags));
|
||||
|
||||
if(lns[tu].fd < 0)
|
||||
return;
|
||||
if(lns[tu].fd < 0)
|
||||
return;
|
||||
|
||||
if (ioctl(lns[tu].fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS, %x): %m", flags);
|
||||
quit();
|
||||
}
|
||||
}
|
||||
if (ioctl(lns[tu].fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0) {
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS, %x): %m", flags);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* sys_init - System-dependent initialization.
|
||||
|
@ -276,6 +280,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp)
|
|||
{
|
||||
u_int x;
|
||||
struct ifreq ifr;
|
||||
int err;
|
||||
|
||||
MAINDEBUG ((LOG_DEBUG, "send_config: mtu = %d\n", mtu));
|
||||
|
||||
|
@ -294,7 +299,9 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp)
|
|||
syslog(LOG_ERR, "ioctl(SIOCSIFMTU): %m, %d %s %d.",sockfd,ifr.ifr_name,ifr.ifr_mtu);
|
||||
}
|
||||
|
||||
x = get_flags(unit);
|
||||
x = get_flags(unit,&err);
|
||||
if(err)
|
||||
return;
|
||||
x = pcomp ? x | SC_COMP_PROT : x & ~SC_COMP_PROT;
|
||||
x = accomp ? x | SC_COMP_AC : x & ~SC_COMP_AC;
|
||||
set_flags(x,unit);
|
||||
|
@ -339,6 +346,7 @@ void ppp_set_xaccm (int unit, ext_accm accm)
|
|||
void ppp_recv_config (int unit,int mru,u_int32_t asyncmap,int pcomp,int accomp)
|
||||
{
|
||||
u_int x;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* If we were called because the link has gone down then there is nothing
|
||||
|
@ -353,16 +361,9 @@ void ppp_recv_config (int unit,int mru,u_int32_t asyncmap,int pcomp,int accomp)
|
|||
if (ioctl(lns[unit].fd, PPPIOCSMRU, (caddr_t) &mru) < 0)
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCSMRU): %m");
|
||||
|
||||
#if 0
|
||||
MAINDEBUG ((LOG_DEBUG, "recv_config: asyncmap = %lx\n", asyncmap));
|
||||
if (ioctl(lns[unit].fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ioctl(PPPIOCSRASYNCMAP): %m");
|
||||
quit();
|
||||
}
|
||||
#endif
|
||||
|
||||
x = get_flags(unit);
|
||||
x = get_flags(unit,&err);
|
||||
if(err)
|
||||
return;
|
||||
x = accomp ? x & ~SC_REJ_COMP_AC : x | SC_REJ_COMP_AC;
|
||||
set_flags (x,unit);
|
||||
}
|
||||
|
@ -393,9 +394,12 @@ int ccp_test (int ccp_unit, u_char *opt_ptr, int opt_len, int for_transmit)
|
|||
void ccp_flags_set (int ccp_unit, int isopen, int isup)
|
||||
{
|
||||
int linkunit = ccp_fsm[ccp_unit].unit;
|
||||
int err;
|
||||
|
||||
if (still_ppp(linkunit)) {
|
||||
int x = get_flags(linkunit);
|
||||
int x = get_flags(linkunit,&err);
|
||||
if(err)
|
||||
return;
|
||||
x = isopen? x | SC_CCP_OPEN : x &~ SC_CCP_OPEN;
|
||||
x = isup? x | SC_CCP_UP : x &~ SC_CCP_UP;
|
||||
set_flags (x,linkunit);
|
||||
|
@ -410,7 +414,11 @@ void ccp_flags_set (int ccp_unit, int isopen, int isup)
|
|||
int ccp_fatal_error (int ccp_unit)
|
||||
{
|
||||
int linkunit = ccp_fsm[ccp_unit].unit;
|
||||
int x = get_flags(linkunit);
|
||||
int err;
|
||||
int x = get_flags(linkunit,&err);
|
||||
|
||||
if(err)
|
||||
return 0;
|
||||
|
||||
return x & SC_DC_FERROR;
|
||||
}
|
||||
|
@ -420,7 +428,11 @@ int ccp_fatal_error (int ccp_unit)
|
|||
*/
|
||||
int sifvjcomp (int unit, int vjcomp, int cidcomp, int maxcid)
|
||||
{
|
||||
u_int x = get_flags(unit);
|
||||
int err;
|
||||
u_int x = get_flags(unit,&err);
|
||||
|
||||
if(err)
|
||||
return 0;
|
||||
|
||||
if (vjcomp) {
|
||||
if (ioctl (lns[unit].fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
|
||||
|
|
189
ipppd/upap.c
189
ipppd/upap.c
|
@ -17,9 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: upap.c,v 1.2 1997/04/26 17:17:47 hipp Exp $";
|
||||
#endif
|
||||
char upap_rcsid[] = "$Id: upap.c,v 1.3 1997/05/19 10:16:30 hipp Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -31,9 +29,15 @@ static char rcsid[] = "$Id: upap.c,v 1.2 1997/04/26 17:17:47 hipp Exp $";
|
|||
#include <sys/time.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "fsm.h"
|
||||
#include "ipppd.h"
|
||||
#include "ipcp.h"
|
||||
#include "upap.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
extern int log_raw_password;
|
||||
/*
|
||||
|
@ -77,13 +81,54 @@ static void upap_rauthnak __P((upap_state *, u_char *, int, int));
|
|||
static void upap_sauthreq __P((upap_state *));
|
||||
static void upap_sresp __P((upap_state *, int, int, char *, int));
|
||||
|
||||
void set_userip(char *ruser,int ruserlen)
|
||||
{
|
||||
char line[1024];
|
||||
char name[64];
|
||||
FILE *fd;
|
||||
int base;
|
||||
int ofs;
|
||||
char *lname;
|
||||
char *lip;
|
||||
ipcp_options *wo = &ipcp_wantoptions[0];
|
||||
|
||||
if (ruserlen) {
|
||||
memcpy(name,ruser, ruserlen);
|
||||
name[ruserlen]='\0';
|
||||
}
|
||||
else
|
||||
strncpy(name, ruser, sizeof(name)-1);
|
||||
fd = fopen(_PATH_USERIPTAB, "r");
|
||||
if (fd) {
|
||||
while (fgets(line, sizeof(line)-1, fd)) {
|
||||
base = strspn(line, " \t\n\r");
|
||||
if (line[base] == '#')
|
||||
continue;
|
||||
lname = &(line[base]);
|
||||
ofs = strcspn(lname, " \n\t\r\n");
|
||||
lname[ofs] = '\0';
|
||||
lip = &(lname[ofs+1]);
|
||||
base = strspn(lip, " \t\n\r");
|
||||
lip = &(lip[base]);
|
||||
ofs = strcspn(lip, " \n\t\r\n");
|
||||
lip[ofs] = '\0';
|
||||
if (!strcmp(name, lname)) {
|
||||
unsigned long int ip;
|
||||
if (inet_aton(lip, (struct in_addr *)&ip)) {
|
||||
wo->hisaddr = ip;
|
||||
UPAPDEBUG((LOG_INFO, "set_userip: found users(%s) ip(%s).",lname, lip));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* upap_init - Initialize a UPAP unit.
|
||||
*/
|
||||
void
|
||||
upap_init(unit)
|
||||
int unit;
|
||||
void upap_init(int unit)
|
||||
{
|
||||
upap_state *u = &upap[unit];
|
||||
|
||||
|
@ -317,82 +362,82 @@ void upap_input(int linkunit,u_char *inpacket,int l)
|
|||
/*
|
||||
* upap_rauth - Receive Authenticate.
|
||||
*/
|
||||
static void
|
||||
upap_rauthreq(upap_state *u,u_char *inp,int id,int len)
|
||||
static void upap_rauthreq(upap_state *u,u_char *inp,int id,int len)
|
||||
{
|
||||
u_char ruserlen, rpasswdlen;
|
||||
char *ruser, *rpasswd;
|
||||
int retcode;
|
||||
char *msg;
|
||||
int msglen;
|
||||
u_char ruserlen, rpasswdlen;
|
||||
char *ruser, *rpasswd;
|
||||
int retcode;
|
||||
char *msg;
|
||||
int msglen;
|
||||
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: Rcvd id %d.", id));
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: Rcvd id %d.", id));
|
||||
|
||||
if (u->us_serverstate < UPAPSS_LISTEN)
|
||||
return;
|
||||
if (u->us_serverstate < UPAPSS_LISTEN)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If we receive a duplicate authenticate-request, we are
|
||||
* supposed to return the same status as for the first request.
|
||||
*/
|
||||
if (u->us_serverstate == UPAPSS_OPEN) {
|
||||
upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */
|
||||
return;
|
||||
}
|
||||
if (u->us_serverstate == UPAPSS_BADAUTH) {
|
||||
upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* If we receive a duplicate authenticate-request, we are
|
||||
* supposed to return the same status as for the first request.
|
||||
*/
|
||||
if (u->us_serverstate == UPAPSS_OPEN) {
|
||||
upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */
|
||||
return;
|
||||
}
|
||||
if (u->us_serverstate == UPAPSS_BADAUTH) {
|
||||
upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse user/passwd.
|
||||
*/
|
||||
if (len < sizeof (u_char)) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
GETCHAR(ruserlen, inp);
|
||||
len -= sizeof (u_char) + ruserlen + sizeof (u_char);
|
||||
if (len < 0) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
ruser = (char *) inp;
|
||||
INCPTR(ruserlen, inp);
|
||||
GETCHAR(rpasswdlen, inp);
|
||||
if (len < rpasswdlen) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
rpasswd = (char *) inp;
|
||||
/*
|
||||
* Parse user/passwd.
|
||||
*/
|
||||
if (len < sizeof (u_char)) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
GETCHAR(ruserlen, inp);
|
||||
len -= sizeof (u_char) + ruserlen + sizeof (u_char);
|
||||
if (len < 0) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
ruser = (char *) inp;
|
||||
INCPTR(ruserlen, inp);
|
||||
GETCHAR(rpasswdlen, inp);
|
||||
if (len < rpasswdlen) {
|
||||
UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
|
||||
return;
|
||||
}
|
||||
rpasswd = (char *) inp;
|
||||
|
||||
/*
|
||||
* Check the username and password given.
|
||||
*/
|
||||
if(ruserlen > 64)
|
||||
ruserlen = 64;
|
||||
if(rpasswdlen > 64)
|
||||
rpasswdlen = 64;
|
||||
strncpy(u->us_ruser,ruser,(int)ruserlen);
|
||||
strncpy(u->us_rpasswd,rpasswd,(int)rpasswdlen);
|
||||
u->us_rpasswdlen = rpasswdlen;
|
||||
u->us_ruserlen = ruserlen;
|
||||
/*
|
||||
* Check the username and password given.
|
||||
*/
|
||||
if(ruserlen > 64)
|
||||
ruserlen = 64;
|
||||
if(rpasswdlen > 64)
|
||||
rpasswdlen = 64;
|
||||
strncpy(u->us_ruser,ruser,(int)ruserlen);
|
||||
strncpy(u->us_rpasswd,rpasswd,(int)rpasswdlen);
|
||||
u->us_rpasswdlen = rpasswdlen;
|
||||
u->us_ruserlen = ruserlen;
|
||||
|
||||
retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd,
|
||||
rpasswdlen, &msg, &msglen);
|
||||
retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd,
|
||||
rpasswdlen, &msg, &msglen);
|
||||
|
||||
upap_sresp(u, retcode, id, msg, msglen);
|
||||
upap_sresp(u, retcode, id, msg, msglen);
|
||||
|
||||
if (retcode == UPAP_AUTHACK) {
|
||||
u->us_serverstate = UPAPSS_OPEN;
|
||||
auth_peer_success(u->us_unit, PPP_PAP);
|
||||
} else {
|
||||
u->us_serverstate = UPAPSS_BADAUTH;
|
||||
auth_peer_fail(u->us_unit, PPP_PAP);
|
||||
}
|
||||
if (retcode == UPAP_AUTHACK) {
|
||||
set_userip(ruser, ruserlen);
|
||||
u->us_serverstate = UPAPSS_OPEN;
|
||||
auth_peer_success(u->us_unit, PPP_PAP);
|
||||
} else {
|
||||
u->us_serverstate = UPAPSS_BADAUTH;
|
||||
auth_peer_fail(u->us_unit, PPP_PAP);
|
||||
}
|
||||
|
||||
if (u->us_reqtimeout > 0)
|
||||
UNTIMEOUT(upap_reqtimeout, (caddr_t) u);
|
||||
if (u->us_reqtimeout > 0)
|
||||
UNTIMEOUT(upap_reqtimeout, (caddr_t) u);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue