Cosmetic (no functional changes):

o   Add missing $Id$s
o   Move extern decls from .c -> .h files
o   Staticize
o   Remove #includes from .h files
o   style(9)ify includes
o   bcopy -> memcpy
    bzero -> memset
    bcmp -> memcmp
    index -> strchr
    rindex -> strrchr
o   Move timeout.h -> timer.h (making it consistent w/ timer.c)
o   Add -Wmissing-prototypes
This commit is contained in:
Brian Somers 1997-10-26 01:04:02 +00:00
parent 11ea2762eb
commit 75240ed178
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30715
74 changed files with 1249 additions and 1306 deletions

View File

@ -1,11 +1,11 @@
# $Id: Makefile,v 1.26 1997/09/27 19:11:39 brian Exp $
# $Id: Makefile,v 1.27 1997/09/28 20:17:59 brian Exp $
PROG= ppp
SRCS= alias_cmd.c arp.c async.c auth.c ccp.c chap.c chat.c command.c \
filter.c fsm.c hdlc.c ip.c ipcp.c lcp.c loadalias.c log.c lqr.c \
main.c mbuf.c modem.c os.c pap.c pred.c route.c server.c sig.c \
slcompress.c systems.c timer.c vars.c vjcomp.c
CFLAGS+=-Wall
defs.c filter.c fsm.c hdlc.c ip.c ipcp.c lcp.c loadalias.c log.c \
lqr.c main.c mbuf.c modem.c os.c pap.c phase.c pred.c route.c \
server.c sig.c slcompress.c systems.c timer.c vars.c vjcomp.c
CFLAGS+=-Wall -Wmissing-prototypes
LDADD+= -lmd -lcrypt -lutil
DPADD+= ${LIBMD} ${LIBCRYPT} ${LIBUTIL}
MAN8= ppp.8

View File

@ -1,34 +1,34 @@
#include <limits.h>
#include <netdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*
* $Id: $
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "command.h"
#include "loadalias.h"
#include "vars.h"
#include "alias_cmd.h"
static int
StrToAddr(char *, struct in_addr * addr);
static int
StrToPort(char *, u_short * port, char *proto);
static int
StrToAddrAndPort(char *, struct in_addr * addr, u_short * port, char *proto);
static int StrToAddr(char *, struct in_addr *);
static int StrToPort(char *, u_short *, char *);
static int StrToAddrAndPort(char *, struct in_addr *, u_short *, char *);
int
AliasRedirectPort(struct cmdtab * list,
int argc,
char **argv,
void *param)
AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
@ -91,10 +91,7 @@ AliasRedirectPort(struct cmdtab * list,
int
AliasRedirectAddr(struct cmdtab * list,
int argc,
char **argv,
void *param)
AliasRedirectAddr(struct cmdtab *list, int argc, char **argv, void *param)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
@ -132,8 +129,7 @@ AliasRedirectAddr(struct cmdtab * list,
static int
StrToAddr(char *str,
struct in_addr * addr)
StrToAddr(char *str, struct in_addr *addr)
{
struct hostent *hp;
@ -151,9 +147,7 @@ StrToAddr(char *str,
static int
StrToPort(char *str,
u_short * port,
char *proto)
StrToPort(char *str, u_short *port, char *proto)
{
int iport;
struct servent *sp;
@ -176,10 +170,7 @@ StrToPort(char *str,
int
StrToAddrAndPort(char *str,
struct in_addr * addr,
u_short * port,
char *proto)
StrToAddrAndPort(char *str, struct in_addr *addr, u_short *port, char *proto)
{
char *ptr;

View File

@ -1,5 +1,6 @@
extern int
AliasRedirectPort(struct cmdtab *, int, char **, void *);
/*
* $Id: $
*/
extern int
AliasRedirectAddr(struct cmdtab *, int, char **, void *);
extern int AliasRedirectPort(struct cmdtab *, int, char **, void *);
extern int AliasRedirectAddr(struct cmdtab *, int, char **, void *);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: arp.c,v 1.14 1997/08/31 22:59:12 brian Exp $
* $Id: arp.c,v 1.15 1997/09/10 02:20:27 brian Exp $
*
*/
@ -25,44 +25,40 @@
* TODO:
*/
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <fcntl.h>
#ifdef __bsdi__
#include <kvm.h>
#endif
#include <net/if_types.h>
#include <netinet/in_var.h>
#if RTM_VERSION >= 3
#include <netinet/if_ether.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "arp.h"
static int rtm_seq;
static int get_ether_addr(int, u_long, struct sockaddr_dl *);
#define BCOPY(s, d, l) memcpy(d, s, l)
#define BZERO(s, n) memset(s, 0, n)
/*
* SET_SA_FAMILY - set the sa_family field of a struct sockaddr,
* if it exists.
*/
#define SET_SA_FAMILY(addr, family) \
BZERO((char *) &(addr), sizeof(addr)); \
memset((char *) &(addr), '\0', sizeof(addr)); \
addr.sa_family = (family); \
addr.sa_len = sizeof(addr);
@ -77,7 +73,7 @@ static struct {
struct sockaddr_inarp dst;
struct sockaddr_dl hwa;
char extra[128];
} arpmsg;
} arpmsg;
static int arpmsg_valid;
@ -166,7 +162,7 @@ sifproxyarp(int unit, u_long hisaddr)
char space[128];
} dls;
BZERO(&arpreq, sizeof(arpreq));
memset(&arpreq, '\0', sizeof(arpreq));
/*
* Get the hardware address of an interface on the same subnet as our local
@ -178,7 +174,7 @@ sifproxyarp(int unit, u_long hisaddr)
}
arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
arpreq.arp_ha.sa_family = AF_UNSPEC;
BCOPY(LLADDR(&dls.sdl), arpreq.arp_ha.sa_data, dls.sdl.sdl_alen);
memcpy(arpreq.arp_ha.sa_data, LLADDR(&dls.sdl), dls.sdl.sdl_alen);
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
arpreq.arp_flags = ATF_PERM | ATF_PUBL;
@ -197,7 +193,7 @@ cifproxyarp(int unit, u_long hisaddr)
{
struct arpreq arpreq;
BZERO(&arpreq, sizeof(arpreq));
memset(&arpreq, '\0', sizeof(arpreq));
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
if (ioctl(unit, SIOCDARP, (caddr_t) & arpreq) < 0) {
@ -216,8 +212,8 @@ cifproxyarp(int unit, u_long hisaddr)
*/
#define MAX_IFS 32
int
get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl * hwaddr)
static int
get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl *hwaddr)
{
struct ifreq *ifr, *ifend, *ifp;
u_long ina, mask;
@ -287,11 +283,7 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl * hwaddr)
* Found the link-level address - copy it out
*/
dla = (struct sockaddr_dl *) & ifr->ifr_addr;
#ifdef __bsdi__
if (dla->sdl_alen == 0)
kmemgetether(ifr->ifr_name, dla);
#endif
BCOPY(dla, hwaddr, dla->sdl_len);
memcpy(hwaddr, dla, dla->sdl_len);
return 1;
}
ifr = (struct ifreq *) ((char *) &ifr->ifr_addr + ifr->ifr_addr.sa_len);
@ -300,102 +292,9 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl * hwaddr)
return 0;
}
#ifdef __bsdi__
#include <nlist.h>
struct nlist nl[] = {
#define N_IFNET 0
{"_ifnet"},
"",
};
kvm_t *kvmd;
/*
* Read kernel memory, return 0 on success.
*/
int
kread(u_long addr, char *buf, int size)
{
if (kvm_read(kvmd, addr, buf, size) != size) {
/* XXX this duplicates kvm_read's error printout */
LogPrintf(LogERROR, "kvm_read %s\n", kvm_geterr(kvmd));
return -1;
}
return 0;
}
void
kmemgetether(char *ifname, struct sockaddr_dl * dlo)
{
struct ifnet ifnet;
int n;
u_long addr, ifaddraddr, ifnetfound, ifaddrfound;
char name[16 + 32];
struct sockaddr *sa;
char *cp;
struct sockaddr_dl *sdl;
union {
struct ifaddr ifa;
struct in_ifaddr in;
} ifaddr;
struct arpcom ac;
kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
if (kvmd) {
n = kvm_nlist(kvmd, nl);
if (n >= 0) {
addr = nl[N_IFNET].n_value;
kread(addr, (char *) &addr, sizeof(addr));
ifaddraddr = ifnetfound = 0;
while (addr || ifaddraddr) {
ifnetfound = addr;
if (ifaddraddr == 0) {
if (kread(addr, (char *) &ifnet, sizeof(ifnet)) ||
kread((u_long) ifnet.if_name, name, 16))
return;
name[15] = 0;
addr = (u_long) ifnet.if_next;
cp = (char *) index(name, '\0');
cp += sprintf(cp, "%d", ifnet.if_unit);
*cp = '\0';
ifaddraddr = (u_long) ifnet.if_addrlist;
}
ifaddrfound = ifaddraddr;
if (ifaddraddr) {
if (kread(ifaddraddr, (char *) &ifaddr, sizeof ifaddr)) {
ifaddraddr = 0;
continue;
}
#define CP(x) ((char *)(x))
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + CP(&ifaddr);
sa = (struct sockaddr *) cp;
if (sa->sa_family == AF_LINK && strcmp(ifname, name) == 0) {
sdl = (struct sockaddr_dl *) sa;
cp = (char *) LLADDR(sdl);
n = sdl->sdl_alen;
if (ifnet.if_type == IFT_ETHER) {
if (n == 0) {
kread(ifnetfound, (char *) &ac, sizeof(ac));
cp = (char *) LLADDR(sdl);
bcopy((char *) ac.ac_enaddr, cp, 6);
sdl->sdl_alen = 6;
}
bcopy(sdl, dlo, sizeof(*sdl));
return;
}
}
ifaddraddr = (u_long) ifaddr.ifa.ifa_next;
}
}
}
}
}
#endif
#ifdef DEBUG
int
main()
{
u_long ipaddr;
@ -406,5 +305,4 @@ main()
sifproxyarp(s, ipaddr);
close(s);
}
#endif

View File

@ -17,13 +17,9 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: arp.h,v 1.4 1997/06/09 03:27:12 brian Exp $
* $Id: arp.h,v 1.5 1997/08/25 00:29:04 brian Exp $
*
*/
#ifndef _ARP_H_
#define _ARP_H_
extern int cifproxyarp(int, u_long);
extern int sifproxyarp(int, u_long);
#endif

View File

@ -17,28 +17,41 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: async.c,v 1.10 1997/06/23 23:08:23 brian Exp $
* $Id: async.c,v 1.11 1997/08/25 00:29:05 brian Exp $
*
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "hdlc.h"
#include "lcp.h"
#include "lcpproto.h"
#include "modem.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "os.h"
#include "async.h"
#define HDLCSIZE (MAX_MRU*2+6)
struct async_state {
static struct async_state {
int mode;
int length;
u_char hbuff[HDLCSIZE]; /* recv buffer */
u_char xbuff[HDLCSIZE]; /* xmit buffer */
u_long my_accmap;
u_long his_accmap;
} AsyncState;
} AsyncState;
#define MODE_HUNT 0x01
#define MODE_ESC 0x02
@ -54,7 +67,7 @@ AsyncInit()
}
void
SetLinkParams(struct lcpstate * lcp)
SetLinkParams(struct lcpstate *lcp)
{
struct async_state *stp = &AsyncState;
@ -66,7 +79,7 @@ SetLinkParams(struct lcpstate * lcp)
* Encode into async HDLC byte code if necessary
*/
static void
HdlcPutByte(u_char ** cp, u_char c, int proto)
HdlcPutByte(u_char **cp, u_char c, int proto)
{
u_char *wp;
@ -85,7 +98,7 @@ HdlcPutByte(u_char ** cp, u_char c, int proto)
}
void
AsyncOutput(int pri, struct mbuf * bp, int proto)
AsyncOutput(int pri, struct mbuf *bp, int proto)
{
struct async_state *hs = &AsyncState;
u_char *cp, *sp, *ep;
@ -120,7 +133,7 @@ AsyncOutput(int pri, struct mbuf * bp, int proto)
pfree(bp);
}
struct mbuf *
static struct mbuf *
AsyncDecode(u_char c)
{
struct async_state *hs = &AsyncState;
@ -164,14 +177,14 @@ AsyncDecode(u_char c)
}
void
AsyncInput(u_char * buff, int cnt)
AsyncInput(u_char *buff, int cnt)
{
struct mbuf *bp;
OsAddInOctets(cnt);
if (DEV_IS_SYNC) {
bp = mballoc(cnt, MB_ASYNC);
bcopy(buff, MBUF_CTOP(bp), cnt);
memcpy(MBUF_CTOP(bp), buff, cnt);
bp->cnt = cnt;
HdlcInput(bp);
} else {

8
usr.sbin/ppp/async.h Normal file
View File

@ -0,0 +1,8 @@
/*
* $Id: $
*/
extern void AsyncInit(void);
extern void SetLinkParams(struct lcpstate *);
extern void AsyncOutput(int, struct mbuf *, int);
extern void AsyncInput(u_char *, int);

View File

@ -17,22 +17,32 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: auth.c,v 1.16 1997/09/04 00:38:17 brian Exp $
* $Id: auth.c,v 1.17 1997/09/09 21:51:38 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "ipcp.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "filter.h"
#include "auth.h"
#include "chat.h"
extern FILE *OpenSecret();
extern void CloseSecret();
#include "systems.h"
void
LocalAuthInit()
@ -73,7 +83,7 @@ LocalAuthValidate(char *fname, char *system, char *key)
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = 0;
bzero(vector, sizeof(vector));
memset(vector, '\0', sizeof(vector));
n = MakeArgs(buff, vector, VECSIZE(vector));
if (n < 1)
continue;
@ -107,7 +117,7 @@ AuthValidate(char *fname, char *system, char *key)
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = 0;
bzero(vector, sizeof(vector));
memset(vector, '\0', sizeof(vector));
n = MakeArgs(buff, vector, VECSIZE(vector));
if (n < 2)
continue;
@ -115,7 +125,7 @@ AuthValidate(char *fname, char *system, char *key)
ExpandString(vector[1], passwd, sizeof(passwd), 0);
if (strcmp(passwd, key) == 0) {
CloseSecret(fp);
bzero(&DefHisAddress, sizeof(DefHisAddress));
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
n -= 2;
if (n > 0) {
if (ParseAddr(n--, &vector[2],
@ -150,14 +160,14 @@ AuthGetSecret(char *fname, char *system, int len, int setaddr)
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = 0;
bzero(vector, sizeof(vector));
memset(vector, '\0', sizeof(vector));
n = MakeArgs(buff, vector, VECSIZE(vector));
if (n < 2)
continue;
if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) {
ExpandString(vector[1], passwd, sizeof(passwd), 0);
if (setaddr) {
bzero(&DefHisAddress, sizeof(DefHisAddress));
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
}
n -= 2;
if (n > 0 && setaddr) {
@ -176,7 +186,7 @@ AuthGetSecret(char *fname, char *system, int len, int setaddr)
}
static void
AuthTimeout(struct authinfo * authp)
AuthTimeout(struct authinfo *authp)
{
struct pppTimer *tp;
@ -189,7 +199,7 @@ AuthTimeout(struct authinfo * authp)
}
void
StartAuthChallenge(struct authinfo * authp)
StartAuthChallenge(struct authinfo *authp)
{
struct pppTimer *tp;
@ -206,7 +216,7 @@ StartAuthChallenge(struct authinfo * authp)
}
void
StopAuthTimer(struct authinfo * authp)
StopAuthTimer(struct authinfo *authp)
{
StopTimer(&authp->authtimer);
}

View File

@ -15,18 +15,16 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: auth.h,v 1.7 1997/08/25 00:29:05 brian Exp $
* $Id: auth.h,v 1.8 1997/09/04 00:38:18 brian Exp $
*
* TODO:
*/
#ifndef _AUTH_H_
#define _AUTH_H_
typedef enum {
VALID, INVALID, NOT_FOUND
} LOCAL_AUTH_VALID;
LOCAL_AUTH_VALID LocalAuthValidate(char *, char *, char *);
VALID,
INVALID,
NOT_FOUND
} LOCAL_AUTH_VALID;
struct authinfo {
void (*ChallengeFunc) ();
@ -34,14 +32,10 @@ struct authinfo {
int retry;
int id;
};
extern struct authinfo AuthPapInfo;
extern struct authinfo AuthChapInfo;
extern void SendPapChallenge(int);
extern void SendChapChallenge(int);
extern LOCAL_AUTH_VALID LocalAuthValidate(char *, char *, char *);
extern void StopAuthTimer(struct authinfo *);
extern void StartAuthChallenge(struct authinfo *);
extern void LocalAuthInit(void);
extern int AuthValidate(char *, char *, char *);
#endif
extern char *AuthGetSecret(char *, char *, int, int);

View File

@ -17,26 +17,37 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.c,v 1.15 1997/08/25 00:29:06 brian Exp $
* $Id: ccp.c,v 1.16 1997/09/10 21:33:31 brian Exp $
*
* TODO:
* o Support other compression protocols
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "lcp.h"
#include "ccp.h"
#include "phase.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "pred.h"
struct ccpstate CcpInfo;
static void CcpSendConfigReq(struct fsm *);
static void CcpSendTerminateReq(struct fsm * fp);
static void CcpSendTerminateAck(struct fsm * fp);
static void CcpDecodeConfig(u_char * cp, int flen, int mode);
static void CcpSendTerminateReq(struct fsm *);
static void CcpSendTerminateAck(struct fsm *);
static void CcpDecodeConfig(u_char *, int, int);
static void CcpLayerStart(struct fsm *);
static void CcpLayerFinish(struct fsm *);
static void CcpLayerUp(struct fsm *);
@ -99,21 +110,21 @@ CcpInit()
struct ccpstate *icp = &CcpInfo;
FsmInit(&CcpFsm);
bzero(icp, sizeof(struct ccpstate));
memset(icp, '\0', sizeof(struct ccpstate));
if (Enabled(ConfPred1))
icp->want_proto = TY_PRED1;
CcpFsm.maxconfig = 10;
}
static void
CcpInitRestartCounter(struct fsm * fp)
CcpInitRestartCounter(struct fsm *fp)
{
fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
fp->restart = 5;
}
static void
CcpSendConfigReq(struct fsm * fp)
CcpSendConfigReq(struct fsm *fp)
{
u_char *cp;
struct ccpstate *icp = &CcpInfo;
@ -128,45 +139,45 @@ CcpSendConfigReq(struct fsm * fp)
}
void
CcpSendResetReq(struct fsm * fp)
CcpSendResetReq(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpSendResetReq\n");
FsmOutput(fp, CODE_RESETREQ, fp->reqid, NULL, 0);
}
static void
CcpSendTerminateReq(struct fsm * fp)
CcpSendTerminateReq(struct fsm *fp)
{
/* XXX: No code yet */
}
static void
CcpSendTerminateAck(struct fsm * fp)
CcpSendTerminateAck(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpSendTerminateAck\n");
FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0);
}
void
CcpRecvResetReq(struct fsm * fp)
CcpRecvResetReq(struct fsm *fp)
{
Pred1Init(2); /* Initialize Output part */
}
static void
CcpLayerStart(struct fsm * fp)
CcpLayerStart(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpLayerStart.\n");
}
static void
CcpLayerFinish(struct fsm * fp)
CcpLayerFinish(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpLayerFinish.\n");
}
static void
CcpLayerDown(struct fsm * fp)
CcpLayerDown(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpLayerDown.\n");
}
@ -175,7 +186,7 @@ CcpLayerDown(struct fsm * fp)
* Called when CCP has reached to OPEN state
*/
static void
CcpLayerUp(struct fsm * fp)
CcpLayerUp(struct fsm *fp)
{
LogPrintf(LogCCP, "CcpLayerUp(%d).\n", fp->state);
LogPrintf(LogCCP, "myproto = %d, hisproto = %d\n",
@ -198,7 +209,7 @@ CcpOpen()
}
static void
CcpDecodeConfig(u_char * cp, int plen, int mode)
CcpDecodeConfig(u_char *cp, int plen, int mode)
{
int type, length;
char tbuff[100];
@ -224,11 +235,11 @@ CcpDecodeConfig(u_char * cp, int plen, int mode)
switch (mode) {
case MODE_REQ:
if (Acceptable(ConfPred1)) {
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
CcpInfo.his_proto = type;
} else {
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
}
break;
@ -242,7 +253,7 @@ CcpDecodeConfig(u_char * cp, int plen, int mode)
case TY_BSD:
default:
CcpInfo.my_reject |= (1 << type);
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
break;
}
@ -252,7 +263,7 @@ CcpDecodeConfig(u_char * cp, int plen, int mode)
}
void
CcpInput(struct mbuf * bp)
CcpInput(struct mbuf *bp)
{
if (phase == PHASE_NETWORK)
FsmInput(&CcpFsm, bp);

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.h,v 1.6 1997/06/09 03:27:14 brian Exp $
* $Id: ccp.h,v 1.7 1997/08/25 00:29:06 brian Exp $
*
* TODO:
*/
#ifndef _CCP_H_
#define _CCP_H_
#define CCP_MAXCODE CODE_RESETACK
#define TY_OUI 0 /* OUI */
@ -48,12 +45,12 @@ struct ccpstate {
};
extern struct ccpstate CcpInfo;
extern struct fsm CcpFsm;
void CcpRecvResetReq(struct fsm *);
void CcpSendResetReq(struct fsm *);
void CcpInput(struct mbuf *);
void CcpUp(void);
void CcpOpen(void);
void CcpInit(void);
#endif
extern void CcpRecvResetReq(struct fsm *);
extern void CcpSendResetReq(struct fsm *);
extern void CcpInput(struct mbuf *);
extern void CcpUp(void);
extern void CcpOpen(void);
extern void CcpInit(void);
extern int ReportCcpStatus(void);

View File

@ -17,15 +17,34 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: chap.c,v 1.22 1997/09/22 23:59:13 brian Exp $
* $Id: chap.c,v 1.23 1997/09/25 00:52:32 brian Exp $
*
* TODO:
*/
#include <sys/types.h>
#include <time.h>
#include <utmp.h>
#include <ctype.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <ctype.h>
#ifdef HAVE_DES
#include <md4.h>
#endif
#include <md5.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include <utmp.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "chap.h"
#include "chap_ms.h"
@ -34,26 +53,15 @@
#include "hdlc.h"
#include "phase.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "auth.h"
#ifdef __OpenBSD__
#include "util.h"
#else
#include "libutil.h"
#endif
static char *chapcodes[] = {
"???", "CHALLENGE", "RESPONSE", "SUCCESS", "FAILURE"
};
struct authinfo AuthChapInfo = {
SendChapChallenge,
};
extern char *AuthGetSecret();
extern int randinit;
void
static void
ChapOutput(u_int code, u_int id, u_char * ptr, int count)
{
int plen;
@ -65,9 +73,9 @@ ChapOutput(u_int code, u_int id, u_char * ptr, int count)
lh.id = id;
lh.length = htons(plen);
bp = mballoc(plen, MB_FSM);
bcopy(&lh, MBUF_CTOP(bp), sizeof(struct fsmheader));
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
if (count)
bcopy(ptr, MBUF_CTOP(bp) + sizeof(struct fsmheader), count);
memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
LogDumpBp(LogDEBUG, "ChapOutput", bp);
LogPrintf(LogLCP, "ChapOutput: %s\n", chapcodes[code]);
HdlcOutput(PRI_LINK, PROTO_CHAP, bp);
@ -77,28 +85,29 @@ ChapOutput(u_int code, u_int id, u_char * ptr, int count)
static char challenge_data[80];
static int challenge_len;
void
static void
SendChapChallenge(int chapid)
{
int len, i;
char *cp;
if (!randinit) {
randinit = 1;
srandomdev();
}
randinit();
cp = challenge_data;
*cp++ = challenge_len = random() % 32 + 16;
for (i = 0; i < challenge_len; i++)
*cp++ = random() & 0xff;
len = strlen(VarAuthName);
bcopy(VarAuthName, cp, len);
memcpy(cp, VarAuthName, len);
cp += len;
ChapOutput(CHAP_CHALLENGE, chapid, challenge_data, cp - challenge_data);
}
void
RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
struct authinfo AuthChapInfo = {
SendChapChallenge,
};
static void
RecvChapTalk(struct fsmheader *chp, struct mbuf *bp)
{
int valsize, len;
int arglen, keylen, namelen;
@ -153,12 +162,13 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
if (VarMSChap) {
digest = argp; /* this is the response */
*digest++ = MS_CHAP_RESPONSE_LEN; /* 49 */
bzero(digest, 24); digest += 24;
memset(digest, '\0', 24);
digest += 24;
ap = answer; /* this is the challenge */
bcopy(keyp, ap, keylen);
memcpy(ap, keyp, keylen);
ap += 2 * keylen;
bcopy(cp, ap, valsize);
memcpy(ap, cp, valsize);
LogDumpBuff(LogDEBUG, "recv", ap, valsize);
ap += valsize;
for (ix = keylen; ix > 0 ; ix--) {
@ -168,7 +178,7 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
MD4Init(&MD4context);
MD4Update(&MD4context, answer, 2 * keylen);
MD4Final(digest, &MD4context);
bcopy(name, digest + 25, namelen);
memcpy(digest + 25, name, namelen);
ap += 2 * keylen;
ChapMS(digest, answer + 2 * keylen, valsize);
LogDumpBuff(LogDEBUG, "answer", digest, 24);
@ -179,16 +189,16 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
*digest++ = 16; /* value size */
ap = answer;
*ap++ = chp->id;
bcopy(keyp, ap, keylen);
memcpy(ap, keyp, keylen);
ap += keylen;
bcopy(cp, ap, valsize);
memcpy(ap, cp, valsize);
LogDumpBuff(LogDEBUG, "recv", ap, valsize);
ap += valsize;
MD5Init(&MD5context);
MD5Update(&MD5context, answer, ap - answer);
MD5Final(digest, &MD5context);
LogDumpBuff(LogDEBUG, "answer", digest, 16);
bcopy(name, digest + 16, namelen);
memcpy(digest + 16, name, namelen);
ap += namelen;
/* Send answer to the peer */
ChapOutput(CHAP_RESPONSE, chp->id, argp, namelen + 17);
@ -206,7 +216,7 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
keylen = strlen(keyp);
ap = answer;
*ap++ = chp->id;
bcopy(keyp, ap, keylen);
memcpy(ap, keyp, keylen);
ap += keylen;
MD5Init(&MD5context);
MD5Update(&MD5context, answer, ap - answer);
@ -218,7 +228,7 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
/*
* Compare with the response
*/
if (bcmp(cp, cdigest, 16) == 0) {
if (memcmp(cp, cdigest, 16) == 0) {
ChapOutput(CHAP_SUCCESS, chp->id, "Welcome!!", 10);
if ((mode & MODE_DIRECT) && isatty(modem) && Enabled(ConfUtmp))
if (Utmp)
@ -250,8 +260,8 @@ RecvChapTalk(struct fsmheader * chp, struct mbuf * bp)
}
}
void
RecvChapResult(struct fsmheader * chp, struct mbuf * bp)
static void
RecvChapResult(struct fsmheader *chp, struct mbuf *bp)
{
int len;
struct lcpstate *lcp = &LcpInfo;
@ -274,7 +284,7 @@ RecvChapResult(struct fsmheader * chp, struct mbuf * bp)
}
void
ChapInput(struct mbuf * bp)
ChapInput(struct mbuf *bp)
{
int len = plength(bp);
struct fsmheader *chp;

View File

@ -15,19 +15,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: chap.h,v 1.6 1997/06/09 03:27:15 brian Exp $
* $Id: chap.h,v 1.7 1997/09/17 23:17:50 brian Exp $
*
* TODO:
*/
#ifndef _CHAP_H_
#define _CHAP_H_
#include <md4.h>
#include <md5.h>
#include "global.h"
#define CHAP_CHALLENGE 1
#define CHAP_RESPONSE 2
#define CHAP_SUCCESS 3
#define CHAP_FAILURE 4
#endif
extern struct authinfo AuthChapInfo;

View File

@ -18,18 +18,23 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: $
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <syslog.h>
#include <string.h>
#include "chap.h"
#include "chap_ms.h"
#include <des.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <syslog.h>
#include "mbuf.h"
#include "timer.h"
#include "chap.h"
#include "chap_ms.h"
/* unused, for documentation only */
/* only NTResp is filled in for FreeBSD */
@ -43,12 +48,12 @@ static void DesEncrypt(u_char *, u_char *, u_char *);
static void MakeKey(u_char *, u_char *);
static void /* IN 8 octets IN 16 octets OUT 24 octets */
ChallengeResponse(u_char* challenge, u_char* pwHash, u_char* response)
ChallengeResponse(u_char *challenge, u_char *pwHash, u_char *response)
{
char ZPasswordHash[21];
bzero(ZPasswordHash, sizeof(ZPasswordHash));
bcopy(pwHash, ZPasswordHash, 16);
memset(ZPasswordHash, '\0', sizeof(ZPasswordHash));
memcpy(ZPasswordHash, pwHash, 16);
DesEncrypt(challenge, ZPasswordHash + 0, response + 0);
DesEncrypt(challenge, ZPasswordHash + 7, response + 8);
@ -56,7 +61,7 @@ ChallengeResponse(u_char* challenge, u_char* pwHash, u_char* response)
}
static void /* IN 8 octets IN 7 octest OUT 8 octets */
DesEncrypt(u_char* clear, u_char* key, u_char* cipher)
DesEncrypt(u_char *clear, u_char *key, u_char *cipher)
{
des_cblock des_key;
des_key_schedule key_schedule;
@ -66,7 +71,7 @@ DesEncrypt(u_char* clear, u_char* key, u_char* cipher)
des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, key_schedule, 1);
}
static u_char Get7Bits(u_char* input, int startBit)
static u_char Get7Bits(u_char *input, int startBit)
{
register unsigned int word;
@ -80,7 +85,7 @@ static u_char Get7Bits(u_char* input, int startBit)
/* IN 56 bit DES key missing parity bits
OUT 64 bit DES key with parity bits added */
static void MakeKey(u_char* key, u_char* des_key)
static void MakeKey(u_char *key, u_char *des_key)
{
des_key[0] = Get7Bits(key, 0);
des_key[1] = Get7Bits(key, 7);
@ -98,12 +103,12 @@ static void MakeKey(u_char* key, u_char* des_key)
challenge 8-bytes peer CHAP challenge
since passwordHash is in a 24-byte buffer, response is written in there */
void
ChapMS(char* passwordHash, char* challenge, int challenge_len)
ChapMS(char *passwordHash, char *challenge, int challenge_len)
{
u_char response[24];
ChallengeResponse(challenge, passwordHash, response);
bcopy(response, passwordHash, 24);
memcpy(passwordHash, response, 24);
passwordHash += 24;
*passwordHash = 1;
}

View File

@ -19,15 +19,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id$
* $Id: chap_ms.h,v 1.1 1997/09/25 00:58:20 brian Exp $
*/
#ifndef _CHAPMS_H_
/* Max # of (Unicode) chars in an NT password */
#define MAX_NT_PASSWORD 256
#define MAX_NT_PASSWORD 256 /* Max # of (Unicode) chars in an NT password */
#define MS_CHAP_RESPONSE_LEN 49 /* Don't rely on sizeof(MS_ChapResponse) in case of struct padding */
/* Don't rely on sizeof(MS_ChapResponse) in case of struct padding */
#define MS_CHAP_RESPONSE_LEN 49
extern void ChapMS(char*, char*, int);
#define _CHAPMS_H_
#endif /* _CHAPMS_H_ */
extern void ChapMS(char *, char *, int);

View File

@ -18,45 +18,55 @@
* Columbus, OH 43221
* (614)451-1883
*
* $Id: chat.c,v 1.33 1997/08/31 22:59:15 brian Exp $
* $Id: chat.c,v 1.34 1997/10/24 22:36:27 brian Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
* o Dialing shoud not block monitor process.
* o Reading modem by select should be unified into main.c
*/
#include "defs.h"
#include <ctype.h>
#include <sys/uio.h>
#ifndef isblank
#define isblank(c) ((c) == '\t' || (c) == ' ')
#endif
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include "timeout.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "chat.h"
#include "sig.h"
#include "chat.h"
#include "modem.h"
#ifndef isblank
#define isblank(c) ((c) == '\t' || (c) == ' ')
#endif
#define IBSIZE 200
static int TimeoutSec;
static int abort_next, timeout_next;
static int numaborts;
char *AbortStrings[50];
char inbuff[IBSIZE * 2 + 1];
extern int ChangeParity(char *);
static char *AbortStrings[50];
static char inbuff[IBSIZE * 2 + 1];
#define MATCH 1
#define NOMATCH 0
@ -265,7 +275,7 @@ connect_log(char *str, int single_p)
flush_log();
}
int
static int
WaitforString(char *estr)
{
struct timeval timeout;
@ -331,8 +341,8 @@ WaitforString(char *estr)
int length;
if ((length = strlen(inbuff)) > IBSIZE) {
bcopy(&(inbuff[IBSIZE]), inbuff, IBSIZE + 1); /* shuffle down next
* part */
/* shuffle down next part */
memcpy(inbuff, &(inbuff[IBSIZE]), IBSIZE + 1);
length = strlen(inbuff);
}
nb = read(modem, &(inbuff[length]), IBSIZE);
@ -376,7 +386,7 @@ WaitforString(char *estr)
} else
s = str;
if (inp == inbuff + IBSIZE) {
bcopy(inp - 100, inbuff, 100);
memcpy(inbuff, inp - 100, 100);
inp = inbuff + 100;
}
if (s == str) {
@ -402,7 +412,7 @@ WaitforString(char *estr)
}
}
void
static void
ExecStr(char *command, char *out)
{
int pid;
@ -411,7 +421,6 @@ ExecStr(char *command, char *out)
int stat, nb;
char *cp;
char tmp[300];
extern int errno;
cp = inbuff + strlen(inbuff) - 1;
while (cp > inbuff) {
@ -479,7 +488,7 @@ ExecStr(char *command, char *out)
}
}
void
static void
SendString(char *str)
{
char *cp;
@ -508,7 +517,7 @@ SendString(char *str)
LogPrintf(LogCHAT, "sending: %s\n", buff + 2);
cp = buff;
if (DEV_IS_SYNC)
bcopy("\377\003", buff, 2); /* Prepend HDLC header */
memcpy(buff, "\377\003", 2); /* Prepend HDLC header */
else
cp += 2;
on = strlen(cp);
@ -516,7 +525,7 @@ SendString(char *str)
}
}
int
static int
ExpectString(char *str)
{
char *minus;
@ -611,7 +620,7 @@ DoChat(char *script)
}
numaborts = 0;
bzero(vector, sizeof(vector));
memset(vector, '\0', sizeof(vector));
n = MakeArgs(script, vector, VECSIZE(vector));
argc = n;
argv = vector;

View File

@ -18,13 +18,12 @@
* Columbus, OH 43221
* (614)451-1883
*
* $Id: chat.h,v 1.6 1997/06/09 03:27:16 brian Exp $
* $Id: chat.h,v 1.7 1997/08/25 00:29:07 brian Exp $
*
*/
#ifndef _CHAT_H_
#define _CHAT_H_
extern char *ExpandString(char *, char *, int, int);
extern int MakeArgs(char *, char **, int);
#define VECSIZE(v) (sizeof(v) / sizeof(v[0]))
#endif
extern char *ExpandString(char *, char *, int, int);
extern int MakeArgs(char *, char **, int);
extern int DoChat(char *);

View File

@ -17,31 +17,43 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.86 1997/10/12 01:49:37 brian Exp $
* $Id: command.c,v 1.87 1997/10/24 22:36:28 brian Exp $
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <termios.h>
#include <sys/wait.h>
#include <time.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <net/route.h>
#include <paths.h>
#include <netdb.h>
#include <alias.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "phase.h"
#include "lcp.h"
#include "ipcp.h"
#include "modem.h"
#include "filter.h"
#include "command.h"
#include "filter.h"
#include "alias_cmd.h"
#include "hdlc.h"
#include "loadalias.h"
@ -49,26 +61,13 @@
#include "systems.h"
#include "chat.h"
#include "os.h"
#include "timeout.h"
#include "server.h"
extern void Cleanup(), TtyTermMode(), PacketMode();
extern int EnableCommand(), DisableCommand(), DisplayCommand();
extern int AcceptCommand(), DenyCommand();
static int AliasCommand();
extern int LocalAuthCommand();
extern int LoadCommand(), SaveCommand();
extern int ChangeParity(char *);
extern int SelectSystem();
extern int ShowRoute();
extern void TtyOldMode(), TtyCommandMode();
extern struct pppvars pppVars;
extern struct cmdtab const SetCommands[];
extern char *IfDevName;
#include "main.h"
#include "route.h"
#include "ccp.h"
#include "slcompress.h"
struct in_addr ifnetmask;
int randinit;
static int ShowCommand(struct cmdtab const *, int, char **);
static int TerminalCommand(struct cmdtab const *, int, char **);
@ -82,6 +81,9 @@ static int DeleteCommand(struct cmdtab const *, int, char **);
static int BgShellCommand(struct cmdtab const *, int, char **);
static int FgShellCommand(struct cmdtab const *, int, char **);
static int ShellCommand(struct cmdtab const *, int, char **, int);
static int AliasCommand(struct cmdtab const *, int, char **);
static int AliasEnable(struct cmdtab const *, int, char **);
static int AliasOption(struct cmdtab const *, int, char **, void *);
static int
HelpCommand(struct cmdtab const * list,
@ -326,7 +328,7 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
return (0);
}
struct cmdtab const Commands[] = {
static struct cmdtab const Commands[] = {
{"accept", NULL, AcceptCommand, LOCAL_AUTH,
"accept option request", "accept option .."},
{"add", NULL, AddCommand, LOCAL_AUTH,
@ -372,15 +374,6 @@ struct cmdtab const Commands[] = {
{NULL, NULL, NULL},
};
extern int ReportCcpStatus();
extern int ReportLcpStatus();
extern int ReportIpcpStatus();
extern int ReportProtStatus();
extern int ReportCompress();
extern int ShowModemStatus();
extern int ReportHdlcStatus();
extern int ShowMemMap();
static int
ShowLoopback()
{
@ -481,9 +474,6 @@ ShowAuthKey()
static int
ShowVersion()
{
extern char VarVersion[];
extern char VarLocalVersion[];
if (!VarTerm)
return 0;
fprintf(VarTerm, "%s - %s \n", VarVersion, VarLocalVersion);
@ -566,9 +556,7 @@ ShowMSExt()
#endif
extern int ShowIfilter(), ShowOfilter(), ShowDfilter(), ShowAfilter();
struct cmdtab const ShowCommands[] = {
static struct cmdtab const ShowCommands[] = {
{"afilter", NULL, ShowAfilter, LOCAL_AUTH,
"Show keep Alive filters", "show afilter option .."},
{"auth", NULL, ShowAuthKey, LOCAL_AUTH,
@ -626,7 +614,7 @@ struct cmdtab const ShowCommands[] = {
{NULL, NULL, NULL},
};
struct cmdtab const *
static struct cmdtab const *
FindCommand(struct cmdtab const * cmds, char *str, int *pmatch)
{
int nmatch;
@ -658,7 +646,7 @@ FindCommand(struct cmdtab const * cmds, char *str, int *pmatch)
return found;
}
int
static int
FindExec(struct cmdtab const * cmdlist, int argc, char **argv)
{
struct cmdtab const *cmd;
@ -682,7 +670,6 @@ FindExec(struct cmdtab const * cmdlist, int argc, char **argv)
}
int aft_cmd = 1;
extern int TermMode;
void
Prompt()
@ -856,10 +843,7 @@ SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
if (strncasecmp(argv[0], "random", 6) == 0 &&
(argv[0][6] == '\0' || argv[0][6] == '.')) {
VarRedialTimeout = -1;
if (!randinit) {
randinit = 1;
srandomdev();
}
randinit();
} else {
timeout = atoi(argv[0]);
@ -871,14 +855,11 @@ SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
}
}
dot = index(argv[0], '.');
dot = strchr(argv[0], '.');
if (dot) {
if (strcasecmp(++dot, "random") == 0) {
VarRedialNextTimeout = -1;
if (!randinit) {
randinit = 1;
srandomdev();
}
randinit();
} else {
timeout = atoi(dot);
if (timeout >= 0)
@ -1084,7 +1065,7 @@ SetIdleTimeout(struct cmdtab const * list, int argc, char **argv)
return -1;
}
struct in_addr
static struct in_addr
GetIpAddr(char *cp)
{
struct hostent *hp;
@ -1092,7 +1073,7 @@ GetIpAddr(char *cp)
hp = gethostbyname(cp);
if (hp && hp->h_addrtype == AF_INET)
bcopy(hp->h_addr, &ipaddr, hp->h_length);
memcpy(&ipaddr, hp->h_addr, hp->h_length);
else if (inet_aton(cp, &ipaddr) == 0)
ipaddr.s_addr = 0;
return (ipaddr);
@ -1155,7 +1136,7 @@ SetInterfaceAddr(struct cmdtab const * list, int argc, char **argv)
#ifndef NOMSEXT
void
static void
SetMSEXT(struct in_addr * pri_addr,
struct in_addr * sec_addr,
int argc,
@ -1234,7 +1215,7 @@ SetVariable(struct cmdtab const * list, int argc, char **argv, int param)
else {
strncpy(VarDevice, arg, sizeof(VarDevice) - 1);
VarDevice[sizeof(VarDevice) - 1] = '\0';
VarBaseDevice = rindex(VarDevice, '/');
VarBaseDevice = strrchr(VarDevice, '/');
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
}
break;
@ -1266,9 +1247,9 @@ SetCtsRts(struct cmdtab const * list, int argc, char **argv)
{
if (argc > 0) {
if (strcmp(*argv, "on") == 0)
VarCtsRts = TRUE;
VarCtsRts = 1;
else if (strcmp(*argv, "off") == 0)
VarCtsRts = FALSE;
VarCtsRts = 0;
else
return -1;
return 0;
@ -1292,9 +1273,7 @@ SetOpenMode(struct cmdtab const * list, int argc, char **argv)
return -1;
}
extern int SetIfilter(), SetOfilter(), SetDfilter(), SetAfilter();
struct cmdtab const SetCommands[] = {
static struct cmdtab const SetCommands[] = {
{"accmap", NULL, SetVariable, LOCAL_AUTH,
"Set accmap value", "set accmap hex-value", (void *) VAR_ACCMAP},
{"afilter", NULL, SetAfilter, LOCAL_AUTH,
@ -1433,9 +1412,6 @@ DeleteCommand(struct cmdtab const * list, int argc, char **argv)
return 0;
}
static int AliasEnable();
static int AliasOption();
static struct cmdtab const AliasCommands[] =
{
{"enable", NULL, AliasEnable, LOCAL_AUTH,

View File

@ -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.6 1997/09/22 00:46:53 brian Exp $
* $Id: command.h,v 1.7 1997/09/25 00:52:34 brian Exp $
*
* TODO:
*/
@ -41,4 +41,11 @@ struct cmdtab {
#ifdef HAVE_DES
#define VAR_ENC 8
#endif
extern int SetVariable(struct cmdtab const *, int, char **, int var_param);
extern struct in_addr ifnetmask;
extern int aft_cmd;
extern int SetVariable(struct cmdtab const *, int, char **, int);
extern void Prompt(void);
extern int IsInteractive(void);
extern void DecodeCommand(char *, int, int);

26
usr.sbin/ppp/defs.c Normal file
View File

@ -0,0 +1,26 @@
/*
* $Id: $
*/
#include <stdlib.h>
#include "defs.h"
int mode = MODE_INTER;
int BGFiledes[2] = { -1, -1 };
int modem = -1;
int tun_in = -1;
int tun_out = -1;
int netfd = -1;
char *dstsystem = NULL;
void
randinit()
{
static int initdone;
if (!initdone) {
initdone = 1;
srandomdev();
}
}

View File

@ -15,44 +15,30 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: defs.h,v 1.20 1997/10/23 21:32:48 ache Exp $
* $Id: defs.h,v 1.21 1997/10/24 22:36:29 brian Exp $
*
* TODO:
*/
#ifndef _DEFS_H_
#define _DEFS_H_
#include <sys/types.h>
#include <machine/endian.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "mbuf.h"
#include "log.h"
/*
* Check follwiing definitions for your machine envirinment
* Check following definitions for your machine environment
*/
#ifdef __FreeBSD__
#define MODEM_DEV "/dev/cuaa1" /* name of tty device */
#define BASE_MODEM_DEV "cuaa1" /* name of base tty device */
# define MODEM_DEV "/dev/cuaa1" /* name of tty device */
# define BASE_MODEM_DEV "cuaa1" /* name of base tty device */
#else
#ifdef __OpenBSD__
#define MODEM_DEV "/dev/cua01" /* name of tty device */
#define BASE_MODEM_DEV "cua01" /* name of base tty device */
#else
#define MODEM_DEV "/dev/tty01" /* name of tty device */
#define BASE_MODEM_DEV "tty01" /* name of base tty device */
#endif
# ifdef __OpenBSD__
# define MODEM_DEV "/dev/cua01" /* name of tty device */
# define BASE_MODEM_DEV "cua01" /* name of base tty device */
# else
# define MODEM_DEV "/dev/tty01" /* name of tty device */
# define BASE_MODEM_DEV "tty01" /* name of base tty device */
# endif
#endif
#define MODEM_SPEED B38400 /* tty speed */
#define SERVER_PORT 3000 /* Base server port no. */
#define MODEM_CTSRTS TRUE /* Default (true): use CTS/RTS signals */
#define MODEM_CTSRTS 1 /* Default (true): use CTS/RTS signals */
#define RECONNECT_TIMER 3 /* Default timer for carrier loss */
#define RECONNECT_TRIES 0 /* Default retries on carrier loss */
#define REDIAL_PERIOD 30 /* Default Hold time to redial */
@ -74,7 +60,6 @@
#define MODE_ALIAS 32 /* Packet aliasing (masquerading) */
#define MODE_BACKGROUND 64 /* Background mode. */
#define EX_SIG -1
#define EX_NORMAL 0
#define EX_START 1
@ -90,24 +75,17 @@
#define EX_NODIAL 12
#define EX_NOLOGIN 13
int mode;
int BGFiledes[2];
int modem;
int tun_in, tun_out;
int netfd;
char *dstsystem;
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
extern int mode;
extern int BGFiledes[2];
extern int modem;
extern int tun_in;
extern int tun_out;
extern int netfd;
extern char *dstsystem;
#ifdef SIGALRM
u_int nointr_sleep(u_int sec);
void nointr_usleep(u_int usec);
extern u_int nointr_sleep(u_int);
extern void nointr_usleep(u_int);
#endif
#endif /* _DEFS_H_ */
extern void randinit(void);

View File

@ -17,27 +17,33 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: filter.c,v 1.14 1997/08/31 22:59:23 brian Exp $
* $Id: filter.c,v 1.15 1997/10/23 10:09:35 brian Exp $
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "filter.h"
#include "loadalias.h"
#include "vars.h"
#include "ipcp.h"
#include "filter.h"
struct filterent ifilters[MAXFILTERS]; /* incoming packet filter */
struct filterent ofilters[MAXFILTERS]; /* outgoing packet filter */
struct filterent dfilters[MAXFILTERS]; /* dial-out packet filter */
struct filterent afilters[MAXFILTERS]; /* keep-alive packet filter */
static struct filterent filterdata;
@ -68,7 +74,7 @@ ParseAddr(int argc,
return (0);
}
pmask->s_addr = 0xffffffff; /* Assume 255.255.255.255 as default */
cp = index(*argv, '/');
cp = strchr(*argv, '/');
if (cp)
*cp++ = '\0';
if (strcasecmp(*argv, "HISADDR") == 0)
@ -104,11 +110,11 @@ ParseProto(int argc, char **argv)
if (argc < 1)
return (P_NONE);
if (STREQ(*argv, "tcp"))
if (!strcmp(*argv, "tcp"))
proto = P_TCP;
else if (STREQ(*argv, "udp"))
else if (!strcmp(*argv, "udp"))
proto = P_UDP;
else if (STREQ(*argv, "icmp"))
else if (!strcmp(*argv, "icmp"))
proto = P_ICMP;
else
proto = P_NONE;
@ -164,7 +170,7 @@ ParseIcmp(int argc, char **argv)
LogPrintf(LogWARN, "ParseIcmp: bad icmp syntax.\n");
return (0);
case 3:
if (STREQ(*argv, "src") && STREQ(argv[1], "eq")) {
if (!strcmp(*argv, "src") && !strcmp(argv[1], "eq")) {
type = strtol(argv[2], &cp, 0);
if (cp == argv[2]) {
LogPrintf(LogWARN, "ParseIcmp: type is expected.\n");
@ -183,11 +189,11 @@ ParseOp(char *cp)
{
int op = OP_NONE;
if (STREQ(cp, "eq"))
if (!strcmp(cp, "eq"))
op = OP_EQ;
else if (STREQ(cp, "gt"))
else if (!strcmp(cp, "gt"))
op = OP_GT;
else if (STREQ(cp, "lt"))
else if (!strcmp(cp, "lt"))
op = OP_LT;
return (op);
}
@ -206,7 +212,7 @@ ParseUdpOrTcp(int argc, char **argv, int proto)
return (1);
}
if (argc >= 3 && STREQ(*argv, "src")) {
if (argc >= 3 && !strcmp(*argv, "src")) {
filterdata.opt.srcop = ParseOp(argv[1]);
if (filterdata.opt.srcop == OP_NONE) {
LogPrintf(LogWARN, "ParseUdpOrTcp: bad operation\n");
@ -220,7 +226,7 @@ ParseUdpOrTcp(int argc, char **argv, int proto)
if (argc == 0)
return (1);
}
if (argc >= 3 && STREQ(argv[0], "dst")) {
if (argc >= 3 && !strcmp(argv[0], "dst")) {
filterdata.opt.dstop = ParseOp(argv[1]);
if (filterdata.opt.dstop == OP_NONE) {
LogPrintf(LogWARN, "ParseUdpOrTcp: bad operation\n");
@ -235,7 +241,7 @@ ParseUdpOrTcp(int argc, char **argv, int proto)
return (1);
}
if (argc == 1 && proto == P_TCP) {
if (STREQ(*argv, "estab")) {
if (!strcmp(*argv, "estab")) {
filterdata.opt.estab = 1;
return (1);
}
@ -279,13 +285,13 @@ Parse(int argc, char **argv, struct filterent * ofp)
argv++;
proto = P_NONE;
bzero(&filterdata, sizeof(filterdata));
memset(&filterdata, '\0', sizeof(filterdata));
if (STREQ(*argv, "permit")) {
if (!strcmp(*argv, "permit")) {
action = A_PERMIT;
} else if (STREQ(*argv, "deny")) {
} else if (!strcmp(*argv, "deny")) {
action = A_DENY;
} else if (STREQ(*argv, "clear")) {
} else if (!strcmp(*argv, "clear")) {
ofp->action = A_NONE;
return (1);
} else {
@ -298,11 +304,11 @@ Parse(int argc, char **argv, struct filterent * ofp)
argv++;
if (fp->action == A_DENY) {
if (STREQ(*argv, "host")) {
if (!strcmp(*argv, "host")) {
fp->action |= A_UHOST;
argc--;
argv++;
} else if (STREQ(*argv, "port")) {
} else if (!strcmp(*argv, "port")) {
fp->action |= A_UPORT;
argc--;
argv++;
@ -370,7 +376,7 @@ Parse(int argc, char **argv, struct filterent * ofp)
}
int
SetIfilter(struct cmdtab * list, int argc, char **argv)
SetIfilter(struct cmdtab *list, int argc, char **argv)
{
if (argc > 0) {
(void) Parse(argc, argv, ifilters);
@ -380,7 +386,7 @@ SetIfilter(struct cmdtab * list, int argc, char **argv)
}
int
SetOfilter(struct cmdtab * list, int argc, char **argv)
SetOfilter(struct cmdtab *list, int argc, char **argv)
{
if (argc > 0) {
(void) Parse(argc, argv, ofilters);
@ -390,7 +396,7 @@ SetOfilter(struct cmdtab * list, int argc, char **argv)
}
int
SetDfilter(struct cmdtab * list, int argc, char **argv)
SetDfilter(struct cmdtab *list, int argc, char **argv)
{
if (argc > 0) {
(void) Parse(argc, argv, dfilters);
@ -400,7 +406,7 @@ SetDfilter(struct cmdtab * list, int argc, char **argv)
}
int
SetAfilter(struct cmdtab * list, int argc, char **argv)
SetAfilter(struct cmdtab *list, int argc, char **argv)
{
if (argc > 0) {
(void) Parse(argc, argv, afilters);

View File

@ -15,15 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: filter.h,v 1.8 1997/06/09 03:27:20 brian Exp $
* $Id: filter.h,v 1.9 1997/08/25 00:29:11 brian Exp $
*
* TODO:
*/
#ifndef _FILTER_H_
#define _FILTER_H_
#define STREQ(a,b) (strcmp(a,b) == 0)
/*
* Actions
*/
@ -65,7 +61,7 @@ struct filterent {
short dstop;
u_short dstport;
int estab;
} opt;
} opt;
};
#define MAXFILTERS 20
@ -74,11 +70,18 @@ struct filterent {
#define FL_OUT 1
#define FL_DIAL 2
#define FL_KEEP 3
struct filterent ifilters[MAXFILTERS];
struct filterent ofilters[MAXFILTERS];
struct filterent dfilters[MAXFILTERS];
struct filterent afilters[MAXFILTERS]; /* keep Alive packet filter */
extern struct filterent ifilters[MAXFILTERS]; /* incoming packet filter */
extern struct filterent ofilters[MAXFILTERS]; /* outgoing packet filter */
extern struct filterent dfilters[MAXFILTERS]; /* dial-out packet filter */
extern struct filterent afilters[MAXFILTERS]; /* keep-alive packet filter */
extern int ParseAddr(int, char **, struct in_addr *, struct in_addr *, int *);
#endif /* _FILTER_H_ */
extern int ShowIfilter(struct cmdtab *, int, char **);
extern int ShowOfilter(struct cmdtab *, int, char **);
extern int ShowDfilter(struct cmdtab *, int, char **);
extern int ShowAfilter(struct cmdtab *, int, char **);
extern int SetIfilter(struct cmdtab *, int, char **);
extern int SetOfilter(struct cmdtab *, int, char **);
extern int SetDfilter(struct cmdtab *, int, char **);
extern int SetAfilter(struct cmdtab *, int, char **);

View File

@ -17,12 +17,23 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: fsm.c,v 1.18 1997/09/10 21:33:32 brian Exp $
* $Id: fsm.c,v 1.19 1997/09/10 23:55:35 brian Exp $
*
* TODO:
* o Refer loglevel for log output
* o Better option log display
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "hdlc.h"
#include "lqr.h"
@ -31,13 +42,21 @@
#include "ccp.h"
#include "modem.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "pred.h"
void FsmSendConfigReq(struct fsm * fp);
void FsmSendTerminateReq(struct fsm * fp);
void FsmInitRestartCounter(struct fsm * fp);
void FsmTimeout(struct fsm * fp);
u_char AckBuff[200];
u_char NakBuff[200];
u_char RejBuff[100];
u_char ReqBuff[200];
u_char *ackp = NULL;
u_char *nakp = NULL;
u_char *rejp = NULL;
static void FsmSendConfigReq(struct fsm *);
static void FsmSendTerminateReq(struct fsm *);
static void FsmInitRestartCounter(struct fsm *);
char const *StateNames[] = {
"Initial", "Starting", "Closed", "Stopped", "Closing", "Stopping",
@ -64,7 +83,7 @@ FsmInit(struct fsm * fp)
fp->maxconfig = 3;
}
void
static void
NewState(struct fsm * fp, int new)
{
LogPrintf(fp->LogLevel, "State change %s --> %s\n",
@ -95,9 +114,9 @@ FsmOutput(struct fsm * fp, u_int code, u_int id, u_char * ptr, int count)
lh.id = id;
lh.length = htons(plen);
bp = mballoc(plen, MB_FSM);
bcopy(&lh, MBUF_CTOP(bp), sizeof(struct fsmheader));
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
if (count)
bcopy(ptr, MBUF_CTOP(bp) + sizeof(struct fsmheader), count);
memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
LogDumpBp(LogDEBUG, "FsmOutput", bp);
HdlcOutput(PRI_LINK, fp->proto, bp);
}
@ -205,7 +224,7 @@ FsmClose(struct fsm * fp)
/*
* Send functions
*/
void
static void
FsmSendConfigReq(struct fsm * fp)
{
if (--fp->maxconfig > 0) {
@ -217,7 +236,7 @@ FsmSendConfigReq(struct fsm * fp)
}
}
void
static void
FsmSendTerminateReq(struct fsm * fp)
{
LogPrintf(fp->LogLevel, "SendTerminateReq.\n");
@ -263,7 +282,7 @@ FsmSendConfigNak(struct fsm * fp,
/*
* Timeout actions
*/
void
static void
FsmTimeout(struct fsm * fp)
{
if (fp->restart) {
@ -302,7 +321,7 @@ FsmTimeout(struct fsm * fp)
}
}
void
static void
FsmInitRestartCounter(struct fsm * fp)
{
StopTimer(&fp->FsmTimer);
@ -315,7 +334,7 @@ FsmInitRestartCounter(struct fsm * fp)
/*
* Actions when receive packets
*/
void
static void
FsmRecvConfigReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RCR */
{
@ -400,7 +419,7 @@ FsmRecvConfigReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvConfigAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RCA */
{
@ -434,7 +453,7 @@ FsmRecvConfigAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvConfigNak(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RCN */
{
@ -487,7 +506,7 @@ FsmRecvConfigNak(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvTermReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RTR */
{
@ -519,7 +538,7 @@ FsmRecvTermReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RTA */
{
@ -544,7 +563,7 @@ FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvConfigRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
/* RCJ */
{
@ -597,14 +616,14 @@ FsmRecvConfigRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvCodeRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvCodeRej\n");
pfree(bp);
}
void
static void
FsmRecvProtoRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
u_short *sp, proto;
@ -633,7 +652,7 @@ FsmRecvProtoRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvEchoReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
u_char *cp;
@ -654,7 +673,7 @@ FsmRecvEchoReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvEchoRep(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
u_long *lp, magic;
@ -677,28 +696,28 @@ FsmRecvEchoRep(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvDiscReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvDiscReq\n");
pfree(bp);
}
void
static void
FsmRecvIdent(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvIdent\n");
pfree(bp);
}
void
static void
FsmRecvTimeRemain(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvTimeRemain\n");
pfree(bp);
}
void
static void
FsmRecvResetReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvResetReq\n");
@ -708,7 +727,7 @@ FsmRecvResetReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
pfree(bp);
}
void
static void
FsmRecvResetAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
LogPrintf(fp->LogLevel, "RecvResetAck\n");

View File

@ -15,18 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: fsm.h,v 1.9 1997/08/20 23:47:43 brian Exp $
* $Id: fsm.h,v 1.10 1997/08/25 00:29:12 brian Exp $
*
* TODO:
*/
#ifndef _FSM_H_
#define _FSM_H_
#include "defs.h"
#include <netinet/in.h>
#include "timeout.h"
/*
* State of machine
*/
@ -120,29 +113,20 @@ struct fsmconfig {
u_char length;
};
u_char AckBuff[200];
u_char NakBuff[200];
u_char RejBuff[100];
u_char ReqBuff[200];
u_char *ackp, *nakp, *rejp;
extern u_char AckBuff[200];
extern u_char NakBuff[200];
extern u_char RejBuff[100];
extern u_char ReqBuff[200];
extern u_char *ackp;
extern u_char *nakp;
extern u_char *rejp;
extern char const *StateNames[];
extern void FsmInit(struct fsm *);
extern void NewState(struct fsm *, int);
extern void FsmOutput(struct fsm *, u_int, u_int, u_char *, int);
extern void FsmOpen(struct fsm *);
extern void FsmUp(struct fsm *);
extern void FsmDown(struct fsm *);
extern void FsmInput(struct fsm *, struct mbuf *);
extern void FsmRecvConfigReq(struct fsm *, struct fsmheader *, struct mbuf *);
extern void FsmRecvConfigAck(struct fsm *, struct fsmheader *, struct mbuf *);
extern void FsmRecvConfigNak(struct fsm *, struct fsmheader *, struct mbuf *);
extern void FsmRecvTermReq(struct fsm *, struct fsmheader *, struct mbuf *);
extern void FsmRecvTermAck(struct fsm *, struct fsmheader *, struct mbuf *);
extern void FsmClose(struct fsm * fp);
extern struct fsm LcpFsm, IpcpFsm, CcpFsm;
#endif /* _FSM_H_ */
extern void FsmClose(struct fsm *);

View File

@ -1,53 +0,0 @@
/*
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
*
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the Internet Initiative Japan. The name of the
* IIJ may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id$
*
* TODO:
*/
/*
* GLOBAL.H - RSAREF types and constants
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif

View File

@ -17,16 +17,28 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: hdlc.c,v 1.18 1997/09/10 21:33:32 brian Exp $
* $Id: hdlc.c,v 1.19 1997/09/10 21:36:54 brian Exp $
*
* TODO:
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "lcp.h"
#include "lqr.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "pred.h"
#include "modem.h"
@ -39,8 +51,11 @@ struct hdlcstat {
int unknownproto;
} HdlcStat;
static int ifOutPackets, ifOutOctets, ifOutLQRs;
static int ifInPackets, ifInOctets;
static int ifOutPackets;
static int ifOutOctets;
static int ifOutLQRs;
static int ifInPackets;
static int ifInOctets;
struct protostat {
u_short number;
@ -321,7 +336,7 @@ HdlcErrorCheck()
struct hdlcstat *hp = &HdlcStat;
struct hdlcstat *op = &laststat;
if (bcmp(hp, op, sizeof(laststat))) {
if (memcmp(hp, op, sizeof(laststat))) {
LogPrintf(LogPHASE, "HDLC errors -> FCS: %u ADDR: %u COMD: %u PROTO: %u\n",
hp->badfcs - op->badfcs, hp->badaddr - op->badaddr,
hp->badcommand - op->badcommand, hp->unknownproto - op->unknownproto);

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: hdlc.h,v 1.9 1997/06/09 03:27:22 brian Exp $
* $Id: hdlc.h,v 1.10 1997/08/25 00:29:13 brian Exp $
*
* TODO:
*/
#ifndef _HDLC_H_
#define _HDLC_H_
/*
* Definition for Async HDLC
*/
@ -60,12 +57,12 @@
extern u_char EscMap[33];
void HdlcInit(void);
void HdlcErrorCheck(void);
void HdlcInput(struct mbuf * bp);
void HdlcOutput(int pri, u_short proto, struct mbuf * bp);
void AsyncOutput(int pri, struct mbuf * bp, int proto);
u_short HdlcFcs(u_short, u_char *, int);
void DecodePacket(u_short, struct mbuf *);
#endif
extern void HdlcInit(void);
extern void HdlcErrorCheck(void);
extern void HdlcInput(struct mbuf *);
extern void HdlcOutput(int, u_short, struct mbuf *bp);
extern void AsyncOutput(int, struct mbuf *, int);
extern u_short HdlcFcs(u_short, u_char *, int);
extern void DecodePacket(u_short, struct mbuf *);
extern int ReportHdlcStatus(void);
extern int ReportProtStatus(void);

View File

@ -17,32 +17,45 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.c,v 1.24 1997/09/03 00:40:49 brian Exp $
* $Id: ip.c,v 1.25 1997/10/04 00:14:39 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
* and optionaly record it into log.
*/
#include "fsm.h"
#include "lcpproto.h"
#include "hdlc.h"
#include <sys/param.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <alias.h>
#include <errno.h>
#include "loadalias.h"
#include "vars.h"
#include "filter.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "hdlc.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "filter.h"
#include "log.h"
#include "os.h"
extern void SendPppFrame();
extern void LcpClose();
#include "ipcp.h"
#include "vjcomp.h"
#include "lcp.h"
#include "ip.h"
static struct pppTimer IdleTimer;
@ -224,7 +237,7 @@ IcmpError(struct ip * pip, int code)
if (pip->ip_p != IPPROTO_ICMP) {
bp = mballoc(cnt, MB_IPIN);
bcopy(ptr, MBUF_CTOP(bp), cnt);
memcpy(MBUF_CTOP(bp), ptr, cnt);
SendPppFrame(bp);
RestartIdleTimer();
ipOutOctets += cnt;
@ -336,9 +349,9 @@ PacketCheck(char *cp, int nb, int direction)
return (-1);
} else {
if (FilterCheck(pip, FL_KEEP) & A_DENY) { /* Check Keep Alive filter */
ipKeepAlive = FALSE;
ipKeepAlive = 0;
} else {
ipKeepAlive = TRUE;
ipKeepAlive = 1;
}
return (pri);
}
@ -355,7 +368,7 @@ IpInput(struct mbuf * bp)
cp = tunbuff;
nb = 0;
for (wp = bp; wp; wp = wp->next) { /* Copy to contiguous region */
bcopy(MBUF_CTOP(wp), cp, wp->cnt);
memcpy(cp, MBUF_CTOP(wp), wp->cnt);
cp += wp->cnt;
nb += wp->cnt;
}
@ -439,24 +452,26 @@ IpEnqueue(int pri, char *ptr, int count)
struct mbuf *bp;
bp = mballoc(count, MB_IPQ);
bcopy(ptr, MBUF_CTOP(bp), count);
memcpy(MBUF_CTOP(bp), ptr, count);
Enqueue(&IpOutputQueues[pri], bp);
}
#if 0
int
IsIpEnqueued()
{
struct mqueue *queue;
int exist = FALSE;
int exist = 0;
for (queue = &IpOutputQueues[PRI_FAST]; queue >= IpOutputQueues; queue--) {
if (queue->qlen > 0) {
exist = TRUE;
exist = 1;
break;
}
}
return (exist);
}
#endif
void
IpStartOutput()

View File

@ -17,14 +17,10 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.h,v 1.4 1997/06/09 03:27:23 brian Exp $
* $Id: ip.h,v 1.5 1997/08/25 00:29:14 brian Exp $
*
*/
#ifndef _IP_H_
#define _IP_H_
extern void IpStartOutput(void);
extern int PacketCheck(char *, int, int);
extern void IpEnqueue(int, char *, int);
#endif

View File

@ -17,19 +17,28 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.c,v 1.29 1997/10/07 00:56:56 brian Exp $
* $Id: ipcp.c,v 1.30 1997/10/17 00:20:30 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
*/
#include <sys/types.h>
#include <netdb.h>
#include <sys/param.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "lcp.h"
@ -38,23 +47,22 @@
#include "os.h"
#include "phase.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
extern void VjInit(int);
extern void PutConfValue();
extern void Prompt();
extern struct in_addr ifnetmask;
struct ipcpstate IpcpInfo;
struct in_range DefMyAddress, DefHisAddress;
struct in_addr TriggerAddress;
int HaveTriggerAddress;
#include "vjcomp.h"
#ifndef NOMSEXT
struct in_addr ns_entries[2], nbns_entries[2];
struct in_addr ns_entries[2];
struct in_addr nbns_entries[2];
#endif
struct ipcpstate IpcpInfo;
struct in_range DefMyAddress;
struct in_range DefHisAddress;
struct in_addr TriggerAddress;
int HaveTriggerAddress;
struct pppTimer IpcpReportTimer;
static void IpcpSendConfigReq(struct fsm *);
static void IpcpSendTerminateAck(struct fsm *);
static void IpcpSendTerminateReq(struct fsm *);
@ -64,8 +72,8 @@ static void IpcpLayerFinish(struct fsm *);
static void IpcpLayerUp(struct fsm *);
static void IpcpLayerDown(struct fsm *);
static void IpcpInitRestartCounter(struct fsm *);
struct pppTimer IpcpReportTimer;
static int IpcpOctetsIn(void);
static int IpcpOctetsOut(void);
static int lastInOctets, lastOutOctets;
static int StartingIpIn, StartingIpOut;
@ -165,14 +173,14 @@ IpcpDefAddress()
struct hostent *hp;
char name[200];
bzero(&DefMyAddress, sizeof(DefMyAddress));
bzero(&DefHisAddress, sizeof(DefHisAddress));
memset(&DefMyAddress, '\0', sizeof(DefMyAddress));
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
TriggerAddress.s_addr = 0;
HaveTriggerAddress = 0;
if (gethostname(name, sizeof(name)) == 0) {
hp = gethostbyname(name);
if (hp && hp->h_addrtype == AF_INET) {
bcopy(hp->h_addr, (char *) &DefMyAddress.ipaddr.s_addr, hp->h_length);
memcpy(&DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length);
}
}
}
@ -183,7 +191,7 @@ IpcpInit()
struct ipcpstate *icp = &IpcpInfo;
FsmInit(&IpcpFsm);
bzero(icp, sizeof(struct ipcpstate));
memset(icp, '\0', sizeof(struct ipcpstate));
if ((mode & MODE_DEDICATED) && !dstsystem) {
icp->want_ipaddr.s_addr = icp->his_ipaddr.s_addr = 0;
} else {
@ -264,7 +272,7 @@ IpcpLayerFinish(struct fsm * fp)
NewPhase(PHASE_TERMINATE);
}
int
static int
IpcpOctetsIn()
{
return ipInOctets < StartingIpIn ?
@ -272,7 +280,7 @@ IpcpOctetsIn()
ipInOctets - StartingIpIn;
}
int
static int
IpcpOctetsOut()
{
return ipOutOctets < StartingIpOut ?
@ -381,13 +389,13 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
* If destination address is not acceptable, insist to use what we
* want to use.
*/
bcopy(cp, nakp, 2);
bcopy(&IpcpInfo.his_ipaddr.s_addr, nakp + 2, length);
memcpy(nakp, cp, 2);
memcpy(nakp+2, &IpcpInfo.his_ipaddr.s_addr, length);
nakp += length;
break;
}
IpcpInfo.his_ipaddr = ipaddr;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
break;
case MODE_NAK:
@ -415,7 +423,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
switch (mode) {
case MODE_REQ:
if (!Acceptable(ConfVjcomp)) {
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
} else {
pcomp = (struct compreq *) (cp + 2);
@ -425,12 +433,12 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
LogPrintf(LogWARN, "Peer is speaking RFC1172 compression protocol !\n");
IpcpInfo.heis1172 = 1;
IpcpInfo.his_compproto = compproto;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
} else {
bcopy(cp, nakp, 2);
memcpy(nakp, cp, 2);
pcomp->proto = htons(PROTO_VJCOMP);
bcopy(&pcomp, nakp + 2, 2);
memcpy(nakp+2, &pcomp, 2);
nakp += length;
}
break;
@ -439,19 +447,19 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
&& pcomp->slots < MAX_STATES && pcomp->slots > 2) {
IpcpInfo.his_compproto = compproto;
IpcpInfo.heis1172 = 0;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
} else {
bcopy(cp, nakp, 2);
memcpy(nakp, cp, 2);
pcomp->proto = htons(PROTO_VJCOMP);
pcomp->slots = MAX_STATES - 1;
pcomp->compcid = 0;
bcopy(&pcomp, nakp + 2, sizeof(pcomp));
memcpy(nakp+2, &pcomp, sizeof(pcomp));
nakp += length;
}
break;
default:
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
break;
}
@ -479,7 +487,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
case MODE_REQ:
IpcpInfo.his_ipaddr = ipaddr;
IpcpInfo.want_ipaddr = dstipaddr;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
break;
case MODE_NAK:
@ -505,7 +513,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
if (!Enabled(ConfMSExt)) {
LogPrintf(LogIPCP, "MS NS req - rejected - msext disabled\n");
IpcpInfo.my_reject |= (1 << type);
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
break;
}
@ -520,12 +528,12 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
* So the client has got the DNS stuff wrong (first request) so
* we'll tell 'em how it is
*/
bcopy(cp, nakp, 2); /* copy first two (type/length) */
memcpy(nakp, cp, 2); /* copy first two (type/length) */
LogPrintf(LogIPCP, "MS NS req %d:%s->%s - nak\n",
type,
inet_ntoa(dnsstuff),
inet_ntoa(ms_info_req));
bcopy(&ms_info_req, nakp + 2, length);
memcpy(nakp+2, &ms_info_req, length);
nakp += length;
break;
}
@ -537,7 +545,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
LogPrintf(LogIPCP, "MS NS req %d:%s ok - ack\n",
type,
inet_ntoa(ms_info_req));
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
break;
case MODE_NAK: /* what does this mean?? */
@ -554,7 +562,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
if (!Enabled(ConfMSExt)) {
LogPrintf(LogIPCP, "MS NBNS req - rejected - msext disabled\n");
IpcpInfo.my_reject |= (1 << type);
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
break;
}
@ -564,8 +572,8 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
dnsstuff.s_addr = *lp;
ms_info_req.s_addr = nbns_entries[((type - TY_PRIMARY_NBNS) ? 1 : 0)].s_addr;
if (dnsstuff.s_addr != ms_info_req.s_addr) {
bcopy(cp, nakp, 2);
bcopy(&ms_info_req.s_addr, nakp + 2, length);
memcpy(nakp, cp, 2);
memcpy(nakp+2, &ms_info_req.s_addr, length);
LogPrintf(LogIPCP, "MS NBNS req %d:%s->%s - nak\n",
type,
inet_ntoa(dnsstuff),
@ -576,7 +584,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
LogPrintf(LogIPCP, "MS NBNS req %d:%s ok - ack\n",
type,
inet_ntoa(ms_info_req));
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
break;
case MODE_NAK:
@ -592,7 +600,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode)
default:
IpcpInfo.my_reject |= (1 << type);
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
break;
}

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.h,v 1.9 1997/08/25 00:29:15 brian Exp $
* $Id: ipcp.h,v 1.10 1997/09/03 02:08:19 brian Exp $
*
* TODO:
*/
#ifndef _IPCP_H_
#define _IPCP_H_
#define IPCP_MAXCODE CODE_CODEREJ
#define TY_IPADDRS 1
@ -36,6 +33,9 @@
#define TY_PRIMARY_NBNS 130
#define TY_SECONDARY_DNS 131
#define TY_SECONDARY_NBNS 132
extern struct in_addr ns_entries[2];
extern struct in_addr nbns_entries[2];
#endif
struct ipcpstate {
@ -67,16 +67,11 @@ extern struct in_range DefMyAddress;
extern struct in_range DefHisAddress;
extern struct in_addr TriggerAddress;
extern int HaveTriggerAddress;
#ifndef NOMSEXT
extern struct in_addr ns_entries[2];
extern struct in_addr nbns_entries[2];
#endif
extern struct fsm IpcpFsm;
extern struct pppTimer IpcpReportTimer;
extern void IpcpInit(void);
extern void IpcpDefAddress(void);
extern int IpcpOctetsIn(void);
extern int IpcpOctetsOut(void);
#endif
extern void IpcpUp(void);
extern void IpcpOpen(void);
extern int ReportIpcpStatus(void);

View File

@ -17,17 +17,28 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lcp.c,v 1.38 1997/10/05 15:00:10 brian Exp $
* $Id: lcp.c,v 1.39 1997/10/15 01:01:17 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
* o Limit data field length by MRU
*/
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <termios.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcp.h"
#include "ipcp.h"
@ -38,32 +49,27 @@
#include "lqr.h"
#include "phase.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "auth.h"
#include "timeout.h"
extern void IpcpUp();
extern void IpcpOpen();
extern void SetLinkParams(struct lcpstate *);
extern void Prompt();
extern void Cleanup();
extern struct pppTimer IpcpReportTimer;
extern int randinit;
#include "pap.h"
#include "chap.h"
#include "async.h"
#include "main.h"
#include "modem.h"
struct lcpstate LcpInfo;
static void LcpSendConfigReq(struct fsm *);
static void LcpSendTerminateReq(struct fsm * fp);
static void LcpSendTerminateAck(struct fsm * fp);
static void LcpDecodeConfig(u_char * cp, int flen, int mode);
static void LcpSendTerminateReq(struct fsm *);
static void LcpSendTerminateAck(struct fsm *);
static void LcpDecodeConfig(u_char *, int, int);
static void LcpInitRestartCounter(struct fsm *);
static void LcpLayerUp(struct fsm *);
static void LcpLayerDown(struct fsm *);
static void LcpLayerStart(struct fsm *);
static void LcpLayerFinish(struct fsm *);
extern int ModemSpeed();
#define REJECTED(p, x) (p->his_reject & (1<<x))
static char *cftypes[] = {
@ -97,45 +103,6 @@ struct fsm LcpFsm = {
static struct pppTimer LcpReportTimer;
static int LcpFailedMagic;
char *PhaseNames[] = {
"Dead", "Establish", "Authenticate", "Network", "Terminate"
};
void
NewPhase(int new)
{
struct lcpstate *lcp = &LcpInfo;
phase = new;
LogPrintf(LogPHASE, "NewPhase: %s\n", PhaseNames[phase]);
switch (phase) {
case PHASE_AUTHENTICATE:
lcp->auth_ineed = lcp->want_auth;
lcp->auth_iwait = lcp->his_auth;
if (lcp->his_auth || lcp->want_auth) {
LogPrintf(LogPHASE, " his = %x, mine = %x\n", lcp->his_auth, lcp->want_auth);
if (lcp->his_auth == PROTO_PAP)
StartAuthChallenge(&AuthPapInfo);
if (lcp->want_auth == PROTO_CHAP)
StartAuthChallenge(&AuthChapInfo);
} else
NewPhase(PHASE_NETWORK);
break;
case PHASE_NETWORK:
IpcpUp();
IpcpOpen();
CcpUp();
CcpOpen();
break;
case PHASE_TERMINATE:
if (mode & MODE_DIRECT)
Cleanup(EX_DEAD);
if (mode & MODE_BACKGROUND && reconnectState != RECON_TRUE)
Cleanup(EX_DEAD);
break;
}
}
static void
LcpReportTime()
{
@ -179,13 +146,10 @@ ReportLcpStatus()
/*
* Generate random number which will be used as magic number.
*/
u_long
static u_long
GenerateMagic()
{
if (!randinit) {
randinit = 1;
srandomdev();
}
randinit();
return (random());
}
@ -197,7 +161,7 @@ LcpInit()
FsmInit(&LcpFsm);
HdlcInit();
bzero(lcp, sizeof(struct lcpstate));
memset(lcp, '\0', sizeof(struct lcpstate));
lcp->want_mru = VarMRU;
lcp->his_mru = DEF_MRU;
lcp->his_accmap = 0xffffffff;
@ -459,15 +423,15 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
mtu = MAX_MTU;
if (mru > mtu) {
*sp = htons(mtu);
bcopy(cp, nakp, 4);
memcpy(nakp, cp, 4);
nakp += 4;
} else if (mru < MIN_MRU) {
*sp = htons(MIN_MRU);
bcopy(cp, nakp, 4);
memcpy(nakp, cp, 4);
nakp += 4;
} else {
LcpInfo.his_mru = mru;
bcopy(cp, ackp, 4);
memcpy(ackp, cp, 4);
ackp += 4;
}
break;
@ -488,7 +452,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
switch (mode) {
case MODE_REQ:
LcpInfo.his_accmap = accmap;
bcopy(cp, ackp, 6);
memcpy(ackp, cp, 6);
ackp += 6;
break;
case MODE_NAK:
@ -514,7 +478,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
}
if (Acceptable(ConfPap)) {
LcpInfo.his_auth = proto;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
} else if (Acceptable(ConfChap)) {
*nakp++ = *cp;
@ -537,7 +501,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
#endif
{
LcpInfo.his_auth = proto;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
#ifdef HAVE_DES
VarMSChap = cp[4] = 0x80;
@ -552,7 +516,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
break;
default:
LogPrintf(LogLCP, " %s not implemented, NAK.\n", request);
bcopy(cp, nakp, length);
memcpy(nakp, cp, length);
nakp += length;
break;
}
@ -577,7 +541,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
if (LcpInfo.his_lqrperiod < 500)
LcpInfo.his_lqrperiod = 500;
req->period = htonl(LcpInfo.his_lqrperiod);
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
}
break;
@ -601,13 +565,13 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
LogPrintf(LogLCP, "Magic is same (%08x) - %d times\n",
magic, ++LcpFailedMagic);
LcpInfo.want_magic = GenerateMagic();
bcopy(cp, nakp, 6);
memcpy(nakp, cp, 6);
nakp += 6;
ualarm(TICKUNIT * (4 + 4 * LcpFailedMagic), 0);
sigpause(0);
} else {
LcpInfo.his_magic = magic;
bcopy(cp, ackp, length);
memcpy(ackp, cp, length);
ackp += length;
LcpFailedMagic = 0;
}
@ -634,18 +598,17 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
case MODE_REQ:
if (Acceptable(ConfProtocomp)) {
LcpInfo.his_protocomp = 1;
bcopy(cp, ackp, 2);
memcpy(ackp, cp, 2);
ackp += 2;
} else {
#ifdef OLDMST
/*
* MorningStar before v1.3 needs NAK
*/
bcopy(cp, nakp, 2);
memcpy(nakp, cp, 2);
nakp += 2;
#else
bcopy(cp, rejp, 2);
memcpy(rejp, cp, 2);
rejp += 2;
LcpInfo.my_reject |= (1 << type);
#endif
@ -664,18 +627,17 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
case MODE_REQ:
if (Acceptable(ConfAcfcomp)) {
LcpInfo.his_acfcomp = 1;
bcopy(cp, ackp, 2);
memcpy(ackp, cp, 2);
ackp += 2;
} else {
#ifdef OLDMST
/*
* MorningStar before v1.3 needs NAK
*/
bcopy(cp, nakp, 2);
memcpy(nakp, cp, 2);
nakp += 2;
#else
bcopy(cp, rejp, 2);
memcpy(rejp, cp, 2);
rejp += 2;
LcpInfo.my_reject |= (1 << type);
#endif
@ -701,7 +663,7 @@ LcpDecodeConfig(u_char * cp, int plen, int mode)
LogPrintf(LogLCP, " ???[%02x]\n", type);
if (mode == MODE_REQ) {
reqreject:
bcopy(cp, rejp, length);
memcpy(rejp, cp, length);
rejp += length;
LcpInfo.my_reject |= (1 << type);
}

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lcp.h,v 1.7 1997/06/09 03:27:25 brian Exp $
* $Id: lcp.h,v 1.8 1997/08/25 00:29:15 brian Exp $
*
* TODO:
*/
#ifndef _LCP_H_
#define _LPC_H_
struct lcpstate {
u_long his_mru;
u_long his_accmap;
@ -73,6 +70,7 @@ struct lqrreq {
};
extern struct lcpstate LcpInfo;
extern struct fsm LcpFsm;
extern void LcpInit(void);
extern void LcpUp(void);
@ -80,5 +78,5 @@ extern void LcpSendProtoRej(u_char *, int);
extern void LcpOpen(int mode);
extern void LcpClose(void);
extern void LcpDown(void);
#endif
extern void PutConfValue(u_char **, char **, u_char, int, u_long);
extern int ReportLcpStatus(void);

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lcpproto.h,v 1.7 1997/06/09 03:27:25 brian Exp $
* $Id: lcpproto.h,v 1.8 1997/08/25 00:29:16 brian Exp $
*
* TODO:
*/
#ifndef _LCPPROTO_H_
#define _LCPPROTO_H_
/*
* Definition of protocol numbers
*/
@ -41,13 +38,11 @@
#define PROTO_LQR 0xc025
#define PROTO_CHAP 0xc223
extern void LcpInput(struct mbuf * bp);
extern void PapInput(struct mbuf * bp);
extern void LqpInput(struct mbuf * bp);
extern void ChapInput(struct mbuf * bp);
extern void IpInput(struct mbuf * bp);
extern struct mbuf *VjCompInput(struct mbuf * bp, int proto);
extern void IpcpInput(struct mbuf * bp);
extern void LqrInput(struct mbuf * bp);
#endif
extern void LcpInput(struct mbuf *);
extern void PapInput(struct mbuf *);
extern void LqpInput(struct mbuf *);
extern void ChapInput(struct mbuf *);
extern void IpInput(struct mbuf *);
extern struct mbuf *VjCompInput(struct mbuf *, int);
extern void IpcpInput(struct mbuf *);
extern void LqrInput(struct mbuf *);

View File

@ -1,12 +1,18 @@
#include <sys/types.h>
#include <sys/socket.h>
/*
* $Id: $
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include <alias.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <unistd.h>
#include "command.h"
#include "systems.h"
#include "mbuf.h"
#include "log.h"

View File

@ -1,18 +1,21 @@
/*
* $Id: $
*/
struct aliasHandlers {
char *(*PacketAliasGetFragment) (char *);
void (*PacketAliasInit) ();
int (*PacketAliasIn) (char *, int);
int (*PacketAliasOut) (char *, int);
struct alias_link *(*PacketAliasRedirectAddr)
(struct in_addr, struct in_addr);
char *(*PacketAliasGetFragment)(char *);
void (*PacketAliasInit)(void);
int (*PacketAliasIn)(char *, int);
int (*PacketAliasOut)(char *, int);
struct alias_link *(*PacketAliasRedirectAddr)(struct in_addr, struct in_addr);
struct alias_link *(*PacketAliasRedirectPort)
(struct in_addr, u_short, struct in_addr, u_short,
struct in_addr, u_short, u_char);
int (*PacketAliasSaveFragment) (char *);
void (*PacketAliasSetAddress) (struct in_addr);
unsigned (*PacketAliasSetMode) (unsigned, unsigned);
void (*PacketAliasFragmentIn) (char *, char *);
(struct in_addr, u_short, struct in_addr, u_short,
struct in_addr, u_short, u_char);
int (*PacketAliasSaveFragment)(char *);
void (*PacketAliasSetAddress)(struct in_addr);
unsigned (*PacketAliasSetMode)(unsigned, unsigned);
void (*PacketAliasFragmentIn)(char *, char *);
};
extern int loadAliasHandlers(struct aliasHandlers *);
extern void unloadAliasHandlers();
extern void unloadAliasHandlers(void);

View File

@ -1,13 +1,19 @@
#include <sys/types.h>
#include <sys/socket.h>
/*
* $Id: $
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <syslog.h>
#include <sys/socket.h>
#include <stdarg.h>
#include <stdio.h>
#include <syslog.h>
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
static char *LogNames[] = {

View File

@ -1,3 +1,7 @@
/*
* $Id: $
*/
#define LogMIN (1)
#define LogASYNC (1) /* syslog(LOG_INFO, ....) */
#define LogCARRIER (2)
@ -24,11 +28,11 @@
extern const char *LogName(int);
extern void LogKeep(int);
extern void LogDiscard(int);
extern void LogDiscardAll();
extern void LogDiscardAll(void);
extern int LogIsKept(int);
extern void LogOpen(const char *);
extern void LogSetTun(int);
extern void LogClose();
extern void LogClose(void);
extern void LogPrintf(int, char *,...);
extern void LogDumpBp(int, char *hdr, struct mbuf * bp);
extern void LogDumpBuff(int, char *hdr, u_char * ptr, int n);
extern void LogDumpBp(int, char *, struct mbuf *);
extern void LogDumpBuff(int, char *, u_char *, int);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lqr.c,v 1.17 1997/08/25 00:29:18 brian Exp $
* $Id: lqr.c,v 1.18 1997/08/31 22:59:35 brian Exp $
*
* o LQR based on RFC1333
*
@ -25,12 +25,22 @@
* o LQM policy
* o Allow user to configure LQM method and interval.
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "lqr.h"
#include "hdlc.h"
#include "lcp.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "main.h"

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lqr.h,v 1.6 1997/06/09 03:27:27 brian Exp $
* $Id: lqr.h,v 1.7 1997/08/25 00:29:19 brian Exp $
*
* TODO:
*/
#ifndef _LQR_H_
#define _LQR_H_
/*
* Structure of LQR packet defined in RFC1333
*/
@ -64,5 +61,3 @@ extern void StartLqm(void);
extern void StopLqr(int);
extern void StopLqrTimer(void);
extern void RecvEchoLqr(struct mbuf *);
#endif

View File

@ -17,27 +17,38 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: main.c,v 1.83 1997/10/16 23:55:18 brian Exp $
* $Id: main.c,v 1.84 1997/10/24 22:36:30 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
* o Add signal handler for misc controls.
*/
#include "fsm.h"
#include <fcntl.h>
#include <paths.h>
#include <sys/time.h>
#include <termios.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sysexits.h>
#include <termios.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "modem.h"
#include "os.h"
#include "hdlc.h"
@ -45,6 +56,7 @@
#include "lcp.h"
#include "ipcp.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "auth.h"
#include "filter.h"
@ -53,6 +65,9 @@
#include "sig.h"
#include "server.h"
#include "lcpproto.h"
#include "main.h"
#include "vjcomp.h"
#include "async.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
@ -60,26 +75,20 @@
#endif
#endif
extern void VjInit(int), AsyncInit();
extern void AsyncInput();
extern int SelectSystem();
extern void DecodeCommand(), Prompt();
extern int aft_cmd;
extern int IsInteractive();
static void DoLoop(void);
static void TerminalStop();
static char *ex_desc();
int TermMode = 0;
int tunno = 0;
static struct termios oldtio; /* Original tty mode */
static struct termios comtio; /* Command level tty mode */
int TermMode;
static pid_t BGPid = 0;
static char pid_filename[MAXPATHLEN];
static char if_filename[MAXPATHLEN];
int tunno;
static int dial_up;
static void DoLoop(void);
static void TerminalStop(int);
static char *ex_desc(int);
static void
TtyInit(int DontWantInt)
{
@ -197,7 +206,7 @@ CloseConnection(int signo)
reconnectState = RECON_FALSE;
reconnectCount = 0;
DownConnection();
dial_up = FALSE;
dial_up = 0;
}
static void
@ -254,7 +263,7 @@ ex_desc(int ex)
return num;
}
void
static void
Usage()
{
fprintf(stderr,
@ -262,7 +271,7 @@ Usage()
exit(EX_START);
}
void
static void
ProcessArgs(int argc, char **argv)
{
int optc;
@ -322,14 +331,11 @@ main(int argc, char **argv)
char *name;
VarTerm = 0;
name = rindex(argv[0], '/');
name = strrchr(argv[0], '/');
LogOpen(name ? name + 1 : argv[0]);
argc--;
argv++;
mode = MODE_INTER; /* default operation is interactive mode */
netfd = modem = tun_in = -1;
server = -2;
ProcessArgs(argc, argv);
if (!(mode & MODE_DIRECT)) {
if (getuid() != 0) {
@ -412,7 +418,7 @@ main(int argc, char **argv)
Cleanup(EX_SOCK);
}
}
/* Create server socket and listen. */
/* Create server socket and listen (initial value is -2) */
if (server == -2)
ServerTcpOpen(SERVER_PORT + tunno);
@ -633,7 +639,7 @@ static char *FrameHeaders[] = {
NULL,
};
u_char *
static u_char *
HdlcDetect(u_char * cp, int n)
{
char *ptr, *fp, **hp;
@ -717,9 +723,9 @@ DoLoop()
reconnectState = RECON_UNKNOWN;
if (mode & MODE_BACKGROUND)
dial_up = TRUE; /* Bring the line up */
dial_up = 1; /* Bring the line up */
else
dial_up = FALSE; /* XXXX */
dial_up = 0; /* XXXX */
tries = 0;
for (;;) {
nfds = 0;
@ -731,19 +737,19 @@ DoLoop()
* If the link is down and we're in DDIAL mode, bring it back up.
*/
if (mode & MODE_DDIAL && LcpFsm.state <= ST_CLOSED)
dial_up = TRUE;
dial_up = 1;
/*
* If we lost carrier and want to re-establish the connection due to the
* "set reconnect" value, we'd better bring the line back up.
*/
if (LcpFsm.state <= ST_CLOSED) {
if (dial_up != TRUE && reconnectState == RECON_TRUE) {
if (!dial_up && reconnectState == RECON_TRUE) {
if (++reconnectCount <= VarReconnectTries) {
LogPrintf(LogPHASE, "Connection lost, re-establish (%d/%d)\n",
reconnectCount, VarReconnectTries);
StartRedialTimer(VarReconnectTimer);
dial_up = TRUE;
dial_up = 1;
} else {
if (VarReconnectTries)
LogPrintf(LogPHASE, "Connection lost, maximum (%d) times\n",
@ -772,7 +778,7 @@ DoLoop()
if (!(mode & MODE_DDIAL) && VarDialTries && tries >= VarDialTries) {
if (mode & MODE_BACKGROUND)
Cleanup(EX_DIAL); /* Can't get the modem */
dial_up = FALSE;
dial_up = 0;
reconnectState = RECON_UNKNOWN;
reconnectCount = 0;
tries = 0;
@ -790,7 +796,7 @@ DoLoop()
nointr_sleep(1); /* little pause to allow peer starts */
ModemTimeout();
PacketMode();
dial_up = FALSE;
dial_up = 0;
reconnectState = RECON_UNKNOWN;
tries = 0;
} else {
@ -806,7 +812,7 @@ DoLoop()
res == EX_SIG)) {
/* I give up ! Can't get through :( */
StartRedialTimer(VarRedialTimeout);
dial_up = FALSE;
dial_up = 0;
reconnectState = RECON_UNKNOWN;
reconnectCount = 0;
tries = 0;
@ -983,7 +989,7 @@ DoLoop()
n = ntohs(((struct ip *) rbuff)->ip_len);
}
bp = mballoc(n, MB_IPIN);
bcopy(rbuff, MBUF_CTOP(bp), n);
memcpy(MBUF_CTOP(bp), rbuff, n);
IpInput(bp);
LogPrintf(LogDEBUG, "Looped back packet addressed to myself\n");
}
@ -1004,7 +1010,7 @@ DoLoop()
n = ntohs(((struct ip *) rbuff)->ip_len);
}
IpEnqueue(pri, rbuff, n);
dial_up = TRUE; /* XXX */
dial_up = 1; /* XXX */
}
continue;
}

View File

@ -17,13 +17,16 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: main.h,v 1.5 1997/08/25 00:29:19 brian Exp $
* $Id: main.h,v 1.6 1997/09/25 00:52:35 brian Exp $
*
*/
#ifndef _MAIN_H_
#define _MAIN_H_
extern int TermMode;
extern int tunno;
void Cleanup(int);
#endif
extern void Cleanup(int);
extern void TtyTermMode(void);
extern void PacketMode(void);
extern void TtyOldMode(void);
extern void TtyTermMode(void);
extern void TtyCommandMode(int);

View File

@ -17,15 +17,22 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: mbuf.c,v 1.8 1997/06/25 19:30:02 brian Exp $
* $Id: mbuf.c,v 1.9 1997/08/25 00:29:20 brian Exp $
*
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "server.h"
@ -60,7 +67,7 @@ mballoc(int cnt, int type)
ServerClose();
exit(1);
}
bzero(bp, sizeof(struct mbuf));
memset(bp, '\0', sizeof(struct mbuf));
p = (u_char *) malloc(cnt);
if (p == NULL) {
LogPrintf(LogALERT, "failed to allocate memory: %d\n", cnt);
@ -108,7 +115,7 @@ mbread(struct mbuf * bp, u_char * ptr, int len)
nb = bp->cnt;
else
nb = len;
bcopy(MBUF_CTOP(bp), ptr, nb);
memcpy(ptr, MBUF_CTOP(bp), nb);
ptr += nb;
bp->cnt -= nb;
len -= nb;
@ -136,7 +143,7 @@ mbwrite(struct mbuf * bp, u_char * ptr, int cnt)
while (cnt > 0) {
nb = (cnt < bp->cnt) ? cnt : bp->cnt;
bcopy(ptr, MBUF_CTOP(bp), nb);
memcpy(MBUF_CTOP(bp), ptr, nb);
cnt -= bp->cnt;
bp = bp->next;
}

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: mbuf.h,v 1.5 1997/06/09 03:27:29 brian Exp $
* $Id: mbuf.h,v 1.6 1997/08/25 00:29:20 brian Exp $
*
* TODO:
*/
#ifndef _MBUF_H_
#define _MBUF_H_
struct mbuf {
u_char *base; /* pointer to top of buffer space */
short size; /* size allocated from base */
@ -55,16 +52,14 @@ struct mqueue {
#define MB_IPQ 10
#define MB_MAX MB_IPQ
extern int plength(struct mbuf * bp);
extern struct mbuf *mballoc(int cnt, int type);
extern struct mbuf *mbfree(struct mbuf * bp);
extern void pfree(struct mbuf * bp);
extern void mbwrite(struct mbuf * bp, u_char * ptr, int cnt);
extern struct mbuf *mbread(struct mbuf * bp, u_char * ptr, int cnt);
extern void DumpBp(struct mbuf * bp);
extern void Enqueue(struct mqueue * queue, struct mbuf * bp);
extern struct mbuf *Dequeue(struct mqueue * queue);
extern void LogMemory();
extern int ShowMemMap();
#endif
extern int plength(struct mbuf *);
extern struct mbuf *mballoc(int, int);
extern struct mbuf *mbfree(struct mbuf *);
extern void pfree(struct mbuf *);
extern void mbwrite(struct mbuf *, u_char *, int);
extern struct mbuf *mbread(struct mbuf *, u_char *, int);
extern void DumpBp(struct mbuf *);
extern void Enqueue(struct mqueue *, struct mbuf *);
extern struct mbuf *Dequeue(struct mqueue *);
extern void LogMemory(void);
extern int ShowMemMap(void);

View File

@ -17,34 +17,48 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: modem.c,v 1.58 1997/09/23 22:07:51 brian Exp $
* $Id: modem.c,v 1.59 1997/10/24 22:36:31 brian Exp $
*
* TODO:
*/
#include "fsm.h"
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <paths.h>
#include <utmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include <utmp.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "hdlc.h"
#include "lcp.h"
#include "ip.h"
#include "modem.h"
#include "loadalias.h"
#include "vars.h"
#include "command.h"
#include "vars.h"
#include "main.h"
#include "chat.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
@ -52,15 +66,10 @@
#endif
#endif
extern int DoChat();
static int mbits; /* Current DCD status */
static int connect_count;
static struct pppTimer ModemTimer;
extern void PacketMode(), TtyTermMode(), TtyCommandMode();
extern int TermMode;
#define Online (mbits & TIOCM_CD)
static struct mbuf *modemout;
@ -230,7 +239,7 @@ static struct speeds {
}
};
int
static int
SpeedToInt(speed_t speed)
{
struct speeds *sp;
@ -326,7 +335,7 @@ ModemTimeout()
}
}
void
static void
StartModemTimer()
{
StopTimer(&ModemTimer);
@ -355,7 +364,7 @@ struct parity {
},
};
int
static int
GetParityValue(char *str)
{
struct parity *pp;
@ -388,7 +397,7 @@ ChangeParity(char *str)
return -1;
}
int
static int
OpenConnection(char *host, char *port)
{
struct sockaddr_in dest;
@ -401,7 +410,7 @@ OpenConnection(char *host, char *port)
if (dest.sin_addr.s_addr == INADDR_NONE) {
hp = gethostbyname(host);
if (hp) {
bcopy(hp->h_addr_list[0], &dest.sin_addr.s_addr, 4);
memcpy(&dest.sin_addr.s_addr, hp->h_addr_list[0], 4);
} else {
LogPrintf(LogWARN, "OpenConnection: unknown host: %s\n", host);
return (-1);
@ -431,10 +440,9 @@ OpenConnection(char *host, char *port)
return (sock);
}
extern int tunno;
static char fn[MAXPATHLEN];
int
static int
LockModem()
{
int res;
@ -464,7 +472,7 @@ LockModem()
return 0;
}
void
static void
UnlockModem()
{
if (*VarDevice != '/')
@ -518,8 +526,8 @@ OpenModem(int mode)
}
LogPrintf(LogDEBUG, "OpenModem: Modem is %s\n", VarDevice);
} else {
/* XXX: PPP over TCP */
cp = index(VarDevice, ':');
/* PPP over TCP */
cp = strchr(VarDevice, ':');
if (cp) {
*cp = 0;
host = VarDevice;
@ -648,7 +656,7 @@ RawModem(int modem)
return (0);
}
void
static void
UnrawModem(int modem)
{
int oldflag;
@ -676,15 +684,11 @@ HangupModem(int flag)
if (modem >= 0 && Online) {
mbits &= ~TIOCM_DTR;
#ifdef __bsdi__ /* not a POSIX way */
ioctl(modem, TIOCMSET, &mbits);
#else
tcgetattr(modem, &tio);
if (cfsetspeed(&tio, B0) == -1) {
LogPrintf(LogWARN, "Unable to set modem to speed 0\n");
}
tcsetattr(modem, TCSANOW, &tio);
#endif
nointr_sleep(1);
}
@ -756,7 +760,7 @@ WriteModem(int pri, char *ptr, int count)
struct mbuf *bp;
bp = mballoc(count, MB_MODEM);
bcopy(ptr, MBUF_CTOP(bp), count);
memcpy(MBUF_CTOP(bp), ptr, count);
/*
* Should be NORMAL and LINK only. All IP frames get here marked NORMAL.

View File

@ -15,18 +15,12 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: modem.h,v 1.8 1997/06/09 03:27:30 brian Exp $
* $Id: modem.h,v 1.9 1997/08/25 00:29:23 brian Exp $
*
* TODO:
*/
#ifndef _MODEM_H_
#define _MODEM_H_
#include <termios.h>
#include "mbuf.h"
extern int RawModem(int);
extern void UnrawModem(int);
extern void UpModem(int);
extern void DownModem(int);
extern void WriteModem(int, char *, int);
@ -36,10 +30,10 @@ extern void CloseModem(void);
extern int ModemSpeed(void);
extern int ModemQlen(void);
extern int DialModem(void);
extern int SpeedToInt(speed_t);
extern speed_t IntToSpeed(int);
extern void ModemTimeout(void);
extern void DownConnection(void);
extern void ModemOutput(int, struct mbuf *);
#endif
extern int ChangeParity(char *);
extern void HangupModem(int);
extern int ShowModemStatus(void);

View File

@ -1,34 +1,34 @@
#include <limits.h>
#include <netdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*
* $Id: $
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "command.h"
#include "loadalias.h"
#include "vars.h"
#include "alias_cmd.h"
static int
StrToAddr(char *, struct in_addr * addr);
static int
StrToPort(char *, u_short * port, char *proto);
static int
StrToAddrAndPort(char *, struct in_addr * addr, u_short * port, char *proto);
static int StrToAddr(char *, struct in_addr *);
static int StrToPort(char *, u_short *, char *);
static int StrToAddrAndPort(char *, struct in_addr *, u_short *, char *);
int
AliasRedirectPort(struct cmdtab * list,
int argc,
char **argv,
void *param)
AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
@ -91,10 +91,7 @@ AliasRedirectPort(struct cmdtab * list,
int
AliasRedirectAddr(struct cmdtab * list,
int argc,
char **argv,
void *param)
AliasRedirectAddr(struct cmdtab *list, int argc, char **argv, void *param)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
@ -132,8 +129,7 @@ AliasRedirectAddr(struct cmdtab * list,
static int
StrToAddr(char *str,
struct in_addr * addr)
StrToAddr(char *str, struct in_addr *addr)
{
struct hostent *hp;
@ -151,9 +147,7 @@ StrToAddr(char *str,
static int
StrToPort(char *str,
u_short * port,
char *proto)
StrToPort(char *str, u_short *port, char *proto)
{
int iport;
struct servent *sp;
@ -176,10 +170,7 @@ StrToPort(char *str,
int
StrToAddrAndPort(char *str,
struct in_addr * addr,
u_short * port,
char *proto)
StrToAddrAndPort(char *str, struct in_addr *addr, u_short *port, char *proto)
{
char *ptr;

View File

@ -1,5 +1,6 @@
extern int
AliasRedirectPort(struct cmdtab *, int, char **, void *);
/*
* $Id: $
*/
extern int
AliasRedirectAddr(struct cmdtab *, int, char **, void *);
extern int AliasRedirectPort(struct cmdtab *, int, char **, void *);
extern int AliasRedirectAddr(struct cmdtab *, int, char **, void *);

View File

@ -17,48 +17,51 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: os.c,v 1.26 1997/09/03 00:40:50 brian Exp $
* $Id: os.c,v 1.27 1997/09/03 02:08:20 brian Exp $
*
*/
#include "fsm.h"
#include <sys/param.h>
#include <sys/socket.h>
#if BSD >= 199206 || _BSDI_VERSION >= 199312
#include <sys/select.h>
#endif
#include <sys/ioctl.h>
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_tun.h>
#include <net/route.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "ipcp.h"
#include "os.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "arp.h"
#include "systems.h"
#include "route.h"
#include "ccp.h"
#include "modem.h"
char *IfDevName;
static struct ifaliasreq ifra;
static struct ifreq ifrq;
static struct in_addr oldmine, oldhis;
static int linkup;
#ifdef bsdi
extern char *inet_ntoa();
#endif
extern void HangupModem();
char *IfDevName;
static int
SetIpDevice(struct in_addr myaddr,
struct in_addr hisaddr,
@ -82,9 +85,9 @@ SetIpDevice(struct in_addr myaddr,
close(s);
return (0);
}
bzero(&ifra.ifra_addr, sizeof(ifra.ifra_addr));
bzero(&ifra.ifra_broadaddr, sizeof(ifra.ifra_addr));
bzero(&ifra.ifra_mask, sizeof(ifra.ifra_addr));
memset(&ifra.ifra_addr, '\0', sizeof(ifra.ifra_addr));
memset(&ifra.ifra_broadaddr, '\0', sizeof(ifra.ifra_addr));
memset(&ifra.ifra_mask, '\0', sizeof(ifra.ifra_addr));
if (ioctl(s, SIOCDIFADDR, &ifra) < 0) {
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCDIFADDR): %s\n",
strerror(errno));
@ -151,16 +154,16 @@ SetIpDevice(struct in_addr myaddr,
/*
* Interface already exists. Just change the address.
*/
bcopy(&ifra.ifra_addr, &ifrq.ifr_addr, sizeof(struct sockaddr));
memcpy(&ifrq.ifr_addr, &ifra.ifra_addr, sizeof(struct sockaddr));
if (ioctl(s, SIOCSIFADDR, &ifra) < 0)
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIFADDR): %s\n",
strerror(errno));
bcopy(&ifra.ifra_broadaddr, &ifrq.ifr_dstaddr, sizeof(struct sockaddr));
memcpy(&ifrq.ifr_dstaddr, &ifra.ifra_broadaddr, sizeof(struct sockaddr));
if (ioctl(s, SIOCSIFDSTADDR, &ifrq) < 0)
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIFDSTADDR): %s\n",
strerror(errno));
#ifdef notdef
bcopy(&ifra.ifra_mask, &ifrq.ifr_broadaddr, sizeof(struct sockaddr));
memcpy(&ifrq.ifr_broadaddr, &ifra.ifra_mask, sizeof(struct sockaddr));
if (ioctl(s, SIOCSIFBRDADDR, &ifrq) < 0)
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIFBRDADDR): %s\n",
strerror(errno));
@ -349,8 +352,8 @@ OpenTunnel(int *ptun)
*/
strncpy(ifname, devname + 5, IFNAMSIZ - 1);
bzero((char *) &ifra, sizeof(ifra));
bzero((char *) &ifrq, sizeof(ifrq));
memset(&ifra, '\0', sizeof(ifra));
memset(&ifrq, '\0', sizeof(ifrq));
strncpy(ifrq.ifr_name, ifname, IFNAMSIZ - 1);
strncpy(ifra.ifra_name, ifname, IFNAMSIZ - 1);

View File

@ -15,26 +15,22 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: os.h,v 1.7 1997/08/25 00:29:24 brian Exp $
* $Id: os.h,v 1.8 1997/09/03 00:40:50 brian Exp $
*
* TODO:
*/
#ifndef _OS_H_
#define _OS_H_
extern char *IfDevName;
int OsSetIpaddress(struct in_addr myaddr, struct in_addr hisaddr,
struct in_addr netmask);
int OsSetIpaddress(struct in_addr, struct in_addr, struct in_addr);
int OsInterfaceDown(int);
void OsSetInterfaceParams(int type, int mtu, int speed);
void OsSetInterfaceParams(int, int, int);
int OpenTunnel(int *);
void OsCloseLink(int flag);
void OsCloseLink(int);
void OsLinkup(void);
int OsLinkIsUp(void);
void OsLinkdown(void);
void OsSetRoute(int, struct in_addr, struct in_addr, struct in_addr);
void DeleteIfRoutes(int);
void OsAddInOctets(int cnt);
void OsAddOutOctets(int cnt);
#endif
void OsAddInOctets(int);
void OsAddOutOctets(int);

View File

@ -18,37 +18,45 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: pap.c,v 1.16 1997/09/27 19:11:41 brian Exp $
* $Id: pap.c,v 1.17 1997/10/16 23:55:19 brian Exp $
*
* TODO:
*/
#include <time.h>
#include <utmp.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include <utmp.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcp.h"
#include "pap.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "phase.h"
#include "auth.h"
#ifdef __OpenBSD__
#include "util.h"
#else
#include "libutil.h"
#endif
static char *papcodes[] = {
"???", "REQUEST", "ACK", "NAK"
};
struct authinfo AuthPapInfo = {
SendPapChallenge,
};
void
static void
SendPapChallenge(int papid)
{
struct fsmheader lh;
@ -69,17 +77,21 @@ SendPapChallenge(int papid)
lh.id = papid;
lh.length = htons(plen + sizeof(struct fsmheader));
bp = mballoc(plen + sizeof(struct fsmheader), MB_FSM);
bcopy(&lh, MBUF_CTOP(bp), sizeof(struct fsmheader));
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
cp = MBUF_CTOP(bp) + sizeof(struct fsmheader);
*cp++ = namelen;
bcopy(VarAuthName, cp, namelen);
memcpy(cp, VarAuthName, namelen);
cp += namelen;
*cp++ = keylen;
bcopy(VarAuthKey, cp, keylen);
memcpy(cp, VarAuthKey, keylen);
HdlcOutput(PRI_LINK, PROTO_PAP, bp);
}
struct authinfo AuthPapInfo = {
SendPapChallenge,
};
static void
SendPapCode(int id, int code, char *message)
{
@ -94,10 +106,10 @@ SendPapCode(int id, int code, char *message)
plen = mlen + 1;
lh.length = htons(plen + sizeof(struct fsmheader));
bp = mballoc(plen + sizeof(struct fsmheader), MB_FSM);
bcopy(&lh, MBUF_CTOP(bp), sizeof(struct fsmheader));
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
cp = MBUF_CTOP(bp) + sizeof(struct fsmheader);
*cp++ = mlen;
bcopy(message, cp, mlen);
memcpy(cp, message, mlen);
LogPrintf(LogPHASE, "PapOutput: %s\n", papcodes[code]);
HdlcOutput(PRI_LINK, PROTO_PAP, bp);
}

View File

@ -15,15 +15,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id$
* $Id: pap.h,v 1.3 1997/02/22 16:10:41 peter Exp $
*
* TODO:
*/
#ifndef _PAP_H_
#define _PAP_H_
#define PAP_REQUEST 1
#define PAP_ACK 2
#define PAP_NAK 3
#endif
extern struct authinfo AuthPapInfo;

View File

@ -31,15 +31,11 @@
* SUCH DAMAGE.
*
*
* $Id: pathnames.h,v 1.6 1997/02/22 16:10:43 peter Exp $
* $Id: pathnames.h,v 1.7 1997/09/10 02:20:33 brian Exp $
*
* @(#)pathnames.h 5.2 (Berkeley) 6/1/90
*/
#ifdef __bsdi__
#include <paths.h>
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#define _PATH_PPP "/etc/ppp"
#else

66
usr.sbin/ppp/phase.c Normal file
View File

@ -0,0 +1,66 @@
/*
* $Id: $
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include "mbuf.h"
#include "log.h"
#include "lcp.h"
#include "lcpproto.h"
#include "timer.h"
#include "auth.h"
#include "pap.h"
#include "chap.h"
#include "ipcp.h"
#include "ccp.h"
#include "defs.h"
#include "main.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "phase.h"
int phase = 0; /* Curent phase */
static char *PhaseNames[] = {
"Dead", "Establish", "Authenticate", "Network", "Terminate"
};
void
NewPhase(int new)
{
struct lcpstate *lcp = &LcpInfo;
phase = new;
LogPrintf(LogPHASE, "NewPhase: %s\n", PhaseNames[phase]);
switch (phase) {
case PHASE_AUTHENTICATE:
lcp->auth_ineed = lcp->want_auth;
lcp->auth_iwait = lcp->his_auth;
if (lcp->his_auth || lcp->want_auth) {
LogPrintf(LogPHASE, " his = %x, mine = %x\n", lcp->his_auth, lcp->want_auth);
if (lcp->his_auth == PROTO_PAP)
StartAuthChallenge(&AuthPapInfo);
if (lcp->want_auth == PROTO_CHAP)
StartAuthChallenge(&AuthChapInfo);
} else
NewPhase(PHASE_NETWORK);
break;
case PHASE_NETWORK:
IpcpUp();
IpcpOpen();
CcpUp();
CcpOpen();
break;
case PHASE_TERMINATE:
if (mode & MODE_DIRECT)
Cleanup(EX_DEAD);
if (mode & MODE_BACKGROUND && reconnectState != RECON_TRUE)
Cleanup(EX_DEAD);
break;
}
}

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: phase.h,v 1.6 1997/06/09 03:27:35 brian Exp $
* $Id: phase.h,v 1.7 1997/08/25 00:29:25 brian Exp $
*
* TODO:
*/
#ifndef _PHASE_H_
#define _PHASE_H_
#define PHASE_DEAD 0 /* Link is dead */
#define PHASE_ESTABLISH 1 /* Establishing link */
#define PHASE_AUTHENTICATE 2 /* Being authenticated */
@ -30,9 +27,6 @@
#define PHASE_TERMINATE 4 /* Terminating link */
#define PHASE_OSLINKED 5 /* The OS is linked up */
int phase; /* Curent phase */
extern int phase; /* Curent phase */
extern void NewPhase(int);
extern char *PhaseNames[];
#endif

View File

@ -1,19 +1,29 @@
#include "fsm.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "ccp.h"
/*
*
* $Id: pred.c,v 1.13 1997/06/09 23:38:37 brian Exp $
*
* pred.c -- Test program for Dave Rand's rendition of the
* predictor algorithm
* Updated by: iand@labtam.labtam.oz.au (Ian Donaldson)
* Updated by: Carsten Bormann <cabo@cs.tu-berlin.de>
* Original : Dave Rand <dlr@bungi.com>/<dave_rand@novell.com>
*
* $Id: pred.c,v 1.14 1997/08/25 00:29:25 brian Exp $
*
*/
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "ccp.h"
#include "pred.h"
/* The following hash code is the heart of the algorithm:
* It builds a sliding hash sum of the previous 3-and-a-bit characters
* which will be used to index the guess table.
@ -95,11 +105,11 @@ Pred1Init(int direction)
{
if (direction & 1) { /* Input part */
iHash = 0;
bzero(InputGuessTable, sizeof(InputGuessTable));
memset(InputGuessTable, '\0', sizeof(InputGuessTable));
}
if (direction & 2) { /* Output part */
oHash = 0;
bzero(OutputGuessTable, sizeof(OutputGuessTable));
memset(OutputGuessTable, '\0', sizeof(OutputGuessTable));
}
}
@ -132,7 +142,7 @@ Pred1Output(int pri, u_short proto, struct mbuf * bp)
wp += len;
CcpInfo.compout += len;
} else {
bcopy(bufp + 2, wp, orglen);
memcpy(wp, bufp + 2, orglen);
wp += orglen;
CcpInfo.compout += orglen;
}

View File

@ -15,16 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: pred.h,v 1.4 1997/06/09 03:27:35 brian Exp $
* $Id: pred.h,v 1.5 1997/08/25 00:29:26 brian Exp $
*
* TODO:
*/
#ifndef _PRED_H_
#define _PRED_H_
extern void Pred1Output(int, u_short, struct mbuf * bp);
extern void Pred1Output(int, u_short, struct mbuf *);
extern void Pred1Input(struct mbuf *);
extern void Pred1Init(int);
#endif

View File

@ -17,32 +17,34 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: route.c,v 1.18 1997/08/25 00:29:26 brian Exp $
* $Id: route.c,v 1.19 1997/08/31 22:59:47 brian Exp $
*
*/
#include <sys/types.h>
#include <machine/endian.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <machine/endian.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "route.h"
static int IfIndex;
@ -70,7 +72,7 @@ OsSetRoute(int cmd,
LogPrintf(LogERROR, "OsSetRoute: socket(): %s\n", strerror(errno));
return;
}
bzero(&rtmes, sizeof(rtmes));
memset(&rtmes, '\0', sizeof(rtmes));
rtmes.m_rtm.rtm_version = RTM_VERSION;
rtmes.m_rtm.rtm_type = cmd;
rtmes.m_rtm.rtm_addrs = RTA_DST | RTA_NETMASK | RTA_GATEWAY;
@ -78,18 +80,18 @@ OsSetRoute(int cmd,
rtmes.m_rtm.rtm_pid = getpid();
rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
bzero(&rtdata, sizeof(rtdata));
memset(&rtdata, '\0', sizeof(rtdata));
rtdata.sin_len = 16;
rtdata.sin_family = AF_INET;
rtdata.sin_port = 0;
rtdata.sin_addr = dst;
cp = rtmes.m_space;
bcopy(&rtdata, cp, 16);
memcpy(cp, &rtdata, 16);
cp += 16;
if (gateway.s_addr) {
rtdata.sin_addr = gateway;
bcopy(&rtdata, cp, 16);
memcpy(cp, &rtdata, 16);
cp += 16;
}
if (dst.s_addr == INADDR_ANY)

View File

@ -17,12 +17,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: route.h,v 1.4 1997/06/09 03:27:36 brian Exp $
* $Id: route.h,v 1.5 1997/08/25 00:29:27 brian Exp $
*
*/
#ifndef _ROUTE_H_
#define _ROUTE_H_
int GetIfIndex(char *);
#endif
extern int GetIfIndex(char *);
extern int ShowRoute(void);
extern void OsSetRoute(int, struct in_addr, struct in_addr, struct in_addr);
extern void DeleteIfRoutes(int);

View File

@ -1,23 +1,32 @@
#include <sys/types.h>
#include <sys/stat.h>
/*
* $Id: $
*/
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "server.h"
#include "log.h"
#include "defs.h"
int server = UNKNOWN_SERVER;
int server = -2;
static struct sockaddr_un ifsun;
static char *rm;
@ -131,16 +140,3 @@ ServerClose()
}
server = -1;
}
int
ServerType()
{
if (server == UNKNOWN_SERVER)
return UNKNOWN_SERVER;
else if (server == NO_SERVER)
return NO_SERVER;
else if (rm)
return LOCAL_SERVER;
else
return INET_SERVER;
}

View File

@ -1,12 +1,9 @@
/*
* $Id: $
*/
extern int server;
extern int ServerLocalOpen(const char *name, mode_t mask);
extern int ServerLocalOpen(const char *, mode_t);
extern int ServerTcpOpen(int);
extern void ServerClose(void);
#define UNKNOWN_SERVER (-2)
#define NO_SERVER (-1)
#define LOCAL_SERVER (1)
#define INET_SERVER (2)
extern int ServerType(void);

View File

@ -1,40 +1,12 @@
/*-
* Copyright (c) 1997
* Brian Somers <brian@awfulhak.demon.co.uk>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sig.c,v 1.7 1997/06/09 03:27:36 brian Exp $
*
* TODO:
*
/*
* $Id: $
*/
#include "sig.h"
#include <sys/types.h>
#include <signal.h>
#include "sig.h"
#include "mbuf.h"
#include "log.h"

View File

@ -1,38 +1,8 @@
/*-
* Copyright (c) 1997
* Brian Somers <brian@awfulhak.demon.co.uk>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sig.h,v 1.8 1997/06/09 03:27:37 brian Exp $
*
* TODO:
*
/*
* $Id: $
*/
typedef void (*sig_type) (int);
typedef void (*sig_type)(int);
/* Call this instead of signal() */
extern sig_type pending_signal(int, sig_type);

View File

@ -17,42 +17,49 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: slcompress.c,v 1.11 1997/10/07 00:56:57 brian Exp $
* $Id: slcompress.c,v 1.12 1997/10/12 21:43:55 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
#ifndef lint
static char const rcsid[] = "$Id: slcompress.c,v 1.11 1997/10/07 00:56:57 brian Exp $";
#endif
#include "defs.h"
#include <sys/param.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "slcompress.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
struct slstat slstat;
static struct slstat {
int sls_packets; /* outbound packets */
int sls_compressed; /* outbound compressed packets */
int sls_searches; /* searches for connection state */
int sls_misses; /* times couldn't find conn. state */
int sls_uncompressedin; /* inbound uncompressed packets */
int sls_compressedin; /* inbound compressed packets */
int sls_errorin; /* inbound unknown type packets */
int sls_tossed; /* inbound packets tossed because of error */
} slstat;
#define INCR(counter) slstat.counter++;
#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
#ifndef KERNEL
#define ovbcopy bcopy
#endif
void
sl_compress_init(struct slcompress * comp, int max_state)
{
register u_int i;
register struct cstate *tstate = comp->tstate;
bzero((char *) comp, sizeof(*comp));
memset(comp, '\0', sizeof(*comp));
for (i = max_state; i > 0; --i) {
tstate[i].cs_id = i;
tstate[i].cs_next = &tstate[i - 1];
@ -239,9 +246,9 @@ sl_compress_tcp(struct mbuf * m,
((u_short *) ip)[4] != ((u_short *) & cs->cs_ip)[4] ||
THOFFSET(th) != THOFFSET(oth) ||
(deltaS > 5 &&
BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
memcmp(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
(THOFFSET(th) > 5 &&
BCMP(th + 1, oth + 1, (THOFFSET(th) - 5) << 2))) {
memcmp(th + 1, oth + 1, (THOFFSET(th) - 5) << 2))) {
goto uncompressed;
}
@ -341,7 +348,7 @@ sl_compress_tcp(struct mbuf * m,
* this packet's header.
*/
deltaA = ntohs(th->th_sum);
BCOPY(ip, &cs->cs_ip, hlen);
memcpy(&cs->cs_ip, ip, hlen);
/*
* We want to use the original packet as our compressed packet. (cp -
@ -374,7 +381,7 @@ sl_compress_tcp(struct mbuf * m,
m->offset += hlen;
*cp++ = deltaA >> 8;
*cp++ = deltaA;
BCOPY(new_seq, cp, deltaS);
memcpy(cp, new_seq, deltaS);
INCR(sls_compressed)
return (TYPE_COMPRESSED_TCP);
@ -384,7 +391,7 @@ sl_compress_tcp(struct mbuf * m,
* use on future compressed packets in the protocol field).
*/
uncompressed:
BCOPY(ip, &cs->cs_ip, hlen);
memcpy(&cs->cs_ip, ip, hlen);
ip->ip_p = cs->cs_id;
comp->last_xmit = cs->cs_id;
return (TYPE_UNCOMPRESSED_TCP);
@ -424,7 +431,7 @@ sl_uncompress_tcp(u_char ** bufp,
hlen += THOFFSET(th) << 2;
if (hlen > MAX_HDR)
goto bad;
BCOPY(ip, &cs->cs_ip, hlen);
memcpy(&cs->cs_ip, ip, hlen);
cs->cs_ip.ip_sum = 0;
cs->cs_hlen = hlen;
INCR(sls_uncompressedin)
@ -534,7 +541,7 @@ sl_uncompress_tcp(u_char ** bufp,
#ifdef notdef
if ((int) cp & 3) {
if (len > 0)
(void) ovbcopy(cp, (caddr_t) ((int) cp & ~3), len);
(void) bcopy(cp, (caddr_t) ((int) cp & ~3), len);
cp = (u_char *) ((int) cp & ~3);
}
#endif
@ -542,7 +549,7 @@ sl_uncompress_tcp(u_char ** bufp,
cp -= cs->cs_hlen;
len += cs->cs_hlen;
cs->cs_ip.ip_len = htons(len);
BCOPY(&cs->cs_ip, cp, cs->cs_hlen);
memcpy(cp, &cs->cs_ip, cs->cs_hlen);
*bufp = cp;
/* recompute the ip header checksum */

View File

@ -1,7 +1,7 @@
/*
* Definitions for tcp compression routines.
*
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.7 1997/08/25 00:29:29 brian Exp $
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.8 1997/10/07 00:56:58 brian Exp $
*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved.
@ -18,7 +18,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: slcompress.h,v 1.7 1997/08/25 00:29:29 brian Exp $
* $Id: slcompress.h,v 1.8 1997/10/07 00:56:58 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
@ -105,7 +105,7 @@ struct cstate {
union {
char csu_hdr[MAX_HDR];
struct ip csu_ip; /* ip/tcp hdr from most recent packet */
} slcs_u;
} slcs_u;
};
#define cs_ip slcs_u.csu_ip
@ -124,22 +124,11 @@ struct slcompress {
struct cstate rstate[MAX_STATES]; /* receive connection states */
};
struct slstat {
int sls_packets; /* outbound packets */
int sls_compressed; /* outbound compressed packets */
int sls_searches; /* searches for connection state */
int sls_misses; /* times couldn't find conn. state */
int sls_uncompressedin; /* inbound uncompressed packets */
int sls_compressedin; /* inbound compressed packets */
int sls_errorin; /* inbound unknown type packets */
int sls_tossed; /* inbound packets tossed because of error */
};
/* flag values */
#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
extern void sl_compress_init(struct slcompress *, int max_state);
extern u_char sl_compress_tcp
__P((struct mbuf *, struct ip *,
struct slcompress *, int compress_cid_flag));
extern int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *);
extern void sl_compress_init(struct slcompress *, int);
extern u_char sl_compress_tcp
(struct mbuf *, struct ip *, struct slcompress *, int);
extern int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *);
extern int ReportCompress(void);

View File

@ -17,23 +17,35 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: systems.c,v 1.15 1997/08/31 22:59:49 brian Exp $
* $Id: systems.c,v 1.16 1997/09/04 00:38:21 brian Exp $
*
* TODO:
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "loadalias.h"
#include "vars.h"
#include "command.h"
#include "ipcp.h"
#include "pathnames.h"
#include "vars.h"
#include "server.h"
#include "command.h"
#include "systems.h"
extern void DecodeCommand();
static int uid, gid;
static int euid, egid;
static int uid;
static int gid;
static int euid;
static int egid;
static int usermode;
int
@ -220,7 +232,7 @@ LoadCommand(struct cmdtab const * list, int argc, char **argv)
}
int
SaveCommand(struct cmdtab const * list, int argc, char **argv)
SaveCommand(struct cmdtab const *list, int argc, char **argv)
{
LogPrintf(LogWARN, "save command is not implemented (yet).\n");
return 1;

View File

@ -17,14 +17,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: systems.h,v 1.5 1997/06/09 03:27:38 brian Exp $
* $Id: systems.h,v 1.6 1997/08/25 00:29:29 brian Exp $
*
*/
#ifndef _SYSTEMS_H_
#define _SYSTEMS_H_
extern int OrigUid(void);
extern void GetUid(void);
extern int SelectSystem(char *, char *);
#endif
extern FILE *OpenSecret(char *);
extern void CloseSecret(FILE *);
extern int LoadCommand(struct cmdtab const *, int, char **);
extern int SaveCommand(struct cmdtab const *, int, char **);

View File

@ -17,20 +17,28 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: timer.c,v 1.20 1997/10/23 21:32:48 ache Exp $
* $Id: timer.c,v 1.21 1997/10/24 22:36:31 brian Exp $
*
* TODO:
*/
#include "defs.h"
#include <sys/time.h>
#include <signal.h>
#include "timeout.h"
#ifdef SIGALRM
#include <errno.h>
#endif
#include "sig.h"
#include <sys/time.h>
#include <unistd.h>
void StopTimerNoBlock(struct pppTimer *);
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "sig.h"
#include "timer.h"
struct pppTimer *TimerList = NULL;
static void StopTimerNoBlock(struct pppTimer *);
static void InitTimerService(void);
void
StopTimer(struct pppTimer * tp)
@ -96,7 +104,7 @@ StartTimer(struct pppTimer * tp)
#endif
}
void
static void
StopTimerNoBlock(struct pppTimer * tp)
{
struct pppTimer *t, *pt;
@ -259,8 +267,8 @@ nointr_usleep(u_int usec)
}
}
void
InitTimerService(void)
static void
InitTimerService()
{
struct itimerval itimer;

View File

@ -15,14 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: timeout.h,v 1.11 1997/08/25 00:29:30 brian Exp $
* $Id: timeout.h,v 1.12 1997/09/03 00:40:51 brian Exp $
*
* TODO:
*/
#ifndef _TIMEOUT_H_
#define _TIMEOUT_H_
#define TICKUNIT 100000 /* Unit in usec */
#define SECTICKS (1000000/TICKUNIT)
@ -30,7 +27,7 @@ struct pppTimer {
int state;
u_long rest; /* Ticks to expire */
u_long load; /* Initial load value */
void (*func) (); /* Function called when timer is expired */
void (*func)(); /* Function called when timer is expired */
void *arg; /* Argument passed to timeout function */
struct pppTimer *next; /* Link to next timer */
struct pppTimer *enext; /* Link to next expired timer */
@ -40,16 +37,13 @@ struct pppTimer {
#define TIMER_RUNNING 1
#define TIMER_EXPIRED 2
struct pppTimer *TimerList;
extern struct pppTimer *TimerList;
extern void StartTimer(struct pppTimer *);
extern void StopTimer(struct pppTimer *);
extern void TimerService(void);
extern void InitTimerService(void);
extern void TermTimerService(void);
extern void StartIdleTimer(void);
extern void StopIdleTimer(void);
extern void UpdateIdleTimer(void);
extern void ShowTimers();
#endif /* _TIMEOUT_H_ */
extern void ShowTimers(void);

View File

@ -17,9 +17,19 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.c,v 1.29 1997/09/21 13:08:00 brian Exp $
* $Id: vars.c,v 1.30 1997/09/22 23:59:16 brian Exp $
*
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "command.h"
#include "hdlc.h"
@ -30,7 +40,15 @@
#include "defs.h"
char VarVersion[] = "PPP Version 1.2";
char VarLocalVersion[] = "$Date: 1997/09/21 13:08:00 $";
char VarLocalVersion[] = "$Date: 1997/09/22 23:59:16 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
int ipKeepAlive = 0;
int ipConnectSecs = 0;
int ipIdleSecs = 0;
int reconnectState = RECON_UNKNOWN;
int reconnectCount = 0;
/*
* Order of conf option is important. See vars.h.

View File

@ -15,16 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.h,v 1.29 1997/09/25 00:52:37 brian Exp $
* $Id: vars.h,v 1.30 1997/09/26 00:23:36 brian Exp $
*
* TODO:
*/
#ifndef _VARS_H_
#define _VARS_H_
#include <sys/param.h>
struct confdesc {
char *name;
int myside, hisside;
@ -97,39 +92,39 @@ struct pppvars {
struct aliasHandlers handler; /* Alias function pointers */
};
#define VarAccmap pppVars.var_accmap
#define VarMRU pppVars.var_mru
#define VarPrefMTU pppVars.pref_mtu
#define VarDevice pppVars.modem_dev
#define VarBaseDevice pppVars.base_modem_dev
#define VarSpeed pppVars.modem_speed
#define VarParity pppVars.modem_parity
#define VarCtsRts pppVars.modem_ctsrts
#define VarOpenMode pppVars.open_mode
#define VarLocalAuth pppVars.lauth
#define VarDialScript pppVars.dial_script
#define VarHangupScript pppVars.hangup_script
#define VarLoginScript pppVars.login_script
#define VarIdleTimeout pppVars.idle_timeout
#define VarLqrTimeout pppVars.lqr_timeout
#define VarRetryTimeout pppVars.retry_timeout
#define VarAuthKey pppVars.auth_key
#define VarAuthName pppVars.auth_name
#define VarAccmap pppVars.var_accmap
#define VarMRU pppVars.var_mru
#define VarPrefMTU pppVars.pref_mtu
#define VarDevice pppVars.modem_dev
#define VarBaseDevice pppVars.base_modem_dev
#define VarSpeed pppVars.modem_speed
#define VarParity pppVars.modem_parity
#define VarCtsRts pppVars.modem_ctsrts
#define VarOpenMode pppVars.open_mode
#define VarLocalAuth pppVars.lauth
#define VarDialScript pppVars.dial_script
#define VarHangupScript pppVars.hangup_script
#define VarLoginScript pppVars.login_script
#define VarIdleTimeout pppVars.idle_timeout
#define VarLqrTimeout pppVars.lqr_timeout
#define VarRetryTimeout pppVars.retry_timeout
#define VarAuthKey pppVars.auth_key
#define VarAuthName pppVars.auth_name
#ifdef HAVE_DES
#define VarMSChap pppVars.use_MSChap
#define VarMSChap pppVars.use_MSChap
#endif
#define VarPhoneList pppVars.phone_numbers
#define VarPhoneCopy pppVars.phone_copy
#define VarNextPhone pppVars.next_phone
#define VarAltPhone pppVars.alt_phone
#define VarShortHost pppVars.shostname
#define VarReconnectTimer pppVars.reconnect_timer
#define VarReconnectTries pppVars.reconnect_tries
#define VarRedialTimeout pppVars.redial_timeout
#define VarRedialNextTimeout pppVars.redial_next_timeout
#define VarDialTries pppVars.dial_tries
#define VarLoopback pppVars.loopback
#define VarTerm pppVars.termfp
#define VarPhoneList pppVars.phone_numbers
#define VarPhoneCopy pppVars.phone_copy
#define VarNextPhone pppVars.next_phone
#define VarAltPhone pppVars.alt_phone
#define VarShortHost pppVars.shostname
#define VarReconnectTimer pppVars.reconnect_timer
#define VarReconnectTries pppVars.reconnect_tries
#define VarRedialTimeout pppVars.redial_timeout
#define VarRedialNextTimeout pppVars.redial_next_timeout
#define VarDialTries pppVars.dial_tries
#define VarLoopback pppVars.loopback
#define VarTerm pppVars.termfp
#define VarAliasHandlers pppVars.handler
#define VarPacketAliasGetFragment (*pppVars.handler.PacketAliasGetFragment)
@ -144,13 +139,20 @@ struct pppvars {
#define VarPacketAliasSetMode (*pppVars.handler.PacketAliasSetMode)
#define VarPacketAliasFragmentIn (*pppVars.handler.PacketAliasFragmentIn)
#define DEV_IS_SYNC (VarSpeed == 0)
#define DEV_IS_SYNC (VarSpeed == 0)
extern struct pppvars pppVars;
extern char VarVersion[];
extern char VarLocalVersion[];
int Utmp; /* Are we in /etc/utmp ? */
int ipInOctets, ipOutOctets, ipKeepAlive;
int ipConnectSecs, ipIdleSecs;
extern int Utmp; /* Are we in /etc/utmp ? */
extern int ipInOctets;
extern int ipOutOctets;
extern int ipKeepAlive;
extern int ipConnectSecs;
extern int ipIdleSecs;
extern int reconnectState;
extern int reconnectCount;
#define RECON_TRUE (1)
#define RECON_FALSE (2)
@ -165,7 +167,6 @@ int ipConnectSecs, ipIdleSecs;
} \
while(0)
int reconnectState, reconnectCount;
/*
* This is the logic behind the reconnect variables:
@ -190,4 +191,9 @@ int reconnectState, reconnectCount;
*
*/
#endif
extern int EnableCommand(struct cmdtab *, int, char **);
extern int DisableCommand(struct cmdtab *, int, char **);
extern int AcceptCommand(struct cmdtab *, int, char **);
extern int DenyCommand(struct cmdtab *, int, char **);
extern int LocalAuthCommand(struct cmdtab *, int, char **);
extern int DisplayCommand(void);

View File

@ -17,17 +17,27 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vjcomp.c,v 1.9 1997/08/25 00:29:32 brian Exp $
* $Id: vjcomp.c,v 1.10 1997/10/07 00:56:58 brian Exp $
*
* TODO:
*/
#include "fsm.h"
#include "lcpproto.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <string.h>
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lcpproto.h"
#include "slcompress.h"
#include "hdlc.h"
#include "ipcp.h"
#include "vjcomp.h"
#define MAX_VJHEADER 16 /* Maximum size of compressed header */
@ -114,7 +124,7 @@ VjUncompressTcp(struct mbuf * bp, u_char type)
len -= olen;
len += rlen;
nbp = mballoc(len, MB_VJCOMP);
bcopy(bufp, MBUF_CTOP(nbp), len);
memcpy(MBUF_CTOP(nbp), bufp, len);
nbp->next = bp;
return (nbp);
}

6
usr.sbin/ppp/vjcomp.h Normal file
View File

@ -0,0 +1,6 @@
/*
* $Id: $
*/
extern void VjInit(int);
extern void SendPppFrame(struct mbuf *);