New user Process PPP based on iij-ppp0.94beta2.

o Supporting SYNC SIO device (But need a device driver)
     - add "set speed sync"
   o Fixing bug for Predictor-1 function.
   o Add new parameter that re-sent interval for set timeout commands.
   o Improving RTT (Round Trip Time) and reducing processor time.
     - Previous Timer service was using polling, and now using
       SIGALRM ;-)
     - A 0.94beta2 will not work correctly....

   -- Follows are additinal feature not including 0.94beta2
   o Support Proxy ARP
     - add "enable/disable proxy" commands
   o Marging common routine in CHAP/PAP.
   o Enhancing LCP/IPCP log information.
   o Support local Authfication connection on port 300x and tty.
     - You can set up pair of your "hostname -s" and
       password in ppp.secret. if either ppp.secret file nor
       your hostname line don't exist, It will notify a message
       and working as same as previous version.(Backword compatibility)
     - If you did set up them, It's allow connection but nothing to do
       except help and passwd command.
     - add "passwd yourpasswd" commands
   o Support afilter - keep Alive filter that a packet can send/receiving
     according to ifilter/ofilter but doesn't count it as preventing idle
     timer expires.
     - Same syntax of other filters.
   o Fixing bugs reported by current user for previous one. Thanks !!

Reviewed by: Atsushi Murai (amurai@spec.co.jp)
This commit is contained in:
Atsushi Murai 1995-02-26 12:18:08 +00:00
parent 550f8550ec
commit 53c9f6c0c4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6735
56 changed files with 2191 additions and 941 deletions

View File

@ -1,10 +1,19 @@
#
# $Id:$
# $Id: ppp.conf.filter.sample,v 1.1.1.1 1995/01/31 06:24:33 amurai Exp $
#
# An example of packet filter definition.
#
#
filterd:
#
# Don't keep Alive with ICMP,DNS and RIP packet
#
set afilter 0 deny icmp
set afilter 1 deny udp src eq 53
set afilter 2 deny udp dst eq 53
set afilter 3 deny udp src eq 520
set afilter 4 deny udp dst eq 520
set afilter 5 permit 0/0 0/0
#
# Don't dial with ICMP packet
#

View File

@ -4,7 +4,7 @@
#
# Written by Toshiharu OHNO
#
# $Id:$
# $Id: ppp.conf.sample,v 1.1.1.1 1995/01/31 06:24:33 amurai Exp $
#
#################################################################
#
@ -99,6 +99,7 @@ pmdemend:
users:
disable pap
enable chap
enable proxy
set authname ppp-server
set ifaddr 192.244.176.44 292.244.184.31
#

View File

@ -1,8 +1,9 @@
##################################################
# Sysname Secret Key Peer's IP address
#
# $Id:$
# $Id: ppp.secret.sample,v 1.1.1.1 1995/01/31 06:24:33 amurai Exp $
#
##################################################
oscar OurSecretKey 192.244.184.34/24
BigBird X4dWg9327 192.244.184.33/32
tama localPasswdForControl

View File

@ -1,3 +1,5 @@
/* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
* Nottingham University 1987.
@ -10,25 +12,26 @@
* roots in a similar driver written by Phil Cockcroft (formerly) at
* UCL. This driver is based much more on read/write/select mode of
* operation though.
*
* $Id: if_tun.c,v 1.9 1993/12/24 03:20:59 deraadt Exp $
*/
#include "tun.h"
#if NTUN > 0
#include "param.h"
#include "kernel.h" /* sigh */
#include "proc.h"
#include "systm.h"
#include "mbuf.h"
#include "buf.h"
#include "protosw.h"
#include "socket.h"
#include "ioctl.h"
#include "errno.h"
#include "syslog.h"
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/buf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/select.h>
#include <sys/file.h>
#ifdef __FreeBSD__
#include <sys/kernel.h>
#endif
#include <machine/cpu.h>
@ -57,11 +60,6 @@
#include <net/if_tun.h>
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define TUNDEBUG if (tundebug) printf
int tundebug = 0;
@ -69,15 +67,21 @@ struct tun_softc tunctl[NTUN];
extern int ifqmaxlen;
int tunopen __P((dev_t, int, int, struct proc *));
int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *rt));
int tunselect __P((dev_t, int, struct proc *));
int tunclose __P((dev_t, int));
int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *rt));
int tunread __P((dev_t, struct uio *));
int tunwrite __P((dev_t, struct uio *));
int tunioctl __P((dev_t, int, caddr_t, int, struct proc *));
int tunifioctl __P((struct ifnet *, int, caddr_t));
int tunioctl __P((dev_t, int, caddr_t, int));
int tunselect __P((dev_t, int));
void tunattach __P((int));
static int tuninit __P((int));
void
tunattach(void)
tunattach(unused)
int unused;
{
register int i;
struct ifnet *ifp;
@ -106,7 +110,9 @@ tunattach(void)
}
}
TEXT_SET(pseudo_set, tunattach);
#ifdef __FreeBSD__
PSEUDO_SET(tunattach);
#endif
/*
* tunnel open - must be superuser & the device must be
@ -122,7 +128,6 @@ tunopen(dev, flag, mode, p)
struct tun_softc *tp;
register int unit, error;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
@ -133,7 +138,6 @@ tunopen(dev, flag, mode, p)
return ENXIO;
ifp = &tp->tun_if;
tp->tun_flags |= TUN_OPEN;
TUNDEBUG("%s%d: open\n", ifp->if_name, ifp->if_unit);
return (0);
}
@ -151,9 +155,7 @@ tunclose(dev, flag)
struct tun_softc *tp = &tunctl[unit];
struct ifnet *ifp = &tp->tun_if;
struct mbuf *m;
int rcoll;
rcoll = tp->tun_flags & TUN_RCOLL;
tp->tun_flags &= ~TUN_OPEN;
/*
@ -170,24 +172,21 @@ tunclose(dev, flag)
if (ifp->if_flags & IFF_UP) {
s = splimp();
if_down(ifp);
#ifdef notdef
if (ifp->if_flags & IFF_RUNNING) {
rtinit(ifp->if_addrlist, (int)RTM_DELETE,
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
/* find internet addresses and delete routes */
register struct ifaddr *ifa;
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family == AF_INET) {
rtinit(ifa, (int)RTM_DELETE,
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
}
}
}
#endif
splx(s);
}
tp->tun_pgrp = 0;
#if BSD >= 199103
selwakeup(&tp->tun_sel);
/* XXX */
tp->tun_sel.si_pid = 0;
#else
if (tp->tun_rsel)
selwakeup(tp->tun_rsel->p_pid, rcoll);
tp -> tun_rsel = tp -> tun_wsel = (struct proc *)0;
#endif
selwakeup(&tp->tun_rsel);
TUNDEBUG ("%s%d: closed\n", ifp->if_name, ifp->if_unit);
return (0);
}
@ -204,17 +203,18 @@ tuninit(unit)
ifp->if_flags |= IFF_UP | IFF_RUNNING;
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
struct sockaddr_in *si;
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *si;
si = (struct sockaddr_in *)ifa->ifa_addr;
if (si && si->sin_addr.s_addr)
tp->tun_flags |= TUN_IASET;
si = (struct sockaddr_in *)ifa->ifa_addr;
if (si && si->sin_addr.s_addr)
tp->tun_flags |= TUN_IASET;
si = (struct sockaddr_in *)ifa->ifa_dstaddr;
if (si && si->sin_addr.s_addr)
tp->tun_flags |= TUN_DSTADDR;
}
si = (struct sockaddr_in *)ifa->ifa_dstaddr;
if (si && si->sin_addr.s_addr)
tp->tun_flags |= TUN_DSTADDR;
}
return 0;
}
@ -235,11 +235,13 @@ tunifioctl(ifp, cmd, data)
switch(cmd) {
case SIOCSIFADDR:
tuninit(ifp->if_unit);
TUNDEBUG("%s%d: address set\n",
ifp->if_name, ifp->if_unit);
break;
case SIOCSIFDSTADDR:
tp->tun_flags |= TUN_DSTADDR;
TUNDEBUG("%s%d: destination address set\n", ifp->if_name,
ifp->if_unit);
tuninit(ifp->if_unit);
TUNDEBUG("%s%d: destination address set\n",
ifp->if_name, ifp->if_unit);
break;
default:
error = EINVAL;
@ -322,17 +324,7 @@ tunoutput(ifp, m0, dst, rt)
else if (p = pfind(-tp->tun_pgrp))
psignal(p, SIGIO);
}
#if BSD >= 199103
selwakeup(&tp->tun_sel);
/* XXX */
tp->tun_sel.si_pid = 0;
#else
if (tp->tun_rsel) {
selwakeup(tp->tun_rsel->p_pid, tp->tun_flags & TUN_RCOLL);
tp->tun_flags &= ~TUN_RCOLL;
tp->tun_rsel = (struct proc *)0;
}
#endif
selwakeup(&tp->tun_rsel);
return 0;
}
@ -340,29 +332,30 @@ tunoutput(ifp, m0, dst, rt)
* the cdevsw interface is now pretty minimal.
*/
int
tunioctl(dev, cmd, data, flag)
tunioctl(dev, cmd, data, flag, p)
dev_t dev;
int cmd;
caddr_t data;
int flag;
struct proc *p;
{
int unit = minor(dev), s;
struct tun_softc *tp = &tunctl[unit];
struct tuninfo *tunp;
struct tuninfo *tunp;
switch (cmd) {
case TUNSIFINFO:
tunp = (struct tuninfo *)data;
tp->tun_if.if_mtu = tunp->tif_mtu;
tp->tun_if.if_type = tunp->tif_type;
tp->tun_if.if_baudrate = tunp->tif_baudrate;
break;
case TUNGIFINFO:
tunp = (struct tuninfo *)data;
tunp->tif_mtu = tp->tun_if.if_mtu;
tunp->tif_type = tp->tun_if.if_type;
tunp->tif_baudrate = tp->tun_if.if_baudrate;
break;
case TUNSIFINFO:
tunp = (struct tuninfo *)data;
tp->tun_if.if_mtu = tunp->mtu;
tp->tun_if.if_type = tunp->type;
tp->tun_if.if_baudrate = tunp->baudrate;
break;
case TUNGIFINFO:
tunp = (struct tuninfo *)data;
tunp->mtu = tp->tun_if.if_mtu;
tunp->type = tp->tun_if.if_type;
tunp->baudrate = tp->tun_if.if_baudrate;
break;
case TUNSDEBUG:
tundebug = *(int *)data;
break;
@ -440,7 +433,7 @@ tunread(dev, uio)
splx(s);
while (m0 && uio->uio_resid > 0 && error == 0) {
len = MIN(uio->uio_resid, m0->m_len);
len = min(uio->uio_resid, m0->m_len);
if (len == 0)
break;
error = uiomove(mtod(m0, caddr_t), len, uio);
@ -486,7 +479,7 @@ tunwrite(dev, uio)
top = 0;
mp = &top;
while (error == 0 && uio->uio_resid > 0) {
m->m_len = MIN (mlen, uio->uio_resid);
m->m_len = min(mlen, uio->uio_resid);
error = uiomove(mtod (m, caddr_t), m->m_len, uio);
*mp = m;
mp = &m->m_next;
@ -543,32 +536,15 @@ tunwrite(dev, uio)
return error;
}
/*
* The new select interface passes down the proc pointer; the old select
* stubs had to grab it out of the user struct. This glue allows either case.
*/
#if BSD >= 199103
#define tun_select tunselect
#else
int
tunselect(dev, rw)
register dev_t dev;
int rw;
{
return (tun_select(dev, rw, u.u_procp));
}
#endif
/*
* tunselect - the select interface, this is only useful on reads
* really. The write detect always returns true, write never blocks
* anyway, it either accepts the packet or drops it.
*/
int
tun_select(dev, rw, p)
tunselect(dev, rw)
dev_t dev;
int rw;
struct proc *p;
{
int unit = minor(dev), s;
struct tun_softc *tp = &tunctl[unit];
@ -576,19 +552,7 @@ tun_select(dev, rw, p)
s = splimp();
TUNDEBUG("%s%d: tunselect\n", ifp->if_name, ifp->if_unit);
#if BSD >= 199103
if (rw != FREAD) {
splx(s);
return 1;
}
if (ifp->if_snd.ifq_len > 0) {
splx(s);
TUNDEBUG("%s%d: tunselect q=%d\n", ifp->if_name,
ifp->if_unit, ifp->if_snd.ifq_len);
return 1;
}
selrecord(p, &tp->tun_sel);
#else
switch (rw) {
case FREAD:
if (ifp->if_snd.ifq_len > 0) {
@ -597,16 +561,12 @@ tun_select(dev, rw, p)
ifp->if_unit, ifp->if_snd.ifq_len);
return 1;
}
if (tp->tun_rsel && tp->tun_rsel == p)
tp->tun_flags |= TUN_RCOLL;
else
tp->tun_rsel = p;
selrecord(curproc, &tp->tun_rsel);
break;
case FWRITE:
splx(s);
return 1;
}
#endif
splx(s);
TUNDEBUG("%s%d: tunselect waiting\n", ifp->if_name, ifp->if_unit);
return 0;

View File

@ -1,3 +1,5 @@
/* $NetBSD: if_tun.h,v 1.5 1994/06/29 06:36:27 cgd Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
* Nottingham University 1987.
@ -11,8 +13,7 @@
* UCL. This driver is based much more on read/write/select mode of
* operation though.
*
* from: $Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp
* $Id: if_tun.h,v 1.3 1993/12/13 14:27:01 deraadt Exp $
* : $Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp
*/
#ifndef _NET_IF_TUN_H_
@ -25,23 +26,16 @@ struct tun_softc {
#define TUN_RCOLL 0x0004
#define TUN_IASET 0x0008
#define TUN_DSTADDR 0x0010
#ifdef notdef
#define TUN_READY 0x0020
#else
#define TUN_READY (TUN_IASET|TUN_OPEN|TUN_DSTADDR)
#endif
#define TUN_RWAIT 0x0040
#define TUN_ASYNC 0x0080
#define TUN_NBIO 0x0100
#define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET)
struct ifnet tun_if; /* the interface */
int tun_pgrp; /* the process group - if any */
#if BSD < 199103
struct proc *tun_rsel;
struct proc *tun_wsel;
#else
u_char tun_pad; /* explicit alignment */
struct selinfo tun_sel; /* bsd select info */
#endif
struct selinfo tun_rsel; /* read select */
struct selinfo tun_wsel; /* write select (not used) */
#if NBPFILTER > 0
caddr_t tun_bpf;
#endif
@ -50,23 +44,17 @@ struct tun_softc {
/* Maximum packet size */
#define TUNMTU 1500
struct tuninfo {
int baudrate; /* linespeed */
short mtu; /* maximum transmission unit */
u_char type; /* ethernet, tokenring, etc. */
u_char dummy; /* place holder */
};
/* ioctl's for get/set debug */
#ifdef __NetBSD__
#define TUNSDEBUG _IOW('t', 90, int)
#define TUNGDEBUG _IOR('t', 89, int)
#define TUNSIFINFO _IOW('t', 91, struct tuninfo)
#define TUNGIFINFO _IOR('t', 92, struct tuninfo)
#else /* Assume BSDI */
#define TUNSDEBUG _IOW('T', 90, int)
#define TUNGDEBUG _IOR('T', 89, int)
#define TUNSIFINFO _IOW('T', 91, struct tuninfo)
#define TUNGIFINFO _IOR('T', 92, struct tuninfo)
#endif
struct tuninfo {
int tif_baudrate; /* linespeed */
short tif_mtu; /* maximum transmission unit */
u_char tif_type; /* ethernet, tokenring, etc. */
u_char tif_dummy; /* place holder */
};
#endif /* !_NET_IF_TUN_H_ */

View File

@ -1,10 +1,10 @@
# $Id:$
# $Id: Makefile,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
PROG= ppp
SRCS= async.c auth.c ccp.c chap.c chat.c command.c filter.c fsm.c hdlc.c \
ip.c ipcp.c lcp.c lqr.c log.c main.c mbuf.c md5c.c modem.c os.c \
pap.c pred.c route.c slcompress.c timer.c systems.c uucplock.c vars.c \
vjcomp.c
vjcomp.c arp.c
MAN8= ppp.8
BINMODE=4555
BINOWN= root

423
usr.sbin/ppp/arp.c Normal file
View File

@ -0,0 +1,423 @@
/*
* sys-bsd.c - System-dependent procedures for setting up
* PPP interfaces on bsd-4.4-ish systems (including 386BSD, NetBSD, etc.)
*
* Copyright (c) 1989 Carnegie Mellon University.
* All rights reserved.
*
* 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 Carnegie Mellon University. The name of the
* University 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:
*/
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <net/if.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>
#include <netinet/if_ether.h>
#include "log.h"
#if RTM_VERSION >= 3
#include <netinet/if_ether.h>
#endif
static int rtm_seq;
#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)); \
addr.sa_family = (family); \
addr.sa_len = sizeof(addr);
#if RTM_VERSION >= 3
/*
* sifproxyarp - Make a proxy ARP entry for the peer.
*/
static struct {
struct rt_msghdr hdr;
struct sockaddr_inarp dst;
struct sockaddr_dl hwa;
char extra[128];
} arpmsg;
static int arpmsg_valid;
int
sifproxyarp(unit, hisaddr)
int unit;
u_long hisaddr;
{
int routes;
int l;
/*
* Get the hardware address of an interface on the same subnet
* as our local address.
*/
memset(&arpmsg, 0, sizeof(arpmsg));
if (!get_ether_addr(unit, hisaddr, &arpmsg.hwa)) {
logprintf("Cannot determine ethernet address for proxy ARP\n");
return 0;
}
if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
logprintf("sifproxyarp: opening routing socket: \n");
return 0;
}
arpmsg.hdr.rtm_type = RTM_ADD;
arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC;
arpmsg.hdr.rtm_version = RTM_VERSION;
arpmsg.hdr.rtm_seq = ++rtm_seq;
arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY;
arpmsg.hdr.rtm_inits = RTV_EXPIRE;
arpmsg.dst.sin_len = sizeof(struct sockaddr_inarp);
arpmsg.dst.sin_family = AF_INET;
arpmsg.dst.sin_addr.s_addr = hisaddr;
arpmsg.dst.sin_other = SIN_PROXY;
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
+ arpmsg.hwa.sdl_len;
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
logprintf("add proxy arp entry: \n");
close(routes);
return 0;
}
close(routes);
arpmsg_valid = 1;
return 1;
}
/*
* cifproxyarp - Delete the proxy ARP entry for the peer.
*/
int
cifproxyarp(unit, hisaddr)
int unit;
u_long hisaddr;
{
int routes;
if (!arpmsg_valid)
return 0;
arpmsg_valid = 0;
arpmsg.hdr.rtm_type = RTM_DELETE;
arpmsg.hdr.rtm_seq = ++rtm_seq;
if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
logprintf("sifproxyarp: opening routing socket: \n");
return 0;
}
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
logprintf("delete proxy arp entry: \n");
close(routes);
return 0;
}
close(routes);
return 1;
}
#else /* RTM_VERSION */
/*
* sifproxyarp - Make a proxy ARP entry for the peer.
*/
int
sifproxyarp(unit, hisaddr)
int unit;
u_long hisaddr;
{
struct arpreq arpreq;
struct {
struct sockaddr_dl sdl;
char space[128];
} dls;
BZERO(&arpreq, sizeof(arpreq));
/*
* Get the hardware address of an interface on the same subnet
* as our local address.
*/
if (!get_ether_addr(unit, hisaddr, &dls.sdl)) {
LogPrintf(LOG_PHASE, "Cannot determine ethernet address for proxy ARP\n");
return 0;
}
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);
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;
if (ioctl(unit, SIOCSARP, (caddr_t)&arpreq) < 0) {
fprintf(stderr, "ioctl(SIOCSARP): \n");
return 0;
}
return 1;
}
/*
* cifproxyarp - Delete the proxy ARP entry for the peer.
*/
int
cifproxyarp(unit, hisaddr)
int unit;
u_long hisaddr;
{
struct arpreq arpreq;
BZERO(&arpreq, 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) {
fprintf(stderr, "ioctl(SIOCDARP): \n");
return 0;
}
return 1;
}
#endif /* RTM_VERSION */
/*
* get_ether_addr - get the hardware address of an interface on the
* the same subnet as ipaddr.
*/
#define MAX_IFS 32
int
get_ether_addr(s, ipaddr, hwaddr)
int s;
u_long ipaddr;
struct sockaddr_dl *hwaddr;
{
struct ifreq *ifr, *ifend, *ifp;
u_long ina, mask;
struct sockaddr_dl *dla;
struct ifreq ifreq;
struct ifconf ifc;
struct ifreq ifs[MAX_IFS];
struct ifreq ifx;
ifc.ifc_len = sizeof(ifs);
ifc.ifc_req = ifs;
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
fprintf(stderr, "ioctl(SIOCGIFCONF): \n");
return 0;
}
/*
* Scan through looking for an interface with an Internet
* address on the same subnet as `ipaddr'.
*/
ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
for (ifr = ifc.ifc_req; ifr < ifend; ) {
if (ifr->ifr_addr.sa_family == AF_INET) {
ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
/*
* Check that the interface is up, and not point-to-point
* or loopback.
*/
if (ioctl(s, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
(IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP))
!= (IFF_UP|IFF_BROADCAST))
goto nextif;
/*
* Get its netmask and check that it's on the right subnet.
*/
if (ioctl(s, SIOCGIFNETMASK, &ifreq) < 0)
continue;
mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
if ((ipaddr & mask) != (ina & mask))
goto nextif;
break;
}
nextif:
ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
}
if (ifr >= ifend)
return 0;
LogPrintf(LOG_PHASE, "found interface %s for proxy arp\n", ifr->ifr_name);
/*
* Now scan through again looking for a link-level address
* for this interface.
*/
ifp = ifr;
for (ifr = ifc.ifc_req; ifr < ifend; ) {
if (strcmp(ifp->ifr_name, ifr->ifr_name) == 0
&& ifr->ifr_addr.sa_family == AF_LINK) {
/*
* 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);
return 1;
}
ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
}
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(addr, buf, size)
u_long addr;
char *buf;
int size;
{
if (kvm_read(kvmd, addr, buf, size) != size) {
/* XXX this duplicates kvm_read's error printout */
(void)fprintf(stderr, "kvm_read %s\n",
kvm_geterr(kvmd));
return (-1);
}
return (0);
}
kmemgetether(ifname, dlo)
char *ifname;
struct sockaddr_dl *dlo;
{
struct ifnet ifnet;
int n;
u_long addr, ifaddraddr, ifnetfound, ifaddrfound;
char name[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
main()
{
u_long ipaddr;
int s;
s = socket(AF_INET, SOCK_DGRAM, 0);
ipaddr = inet_addr("192.168.1.32");
sifproxyarp(s, ipaddr);
close(s);
}
#endif

View File

@ -18,20 +18,20 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
*/
#include "fsm.h"
#include "hdlc.h"
#include "lcp.h"
#include "lcpproto.h"
#include "modem.h"
#include "vars.h"
#define HDLCSIZE (MAX_MRU*2+6)
struct async_state {
int mode;
int length;
struct mbuf *hpacket;
u_char hbuff[HDLCSIZE]; /* recv buffer */
u_char xbuff[HDLCSIZE]; /* xmit buffer */
u_long my_accmap;
@ -47,6 +47,7 @@ AsyncInit()
struct async_state *stp = &AsyncState;
stp->mode = MODE_HUNT;
stp->length = 0;
stp->my_accmap = stp->his_accmap = 0xffffffff;
}
@ -176,10 +177,17 @@ int cnt;
struct mbuf *bp;
OsAddInOctets(cnt);
while (cnt > 0) {
bp = AsyncDecode(*buff++);
if (bp)
HdlcInput(bp);
cnt--;
if (DEV_IS_SYNC) {
bp = mballoc(cnt, MB_ASYNC);
bcopy(buff, MBUF_CTOP(bp), cnt);
bp->cnt = cnt;
HdlcInput(bp);
} else {
while (cnt > 0) {
bp = AsyncDecode(*buff++);
if (bp)
HdlcInput(bp);
cnt--;
}
}
}

View File

@ -16,18 +16,69 @@
* 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:
* o Imprement check against with registerd IP addresses.
*/
#include "fsm.h"
#include "lcpproto.h"
#include "ipcp.h"
#include "vars.h"
#include "auth.h"
extern FILE *OpenSecret();
extern void CloseSecret();
LOCAL_AUTH_VALID
LocalAuthInit(void){
char *p;
if ( gethostname( VarShortHost, sizeof(VarShortHost))) {
return(1);
}
if ( p = strchr( VarShortHost, '.' ) )
*p = '\0';
return LocalAuthValidate( SECRETFILE, VarShortHost, "" );
}
LOCAL_AUTH_VALID
LocalAuthValidate( char *fname, char *system, char *key) {
FILE *fp;
int n;
char *vector[20]; /* XXX */
char buff[200]; /* XXX */
LOCAL_AUTH_VALID rc;
rc = NOT_FOUND; /* No system entry */
fp = OpenSecret(fname);
if (fp == NULL)
return( rc );
while (fgets(buff, sizeof(buff), fp)) {
if (buff[0] == '#')
continue;
buff[strlen(buff)-1] = 0;
bzero(vector, sizeof(vector));
n = MakeArgs(buff, &vector);
if (n < 1)
continue;
if (strcmp(vector[0], system) == 0) {
if ( vector[1] != (char *) NULL && strcmp(vector[1], key) == 0) {
rc = VALID; /* Valid */
} else {
rc = INVALID; /* Invalid */
}
break;
}
}
CloseSecret(fp);
return( rc );
}
int
AuthValidate(fname, system, key)
char *fname, *system, *key;
@ -110,3 +161,42 @@ int len, setaddr;
CloseSecret(fp);
return(NULL); /* Invalid */
}
static void
AuthTimeout(authp)
struct authinfo *authp;
{
struct pppTimer *tp;
tp = &authp->authtimer;
StopTimer(tp);
if (--authp->retry > 0) {
StartTimer(tp);
(authp->ChallengeFunc)(++authp->id);
}
}
void
StartAuthChallenge(authp)
struct authinfo *authp;
{
struct pppTimer *tp;
tp = &authp->authtimer;
StopTimer(tp);
tp->func = AuthTimeout;
tp->load = VarRetryTimeout * SECTICKS;
tp->state = TIMER_STOPPED;
tp->arg = (void *)authp;
StartTimer(tp);
authp->retry = 3;
authp->id = 1;
(authp->ChallengeFunc)(authp->id);
}
void
StopAuthTimer(authp)
struct authinfo *authp;
{
StopTimer(&authp->authtimer);
}

View File

@ -16,9 +16,9 @@
* 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:
* o Support other compression protocols
*/
@ -28,20 +28,21 @@
#include "ccp.h"
#include "phase.h"
#include "vars.h"
extern void PutConfValue();
#include "cdefs.h"
extern void PutConfValue __P((void));
struct ccpstate CcpInfo;
static void CcpSendConfigReq(struct fsm *);
static void CcpSendTerminateReq(struct fsm *fp);
static void CcpSendTerminateAck(struct fsm *fp);
static void CcpDecodeConfig(struct mbuf *bp, int mode);
static void CcpLayerStart(struct fsm *);
static void CcpLayerFinish(struct fsm *);
static void CcpLayerUp(struct fsm *);
static void CcpLayerDown(struct fsm *);
static void CcpInitRestartCounter(struct fsm *);
static void CcpSendConfigReq __P((struct fsm *));
static void CcpSendTerminateReq __P((struct fsm *fp));
static void CcpSendTerminateAck __P((struct fsm *fp));
static void CcpDecodeConfig __P((u_char *cp, int flen, int mode));
static void CcpLayerStart __P((struct fsm *));
static void CcpLayerFinish __P((struct fsm *));
static void CcpLayerUp __P((struct fsm *));
static void CcpLayerDown __P((struct fsm *));
static void CcpInitRestartCounter __P((struct fsm *));
#define REJECTED(p, x) (p->his_reject & (1<<x))
@ -105,7 +106,7 @@ static void
CcpInitRestartCounter(fp)
struct fsm *fp;
{
fp->FsmTimer.load = 3 * SECTICKS;
fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
fp->restart = 5;
}
@ -207,20 +208,17 @@ CcpOpen()
}
static void
CcpDecodeConfig(bp, mode)
struct mbuf *bp;
CcpDecodeConfig(cp, plen, mode)
u_char *cp;
int plen;
int mode;
{
u_char *cp;
int plen, type, length;
int type, length;
u_long *lp, compproto;
struct compreq *pcomp;
struct in_addr ipaddr, dstipaddr;
char tbuff[100];
plen = plength(bp);
cp = MBUF_CTOP(bp);
ackp = AckBuff;
nakp = NakBuff;
rejp = RejBuff;

View File

@ -16,11 +16,10 @@
* 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:
* o Imprement retransmission timer.
*/
#include "fsm.h"
#include "chap.h"
@ -29,13 +28,16 @@
#include "hdlc.h"
#include "phase.h"
#include "vars.h"
static int chapid;
#include "auth.h"
static char *chapcodes[] = {
"???", "CHALLENGE", "RESPONCE", "SUCCESS", "FAILURE"
};
struct authinfo AuthChapInfo = {
SendChapChallenge,
};
extern char *AuthGetSecret();
void
@ -68,13 +70,13 @@ static char challenge_data[80];
static int challenge_len;
void
SendChapChallenge()
SendChapChallenge(chapid)
int chapid;
{
int keylen, len, i;
char *cp;
srandom(time(NULL));
++chapid;
cp = challenge_data;
*cp++ = challenge_len = random() % 32 + 16;
@ -91,6 +93,7 @@ void
DumpDigest(mes, cp, len)
char *mes;
char *cp;
int len;
{
int i;
@ -244,8 +247,10 @@ ChapInput(struct mbuf *bp)
bp->cnt -= sizeof(struct fsmheader);
switch (chp->code) {
case CHAP_CHALLENGE:
case CHAP_RESPONSE:
StopAuthTimer(&AuthChapInfo);
/* Fall into.. */
case CHAP_CHALLENGE:
RecvChapTalk(chp, bp);
break;
case CHAP_SUCCESS:

View File

@ -17,9 +17,9 @@
* 1760 Zollinger Road
* Columbus, OH 43221
* (614)451-1883
*
*
* $Id:$
*
*
* TODO:
* o Support more UUCP compatible control sequences.
* o Dialing shoud not block monitor process.
@ -32,13 +32,19 @@
#endif
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include "timeout.h"
#include "vars.h"
#define IBSIZE 200
static int TimeoutSec;
static int abort_next, timeout_next;
static int numaborts;
char *AbortStrings[50];
char inbuff[IBSIZE];
extern int ChangeParity(char *);
@ -177,15 +183,17 @@ int
WaitforString(estr)
char *estr;
{
#define IBSIZE 200
struct timeval timeout;
char *s, *str, ch;
char *inp;
fd_set rfds;
int i, nfds;
int i, nfds, nb;
char buff[200];
char inbuff[IBSIZE];
#ifdef SIGALRM
int omask;
omask = sigblock(sigmask(SIGALRM));
#endif
(void) ExpandString(estr, buff, 0);
LogPrintf(LOG_CHAT, "Wait for (%d): %s --> %s\n", TimeoutSec, estr, buff);
str = buff;
@ -202,52 +210,150 @@ char *estr;
*/
timeout.tv_sec = TimeoutSec;
timeout.tv_usec = 0;
i = select(nfds, &rfds, NULL, NULL, &timeout);
#ifdef notdef
TimerService();
#endif
if (i < 0) {
#ifdef SIGALRM
if (errno == EINTR)
continue;
sigsetmask(omask);
#endif
perror("select");
*inp = 0;
return(NOMATCH);
} else if (i == 0) { /* Timeout reached! */
*inp = 0;
if (inp != inbuff)
LogPrintf(LOG_CHAT, "got: %s\n", inbuff);
LogPrintf(LOG_CHAT, "can't get (%d).\n", timeout.tv_sec);
#ifdef SIGALRM
sigsetmask(omask);
#endif
return(NOMATCH);
}
if (FD_ISSET(modem, &rfds)) { /* got something */
read(modem, &ch, 1);
*inp++ = ch;
if (ch == *s) {
s++;
if (*s == '\0') {
if (DEV_IS_SYNC) {
nb = read(modem, inbuff, IBSIZE-1);
inbuff[nb] = 0;
if (strstr(inbuff, str)) {
#ifdef SIGALRM
sigsetmask(omask);
#endif
return(MATCH);
}
} else {
s = str;
if (inp == inbuff+ IBSIZE) {
bcopy(inp - 100, inbuff, 100);
inp = inbuff + 100;
}
for (i = 0; i < numaborts; i++) { /* Look for Abort strings */
int len;
char *s1;
s1 = AbortStrings[i];
len = strlen(s1);
if ((len <= inp - inbuff) && (strncmp(inp - len, s1, len) == 0)) {
LogPrintf(LOG_CHAT, "Abort: %s\n", s1);
for (i = 0; i < numaborts; i++) {
if (strstr(inbuff, AbortStrings[i])) {
LogPrintf(LOG_CHAT, "Abort: %s\n", AbortStrings[i]);
#ifdef SIGALRM
sigsetmask(omask);
#endif
return(ABORT);
}
}
} else {
read(modem, &ch, 1);
*inp++ = ch;
if (ch == *s) {
s++;
if (*s == '\0') {
#ifdef SIGALRM
sigsetmask(omask);
#endif
*inp = 0;
return(MATCH);
}
} else {
s = str;
if (inp == inbuff+ IBSIZE) {
bcopy(inp - 100, inbuff, 100);
inp = inbuff + 100;
}
for (i = 0; i < numaborts; i++) { /* Look for Abort strings */
int len;
char *s1;
s1 = AbortStrings[i];
len = strlen(s1);
if ((len <= inp - inbuff) && (strncmp(inp - len, s1, len) == 0)) {
LogPrintf(LOG_CHAT, "Abort: %s\n", s1);
*inp = 0;
#ifdef SIGALRM
sigsetmask(omask);
#endif
return(ABORT);
}
}
}
}
}
}
#ifdef SIGALRM
sigsetmask(omask);
#endif
}
void
ExecStr(command, out)
char *command, *out;
{
int pid;
int fids[2];
char *vector[20];
int stat, nb;
char *cp;
char tmp[300];
extern int errno;
cp = inbuff + strlen(inbuff) - 1;
while (cp > inbuff) {
if (*cp < ' ' && *cp != '\t') {
cp++;
break;
}
cp--;
}
sprintf(tmp, "%s %s", command, cp);
(void) MakeArgs(tmp, &vector);
pipe(fids);
pid = fork();
if (pid == 0) {
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
close(fids[0]);
dup2(fids[1], 1);
close(fids[1]);
nb = open("/dev/tty", O_RDWR);
dup2(nb, 0);
LogPrintf(LOG_CHAT, "exec: %s\n", command);
pid = execvp(command, vector);
LogPrintf(LOG_CHAT, "execvp failed for (%d/%d): %s\n", pid, errno, command);
exit(127);
} else {
close(fids[1]);
for (;;) {
nb = read(fids[0], out, 1);
if (nb <= 0)
break;
out++;
}
*out = '\0';
close(fids[0]);
close(fids[1]);
waitpid(pid, &stat, WNOHANG);
}
}
void
SendString(str)
char *str;
{
char *cp;
int nb, on;
char buff[200];
if (abort_next) {
@ -260,9 +366,20 @@ char *str;
if (TimeoutSec <= 0)
TimeoutSec = 30;
} else {
(void) ExpandString(str, buff, 1);
LogPrintf(LOG_CHAT, "sending: %s\n", buff);
write(modem, buff, strlen(buff));
if (*str == '!') {
(void) ExpandString(str+1, buff+2, 0);
ExecStr(buff + 2, buff + 2);
} else {
(void) ExpandString(str, buff+2, 1);
}
LogPrintf(LOG_CHAT, "sending: %s\n", buff+2);
cp = buff;
if (DEV_IS_SYNC)
bcopy("\377\003", buff, 2); /* Prepend HDLC header */
else
cp += 2;
on = strlen(cp);
nb = write(modem, cp, on);
}
}

View File

@ -16,11 +16,12 @@
* 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 <ctype.h>
#include <termios.h>
#include "fsm.h"
#include "phase.h"
#include "lcp.h"
@ -29,6 +30,7 @@
#include "command.h"
#include "hdlc.h"
#include "vars.h"
#include "auth.h"
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@ -39,10 +41,12 @@ extern int MakeArgs();
extern void Cleanup(), TtyTermMode(), PacketMode();
extern int EnableCommand(), DisableCommand(), DisplayCommand();
extern int AcceptCommand(), DenyCommand();
extern int LocalAuthCommand();
extern int LoadCommand(), SaveCommand();
extern int ChangeParity(char *);
extern int SelectSystem();
extern int ShowRoute();
extern struct pppvars pppVars;
struct in_addr ifnetmask;
@ -113,18 +117,18 @@ char **argv;
}
if (!IsInteractive())
return(1);
modem = OpenModem(mode);
if (modem < 0) {
printf("failed to open modem.\n");
modem = 0;
return(1);
}
if (argc > 0) {
if (SelectSystem(*argv, CONFFILE) < 0) {
printf("%s: not found.\n", *argv);
return(1);
}
}
modem = OpenModem(mode);
if (modem < 0) {
printf("failed to open modem.\n");
modem = 0;
return(1);
}
if (DialModem()) {
sleep(1);
ModemTimeout();
@ -138,40 +142,42 @@ static char StrRemote[] = "[remote]";
char StrNull[] = "";
struct cmdtab Commands[] = {
{ "accept", NULL, AcceptCommand,
"accept option request", StrOption },
{ "add", NULL, AddCommand,
"add route", "dest mask gateway" },
{ "close", NULL, CloseCommand,
"Close connection", StrNull },
{ "delete", NULL, DeleteCommand,
"delete route", "dest gateway" },
{ "deny", NULL, DenyCommand,
"Deny option request", StrOption },
{ "dial", "call", DialCommand,
"Dial and login", StrRemote },
{ "disable", NULL, DisableCommand,
"Disable option", StrOption },
{ "display", NULL, DisplayCommand,
"Display option configs", StrNull },
{ "enable", NULL, EnableCommand,
"Enable option", StrOption },
{ "load", NULL, LoadCommand,
"Load settings", StrRemote },
{ "save", NULL, SaveCommand,
"Save settings", StrNull },
{ "set", "setup", SetCommand,
"Set parameters", "var value" },
{ "show", NULL, ShowCommand,
"Show status and statictics", "var" },
{ "term", NULL, TerminalCommand,
"Enter to terminal mode", StrNull },
{ "quit", "bye", QuitCommand,
"Quit PPP program", StrNull },
{ "help", "?", HelpCommand,
{ "accept", NULL, AcceptCommand, LOCAL_AUTH,
"accept option request", StrOption},
{ "add", NULL, AddCommand, LOCAL_AUTH,
"add route", "dest mask gateway"},
{ "close", NULL, CloseCommand, LOCAL_AUTH,
"Close connection", StrNull},
{ "delete", NULL, DeleteCommand, LOCAL_AUTH,
"delete route", "dest gateway"},
{ "deny", NULL, DenyCommand, LOCAL_AUTH,
"Deny option request", StrOption},
{ "dial", "call", DialCommand, LOCAL_AUTH,
"Dial and login", StrRemote},
{ "disable", NULL, DisableCommand, LOCAL_AUTH,
"Disable option", StrOption},
{ "display", NULL, DisplayCommand, LOCAL_AUTH,
"Display option configs", StrNull},
{ "enable", NULL, EnableCommand, LOCAL_AUTH,
"Enable option", StrOption},
{ "passwd", NULL, LocalAuthCommand,LOCAL_NO_AUTH | LOCAL_NO_AUTH,
"Password for manupilation", StrOption},
{ "load", NULL, LoadCommand, LOCAL_AUTH,
"Load settings", StrRemote},
{ "save", NULL, SaveCommand, LOCAL_AUTH,
"Save settings", StrNull},
{ "set", "setup", SetCommand, LOCAL_AUTH,
"Set parameters", "var value"},
{ "show", NULL, ShowCommand, LOCAL_AUTH,
"Show status and statictics", "var"},
{ "term", NULL, TerminalCommand,LOCAL_AUTH,
"Enter to terminal mode", StrNull},
{ "quit", "bye", QuitCommand, LOCAL_AUTH,
"Quit PPP program", StrNull},
{ "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
"Display this message", "[command]", (void *)Commands },
{ NULL, "down", DownCommand,
"Generate down event", StrNull },
{ NULL, "down", DownCommand, LOCAL_AUTH,
"Generate down event", StrNull},
{ NULL, NULL, NULL },
};
@ -223,8 +229,8 @@ static int ShowEscape()
static int ShowTimeout()
{
printf(" Idle Timer: %d secs LQR Timer: %d secs\n",
VarIdleTimeout, VarLqrTimeout);
printf(" Idle Timer: %d secs LQR Timer: %d secs Retry Timer: %d secs\n",
VarIdleTimeout, VarLqrTimeout, VarRetryTimeout);
return(1);
}
@ -249,47 +255,49 @@ static int ShowLogList()
return(1);
}
extern int ShowIfilter(), ShowOfilter(), ShowDfilter();
extern int ShowIfilter(), ShowOfilter(), ShowDfilter(), ShowAfilter();
struct cmdtab ShowCommands[] = {
{ "auth", NULL, ShowAuthKey, "Show auth name/key",
StrNull, },
{ "ccp", NULL, ReportCcpStatus, "Show CCP status",
StrNull, },
{ "compress", NULL, ReportCompress, "Show compression statictics",
StrNull },
{ "debug", NULL, ShowDebugLevel, "Show current debug level",
StrNull },
{ "dfilter", NULL, ShowDfilter, "Show Demand filters",
StrOption },
{ "escape", NULL, ShowEscape, "Show escape characters",
StrNull },
{ "hdlc", NULL, ReportHdlcStatus, "Show HDLC error summary",
StrNull },
{ "ifilter", NULL, ShowIfilter, "Show Input filters",
StrOption },
{ "ipcp", NULL, ReportIpcpStatus, "Show IPCP status",
StrNull, },
{ "lcp", NULL, ReportLcpStatus, "Show LCP status",
StrNull, },
{ "log", NULL, ShowLogList, "Show log records",
StrNull, },
{ "mem", NULL, ShowMemMap, "Show memory map",
StrNull, },
{ "modem", NULL, ShowModemStatus, "Show modem setups",
StrNull, },
{ "ofilter", NULL, ShowOfilter, "Show Output filters",
StrOption },
{ "proto", NULL, ReportProtStatus, "Show protocol summary",
StrNull, },
{ "route", NULL, ShowRoute, "Show routing table",
StrNull, },
{ "timeout", NULL, ShowTimeout, "Show Idle timeout value",
StrNull, },
{ "version", NULL, ShowVersion, "Show version string",
StrNull, },
{ "help", "?", HelpCommand, "Display this message",
StrNull, (void *)ShowCommands },
{ "afilter", NULL, ShowAfilter, LOCAL_AUTH,
"Show keep Alive filters", StrOption},
{ "auth", NULL, ShowAuthKey, LOCAL_AUTH,
"Show auth name/key", StrNull},
{ "ccp", NULL, ReportCcpStatus, LOCAL_AUTH,
"Show CCP status", StrNull},
{ "compress", NULL, ReportCompress, LOCAL_AUTH,
"Show compression statictics", StrNull},
{ "debug", NULL, ShowDebugLevel, LOCAL_AUTH,
"Show current debug level", StrNull},
{ "dfilter", NULL, ShowDfilter, LOCAL_AUTH,
"Show Demand filters", StrOption},
{ "escape", NULL, ShowEscape, LOCAL_AUTH,
"Show escape characters", StrNull},
{ "hdlc", NULL, ReportHdlcStatus, LOCAL_AUTH,
"Show HDLC error summary", StrNull},
{ "ifilter", NULL, ShowIfilter, LOCAL_AUTH,
"Show Input filters", StrOption},
{ "ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH,
"Show IPCP status", StrNull},
{ "lcp", NULL, ReportLcpStatus, LOCAL_AUTH,
"Show LCP status", StrNull},
{ "log", NULL, ShowLogList, LOCAL_AUTH,
"Show log records", StrNull},
{ "mem", NULL, ShowMemMap, LOCAL_AUTH,
"Show memory map", StrNull},
{ "modem", NULL, ShowModemStatus, LOCAL_AUTH,
"Show modem setups", StrNull},
{ "ofilter", NULL, ShowOfilter, LOCAL_AUTH,
"Show Output filters", StrOption},
{ "proto", NULL, ReportProtStatus, LOCAL_AUTH,
"Show protocol summary", StrNull},
{ "route", NULL, ShowRoute, LOCAL_AUTH,
"Show routing table", StrNull},
{ "timeout", NULL, ShowTimeout, LOCAL_AUTH,
"Show Idle timeout value", StrNull},
{ "version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
"Show version string", StrNull},
{ "help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
"Display this message", StrNull, (void *)ShowCommands},
{ NULL, NULL, NULL },
};
@ -329,8 +337,8 @@ char **argv;
cmd = FindCommand(cmdlist, *argv, &nmatch);
if (nmatch > 1)
printf("Anbiguous.\n");
else if (cmd)
printf("Ambiguous.\n");
else if (cmd && ( cmd->lauth & VarLocalAuth ) )
val = (cmd->func)(cmd, --argc, ++argv, cmd->args);
else
printf("what?\n");
@ -341,13 +349,22 @@ void
Prompt(flag)
int flag;
{
char *pconnect, *pauth;
if (!(mode & MODE_INTER))
return;
if (flag) printf("\n");
if (IpcpFsm.state == ST_OPENED && phase == PHASE_NETWORK)
printf("PPP> ");
if ( VarLocalAuth == LOCAL_AUTH )
pauth = " ON ";
else
printf("ppp> ");
pauth = " on ";
if (IpcpFsm.state == ST_OPENED && phase == PHASE_NETWORK)
pconnect = "PPP";
else
pconnect = "ppp";
printf("%s%s%s> ", pconnect, pauth, VarShortHost);
fflush(stdout);
}
@ -425,6 +442,7 @@ char **argv;
if (argc > 0) {
Cleanup(EX_NORMAL);
} else {
VarLocalAuth = LOCAL_NO_AUTH;
close(netfd);
close(1);
netfd = -1;
@ -449,25 +467,22 @@ DownCommand()
return(1);
}
static int validspeed[] = {
1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 0
};
static int SetModemSpeed(list, argc, argv)
struct cmdtab *list;
int argc;
char **argv;
{
int speed;
int *sp;
if (argc > 0) {
if (strcmp(*argv, "sync") == 0) {
VarSpeed = 0;
return(1);
}
speed = atoi(*argv);
for (sp = validspeed; *sp; sp++) {
if (*sp == speed) {
VarSpeed = speed;
return(1);
}
if (IntToSpeed(speed) != B0) {
VarSpeed = speed;
return(1);
}
printf("invalid speed.\n");
}
@ -567,8 +582,16 @@ char **argv;
{
if (argc-- > 0) {
VarIdleTimeout = atoi(*argv++);
if (argc > 0)
VarLqrTimeout = atoi(*argv);
if (argc-- > 0) {
VarLqrTimeout = atoi(*argv++);
if (VarLqrTimeout < 1)
VarLqrTimeout = 30;
if (argc > 0) {
VarRetryTimeout = atoi(*argv);
if (VarRetryTimeout < 1 || VarRetryTimeout > 10)
VarRetryTimeout = 3;
}
}
}
return(1);
}
@ -620,7 +643,7 @@ char **argv;
DefHisAddress.width = 0;
}
if ((mode & MODE_AUTO) |
if ((mode & MODE_AUTO) ||
((mode & MODE_DEDICATED) && dstsystem)) {
OsSetIpaddress(DefMyAddress.ipaddr, DefHisAddress.ipaddr, ifnetmask);
}
@ -693,47 +716,49 @@ char **argv;
static char StrChatStr[] = "chat-script";
static char StrValue[] = "value";
extern int SetIfilter(), SetOfilter(), SetDfilter();
extern int SetIfilter(), SetOfilter(), SetDfilter(), SetAfilter();
struct cmdtab SetCommands[] = {
{ "accmap", NULL, SetVariable, "Set accmap value",
"hex-value", (void *)VAR_ACCMAP },
{ "authkey", "key", SetVariable, "Set authentication key",
"key", (void *)VAR_AUTHKEY },
{ "authname", NULL, SetVariable, "Set authentication name",
"name", (void *)VAR_AUTHNAME },
{ "debug", NULL, SetDebugLevel, "Set debug level",
StrValue },
{ "device", "line", SetVariable, "Set modem device name",
"device-name", (void *)VAR_DEVICE },
{ "dfilter", NULL, SetDfilter, "Set demand filter",
"..." },
{ "dial", NULL, SetVariable, "Set dialing script",
StrChatStr, (void *)VAR_DIAL },
{ "escape", NULL, SetEscape, "Set escape characters",
"hex-digit ..."},
{ "ifaddr", NULL, SetInterfaceAddr, "Set destination address",
"src-addr dst-addr netmask" },
{ "ifilter", NULL, SetIfilter, "Set input filter",
"..." },
{ "login", NULL, SetVariable, "Set login script",
StrChatStr, (void *)VAR_LOGIN },
{ "mru", "mtu", SetInitialMRU, "Set Initial MRU value",
StrValue },
{ "ofilter", NULL, SetOfilter, "Set output filter",
"..." },
{ "openmode", NULL, SetOpenMode, "Set open mode",
"[active|passive]" },
{ "parity", NULL, SetModemParity, "Set modem parity",
"[odd|even|none]" },
{ "phone", NULL, SetVariable, "Set telephone number",
"phone-number", (void *)VAR_PHONE },
{ "speed", NULL, SetModemSpeed, "Set modem speed",
"speed" },
{ "timeout", NULL, SetIdleTimeout, "Set Idle timeout",
StrValue },
{ "help", "?", HelpCommand, "Display this message",
StrNull, (void *)SetCommands },
{ "accmap", NULL, SetVariable, LOCAL_AUTH,
"Set accmap value", "hex-value", (void *)VAR_ACCMAP},
{ "afilter", NULL, SetAfilter, LOCAL_AUTH,
"Set keep Alive filter", "..."},
{ "authkey", "key", SetVariable, LOCAL_AUTH,
"Set authentication key", "key", (void *)VAR_AUTHKEY},
{ "authname", NULL, SetVariable, LOCAL_AUTH,
"Set authentication name", "name", (void *)VAR_AUTHNAME},
{ "debug", NULL, SetDebugLevel, LOCAL_AUTH,
"Set debug level", StrValue},
{ "device", "line", SetVariable, LOCAL_AUTH,
"Set modem device name", "device-name", (void *)VAR_DEVICE},
{ "dfilter", NULL, SetDfilter, LOCAL_AUTH,
"Set demand filter", "..."},
{ "dial", NULL, SetVariable, LOCAL_AUTH,
"Set dialing script", StrChatStr, (void *)VAR_DIAL},
{ "escape", NULL, SetEscape, LOCAL_AUTH,
"Set escape characters", "hex-digit ..."},
{ "ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH,
"Set destination address", "src-addr dst-addr netmask"},
{ "ifilter", NULL, SetIfilter, LOCAL_AUTH,
"Set input filter", "..."},
{ "login", NULL, SetVariable, LOCAL_AUTH,
"Set login script", StrChatStr, (void *)VAR_LOGIN },
{ "mru", "mtu", SetInitialMRU, LOCAL_AUTH,
"Set Initial MRU value", StrValue },
{ "ofilter", NULL, SetOfilter, LOCAL_AUTH,
"Set output filter", "..." },
{ "openmode", NULL, SetOpenMode, LOCAL_AUTH,
"Set open mode", "[active|passive]"},
{ "parity", NULL, SetModemParity, LOCAL_AUTH,
"Set modem parity", "[odd|even|none]"},
{ "phone", NULL, SetVariable, LOCAL_AUTH,
"Set telephone number", "phone-number", (void *)VAR_PHONE },
{ "speed", NULL, SetModemSpeed, LOCAL_AUTH,
"Set modem speed", "speed"},
{ "timeout", NULL, SetIdleTimeout, LOCAL_AUTH,
"Set Idle timeout", StrValue},
{ "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
"Display this message", StrNull, (void *)SetCommands},
{ NULL, NULL, NULL },
};

View File

@ -24,6 +24,7 @@ struct cmdtab {
char *name;
char *alias;
int (*func)();
u_char lauth;
char *helpmes;
char *syntax;
void *args;

View File

@ -29,6 +29,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "mbuf.h"
#include "log.h"
@ -36,7 +37,11 @@
* Check follwiing definitions for your machine envirinment
*/
#define LOGFILE "/var/log/ppp.log" /* Name of log file */
#ifdef __FreeBSD__
#define MODEM_DEV "/dev/cua01" /* name of tty device */
#else
#define MODEM_DEV "/dev/tty01" /* name of tty device */
#endif
#define MODEM_SPEED B38400 /* tty speed */
#define SERVER_PORT 3000 /* Base server port no. */
@ -74,4 +79,11 @@ int tun_in, tun_out;
int netfd;
char *dstsystem;
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#endif /* _DEFS_H_ */

View File

@ -16,9 +16,9 @@
* 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: filter.c,v 1.1.1.1 1995/01/31 06:29:57 amurai Exp $
*
*
* $Id:$
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
@ -326,9 +326,9 @@ struct filterent *ofp;
argc--; argv++;
}
proto = ParseProto(argc, argv);
}
if (proto) {
argc--; argv++;
if (proto) {
argc--; argv++;
}
}
} else {
printf("Address/protocol expected.\n");
@ -409,6 +409,19 @@ char **argv;
return(1);
}
int
SetAfilter(list, argc, argv)
struct cmdtab *list;
int argc;
char **argv;
{
if (argc > 0)
(void) Parse(argc, argv, afilters);
else
printf("syntax error.\n");
return(1);
}
static char *protoname[] = {
"none", "tcp", "udp", "icmp",
};
@ -474,3 +487,13 @@ char **argv;
ShowFilter(dfilters);
return(1);
}
int
ShowAfilter(list, argc, argv)
struct cmdtab *list;
int argc;
char **argv;
{
ShowFilter(afilters);
return(1);
}

View File

@ -73,5 +73,6 @@ struct filterent {
struct filterent ifilters[MAXFILTERS];
struct filterent ofilters[MAXFILTERS];
struct filterent dfilters[MAXFILTERS];
struct filterent afilters[MAXFILTERS]; /* keep Alive packet filter */
#endif _FILTER_H_

View File

@ -16,9 +16,9 @@
* 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:
* o Refer loglevel for log output
* o Better option log display
@ -229,6 +229,7 @@ u_char *option;
int count;
{
LogPrintf(LOG_LCP, "%s: SendConfigAck(%s)\n", fp->name, StateNames[fp->state]);
(fp->DecodeConfig)(option, count, MODE_NOP);
FsmOutput(fp, CODE_CONFIGACK, lhp->id, option, count);
}
@ -240,6 +241,7 @@ u_char *option;
int count;
{
LogPrintf(LOG_LCP, "%s: SendConfigRej(%s)\n", fp->name, StateNames[fp->state]);
(fp->DecodeConfig)(option, count, MODE_NOP);
FsmOutput(fp, CODE_CONFIGREJ, lhp->id, option, count);
}
@ -252,6 +254,7 @@ int count;
{
LogPrintf(LOG_LCP, "%s: SendConfigNak(%s)\n",
fp->name, StateNames[fp->state]);
(fp->DecodeConfig)(option, count, MODE_NOP);
FsmOutput(fp, CODE_CONFIGNAK, lhp->id, option, count);
}
@ -318,16 +321,18 @@ struct fsm *fp;
struct fsmheader *lhp;
struct mbuf *bp;
{
int plen;
int plen, flen;
int ackaction = 0;
plen = plength(bp);
if (plen < sizeof(struct fsmconfig)) {
logprintf("** plen = %d\n", plen);
flen = ntohs(lhp->length) - sizeof(*lhp);
if (plen < flen) {
logprintf("** plen (%d) < flen (%d)\n", plen, flen);
pfree(bp);
return;
}
/*
* Check and process easy case
*/
@ -349,7 +354,7 @@ logprintf("## state = %d\n", fp->state);
return;
}
(fp->DecodeConfig)(bp, MODE_REQ);
(fp->DecodeConfig)(MBUF_CTOP(bp), flen, MODE_REQ);
if (nakp == NakBuff && rejp == RejBuff)
ackaction = 1;
@ -440,10 +445,11 @@ struct fsm *fp;
struct fsmheader *lhp;
struct mbuf *bp;
{
int plen;
int plen, flen;
plen = plength(bp);
if (plen < sizeof(struct fsmconfig)) {
flen = ntohs(lhp->length) - sizeof(*lhp);
if (plen < flen) {
pfree(bp);
return;
}
@ -469,7 +475,7 @@ struct mbuf *bp;
return;
}
(fp->DecodeConfig)(bp, MODE_NAK);
(fp->DecodeConfig)(MBUF_CTOP(bp), flen, MODE_NAK);
switch (fp->state) {
case ST_REQSENT:
@ -556,10 +562,11 @@ struct fsm *fp;
struct fsmheader *lhp;
struct mbuf *bp;
{
int plen;
int plen, flen;
plen = plength(bp);
if (plen < sizeof(struct fsmconfig)) {
flen = ntohs(lhp->length) - sizeof(*lhp);
if (plen < flen) {
pfree(bp);
return;
}
@ -586,7 +593,7 @@ struct mbuf *bp;
return;
}
(fp->DecodeConfig)(bp, MODE_REJ);
(fp->DecodeConfig)(MBUF_CTOP(bp), flen, MODE_REJ);
switch (fp->state) {
case ST_REQSENT:
@ -791,7 +798,7 @@ struct mbuf *bp;
codep = FsmCodes + lhp->code - 1;
LogPrintf(LOG_LCP, "%s: Received %s (%d) state = %s (%d)\n",
fp->name, codep->name, lhp->code, StateNames[fp->state], fp->state);
fp->name, codep->name, lhp->id, StateNames[fp->state], fp->state);
#ifdef DEBUG
LogMemory();
#endif

View File

@ -19,12 +19,14 @@
*
* TODO:
*/
#ifndef _FSM_H_
#define _FSM_H_
#include "defs.h"
#include <netinet/in.h>
#include "timeout.h"
#include "cdefs.h"
/*
* State of machine
@ -46,6 +48,7 @@
#define MODE_REQ 0
#define MODE_NAK 1
#define MODE_REJ 2
#define MODE_NOP 3
#define OPEN_ACTIVE 0
#define OPEN_PASSIVE 1
@ -63,15 +66,15 @@ struct fsm {
int reqcode; /* Request code sent */
struct pppTimer FsmTimer; /* Restart Timer */
void (*LayerUp)();
void (*LayerDown)();
void (*LayerStart)();
void (*LayerFinish)();
void (*InitRestartCounter)();
void (*SendConfigReq)();
void (*SendTerminateReq)();
void (*SendTerminateAck)();
void (*DecodeConfig)();
void (*LayerUp) __P((struct fsm *));
void (*LayerDown) __P((struct fsm *));
void (*LayerStart) __P((struct fsm *));
void (*LayerFinish) __P((struct fsm *));
void (*InitRestartCounter) __P((struct fsm *));
void (*SendConfigReq) __P((struct fsm *));
void (*SendTerminateReq) __P((struct fsm *));
void (*SendTerminateAck) __P((struct fsm *));
void (*DecodeConfig) __P((u_char *, int, int));
};
struct fsmheader {
@ -97,7 +100,7 @@ struct fsmheader {
#define CODE_RESETACK 15 /* Used in CCP */
struct fsmcodedesc {
void (*action)();
void (*action) __P((struct fsm *, struct fsmheader *, struct mbuf *));
char *name;
};
@ -114,20 +117,20 @@ u_char ReqBuff[200];
u_char *ackp, *nakp, *rejp;
extern char *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 FsmInit __P((struct fsm *));
extern void NewState __P((struct fsm *, int));
extern void FsmOutput __P((struct fsm *, u_int, u_int, u_char *, int));
extern void FsmOpen __P((struct fsm *));
extern void FsmUp __P((struct fsm *));
extern void FsmDown __P((struct fsm *));
extern void FsmInput __P((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 void FsmRecvConfigReq __P((struct fsm *, struct fsmheader *, struct mbuf *));
extern void FsmRecvConfigAck __P((struct fsm *, struct fsmheader *, struct mbuf *));
extern void FsmRecvConfigNak __P((struct fsm *, struct fsmheader *, struct mbuf *));
extern void FsmRecvTermReq __P((struct fsm *, struct fsmheader *, struct mbuf *));
extern void FsmRecvTermAck __P((struct fsm *, struct fsmheader *, struct mbuf *));
extern void FsmClose __P((struct fsm *fp));
extern struct fsm LcpFsm, IpcpFsm, CcpFsm;

View File

@ -1,6 +1,4 @@
/*
* GLOBAL.H - RSAREF types and constants
*
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
*
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
@ -22,10 +20,14 @@
* 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.
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

View File

@ -16,9 +16,9 @@
* 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:
*/
#include "fsm.h"
@ -26,6 +26,7 @@
#include "lcpproto.h"
#include "lcp.h"
#include "lqr.h"
#include "vars.h"
struct hdlcstat {
int badfcs;
@ -129,7 +130,10 @@ HdlcOutput(int pri, u_short proto, struct mbuf *bp)
return;
}
}
mfcs = mballoc(2, MB_HDLCOUT);
if (DEV_IS_SYNC)
mfcs = NULLBUFF;
else
mfcs = mballoc(2, MB_HDLCOUT);
mhp = mballoc(4, MB_HDLCOUT);
mhp->cnt = 0;
cp = MBUF_CTOP(mhp);
@ -172,19 +176,24 @@ HdlcOutput(int pri, u_short proto, struct mbuf *bp)
LqrChangeOrder(lqr, (struct lqrdata *)(MBUF_CTOP(bp)));
}
fcs = HdlcFcs(INITFCS, MBUF_CTOP(mhp), mhp->cnt);
fcs = HdlcFcs(fcs, MBUF_CTOP(bp), bp->cnt);
fcs = ~fcs;
cp = MBUF_CTOP(mfcs);
*cp++ = fcs & 0377; /* Low byte first!! */
*cp++ = fcs >> 8;
if (!DEV_IS_SYNC) {
fcs = HdlcFcs(INITFCS, MBUF_CTOP(mhp), mhp->cnt);
fcs = HdlcFcs(fcs, MBUF_CTOP(bp), bp->cnt);
fcs = ~fcs;
cp = MBUF_CTOP(mfcs);
*cp++ = fcs & 0377; /* Low byte first!! */
*cp++ = fcs >> 8;
}
LogDumpBp(LOG_HDLC, "HdlcOutput", mhp);
for (statp = ProtocolStat; statp->number; statp++)
if (statp->number == proto)
break;
statp->out_count++;
AsyncOutput(pri, mhp, proto);
if (DEV_IS_SYNC)
ModemOutput(pri, mhp);
else
AsyncOutput(pri, mhp, proto);
}
DecodePacket(proto, bp)
@ -211,6 +220,9 @@ struct mbuf *bp;
case PROTO_VJUNCOMP:
case PROTO_VJCOMP:
bp = VjCompInput(bp, proto);
if (bp == NULLBUFF) {
break;
}
/* fall down */
case PROTO_IP:
IpInput(bp);
@ -295,7 +307,10 @@ HdlcInput(struct mbuf *bp)
struct protostat *statp;
LogDumpBp(LOG_HDLC, "HdlcInput:", bp);
fcs = HdlcFcs(INITFCS, MBUF_CTOP(bp), bp->cnt);
if (DEV_IS_SYNC)
fcs = GOODFCS;
else
fcs = HdlcFcs(INITFCS, MBUF_CTOP(bp), bp->cnt);
HisLqrSave.SaveInOctets += bp->cnt + 1;
#ifdef DEBUG
@ -310,7 +325,8 @@ HdlcInput(struct mbuf *bp)
pfree(bp);
return;
}
bp->cnt -= 2; /* discard FCS part */
if (!DEV_IS_SYNC)
bp->cnt -= 2; /* discard FCS part */
cp = MBUF_CTOP(bp);
ifInPackets++;

View File

@ -51,8 +51,9 @@
unsigned char EscMap[33];
void HdlcInput(struct mbuf *bp);
void HdlcOutput(int pri, u_short proto, struct mbuf *bp);
void AsyncOutput(int pri, struct mbuf *bp, int proto);
void HdlcInit __P((void));
void HdlcInput __P((struct mbuf *bp));
void HdlcOutput __P((int pri, u_short proto, struct mbuf *bp));
void AsyncOutput __P((int pri, struct mbuf *bp, int proto));
#endif

View File

@ -16,9 +16,9 @@
* 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:
* o Return ICMP message for filterd packet
* and optionaly record it into log.
@ -34,7 +34,7 @@
#include "vars.h"
#include "filter.h"
extern void SendPppFlame();
extern void SendPppFrame();
extern int PacketCheck();
extern void LcpClose();
@ -74,8 +74,8 @@ StopIdleTimer()
static void
RestartIdleTimer()
{
if (!(mode & MODE_DEDICATED)) {
StopTimer(&IdleTimer);
if (!(mode & MODE_DEDICATED) && ipKeepAlive ) {
/* StopTimer(&IdleTimer); */
StartTimer(&IdleTimer);
ipIdleSecs = 0;
}
@ -91,8 +91,8 @@ static char *TcpFlags[] = {
"FIN", "SYN", "RST", "PSH", "ACK", "URG",
};
static char *Direction[] = { "INP", "OUT", "OUT" };
static struct filterent *Filters[] = { ifilters, ofilters, dfilters };
static char *Direction[] = { "INP", "OUT", "OUT", "IN/OUT" };
static struct filterent *Filters[] = { ifilters, ofilters, dfilters, afilters };
static int
PortMatch(op, pport, rport)
@ -155,6 +155,10 @@ logprintf("rule = %d\n", n);
cproto = P_TCP; th = (struct tcphdr *)ptop;
sport = ntohs(th->th_sport); dport = ntohs(th->th_dport);
estab = (th->th_flags & TH_ACK);
#ifdef DEBUG
if (estab == 0)
logprintf("flag = %02x, sport = %d, dport = %d\n", th->th_flags, sport, dport);
#endif
break;
default:
return(A_DENY); /* We'll block unknown type of packet */
@ -163,8 +167,6 @@ logprintf("rule = %d\n", n);
#ifdef DEBUG
logprintf("dir = %d, proto = %d, srcop = %d, dstop = %d, estab = %d\n",
direction, cproto, fp->opt.srcop, fp->opt.dstop, estab);
if (estab == 0)
logprintf("flag = %02x, sport = %d, dport = %d\n", th->th_flags, sport, dport);
#endif
}
#ifdef DEBUG
@ -211,7 +213,7 @@ int code;
if (pip->ip_p != IPPROTO_ICMP) {
bp = mballoc(cnt, MB_IPIN);
bcopy(ptr, MBUF_CTOP(bp), cnt);
SendPppFlame(PRI_URGENT, bp);
SendPppFrame(PRI_URGENT, bp);
RestartIdleTimer();
ipOutOctets += cnt;
}
@ -299,6 +301,11 @@ int direction;
if (direction == 0) IcmpError(pip, pri);
return(-1);
} else {
if ( FilterCheck(pip, 3) & A_DENY ) { /* Check Keep Alive filter */
ipKeepAlive = FALSE;
} else {
ipKeepAlive = TRUE;
}
return(pri);
}
}
@ -352,7 +359,7 @@ int cnt; /* IN: Length of packet */
if (pri >= 0) {
bp = mballoc(cnt, MB_IPIN);
bcopy(ptr, MBUF_CTOP(bp), cnt);
SendPppFlame(pri, bp);
SendPppFrame(pri, bp);
RestartIdleTimer();
ipOutOctets += cnt;
}
@ -388,7 +395,7 @@ IpStartOutput()
bp = Dequeue(queue);
if (bp) {
cnt = plength(bp);
SendPppFlame(pri, bp);
SendPppFrame(pri, bp);
RestartIdleTimer();
ipOutOctets += cnt;
}

View File

@ -18,7 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
* o More RFC1772 backwoard compatibility
*/
@ -43,15 +43,15 @@ extern struct in_addr ifnetmask;
struct ipcpstate IpcpInfo;
struct in_range DefMyAddress, DefHisAddress;
static void IpcpSendConfigReq(struct fsm *);
static void IpcpSendTerminateAck(struct fsm *);
static void IpcpSendTerminateReq(struct fsm *);
static void IpcpDecodeConfig();
static void IpcpLayerStart(struct fsm *);
static void IpcpLayerFinish(struct fsm *);
static void IpcpLayerUp(struct fsm *);
static void IpcpLayerDown(struct fsm *);
static void IpcpInitRestartCounter(struct fsm *);
static void IpcpSendConfigReq __P((struct fsm *));
static void IpcpSendTerminateAck __P((struct fsm *));
static void IpcpSendTerminateReq __P((struct fsm *));
static void IpcpDecodeConfig __P((u_char *, int, int));
static void IpcpLayerStart __P((struct fsm *));
static void IpcpLayerFinish __P((struct fsm *));
static void IpcpLayerUp __P((struct fsm *));
static void IpcpLayerDown __P((struct fsm *));
static void IpcpInitRestartCounter __P((struct fsm *));
static struct pppTimer IpcpReportTimer;
@ -174,7 +174,7 @@ static void
IpcpInitRestartCounter(fp)
struct fsm *fp;
{
fp->FsmTimer.load = 3 * SECTICKS;
fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
fp->restart = 5;
}
@ -187,7 +187,8 @@ struct fsm *fp;
cp = ReqBuff;
LogPrintf(LOG_LCP, "%s: SendConfigReq\n", fp->name);
PutConfValue(&cp, cftypes, TY_IPADDR, 6, ntohl(icp->want_ipaddr.s_addr));
if (!DEV_IS_SYNC || !REJECTED(icp, TY_IPADDR))
PutConfValue(&cp, cftypes, TY_IPADDR, 6, ntohl(icp->want_ipaddr.s_addr));
if (icp->want_compproto && !REJECTED(icp, TY_COMPPROTO)) {
if (icp->heis1172)
PutConfValue(&cp, cftypes, TY_COMPPROTO, 4, icp->want_compproto >> 16);
@ -288,20 +289,17 @@ struct in_addr ipaddr;
}
static void
IpcpDecodeConfig(bp, mode)
struct mbuf *bp;
IpcpDecodeConfig(cp, plen, mode)
u_char *cp;
int plen;
int mode;
{
u_char *cp;
int plen, type, length;
int type, length;
u_long *lp, compproto;
struct compreq *pcomp;
struct in_addr ipaddr, dstipaddr;
char tbuff[100];
plen = plength(bp);
cp = MBUF_CTOP(bp);
ackp = AckBuff;
nakp = NakBuff;
rejp = RejBuff;

View File

@ -57,6 +57,6 @@ extern struct ipcpstate IpcpInfo;
extern struct in_range DefMyAddress;
extern struct in_range DefHisAddress;
extern void IpcpInit(void);
extern void IpcpDefAddress();
extern void IpcpInit __P((void));
extern void IpcpDefAddress __P((void));
#endif

View File

@ -16,16 +16,14 @@
* 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:
* o Validate magic number received from peer.
* o Limit data field length by MRU
*/
#if __FreeBSD__ >=2
#include <sys/time.h>
#endif
#include "fsm.h"
#include "lcp.h"
#include "ipcp.h"
@ -35,29 +33,29 @@
#include "lqr.h"
#include "phase.h"
#include "vars.h"
#include "auth.h"
extern void IpcpUp();
extern void IpcpOpen();
extern void SendPapChallenge();
extern void SendChapChallenge();
extern void StartPapChallenge();
extern void StartChapChallenge();
extern void SetLinkParams(struct lcpstate *);
extern void Prompt();
extern void StopIdleTimer();
extern void HdlcInit();
extern void OsLinkdown();
extern void Cleanup();
struct lcpstate LcpInfo;
static void LcpSendConfigReq(struct fsm *);
static void LcpSendTerminateReq(struct fsm *fp);
static void LcpSendTerminateAck(struct fsm *fp);
static void LcpDecodeConfig(struct mbuf *bp, int mode);
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 *);
static void LcpSendConfigReq __P((struct fsm *));
static void LcpSendTerminateReq __P((struct fsm *fp));
static void LcpSendTerminateAck __P((struct fsm *fp));
static void LcpDecodeConfig __P((u_char *cp, int flen,int mode));
static void LcpInitRestartCounter __P((struct fsm *));
static void LcpLayerUp __P((struct fsm *));
static void LcpLayerDown __P((struct fsm *));
static void LcpLayerStart __P((struct fsm *));
static void LcpLayerFinish __P((struct fsm *));
extern int ModemSpeed();
@ -111,9 +109,9 @@ int new;
LogPrintf(LOG_PHASE, " his = %x, mine = %x\n", lcp->his_auth, lcp->want_auth);
if (lcp->his_auth || lcp->want_auth) {
if (lcp->his_auth == PROTO_PAP)
SendPapChallenge();
StartAuthChallenge(&AuthPapInfo);
if (lcp->want_auth == PROTO_CHAP)
SendChapChallenge();
StartAuthChallenge(&AuthChapInfo);
} else
NewPhase(PHASE_NETWORK);
break;
@ -208,7 +206,7 @@ static void
LcpInitRestartCounter(fp)
struct fsm *fp;
{
fp->FsmTimer.load = 5 * SECTICKS;
fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
fp->restart = 5;
}
@ -250,18 +248,20 @@ struct fsm *fp;
LogPrintf(LOG_LCP, "%s: SendConfigReq\n", fp->name);
cp = ReqBuff;
if (lcp->want_acfcomp && !REJECTED(lcp, TY_ACFCOMP)) {
*cp++ = TY_ACFCOMP; *cp++ = 2;
LogPrintf(LOG_LCP, " %s\n", cftypes[TY_ACFCOMP]);
}
if (lcp->want_protocomp && !REJECTED(lcp, TY_PROTOCOMP)) {
*cp++ = TY_PROTOCOMP; *cp++ = 2;
LogPrintf(LOG_LCP, " %s\n", cftypes[TY_PROTOCOMP]);
if (!DEV_IS_SYNC) {
if (lcp->want_acfcomp && !REJECTED(lcp, TY_ACFCOMP)) {
*cp++ = TY_ACFCOMP; *cp++ = 2;
LogPrintf(LOG_LCP, " %s\n", cftypes[TY_ACFCOMP]);
}
if (lcp->want_protocomp && !REJECTED(lcp, TY_PROTOCOMP)) {
*cp++ = TY_PROTOCOMP; *cp++ = 2;
LogPrintf(LOG_LCP, " %s\n", cftypes[TY_PROTOCOMP]);
}
if (!REJECTED(lcp, TY_ACCMAP))
PutConfValue(&cp, cftypes, TY_ACCMAP, 6, lcp->want_accmap);
}
if (!REJECTED(lcp, TY_MRU))
PutConfValue(&cp, cftypes, TY_MRU, 4, lcp->want_mru);
if (!REJECTED(lcp, TY_ACCMAP))
PutConfValue(&cp, cftypes, TY_ACCMAP, 6, lcp->want_accmap);
if (lcp->want_magic && !REJECTED(lcp, TY_MAGICNUM))
PutConfValue(&cp, cftypes, TY_MAGICNUM, 6, lcp->want_magic);
if (lcp->want_lqrperiod && !REJECTED(lcp, TY_QUALPROTO)) {
@ -318,6 +318,15 @@ struct fsm *fp;
NewPhase(PHASE_ESTABLISH);
}
static void
StopAllTimers()
{
StopTimer(&LcpReportTimer);
StopIdleTimer();
StopTimer(&AuthPapInfo.authtimer);
StopTimer(&AuthChapInfo.authtimer);
}
static void
LcpLayerFinish(fp)
struct fsm *fp;
@ -333,8 +342,7 @@ struct fsm *fp;
OsCloseLink(1);
#endif
NewPhase(PHASE_DEAD);
StopTimer(&LcpReportTimer);
StopIdleTimer();
StopAllTimers();
OsInterfaceDown(0);
}
@ -361,6 +369,7 @@ LcpLayerDown(fp)
struct fsm *fp;
{
LogPrintf(LOG_LCP, "%s: LayerDown\n", fp->name);
StopAllTimers();
OsLinkdown();
NewPhase(PHASE_TERMINATE);
}
@ -372,9 +381,10 @@ LcpUp()
}
void
LcpDown()
LcpDown() /* Sudden death */
{
NewPhase(PHASE_DEAD);
StopAllTimers();
FsmDown(&LcpFsm);
}
@ -396,20 +406,17 @@ LcpClose()
* XXX: Should validate option length
*/
static void
LcpDecodeConfig(bp, mode)
struct mbuf *bp;
LcpDecodeConfig(cp, plen, mode)
u_char *cp;
int plen;
int mode;
{
u_char *cp;
char *request;
int plen, type, length, mru;
int type, length, mru;
u_long *lp, magic, accmap;
u_short *sp, proto;
struct lqrreq *req;
plen = plength(bp);
cp = MBUF_CTOP(bp);
ackp = AckBuff;
nakp = NakBuff;
rejp = RejBuff;
@ -471,7 +478,7 @@ int mode;
case TY_AUTHPROTO:
sp = (u_short *)(cp + 2);
proto = ntohs(*sp);
LogPrintf(LOG_LCP, " %s proto = %x\n", request, proto);
LogPrintf(LOG_LCP, " %s proto = %04x\n", request, proto);
switch (mode) {
case MODE_REQ:
@ -486,7 +493,7 @@ int mode;
bcopy(cp, ackp, length); ackp += length;
} else if (Acceptable(ConfChap)) {
*nakp++ = *cp; *nakp++ = 5;
*nakp++ = (unsigned char)PROTO_CHAP >> 8;
*nakp++ = (unsigned char)(PROTO_CHAP >> 8);
*nakp++ = (unsigned char)PROTO_CHAP;
*nakp++ = 5;
} else
@ -502,7 +509,7 @@ int mode;
bcopy(cp, ackp, length); ackp += length;
} else if (Acceptable(ConfPap)) {
*nakp++ = *cp; *nakp++ = 4;
*nakp++ = (unsigned char)PROTO_PAP >> 8;
*nakp++ = (unsigned char)(PROTO_PAP >> 8);
*nakp++ = (unsigned char)PROTO_PAP;
} else
goto reqreject;
@ -638,10 +645,13 @@ int mode;
}
break;
default:
LogPrintf(LOG_LCP, " ???[%02x]\n", type);
if (mode == MODE_REQ) {
reqreject:
bcopy(cp, rejp, length);
rejp += length;
LcpInfo.my_reject |= (1 << type);
bcopy(cp, rejp, length);
rejp += length;
LcpInfo.my_reject |= (1 << type);
}
break;
}
plen -= length;

View File

@ -22,6 +22,7 @@
#ifndef _LCP_H_
#define _LPC_H_
#include "cdefs.h"
struct lcpstate {
u_long his_mru;
@ -74,10 +75,10 @@ struct lqrreq {
extern struct lcpstate LcpInfo;
extern void LcpInit(void);
extern void LcpUp(void);
extern void LcpSendProtoRej(u_char *, int);
extern void LcpOpen(int mode);
extern void LcpClose(void);
extern void LcpDown(void);
extern void LcpInit __P((void));
extern void LcpUp __P((void));
extern void LcpSendProtoRej __P((u_char *, int));
extern void LcpOpen __P((int mode));
extern void LcpClose __P((void));
extern void LcpDown __P((void));
#endif

View File

@ -22,6 +22,7 @@
#ifndef _LCPPROTO_H_
#define _LCPPROTO_H_
#include "cdefs.h"
/*
* Definition of protocol numbers
@ -41,12 +42,12 @@
#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);
extern void LcpInput __P((struct mbuf *bp));
extern void PapInput __P((struct mbuf *bp));
extern void LqpInput __P((struct mbuf *bp));
extern void ChapInput __P((struct mbuf *bp));
extern void IpInput __P((struct mbuf *bp));
extern struct mbuf *VjCompInput __P((struct mbuf *bp, int proto));
extern void IpcpInput __P((struct mbuf *bp));
extern void LqrInput __P((struct mbuf *bp));
#endif

View File

@ -18,13 +18,19 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
* TODO:
*
*
*/
#include "defs.h"
#include <time.h>
#include <netdb.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifdef NO_VSPRINTF
#include <stdio.h>
#endif
#include "hdlc.h"
@ -118,16 +124,54 @@ LogClose()
#endif
}
#ifdef NO_VSPRINTF
void
logprintf(format, arg1, arg2, arg3, arg4, arg5, arg6)
char *format;
void *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
vsprintf(buf, fmt, av)
char *buf;
char *fmt;
va_list av;
{
sprintf(logptr, format, arg1, arg2, arg3, arg4, arg5, arg6);
FILE foo;
foo._cnt = BUFSIZ;
foo._base = foo._ptr = buf; /* may have to cast(unsigned char *) */
foo._flag = _IOWRT+_IOSTRG;
(void) _doprnt(fmt, (va_list)av, &foo);
*foo._ptr = '\0'; /* plant terminating null character */
}
#endif
static void
vlogprintf(format, ap)
char *format;
va_list ap;
{
vsprintf(logptr, format, ap);
logptr += strlen(logptr);
LogFlush();
}
void
#ifdef __STDC__
logprintf(char *format, ...)
#else
logprintf(va_alist)
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, format);
#else
char *format;
va_start(ap);
format = va_arg(ap, char *);
#endif
vlogprintf(format, ap);
va_end(ap);
}
void
LogDumpBp(level, header, bp)
int level;
@ -211,13 +255,27 @@ LogTimeStamp()
}
void
LogPrintf(level, format, arg1, arg2, arg3, arg4, arg5, arg6)
int level;
char *format;
void *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
#ifdef __STDC__
LogPrintf(int level, char *format, ...)
#else
LogPrintf(va_alist)
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, format);
#else
int level;
char *format;
va_start(ap);
int = va_arg(ap, int);
format = va_arg(ap, char *);
#endif
if (!(loglevel & (1 << level)))
return;
LogTimeStamp();
logprintf(format, arg1, arg2, arg3, arg4, arg5, arg6);
vlogprintf(format, ap);
va_end(ap);
}

View File

@ -22,6 +22,7 @@
#ifndef _LOG_H_
#define _LOG_H_
#include "cdefs.h"
/*
* Definition of log level
*/
@ -43,11 +44,11 @@
extern int loglevel;
extern void LogTimeStamp();
extern int LogOpen();
extern void DupLog();
extern void LogClose();
extern void logprintf(), LogPrintf();
extern void LogDumpBp(int level, char *header, struct mbuf *bp);
extern void LogDumpBuff(int level, char *header, u_char *ptr, int cnt);
extern void LogTimeStamp __P((void));
extern int LogOpen __P((void));
extern void DupLog __P((void));
extern void LogClose __P((void));
extern void logprintf __P((char *, ...)), LogPrintf __P((int, char *, ...));
extern void LogDumpBp __P((int level, char *header, struct mbuf *bp));
extern void LogDumpBuff __P((int level, char *header, u_char *ptr, int cnt));
#endif

View File

@ -17,9 +17,9 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* o LQR based on RFC1333
*
* $Id:$
*
* o LQR based on RFC1333
*
* TODO:
* o LQM policy

View File

@ -58,9 +58,9 @@ struct lqrsave HisLqrSave;
#define LQM_LQR 1
#define LQM_ECHO 2
extern void LqrDump(char *, struct lqrdata *);
extern void LqrChangeOrder(struct lqrdata *, struct lqrdata *);
extern void StartLqm(void);
extern void StopLqr(int);
extern void RecvEchoLqr(struct mbuf *);
extern void LqrDump __P((char *, struct lqrdata *));
extern void LqrChangeOrder __P((struct lqrdata *, struct lqrdata *));
extern void StartLqm __P((void));
extern void StopLqr __P((int));
extern void RecvEchoLqr __P((struct mbuf *));
#endif

View File

@ -18,7 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
* o Add commands for traffic summary, version display, etc.
* o Add signal handler for misc controls.
@ -27,7 +27,6 @@
#include <fcntl.h>
#include <sys/time.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
@ -40,6 +39,13 @@
#include "lcp.h"
#include "ipcp.h"
#include "vars.h"
#include "auth.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
#define O_NONBLOCK O_NDELAY
#endif
#endif
extern void VjInit(), AsyncInit();
extern void AsyncInput(), IpOutput();
@ -74,7 +80,7 @@ TtyInit()
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
newtio.c_cflag |= CS8;
ioctl(0, TIOCSETA, &newtio);
tcsetattr(0, TCSADRAIN, &newtio);
comtio = newtio;
}
@ -89,11 +95,11 @@ TtyCommandMode()
if (!(mode & MODE_INTER))
return;
ioctl(0, TIOCGETA, &newtio);
tcgetattr(0, &newtio);
newtio.c_lflag |= (ECHO|ICANON);
newtio.c_iflag = oldtio.c_iflag;
newtio.c_oflag |= OPOST;
ioctl(0, TIOCSETA, &newtio);
tcsetattr(0, TCSADRAIN, &newtio);
stat = fcntl(0, F_GETFL, 0);
stat |= O_NONBLOCK;
fcntl(0, F_SETFL, stat);
@ -109,7 +115,7 @@ TtyTermMode()
{
int stat;
ioctl(0, TIOCSETA, &comtio);
tcsetattr(0, TCSADRAIN, &comtio);
stat = fcntl(0, F_GETFL, 0);
stat &= ~O_NONBLOCK;
fcntl(0, F_SETFL, stat);
@ -123,10 +129,12 @@ int excode;
int stat;
OsLinkdown();
#ifdef notdef
stat = fcntl(0, F_GETFL, 0);
stat &= ~O_NONBLOCK;
fcntl(0, F_SETFL, stat);
ioctl(0, TIOCSETA, &oldtio);
tcsetattr(0, TCSANOW, &oldtio);
#endif
OsCloseLink(1);
sleep(1);
if (mode & MODE_AUTO)
@ -136,6 +144,12 @@ int excode;
LogClose();
if (server > 0)
close(server);
#ifndef notdef
stat = fcntl(0, F_GETFL, 0);
stat &= ~O_NONBLOCK;
fcntl(0, F_SETFL, stat);
tcsetattr(0, TCSANOW, &oldtio);
#endif
exit(excode);
}
@ -226,6 +240,16 @@ char **argv;
if (LogOpen())
exit(EX_START);
switch ( LocalAuthInit() ) {
case NOT_FOUND:
fprintf(stderr, "Warning: No password entry in secret file\n");
fprintf(stderr, "Warning: Anyone is allowd manipulating!!!\n");
VarLocalAuth = LOCAL_AUTH;
break;
default:
break;
}
if (OpenTunnel(&tunno) < 0) {
perror("open_tun");
exit(EX_START);
@ -244,12 +268,20 @@ char **argv;
}
}
ioctl(0, TIOCGETA, &oldtio); /* Save original tty mode */
tcgetattr(0, &oldtio); /* Save original tty mode */
signal(SIGHUP, Hangup);
signal(SIGTERM, CloseSession);
signal(SIGINT, CloseSession);
#ifdef SIGSEGV
signal(SIGSEGV, Hangup);
#endif
#ifdef SIGPIPE
signal(SIGPIPE, Hangup);
#endif
#ifdef SIGALRM
signal(SIGALRM, SIG_IGN);
#endif
if (dstsystem) {
if (SelectSystem(dstsystem, CONFFILE) < 0) {
@ -298,7 +330,7 @@ char **argv;
}
LogPrintf(LOG_PHASE, "Listening at %d.\n", port);
#ifdef DOTTYINIT
if (mode & (MODE_DIRECT|MODE_DEDICATED)) {
if (mode & (MODE_DIRECT|MODE_DEDICATED)) { /* } */
#else
if (mode & MODE_DIRECT) {
#endif
@ -371,12 +403,13 @@ ReadTty()
#endif
if (!TermMode) {
n = read(netfd, linebuff, sizeof(linebuff)-1);
if (n > 0)
if (n > 0) {
DecodeCommand(linebuff, n, 1);
else {
} else {
#ifdef DEBUG
logprintf("connection closed.\n");
#endif
VarLocalAuth = LOCAL_NO_AUTH;
close(netfd);
netfd = -1;
mode &= ~MODE_INTER;
@ -455,10 +488,11 @@ ReadTty()
*/
static char *FrameHeaders[] = {
"\176\177\175\043",
"\176\377\175\043",
"\176\175\137\175\043",
"\176\175\337\175\043",
"\176\377\003\300\041",
"\176\377\175\043\300\041",
"\176\177\175\043\100\041",
"\176\175\337\175\043\300\041",
"\176\175\137\175\043\100\041",
NULL,
};
@ -467,12 +501,15 @@ HdlcDetect(cp, n)
u_char *cp;
int n;
{
char *ptr, **hp;
char *ptr, *fp, **hp;
cp[n] = '\0'; /* be sure to null terminated */
ptr = NULL;
for (hp = FrameHeaders; *hp; hp++) {
if (ptr = strstr((char *)cp, *hp))
fp = *hp;
if (DEV_IS_SYNC)
fp++;
if (ptr = strstr((char *)cp, fp))
break;
}
return((u_char *)ptr);
@ -509,6 +546,7 @@ DoLoop()
int ssize = sizeof(hisaddr);
u_char *cp;
u_char rbuff[MAX_MRU];
struct itimerval itimer;
if (mode & MODE_DIRECT) {
modem = OpenModem(mode);
@ -522,7 +560,14 @@ DoLoop()
fflush(stdout);
timeout.tv_sec = 0;;
#ifdef SIGALRM
signal(SIGALRM, (void (*)(int))TimerService);
itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT;
setitimer(ITIMER_REAL, &itimer, NULL);
#else
timeout.tv_usec = 0;
#endif
for (;;) {
IpStartOutput();
@ -537,18 +582,23 @@ DoLoop()
* too big, it results loss of characters from modem and poor responce.
* If this values is too small, ppp process eats many CPU time.
*/
#ifndef SIGALRM
usleep(TICKUNIT);
TimerService();
#endif
if (modem) {
FD_SET(modem, &rfds);
FD_SET(modem, &efds);
FD_SET(modem, &wfds);
if (ModemQlen() > 0) {
FD_SET(modem, &wfds);
}
}
if (netfd > -1) {
FD_SET(netfd, &rfds);
FD_SET(netfd, &efds);
}
#ifndef SIGALRM
/*
* Normally, slect() will not block because modem is writable.
* In AUTO mode, select will block until we find packet from tun.
@ -556,10 +606,16 @@ DoLoop()
*/
tp = (RedialTimer.state == TIMER_RUNNING)? &timeout : NULL;
i = select(tun_in+10, &rfds, &wfds, &efds, tp);
#else
i = select(tun_in+10, &rfds, &wfds, &efds, NULL);
#endif
if (i == 0) {
continue;
}
if (i < 0) {
if (errno == EINTR)
continue;
perror("select");
break;
}
@ -596,6 +652,8 @@ DoLoop()
ModemStartOutput(modem);
}
if (FD_ISSET(modem, &rfds)) { /* something to read from modem */
if (LcpFsm.state <= ST_CLOSED)
usleep(10000);
n = read(modem, rbuff, sizeof(rbuff));
if ((mode & MODE_DIRECT) && n <= 0) {
DownConnection();
@ -668,12 +726,9 @@ DoLoop()
if (DialModem()) {
sleep(1); /* little pause to allow peer starts */
ModemTimeout();
ModemTimeout();
PacketMode();
} else {
#ifdef notdef
Cleanup(EX_DIAL);
#endif
CloseModem();
/* Dial failed. Keep quite during redial wait period. */
/* XXX: We shoud implement re-dial */
@ -689,5 +744,10 @@ DoLoop()
IpEnqueue(pri, rbuff, n);
}
}
#ifdef SIGALRM
itimer.it_value.tv_usec = itimer.it_value.tv_sec = 0;
setitimer(ITIMER_REAL, &itimer, NULL);
signal(SIGALRM, SIG_DFL);
#endif
logprintf("job done.\n");
}

View File

@ -18,8 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
* TODO:
*
*/
#include "defs.h"

View File

@ -55,13 +55,13 @@ 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 int plength __P((struct mbuf *bp));
extern struct mbuf *mballoc __P((int cnt, int type));
extern struct mbuf *mbfree __P((struct mbuf *bp));
extern void pfree __P((struct mbuf *bp));
extern void mbwrite __P((struct mbuf *bp, u_char *ptr, int cnt));
extern struct mbuf *mbread __P((struct mbuf *bp, u_char *ptr, int cnt));
extern void DumpBp __P((struct mbuf *bp));
extern void Enqueue __P((struct mqueue *queue, struct mbuf *bp));
extern struct mbuf *Dequeue __P((struct mqueue *queue));
#endif

View File

@ -1,29 +1,29 @@
/*
* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*
* $Id:$
*
*
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "global.h"

View File

@ -18,18 +18,25 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
*/
#include "fsm.h"
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include "hdlc.h"
#include "lcp.h"
#include "modem.h"
#include "vars.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
#define O_NONBLOCK O_NDELAY
#endif
#endif
extern int DoChat();
static int mbits; /* Current DCD status */
@ -86,6 +93,113 @@ struct mqueue *queue;
return(bp);
}
static struct speeds{
int nspeed;
speed_t speed;
} speeds[] = {
#ifdef B50
{ 50, B50, },
#endif
#ifdef B75
{ 75, B75, },
#endif
#ifdef B110
{ 110, B110, },
#endif
#ifdef B134
{ 134, B134, },
#endif
#ifdef B150
{ 150, B150, },
#endif
#ifdef B200
{ 200, B200, },
#endif
#ifdef B300
{ 300, B300, },
#endif
#ifdef B600
{ 600, B600, },
#endif
#ifdef B1200
{ 1200, B1200, },
#endif
#ifdef B1800
{ 1800, B1800, },
#endif
#ifdef B2400
{ 2400, B2400, },
#endif
#ifdef B4800
{ 4800, B4800, },
#endif
#ifdef B9600
{ 9600, B9600, },
#endif
#ifdef B19200
{ 19200, B19200, },
#endif
#ifdef B38400
{ 38400, B38400, },
#endif
#ifndef POSIX_SOURCE
#ifdef B7200
{ 7200, B7200, },
#endif
#ifdef B14400
{ 14400, B14400, },
#endif
#ifdef B28800
{ 28800, B28800, },
#endif
#ifdef B57600
{ 57600, B57600, },
#endif
#ifdef B76800
{ 76800, B76800, },
#endif
#ifdef B115200
{ 115200, B115200, },
#endif
#ifdef B230400
{ 230400, B230400, },
#endif
#ifdef EXTA
{ 19200, EXTA, },
#endif
#ifdef EXTB
{ 38400, EXTB, },
#endif
#endif /*_POSIX_SOURCE */
{ 0, 0 }
};
int SpeedToInt(speed)
speed_t speed;
{
struct speeds *sp;
for (sp = speeds; sp->nspeed; sp++) {
if (sp->speed == speed) {
return(sp->nspeed);
}
}
return 0;
}
speed_t IntToSpeed(nspeed)
int nspeed;
{
struct speeds *sp;
for (sp = speeds; sp->nspeed; sp++) {
if (sp->nspeed == nspeed) {
return(sp->speed);
}
}
return B0;
}
static time_t uptime;
void
@ -132,12 +246,13 @@ ModemTimeout()
}
} else {
if (!Online) {
online:
time(&uptime);
LogPrintf(LOG_PHASE, "Connected!\n");
mbits = TIOCM_CD;
connect_count++;
connect_time = 0;
} else if (uptime == 0) {
time(&uptime);
}
}
}
@ -188,10 +303,10 @@ char *str;
val = GetParityValue(str);
if (val > 0) {
VarParity = val;
ioctl(modem, TIOCGETA, &rstio);
tcgetattr(modem, &rstio);
rstio.c_cflag &= ~(CSIZE|PARODD|PARENB);
rstio.c_cflag |= val;
ioctl(modem, TIOCSETA, &rstio);
tcsetattr(modem, TCSADRAIN, &rstio);
}
return(val);
}
@ -254,7 +369,7 @@ int mode;
mbits = 0;
if (mode & MODE_DIRECT) {
if (isatty(0))
modem = open("/dev/tty", O_RDWR|O_NONBLOCK);
modem = open(ctermid(NULL), O_RDWR|O_NONBLOCK);
} else if (modem == 0) {
if (strncmp(VarDevice, "/dev", 4) == 0) {
uucplock = rindex(VarDevice, '/')+1;
@ -295,8 +410,11 @@ int mode;
* the one desired for further operation. In this implementation,
* we assume that modem is configuted to use CTS/RTS flow control.
*/
if (dev_is_modem = isatty(modem)) {
ioctl(modem, TIOCGETA, &rstio);
dev_is_modem = isatty(modem) || DEV_IS_SYNC;
if (DEV_IS_SYNC)
sleep(1);
if (dev_is_modem && !DEV_IS_SYNC) {
tcgetattr(modem, &rstio);
#ifdef DEBUG
logprintf("## modem = %d\n", modem);
logprintf("modem (get): iflag = %x, oflag = %x, cflag = %x\n",
@ -314,7 +432,7 @@ int mode;
*/
rstio.c_cflag &= ~(CSIZE|PARENB|PARODD);
rstio.c_cflag |= VarParity;
rstio.c_ispeed = rstio.c_ospeed = VarSpeed;
cfsetspeed(&rstio, IntToSpeed(VarSpeed));
}
rstio.c_iflag |= (IGNBRK | ISTRIP | IGNPAR | IXON | IXOFF);
rstio.c_iflag &= ~(BRKINT|ICRNL|IXANY|IMAXBEL);
@ -328,19 +446,20 @@ int mode;
rstio.c_cc[VMIN] = 1;
rstio.c_cc[VTIME] = 0;
#endif
ioctl(modem, TIOCSETA, &rstio);
tcsetattr(modem, TCSADRAIN, &rstio);
#ifdef DEBUG
logprintf("modem (put): iflag = %x, oflag = %x, cflag = %x\n",
rstio.c_iflag, rstio.c_oflag, rstio.c_cflag);
#endif
if (!(mode & MODE_DIRECT))
ioctl(modem, TIOCMGET, &mbits);
#ifdef DEBUG
ioctl(modem, TIOCMGET, &mbits);
fprintf(stderr, "modem control = %o\n", mbits);
#endif
oldflag = fcntl(modem, F_GETFL, 0);
fcntl(modem, F_SETFL, oldflag & ~O_NDELAY);
fcntl(modem, F_SETFL, oldflag & ~O_NONBLOCK);
}
StartModemTimer();
@ -352,8 +471,8 @@ ModemSpeed()
{
struct termios rstio;
ioctl(modem, TIOCGETA, &rstio);
return(rstio.c_ispeed);
tcgetattr(modem, &rstio);
return(SpeedToInt(cfgetispeed(&rstio)));
}
static struct termios modemios;
@ -368,7 +487,7 @@ int modem;
struct termios rstio;
int oldflag;
if (!isatty(modem))
if (!isatty(modem) || DEV_IS_SYNC)
return(0);
if (!(mode & MODE_DIRECT) && modem && !Online) {
#ifdef DEBUG
@ -378,14 +497,14 @@ int modem;
return(-1);
#endif
}
ioctl(modem, TIOCGETA, &rstio);
tcgetattr(modem, &rstio);
modemios = rstio;
rstio.c_cflag &= ~(CSIZE|PARENB|PARODD);
rstio.c_cflag |= CS8;
rstio.c_iflag &= ~(ISTRIP|IXON|IXOFF|BRKINT|ICRNL|INLCR);
ioctl(modem, TIOCSETA, &rstio);
tcsetattr(modem, TCSADRAIN, &rstio);
oldflag = fcntl(modem, F_GETFL, 0);
fcntl(modem, F_SETFL, oldflag | O_NDELAY);
fcntl(modem, F_SETFL, oldflag | O_NONBLOCK);
#ifdef DEBUG
oldflag = fcntl(modem, F_GETFL, 0);
logprintf("modem (put2): iflag = %x, oflag = %x, cflag = %x\n",
@ -402,9 +521,9 @@ int modem;
int oldflag;
if (isatty(modem)) {
ioctl(modem, TIOCSETA, &modemios);
tcsetattr(modem, TCSADRAIN, &modemios);
oldflag = fcntl(modem, F_GETFL, 0);
fcntl(modem, F_SETFL, oldflag & ~O_NDELAY);
fcntl(modem, F_SETFL, oldflag & ~O_NONBLOCK);
}
}
@ -412,7 +531,7 @@ void
HangupModem(flag)
int flag;
{
int n = 0;
struct termios tio;
if (!isatty(modem)) {
mbits &= ~TIOCM_DTR;
@ -421,9 +540,15 @@ int flag;
return;
}
if (Online) {
if (modem && Online) {
mbits &= ~TIOCM_DTR;
#ifdef __bsdi__ /* not a POSIX way */
ioctl(modem, TIOCMSET, &mbits);
#else
tcgetattr(modem, &tio);
cfsetspeed(&tio, B0);
tcsetattr(modem, TCSANOW, &tio);
#endif
sleep(1);
#ifdef notdef
mbits &= ~TIOCM_CD;
@ -436,14 +561,20 @@ int flag;
if (modem && (flag || !(mode & MODE_DEDICATED))) {
ModemTimeout(); /* XXX */
StopTimer(&ModemTimer); /* XXX */
ioctl(modem, TIOCFLUSH, &n);
tcflush(modem, TIOCFLUSH);
UnrawModem(modem);
close(modem);
(void) uu_unlock(uucplock);
modem = 0; /* Mark as modem has closed */
} else {
} else if (modem) {
mbits |= TIOCM_DTR;
#ifndef notyet
ioctl(modem, TIOCMSET, &mbits);
#else
tcgetattr(modem, &ts);
cfsetspeed(&ts, IntToSpeed(VarSpeed));
tcsetattr(modem, TCSADRAIN, &ts);
#endif
}
}
@ -471,6 +602,21 @@ int count;
Enqueue(&OutputQueues[pri], bp);
}
void
ModemOutput(pri, bp)
int pri;
struct mbuf *bp;
{
struct mbuf *wp;
int len;
len = plength(bp);
wp = mballoc(len, MB_MODEM);
mbread(bp, MBUF_CTOP(wp), len);
Enqueue(&OutputQueues[pri], wp);
ModemStartOutput(modem);
}
int
ModemQlen()
{
@ -514,7 +660,7 @@ int fd;
}
if (modemout) {
nb = modemout->cnt;
if (nb > 300) nb = 300;
if (nb > 1600) nb = 1600;
if (fd == 0) fd = 1;
nw = write(fd, MBUF_CTOP(modemout), nb);
#ifdef QDEBUG
@ -560,9 +706,16 @@ DialModem()
int
ShowModemStatus()
{
#ifdef TIOCOUTQ
int nb;
#endif
printf("device: %s speed: ", VarDevice);
if (DEV_IS_SYNC)
printf("sync\n");
else
printf("%d\n", VarSpeed);
printf("device: %s speed: %d\n", VarDevice, VarSpeed);
switch (VarParity & CSIZE) {
case CS7:
printf("cs7, ");
@ -582,8 +735,10 @@ ShowModemStatus()
printf("fd = %d, modem control = %o\n", modem, mbits);
#endif
printf("connect count: %d\n", connect_count);
#ifdef TIOCOUTQ
ioctl(modem, TIOCOUTQ, &nb);
printf("outq: %d\n", nb);
#endif
printf("DialScript = %s\n", VarDialScript);
printf("LoginScript = %s\n", VarLoginScript);
printf("PhoneNumber = %s\n", VarPhone);

View File

@ -15,23 +15,26 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
* $Id: modem.h,v 1.1.1.1 1995/01/31 06:29:56 amurai Exp $
*
* TODO:
*/
#ifndef _MODEM_H_
#define _MODEM_H_
#include <termios.h>
#include "mbuf.h"
#include "cdefs.h"
extern int RawModem(int);
extern void UnrawModem(int);
extern void UpModem(int);
extern void DownModem(int);
extern void WriteModem(int, char *, int);
extern void ModemStartOutput(int);
extern int OpenModem(int);
extern int ModemSpeed(void);
extern int ModemQlen(void);
extern int DialModem(void);
extern int RawModem __P((int));
extern void UnrawModem __P((int));
extern void UpModem __P((int));
extern void DownModem __P((int));
extern void WriteModem __P((int, char *, int));
extern void ModemStartOutput __P((int));
extern int OpenModem __P((int));
extern int ModemSpeed __P((void));
extern int ModemQlen __P((void));
extern int DialModem __P((void));
#endif

View File

@ -16,20 +16,15 @@
* 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:
*
*/
#include "fsm.h"
#include <sys/param.h>
#include <sys/socket.h>
#include <net/route.h>
#if __FreeBSD__ >= 2
#include <osreldate.h>
#endif
#if defined(__NetBSD__) || _BSDI_VERSION >= 199312 || __FreeBSD_version >=199412
#if BSD >= 199206 || _BSDI_VERSION >= 199312
#include <sys/select.h>
#endif
#include <sys/ioctl.h>
@ -39,6 +34,7 @@
#include <errno.h>
#include "ipcp.h"
#include "os.h"
#include "vars.h"
static struct ifaliasreq ifra;
static struct ifreq ifrq;
@ -69,7 +65,10 @@ int updown;
}
if (updown == 0) {
if (Enabled(ConfProxy))
cifproxyarp(s, oldhis.s_addr);
if (oldmine.s_addr == 0 && oldhis.s_addr == 0) {
close(s);
return(0);
}
bzero(&ifra.ifra_addr, sizeof(ifra.ifra_addr));
@ -80,6 +79,7 @@ int updown;
#endif
if (ioctl(s, SIOCDIFADDR, &ifra) < 0) {
perror("SIOCDIFADDR");
close(s);
return(-1);
}
@ -147,8 +147,11 @@ int updown;
#endif
} else if (ioctl(s, SIOCAIFADDR, &ifra) < 0) {
perror("SIOCAIFADDR");
close(s);
return(-1);
}
if (Enabled(ConfProxy))
sifproxyarp(s, hisaddr.s_addr);
}
close(s);
return(0);
@ -235,15 +238,10 @@ OsSetInterfaceParams(type, mtu, speed)
int type, mtu, speed;
{
struct tuninfo info;
#if __FreeBSD__ >= 2
info.tif_type = type;
info.tif_mtu = mtu;
info.tif_baudrate = speed;
#else
info.if_type = type;
info.if_mtu = mtu;
info.if_baudrate = speed;
#endif
info.type = type;
info.mtu = mtu;
info.baudrate = speed;
if (ioctl(tun_out, TUNSIFINFO, &info) < 0)
perror("TUNSIFINFO");
}

View File

@ -15,20 +15,21 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
* $Id: os.h,v 1.1.1.1 1995/01/31 06:29:56 amurai Exp $
*
* TODO:
*/
#ifndef _OS_H_
#define _OS_H_
#include "cdefs.h"
int OsSetIpaddress(struct in_addr myaddr, struct in_addr hisaddr, struct in_addr netmask);
int OsInterfaceDown(int);
void OsSetInterfaceParams(int type, int mtu, int speed);
int OpenTunnel(int *);
void OsCloseLink(int flag);
void OsLinkup(void), OsLinkdown(void);
void OsSetRoute();
void DeleteIfRoutes(int);
int OsSetIpaddress __P((struct in_addr myaddr, struct in_addr hisaddr, struct in_addr netmask));
int OsInterfaceDown __P((int));
void OsSetInterfaceParams __P((int type, int mtu, int speed));
int OpenTunnel __P((int *));
void OsCloseLink __P((int flag));
void OsLinkup __P((void)), OsLinkdown __P((void));
void OsSetRoute __P((int, struct in_addr, struct in_addr, struct in_addr));
void DeleteIfRoutes __P((int));
#endif

View File

@ -19,9 +19,8 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
* o Imprement retransmission timer.
*/
#include "fsm.h"
#include "lcp.h"
@ -30,15 +29,19 @@
#include "hdlc.h"
#include "lcpproto.h"
#include "phase.h"
#include "auth.h"
static char *papcodes[] = {
"???", "REQUEST", "ACK", "NAK"
};
static int papid;
struct authinfo AuthPapInfo = {
SendPapChallenge,
};
void
SendPapChallenge()
SendPapChallenge(papid)
int papid;
{
struct fsmheader lh;
struct mbuf *bp;
@ -50,10 +53,10 @@ SendPapChallenge()
plen = namelen + keylen + 2;
#ifdef DEBUG
logprintf("namelen = %d, keylen = %d\n", namelen, keylen);
LogPrintf(LOG_PHASE, "PAP: %s (%s)\n", VarAuthName, VarAuthKey);
#endif
LogPrintf(LOG_PHASE, "PAP: %s (%s)\n", VarAuthName, VarAuthKey);
lh.code = PAP_REQUEST;
lh.id = ++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));
@ -105,7 +108,9 @@ u_char *name, *key;
klen = *key;
*key++ = 0;
key[klen] = 0;
#ifdef DEBUG
logprintf("name: %s (%d), key: %s (%d)\n", name, nlen, key, klen);
#endif
return(AuthValidate(SECRETFILE, name, key));
}
@ -139,6 +144,7 @@ struct mbuf *bp;
}
break;
case PAP_ACK:
StopAuthTimer(&AuthPapInfo);
cp = (u_char *)(php + 1);
len = *cp++;
cp[len] = 0;
@ -150,6 +156,7 @@ struct mbuf *bp;
}
break;
case PAP_NAK:
StopAuthTimer(&AuthPapInfo);
cp = (u_char *)(php + 1);
len = *cp++;
cp[len] = 0;

View File

@ -30,22 +30,29 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* $Id:$
*
* @(#)pathnames.h 5.2 (Berkeley) 6/1/90
*
* $Id: pathnames.h,v 1.1.1.1 1995/01/31 06:29:56 amurai Exp $
*/
#ifdef __bsdi__
#include <paths.h>
#endif
#define _PATH_ACULOG "/var/log/aculog"
#if defined (__FreeBSD__)
#if defined(__NetBSD__) || defined(__FreeBSD__)
#define _PATH_LOCKDIRNAME "/var/spool/lock/LCK..%s"
#else
#define _PATH_LOCKDIRNAME "/var/spool/uucp/LCK..%s"
#endif
#endif
#ifdef notdef
#define _PATH_LOCKDIRNAME "/var/spool/uucp/LCK/LCK..%s"
#endif
#define _PATH_PHONES "/etc/phones"
#define _PATH_REMOTE "/etc/remote"
#if defined(__FreeBSD__)
#define _PATH_PPP "/etc/ppp"
#else
#define _PATH_PPP "/etc"
#endif

View File

@ -15,13 +15,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
* $Id: phase.h,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
*
* TODO:
*/
#ifndef _PHASE_H_
#define _PHASE_H_
#include "cdefs.h"
#define PHASE_DEAD 0 /* Link is dead */
#define PHASE_ESTABLISH 1 /* Establishing link */
@ -31,6 +32,6 @@
int phase; /* Curent phase */
extern void NewPhase(int);
extern void NewPhase __P((int));
extern char *PhaseNames[];
#endif

View File

@ -1,5 +1,5 @@
.\" manual page [] for ppp 0.93
.\" $Id:$
.\" manual page [] for ppp 0.94 beta2 + alpha
.\" $Id: ppp.8,v 1.1.1.1 1995/01/31 06:29:58 amurai Exp $
.\" SH section heading
.\" SS subsection heading
.\" LP paragraph
@ -17,37 +17,57 @@ ppp \- Point to Point Protocol (aka iijppp)
]
.SH DESCRIPTION
.LP
This is user process \fIPPP\fR software package. Normally, \fIPPP\fR is implemented as a part of kernel and hard to debug and/or modify its behavior. However, in this implementation, \fIPPP\fR is implemented as a user process with the help of tunnel device driver.
This is user process \fIPPP\fR software package. Normally, \fIPPP\fR
is implemented as a part of kernel and hard to debug and/or modify its
behavior. However, in this implementation, \fIPPP\fR is implemented as
a user process with the help of tunnel device driver.
.LP
.SH Major Features
.TP 2
o
Provide interactive user interface. Using its command mode, user can easily enter commands to establish the connection with the peer, check the status of connection, and close the connection.
o Provide interactive user interface. Using its command mode, user can
easily enter commands to establish the connection with the peer, check
the status of connection, and close the connection. And now, all
functions has password protected if describe your hostname/password in
secret file or exist secret file itself.
.TP 2
o
Supports both of manual and automatic dialing. Interactive mode has ``term'' command which enables you to talk to your modem directory. When your modem is connected to the peer, and it starts to speak \fIPPP\fR, \fIPPP\fR software detects it and turns into packet mode automatically. Once you have convinced how to connect with the peer, you can write chat script to define necessary dialing and login procedure for later convenience.
o Supports both of manual and automatic dialing. Interactive mode has
``term'' command which enables you to talk to your modem
directory. When your modem is connected to the peer, and it starts to
speak \fIPPP\fR, \fIPPP\fR software detects it and turns into packet
mode automatically. Once you have convinced how to connect with the
peer, you can write chat script to define necessary dialing and login
procedure for later convenience.
.TP 2
o
Supports on-demand dialup capability. By using auto mode, \fIPPP\fR program will act as a daemon and wait for the packet send to the peer. Once packet is found, daemon automatically dials and establish the connection.
o Supports on-demand dialup capability. By using auto mode, \fIPPP\fR
program will act as a daemon and wait for the packet send to the peer.
Once packet is found, daemon automatically dials and establish the
connection.
.TP 2
o
Can act as server which accept incoming \fIPPP\fR connection.
Can act as server which accept incoming \fIPPP\fR connection.
.TP 2
o
Supports PAP and CHAP authentification.
.TP 2
o
Supports packet filtering. User can define three kinds of filters; ifilter for incoming packet, ofilter for outgoing packet and dfilter to define dialing trigger packet.
o
Supports Proxy Arp.
.TP 2
o
Tunnel driver supports bpf. That is, user can use tcpdump to check packet flow over the \fIPPP\fR link.
o Supports packet filtering. User can define four kinds of filters;
ifilter for incoming packet, ofilter for outgoing packet, dfilter to
define dialing trigger packet and afilter to keep alive a connection
by trigger packet.
.TP 2
o Tunnel driver supports bpf. That is, user can use tcpdump to check
packet flow over the \fIPPP\fR link.
.TP 2
o
@ -58,23 +78,27 @@ o
Supports IETF draft Predictor-1 compression.
.TP 2
o
Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also available on the net.
o Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also
available on the net.
.SH MANUAL DIALING
.LP
% ppp
User Process PPP written by Toshiharu OHNO.
-- If you write your hostname and password in ppp.secret,
you can't do anything even quit command --
ppp on tama> quit
what ?
ppp on tama> pass <password>
-- You can specify modem and device name using following commands.
ppp> set line /dev/cua01
ppp> set speed 38400
ppp> set parity even
ppp> show modem
ppp ON tama> set line /dev/cua01
ppp ON tama> set speed 38400
ppp ON tama> set parity even
ppp ON tama> show modem
-- Modem related parameters are shown in here
ppp>
ppp ON tama>
-- Use term command to talk with your modem
ppp> term
ppp ON tama> term
at
OK
atdt123456
@ -86,44 +110,46 @@ Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also available on
-- When peer start to speak PPP, the program will detect it
-- automatically and back to command mode.
ppp>
ppp on tama>
\fBPPP\fR>
-- NOW, you are get connected !! Note that prompt has changed to
-- capital letters
PPP> show lcp
PPP ON tama> show lcp
-- You'll see LCP status --
PPP> show ipcp
PPP ON tama> show ipcp
-- You'll see IPCP status --
-- At this point, your machine has host route to the peer.
-- If your want to add default route entry, then enter
PPP> add 0 0 HISADDR
PPP ON tama> add 0 0 HISADDR
-- Here string `HISADDR' represents IP address of connected peer.
PPP>
PPP ON tama>
-- Use applications (i.e. ping, telnet, ftp) in other windows
PPP> show log
PPP ON tama> show log
-- Gives you some logging messages
PPP> close
PPP ON tama> close
-- Connection is closed, and modem will be hanged.
ppp> quit
ppp ON tama> quit
%
.LP
.SH AUTOMATIC DIALING
.LP
To use automatic dialing, you must prepare Dial and Login chat script.See example definition found in ppp.conf.sample(Format of ppp.conf is pretty simple.)
.LP
To use automatic dialing, you must prepare Dial and Login chat script.
See example definition found in ppp.conf.sample (Format of ppp.conf is
pretty simple.)
.TP 2
o
@ -142,7 +168,10 @@ o
Command line must contains space or tab at first column.
.LP
If ppp.conf is ready, specify destination label name when you invoke ppp. Commands associated with destination label is executed when ppp command is invoked. Note that commands associated with ``default'' label is ALWAYS executed.
If ppp.conf is ready, specify destination label name when you invoke
ppp. Commands associated with destination label is executed when ppp
command is invoked. Note that commands associated with ``default''
label is ALWAYS executed.
Once connection is made, you'll find that prompt is changed to
@ -150,40 +179,52 @@ Once connection is made, you'll find that prompt is changed to
% ppp pm2
...
ppp> dial
ppp ON tama> dial
dial OK!
login OK!
PPP>
PPP ON tama>
If ppp.linkup file is available, its contents are executed when
\fIPPP\fR link is connected. See example which add default route.
The string HISADDR matches with IP address of connected peer.
If ppp.linkup file is available, its contents are executed when \fIPPP\fR link is connected. See example which add default route. The string HISADDR matches with IP address of connected peer.
.LP
.SH DAIL ON DEMAND
.LP
To play with demand dialing, you must use -auto option. Also, you must specify destination label with proper setup in ppp.conf. It must contain ``ifaddr'' command to define peer's IP address. (refer /etc/ppp/ppp.conf.sample)
.LP
To play with demand dialing, you must use -auto option. Also, you
must specify destination label with proper setup in ppp.conf. It must
contain ``ifaddr'' command to define peer's IP address. (refer
/etc/ppp/ppp.conf.sample)
% ppp -auto pm2demand
...
%
.LP
When -auto is specified, \fIPPP\fR program works as a daemon. But, you are still able to use command features to check its behavior.
.LP
When -auto is specified, \fIPPP\fR program works as a daemon. But,
you are still able to use command features to check its behavior.
% telnet localhost 3000
...
PPP> show ipcp
PPP on tama> show ipcp
....
.LP
Each ppp has associated port number, which is computed as "3000 + tunnel_device_number". If 3000 is not good base number, edit defs.h. When packet toward to remote network is detected, \fIPPP\fR will take dialing action and try to connect with the peer. If dialing is failed, program will wait for 30 seconds. Once this hold time expired, another trigger packet cause dialing action. Note that automatic re-dialing is NOT implemented.
.LP
Each ppp has associated port number, which is computed as "3000 +
tunnel_device_number". If 3000 is not good base number, edit defs.h.
When packet toward to remote network is detected, \fIPPP\fR will take
dialing action and try to connect with the peer. If dialing is failed,
program will wait for 30 seconds. Once this hold time expired, another
trigger packet cause dialing action. Note that automatic re-dialing is
NOT implemented.
To terminate program, use
PPP> close
PPP on tama> close
\fBppp\fR> quit all
.LP
@ -291,18 +332,26 @@ ppp:*:21:0:PPP Login User:/home/ppp:/usr/local/bin/ppplogin
.SH Controlling IP address
.LP
\fIPPP\fR uses IPCP to negotiate IP addresses. Each side of node informs IP address that willing to use to the peer, and if requested IP address is acceptable, \fIPPP\fR returns ACK to requester. Otherwise, \fIPPP\fR returns NAK to suggest the peer to use different IP address. When both side of nodes agrees to accept the received request (and send ACK), IPCP is reached to open state and network level connection is established.
.LP
\fIPPP\fR uses IPCP to negotiate IP addresses. Each side of node
informs IP address that willing to use to the peer, and if requested
IP address is acceptable, \fIPPP\fR returns ACK to
requester. Otherwise, \fIPPP\fR returns NAK to suggest the peer to use
different IP address. When both side of nodes agrees to accept the
received request (and send ACK), IPCP is reached to open state and
network level connection is established.
.LP
To control, this IPCP behavior, this implementation has ``set ifaddr'' to define MY and HIS IP address.
.LP
To control, this IPCP behavior, this implementation has ``set
ifaddr'' to define MY and HIS IP address.
.TP3
ifaddr src_addr dst_addr
.LP
Where, src_addr is the IP address that my side is willing to use, and dst_addr is the IP address which his side should use.
Where, src_addr is the IP address that my side is willing to use, and
dst_addr is the IP address which his side should use.
.LP
.TP3
@ -311,46 +360,51 @@ ifaddr 192.244.177.38 192.244.177.2
For example, above specification means
.TP
o
I strongly want to use 192.244.177.38 as my side. I'll disagree when peer suggest me to use other addresses.
o I strongly want to use 192.244.177.38 as my side. I'll disagree when
peer suggest me to use other addresses.
.TP 2
o
I strongly insists peer to use 192.244.177.2 as his side address. I don't permit him to use any IP address but 192.244.177.2. When peer request other IP address, I always suggest him to use 192.244.177.2.
o I strongly insists peer to use 192.244.177.2 as his side address. I
don't permit him to use any IP address but 192.244.177.2. When peer
request other IP address, I always suggest him to use 192.244.177.2.
.LP
This is all right, when each side has pre-determined IP address.
However, it is often the case one side is acting as a server which
controls IP address and the other side should obey the direction from him.
In order to allow more flexible behavior, `ifaddr' command allows user to specify IP address more loosely.
.LP
However, it is often the case one side is acting as a server which
controls IP address and the other side should obey the direction from
him. In order to allow more flexible behavior, `ifaddr' command
allows user to specify IP address more loosely.
.TP 2
ifaddr 192.244.177.38/24 192.244.177.2/20
Number followed by slash (/) represents number of bits significant in IP address. That is, this example means
Number followed by slash (/) represents number of bits significant in
IP address. That is, this example means
.TP 2
o
I'd like to use 192.244.177.38 as my side address, if it is possible. But I also accept any IP address between 192.244.177.0 and 192.244.177.255.
o I'd like to use 192.244.177.38 as my side address, if it is
possible. But I also accept any IP address between 192.244.177.0 and
192.244.177.255.
.TP 2
o
I'd like to make him to use 192.244.177.2 as his side address. But I also permit him to use any IP address between 192.244.176.0 and 192.244.191.255.
o I'd like to make him to use 192.244.177.2 as his side address. But
I also permit him to use any IP address between 192.244.176.0 and
192.244.191.255.
Notes:
.TP 2
o
As you may have already noticed, 192.244.177.2 is equivalent to say 192.244.177.2/32.
o As you may have already noticed, 192.244.177.2 is equivalent to say
192.244.177.2/32.
.TP 2
o
As an exception, 0 is equivalent to 0.0.0.0/0. Means, I have no idea about IP address and obey what he says.
o As an exception, 0 is equivalent to 0.0.0.0/0. Means, I have no idea
about IP address and obey what he says.
.TP 2
o
192.244.177.2/0 means that I'll accept/permit any IP address but I'll try to insist to use 192.244.177.2 at first.
o 192.244.177.2/0 means that I'll accept/permit any IP address but
I'll try to insist to use 192.244.177.2 at first.
.SH Connecting with service provider
@ -388,14 +442,15 @@ add next lines into your ppp.conf.
.TP 3
.LP
Please refer /etc/ppp/example/ppp.conf.iij for some real examples.
Please refer /etc/ppp/ppp.conf.iij for some real examples.
.LP
.SH Logging facility
.LP
\fI\fIPPP\fR\fR is able to generate following level log info as /var/log/ppp.log
.LP
\fI\fIPPP\fR\fR is able to generate following level log info as
/var/log/ppp.log
.TP
.B Phase
@ -413,16 +468,16 @@ Generate LCP/IPCP packet trace
.B TCP/IP
Dump TCP/IP packet
.TP
HDLC
.B HDLC
Dump HDLC packet in hex
.TP
.B Async
Dump async level packet in hex
.LP
``set debug'' command allows you to set logging output level,
and multiple levels can be specified.
Default is equivalent to ``set debug phase lcp''.
``set debug'' command allows you to set logging output level, and
multiple levels can be specified. Default is equivalent to ``set
debug phase lcp''.
.SH For more details
@ -449,13 +504,12 @@ Please contact to author if you need old driver code.
.SH FILES
.LP
\fIPPP\fR may refers three files, ppp.conf, ppp.linkup and ppp.secret.
These files are placed in /etc/ppp,
but user can create his own files under HOME directory as .ppp.conf,
.ppp.linkup and .ppp.secret.
the ppp always try to consult to user's personal setup first.
These files are placed in /etc/ppp, but user can create his own files
under HOME directory as .ppp.conf,.ppp.linkup and .ppp.secret.the ppp
always try to consult to user's personal setup first.
.TP
.B $HOME/ppp/.ppp.[linkup|secret]
.B $HOME/ppp/.ppp.[conf|linkup|secret]
User depend configuration files.
.TP
@ -481,12 +535,10 @@ Logging and debug information file.
tty port locking file.
.SH BUGS
A Proxy arp is not support, yet.
The TTS is little bit longer than pppd2.1, it's under improving ;-)
.SH HISTORY
This programm has deliverd into core since FreeBSD-2.1
by Atsushi Murai (amurai@spec.co.jp).
This programm has deliverd into core since FreeBSD-2.1 by Atsushi
Murai (amurai@spec.co.jp).
.SH AUTHORS
Toshiharu OHNO (tony-o@iij.ad.jp)

View File

@ -1,5 +1,5 @@
.\" manual page [] for ppp 0.93
.\" $Id:$
.\" manual page [] for ppp 0.94 beta2 + alpha
.\" $Id: ppp.8,v 1.1.1.1 1995/01/31 06:29:58 amurai Exp $
.\" SH section heading
.\" SS subsection heading
.\" LP paragraph
@ -17,37 +17,57 @@ ppp \- Point to Point Protocol (aka iijppp)
]
.SH DESCRIPTION
.LP
This is user process \fIPPP\fR software package. Normally, \fIPPP\fR is implemented as a part of kernel and hard to debug and/or modify its behavior. However, in this implementation, \fIPPP\fR is implemented as a user process with the help of tunnel device driver.
This is user process \fIPPP\fR software package. Normally, \fIPPP\fR
is implemented as a part of kernel and hard to debug and/or modify its
behavior. However, in this implementation, \fIPPP\fR is implemented as
a user process with the help of tunnel device driver.
.LP
.SH Major Features
.TP 2
o
Provide interactive user interface. Using its command mode, user can easily enter commands to establish the connection with the peer, check the status of connection, and close the connection.
o Provide interactive user interface. Using its command mode, user can
easily enter commands to establish the connection with the peer, check
the status of connection, and close the connection. And now, all
functions has password protected if describe your hostname/password in
secret file or exist secret file itself.
.TP 2
o
Supports both of manual and automatic dialing. Interactive mode has ``term'' command which enables you to talk to your modem directory. When your modem is connected to the peer, and it starts to speak \fIPPP\fR, \fIPPP\fR software detects it and turns into packet mode automatically. Once you have convinced how to connect with the peer, you can write chat script to define necessary dialing and login procedure for later convenience.
o Supports both of manual and automatic dialing. Interactive mode has
``term'' command which enables you to talk to your modem
directory. When your modem is connected to the peer, and it starts to
speak \fIPPP\fR, \fIPPP\fR software detects it and turns into packet
mode automatically. Once you have convinced how to connect with the
peer, you can write chat script to define necessary dialing and login
procedure for later convenience.
.TP 2
o
Supports on-demand dialup capability. By using auto mode, \fIPPP\fR program will act as a daemon and wait for the packet send to the peer. Once packet is found, daemon automatically dials and establish the connection.
o Supports on-demand dialup capability. By using auto mode, \fIPPP\fR
program will act as a daemon and wait for the packet send to the peer.
Once packet is found, daemon automatically dials and establish the
connection.
.TP 2
o
Can act as server which accept incoming \fIPPP\fR connection.
Can act as server which accept incoming \fIPPP\fR connection.
.TP 2
o
Supports PAP and CHAP authentification.
.TP 2
o
Supports packet filtering. User can define three kinds of filters; ifilter for incoming packet, ofilter for outgoing packet and dfilter to define dialing trigger packet.
o
Supports Proxy Arp.
.TP 2
o
Tunnel driver supports bpf. That is, user can use tcpdump to check packet flow over the \fIPPP\fR link.
o Supports packet filtering. User can define four kinds of filters;
ifilter for incoming packet, ofilter for outgoing packet, dfilter to
define dialing trigger packet and afilter to keep alive a connection
by trigger packet.
.TP 2
o Tunnel driver supports bpf. That is, user can use tcpdump to check
packet flow over the \fIPPP\fR link.
.TP 2
o
@ -58,23 +78,27 @@ o
Supports IETF draft Predictor-1 compression.
.TP 2
o
Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also available on the net.
o Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also
available on the net.
.SH MANUAL DIALING
.LP
% ppp
User Process PPP written by Toshiharu OHNO.
-- If you write your hostname and password in ppp.secret,
you can't do anything even quit command --
ppp on tama> quit
what ?
ppp on tama> pass <password>
-- You can specify modem and device name using following commands.
ppp> set line /dev/cua01
ppp> set speed 38400
ppp> set parity even
ppp> show modem
ppp ON tama> set line /dev/cua01
ppp ON tama> set speed 38400
ppp ON tama> set parity even
ppp ON tama> show modem
-- Modem related parameters are shown in here
ppp>
ppp ON tama>
-- Use term command to talk with your modem
ppp> term
ppp ON tama> term
at
OK
atdt123456
@ -86,44 +110,46 @@ Runs under BSDI-1.1 and FreeBSD-1.1. Patch for NeXTSTEP 3.2 is also available on
-- When peer start to speak PPP, the program will detect it
-- automatically and back to command mode.
ppp>
ppp on tama>
\fBPPP\fR>
-- NOW, you are get connected !! Note that prompt has changed to
-- capital letters
PPP> show lcp
PPP ON tama> show lcp
-- You'll see LCP status --
PPP> show ipcp
PPP ON tama> show ipcp
-- You'll see IPCP status --
-- At this point, your machine has host route to the peer.
-- If your want to add default route entry, then enter
PPP> add 0 0 HISADDR
PPP ON tama> add 0 0 HISADDR
-- Here string `HISADDR' represents IP address of connected peer.
PPP>
PPP ON tama>
-- Use applications (i.e. ping, telnet, ftp) in other windows
PPP> show log
PPP ON tama> show log
-- Gives you some logging messages
PPP> close
PPP ON tama> close
-- Connection is closed, and modem will be hanged.
ppp> quit
ppp ON tama> quit
%
.LP
.SH AUTOMATIC DIALING
.LP
To use automatic dialing, you must prepare Dial and Login chat script.See example definition found in ppp.conf.sample(Format of ppp.conf is pretty simple.)
.LP
To use automatic dialing, you must prepare Dial and Login chat script.
See example definition found in ppp.conf.sample (Format of ppp.conf is
pretty simple.)
.TP 2
o
@ -142,7 +168,10 @@ o
Command line must contains space or tab at first column.
.LP
If ppp.conf is ready, specify destination label name when you invoke ppp. Commands associated with destination label is executed when ppp command is invoked. Note that commands associated with ``default'' label is ALWAYS executed.
If ppp.conf is ready, specify destination label name when you invoke
ppp. Commands associated with destination label is executed when ppp
command is invoked. Note that commands associated with ``default''
label is ALWAYS executed.
Once connection is made, you'll find that prompt is changed to
@ -150,40 +179,52 @@ Once connection is made, you'll find that prompt is changed to
% ppp pm2
...
ppp> dial
ppp ON tama> dial
dial OK!
login OK!
PPP>
PPP ON tama>
If ppp.linkup file is available, its contents are executed when
\fIPPP\fR link is connected. See example which add default route.
The string HISADDR matches with IP address of connected peer.
If ppp.linkup file is available, its contents are executed when \fIPPP\fR link is connected. See example which add default route. The string HISADDR matches with IP address of connected peer.
.LP
.SH DAIL ON DEMAND
.LP
To play with demand dialing, you must use -auto option. Also, you must specify destination label with proper setup in ppp.conf. It must contain ``ifaddr'' command to define peer's IP address. (refer /etc/ppp/ppp.conf.sample)
.LP
To play with demand dialing, you must use -auto option. Also, you
must specify destination label with proper setup in ppp.conf. It must
contain ``ifaddr'' command to define peer's IP address. (refer
/etc/ppp/ppp.conf.sample)
% ppp -auto pm2demand
...
%
.LP
When -auto is specified, \fIPPP\fR program works as a daemon. But, you are still able to use command features to check its behavior.
.LP
When -auto is specified, \fIPPP\fR program works as a daemon. But,
you are still able to use command features to check its behavior.
% telnet localhost 3000
...
PPP> show ipcp
PPP on tama> show ipcp
....
.LP
Each ppp has associated port number, which is computed as "3000 + tunnel_device_number". If 3000 is not good base number, edit defs.h. When packet toward to remote network is detected, \fIPPP\fR will take dialing action and try to connect with the peer. If dialing is failed, program will wait for 30 seconds. Once this hold time expired, another trigger packet cause dialing action. Note that automatic re-dialing is NOT implemented.
.LP
Each ppp has associated port number, which is computed as "3000 +
tunnel_device_number". If 3000 is not good base number, edit defs.h.
When packet toward to remote network is detected, \fIPPP\fR will take
dialing action and try to connect with the peer. If dialing is failed,
program will wait for 30 seconds. Once this hold time expired, another
trigger packet cause dialing action. Note that automatic re-dialing is
NOT implemented.
To terminate program, use
PPP> close
PPP on tama> close
\fBppp\fR> quit all
.LP
@ -291,18 +332,26 @@ ppp:*:21:0:PPP Login User:/home/ppp:/usr/local/bin/ppplogin
.SH Controlling IP address
.LP
\fIPPP\fR uses IPCP to negotiate IP addresses. Each side of node informs IP address that willing to use to the peer, and if requested IP address is acceptable, \fIPPP\fR returns ACK to requester. Otherwise, \fIPPP\fR returns NAK to suggest the peer to use different IP address. When both side of nodes agrees to accept the received request (and send ACK), IPCP is reached to open state and network level connection is established.
.LP
\fIPPP\fR uses IPCP to negotiate IP addresses. Each side of node
informs IP address that willing to use to the peer, and if requested
IP address is acceptable, \fIPPP\fR returns ACK to
requester. Otherwise, \fIPPP\fR returns NAK to suggest the peer to use
different IP address. When both side of nodes agrees to accept the
received request (and send ACK), IPCP is reached to open state and
network level connection is established.
.LP
To control, this IPCP behavior, this implementation has ``set ifaddr'' to define MY and HIS IP address.
.LP
To control, this IPCP behavior, this implementation has ``set
ifaddr'' to define MY and HIS IP address.
.TP3
ifaddr src_addr dst_addr
.LP
Where, src_addr is the IP address that my side is willing to use, and dst_addr is the IP address which his side should use.
Where, src_addr is the IP address that my side is willing to use, and
dst_addr is the IP address which his side should use.
.LP
.TP3
@ -311,46 +360,51 @@ ifaddr 192.244.177.38 192.244.177.2
For example, above specification means
.TP
o
I strongly want to use 192.244.177.38 as my side. I'll disagree when peer suggest me to use other addresses.
o I strongly want to use 192.244.177.38 as my side. I'll disagree when
peer suggest me to use other addresses.
.TP 2
o
I strongly insists peer to use 192.244.177.2 as his side address. I don't permit him to use any IP address but 192.244.177.2. When peer request other IP address, I always suggest him to use 192.244.177.2.
o I strongly insists peer to use 192.244.177.2 as his side address. I
don't permit him to use any IP address but 192.244.177.2. When peer
request other IP address, I always suggest him to use 192.244.177.2.
.LP
This is all right, when each side has pre-determined IP address.
However, it is often the case one side is acting as a server which
controls IP address and the other side should obey the direction from him.
In order to allow more flexible behavior, `ifaddr' command allows user to specify IP address more loosely.
.LP
However, it is often the case one side is acting as a server which
controls IP address and the other side should obey the direction from
him. In order to allow more flexible behavior, `ifaddr' command
allows user to specify IP address more loosely.
.TP 2
ifaddr 192.244.177.38/24 192.244.177.2/20
Number followed by slash (/) represents number of bits significant in IP address. That is, this example means
Number followed by slash (/) represents number of bits significant in
IP address. That is, this example means
.TP 2
o
I'd like to use 192.244.177.38 as my side address, if it is possible. But I also accept any IP address between 192.244.177.0 and 192.244.177.255.
o I'd like to use 192.244.177.38 as my side address, if it is
possible. But I also accept any IP address between 192.244.177.0 and
192.244.177.255.
.TP 2
o
I'd like to make him to use 192.244.177.2 as his side address. But I also permit him to use any IP address between 192.244.176.0 and 192.244.191.255.
o I'd like to make him to use 192.244.177.2 as his side address. But
I also permit him to use any IP address between 192.244.176.0 and
192.244.191.255.
Notes:
.TP 2
o
As you may have already noticed, 192.244.177.2 is equivalent to say 192.244.177.2/32.
o As you may have already noticed, 192.244.177.2 is equivalent to say
192.244.177.2/32.
.TP 2
o
As an exception, 0 is equivalent to 0.0.0.0/0. Means, I have no idea about IP address and obey what he says.
o As an exception, 0 is equivalent to 0.0.0.0/0. Means, I have no idea
about IP address and obey what he says.
.TP 2
o
192.244.177.2/0 means that I'll accept/permit any IP address but I'll try to insist to use 192.244.177.2 at first.
o 192.244.177.2/0 means that I'll accept/permit any IP address but
I'll try to insist to use 192.244.177.2 at first.
.SH Connecting with service provider
@ -388,14 +442,15 @@ add next lines into your ppp.conf.
.TP 3
.LP
Please refer /etc/ppp/example/ppp.conf.iij for some real examples.
Please refer /etc/ppp/ppp.conf.iij for some real examples.
.LP
.SH Logging facility
.LP
\fI\fIPPP\fR\fR is able to generate following level log info as /var/log/ppp.log
.LP
\fI\fIPPP\fR\fR is able to generate following level log info as
/var/log/ppp.log
.TP
.B Phase
@ -413,16 +468,16 @@ Generate LCP/IPCP packet trace
.B TCP/IP
Dump TCP/IP packet
.TP
HDLC
.B HDLC
Dump HDLC packet in hex
.TP
.B Async
Dump async level packet in hex
.LP
``set debug'' command allows you to set logging output level,
and multiple levels can be specified.
Default is equivalent to ``set debug phase lcp''.
``set debug'' command allows you to set logging output level, and
multiple levels can be specified. Default is equivalent to ``set
debug phase lcp''.
.SH For more details
@ -449,13 +504,12 @@ Please contact to author if you need old driver code.
.SH FILES
.LP
\fIPPP\fR may refers three files, ppp.conf, ppp.linkup and ppp.secret.
These files are placed in /etc/ppp,
but user can create his own files under HOME directory as .ppp.conf,
.ppp.linkup and .ppp.secret.
the ppp always try to consult to user's personal setup first.
These files are placed in /etc/ppp, but user can create his own files
under HOME directory as .ppp.conf,.ppp.linkup and .ppp.secret.the ppp
always try to consult to user's personal setup first.
.TP
.B $HOME/ppp/.ppp.[linkup|secret]
.B $HOME/ppp/.ppp.[conf|linkup|secret]
User depend configuration files.
.TP
@ -481,12 +535,10 @@ Logging and debug information file.
tty port locking file.
.SH BUGS
A Proxy arp is not support, yet.
The TTS is little bit longer than pppd2.1, it's under improving ;-)
.SH HISTORY
This programm has deliverd into core since FreeBSD-2.1
by Atsushi Murai (amurai@spec.co.jp).
This programm has deliverd into core since FreeBSD-2.1 by Atsushi
Murai (amurai@spec.co.jp).
.SH AUTHORS
Toshiharu OHNO (tony-o@iij.ad.jp)

View File

@ -1,31 +1,12 @@
/*
* 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:
*/
#include "fsm.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "ccp.h"
/*
*
* $Id:$
*
* pred.c -- Test program for Dave Rand's rendition of the
* predictor algorithm
* Updated by: iand@labtam.labtam.oz.au (Ian Donaldson)

View File

@ -18,6 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*/
#include <sys/types.h>
#include <machine/endian.h>
@ -30,8 +31,7 @@
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#if __FreeBSD__ >= 2
#include <osreldate.h>
#if (BSD >= 199306)
#include <sys/sysctl.h>
#else
#include <sys/kinfo.h>
@ -170,18 +170,21 @@ ShowRoute()
int *lp;
int needed, nb;
u_long mask;
#if ( __FreeBSD_version >= 199412 )
int mib[6];
#if (BSD >= 199306)
int mib[6];
#endif
#if ( __FreeBSD_version >= 199412 )
#if (BSD >= 199306)
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0; /* protocol */
mib[3] = 0; /* wildcard address family */
mib[2] = 0;
mib[3] = 0;
mib[4] = NET_RT_DUMP;
mib[5] = 0; /* no flags */
needed = sysctl(mib, 6, NULL, &needed, NULL, 0 );
mib[5] = 0;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
perror("sysctl-estimate");
return(1);
}
#else
needed = getkerninfo(KINFO_RT_DUMP, 0, 0, 0);
#endif
@ -190,9 +193,11 @@ ShowRoute()
sp = malloc(needed);
if (sp == NULL)
return(1);
#if ( __FreeBSD_version >= 199412 )
if (sysctl(mib, 6, sp, &needed, NULL, 0 ) < 0)
#if (BSD >= 199306)
if (sysctl(mib, 6, sp, &needed, NULL, 0) < 0) {
perror("sysctl-getroute");
return(1);
}
#else
if (getkerninfo(KINFO_RT_DUMP, sp, &needed, 0) < 0)
return(1);
@ -250,24 +255,28 @@ int all;
u_long mask;
int *lp, nb;
u_char *wp;
#if ( __FreeBSD_version >= 199412 )
int mib[6];
#if (BSD >= 199306)
int mib[6];
#endif
#ifdef DEBUG
logprintf("DeleteIfRoutes (%d)\n", IfIndex);
#endif
#if ( __FreeBSD_version >= 199412 )
#if (BSD >= 199306)
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0; /* protocol */
mib[3] = 0; /* wildcard address family */
mib[2] = 0;
mib[3] = 0;
mib[4] = NET_RT_DUMP;
mib[5] = 0; /* no flags */
needed = sysctl(mib, 6, NULL, &needed, NULL, 0 );
mib[5] = 0;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
perror("sysctl-estimate");
return;
}
#else
needed = getkerninfo(KINFO_RT_DUMP, 0, 0, 0);
#endif
if (needed < 0)
return;
@ -275,9 +284,10 @@ int all;
if (sp == NULL)
return;
#if ( __FreeBSD_version >= 199412 )
if (sysctl(mib, 6, sp, &needed, NULL, 0 ) < 0) {
#if (BSD >= 199306)
if (sysctl(mib, 6, sp, &needed, NULL, 0) < 0) {
free(sp);
perror("sysctl-getroute");
return;
}
#else
@ -374,17 +384,12 @@ char *name;
IfIndex = index;
return(index);
}
#if defined(__FreeBSD__) || (_BSDI_VERSION >= 199312)
index++;
#endif
}
len -= elen;
ifrp = (struct ifreq *)((char *)ifrp + elen);
ifrp++;
#if defined(_BSDI_VERSION) && (_BSDI_VERSION < 199312)
index++;
#endif
}
close(s);

View File

@ -18,7 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
@ -43,8 +43,6 @@ struct slstat slstat;
#define ovbcopy bcopy
#endif
static int reason1, reason2, reason3, reason4, reason5;
void
sl_compress_init(comp)
struct slcompress *comp;
@ -214,7 +212,6 @@ sl_compress_tcp(m, ip, comp, compress_cid)
hlen <<= 2;
if (hlen > m->cnt)
return(TYPE_IP);
reason1++;
goto uncompressed;
found:
@ -256,7 +253,6 @@ reason1++;
BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
(THOFFSET(th) > 5 &&
BCMP(th + 1, oth + 1, (THOFFSET(th) - 5) << 2))) {
reason2++;
goto uncompressed;
}
@ -275,7 +271,6 @@ reason2++;
* implementation should never do this but RFC793
* doesn't prohibit the change so we have to deal
* with it. */
reason3++;
goto uncompressed;
}
@ -288,7 +283,6 @@ reason3++;
deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack);
if (deltaA) {
if (deltaA > 0xffff) {
reason4++;
goto uncompressed;
}
ENCODE(deltaA);
@ -298,7 +292,6 @@ reason4++;
deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq);
if (deltaS) {
if (deltaS > 0xffff) {
reason4++;
goto uncompressed;
}
ENCODE(deltaS);
@ -328,7 +321,6 @@ reason4++;
* actual changes match one of our special case encodings --
* send packet uncompressed.
*/
reason5++;
goto uncompressed;
case NEW_S|NEW_A:
@ -464,7 +456,7 @@ sl_uncompress_tcp(bufp, len, type, comp)
if (changes & NEW_C) {
/* Make sure the state index is in range, then grab the state.
* If we have a good state index, clear the 'discard' flag. */
if (*cp >= MAX_STATES)
if (*cp >= MAX_STATES || comp->last_recv == 255)
goto bad;
comp->flags &=~ SLF_TOSS;
@ -584,6 +576,5 @@ ReportCompress()
slstat.sls_compressedin, slstat.sls_uncompressedin);
printf(" %d (error), %d (tossed)\n",
slstat.sls_errorin, slstat.sls_tossed);
printf("%d, %d, %d, %d, %d\n", reason1, reason2, reason3, reason4, reason5);
return(1);
}

View File

@ -17,11 +17,13 @@
* 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:$
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
#include "cdefs.h"
#define MAX_STATES 16 /* must be > 2 and < 256 */
#define MAX_HDR 128 /* XXX 4bsd-ism: should really be 128 */
@ -136,7 +138,7 @@ struct slstat {
/* flag values */
#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
extern void sl_compress_init(/* struct slcompress * */);
extern u_char sl_compress_tcp(/* struct mbuf *, struct ip *,
struct slcompress *, int compress_cid_flag */);
extern int sl_uncompress_tcp(/* u_char **, int, u_char, struct slcompress * */);
extern void sl_compress_init __P((struct slcompress *));
extern u_char sl_compress_tcp __P((struct mbuf *, struct ip *,
struct slcompress *, int compress_cid_flag));
extern int sl_uncompress_tcp __P((u_char **, int, u_int, struct slcompress *));

View File

@ -16,15 +16,16 @@
* 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: systems.c,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
*
* $Id:$
*
* TODO:
*/
#include "fsm.h"
#include "vars.h"
#include "ipcp.h"
#include "pathnames.h"
#include "vars.h"
extern void DecodeCommand();
@ -93,7 +94,7 @@ char *file;
}
if (fp == NULL) {
SetPppId();
sprintf(line, "%s/%s", _PATH_PPP, file);
sprintf(line, "%s/%s",_PATH_PPP, file);
fp = fopen(line, "r");
}
if (fp == NULL) {
@ -121,6 +122,7 @@ char *file;
char *cp, *wp;
int n;
int val = -1;
u_char olauth;
char line[200];
fp = NULL;
@ -132,7 +134,7 @@ char *file;
}
if (fp == NULL) {
SetPppId(); /* fix from pdp@ark.jr3uom.iijnet.or.jp */
sprintf(line, "%s/%s", _PATH_PPP, file);
sprintf(line, "%s/%s",_PATH_PPP, file);
fp = fopen(line, "r");
}
if (fp == NULL) {
@ -164,7 +166,10 @@ char *file;
fprintf(stderr, "%s", cp);
#endif
SetPppId();
olauth = VarLocalAuth;
VarLocalAuth = LOCAL_AUTH;
DecodeCommand(cp, strlen(cp), 0);
VarLocalAuth = olauth;
SetUserId();
} else if (*cp == '#') {
continue;

View File

@ -15,15 +15,16 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
* $Id: timeout.h,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
*
* TODO:
*/
#ifndef _TIMEOUT_H_
#define _TIMEOUT_H_
#include "cdefs.h"
#define TICKUNIT 10000 /* Unit in usec */
#define TICKUNIT 100000 /* Unit in usec */
#define SECTICKS (1000000/TICKUNIT)
struct pppTimer {
@ -42,8 +43,8 @@ struct pppTimer {
struct pppTimer *TimerList;
extern void StartTimer(struct pppTimer *);
extern void StopTimer(struct pppTimer *);
extern void TimerService(void);
extern void StartIdleTimer(void);
extern void StartTimer __P((struct pppTimer *));
extern void StopTimer __P((struct pppTimer *));
extern void TimerService __P((void));
extern void StartIdleTimer __P((void));
#endif /* _TIMEOUT_H_ */

View File

@ -18,14 +18,31 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
*/
#include "defs.h"
#include <sys/time.h>
#include <signal.h>
#include "timeout.h"
#ifdef SIGALRM
#include <errno.h>
#endif
void StopTimerNoBlock( struct pppTimer *);
void ShowTimers(void);
void
StopTimer( struct pppTimer *tp )
{
#ifdef SIGALRM
int omask;
omask = sigblock(sigmask(SIGALRM));
#endif
StopTimerNoBlock(tp);
#ifdef SIGALRM
sigsetmask(omask);
#endif
}
void
StartTimer(tp)
struct pppTimer *tp;
@ -33,19 +50,25 @@ struct pppTimer *tp;
struct pppTimer *t, *pt;
u_long ticks = 0;
if (tp->state == TIMER_RUNNING) {
StopTimer(tp);
#ifdef SIGALRM
int omask;
omask = sigblock(sigmask(SIGALRM));
#endif
if (tp->state != TIMER_STOPPED) {
StopTimerNoBlock(tp);
}
if (tp->load == 0) {
#ifdef DEBUG
logprintf("timer %x has 0 load!\n", tp);
#endif
sigsetmask(omask);
return;
}
pt = NULL;
for (t = TimerList; t; t = t->next) {
#ifdef DEBUG
logprintf("%x(%d): ticks: %d, rest: %d\n", t, t->state, ticks, t->rest);
logprintf("StartTimer: %x(%d): ticks: %d, rest: %d\n", t, t->state, ticks, t->rest);
#endif
if (ticks + t->rest >= tp->load)
break;
@ -66,24 +89,35 @@ struct pppTimer *tp;
TimerList = tp;
if (t)
t->rest -= tp->rest;
#ifdef SIGALRM
sigsetmask(omask);
#endif
}
void
StopTimer(tp)
StopTimerNoBlock(tp)
struct pppTimer *tp;
{
struct pppTimer *t, *pt;
/*
* A Running Timer should be removing TimerList,
* But STOPPED/EXPIRED is already removing TimerList.
* So just marked as TIMER_STOPPED.
* Do not change tp->enext!! (Might be Called by expired proc)
*/
#ifdef DEBUG
logprintf("StopTimer: %x, next = %x state=%x\n", tp, tp->next, tp->state);
#endif
if (tp->state != TIMER_RUNNING) {
tp->next = NULL;
tp->next = NULL;
tp->state = TIMER_STOPPED;
return;
}
#ifdef DEBUG
logprintf("StopTimer: %x, next = %x\n", tp, tp->next);
#endif
pt = NULL;
for (t = TimerList; t != tp; t = t->next)
for (t = TimerList; t != tp && t !=NULL ; t = t->next)
pt = t;
if (t) {
if (pt)
@ -92,8 +126,9 @@ struct pppTimer *tp;
TimerList = t->next;
if (t->next)
t->next->rest += tp->rest;
} else
fprintf(stderr, "Oops, timer not found!!\n");
} else {
logprintf("Oops, timer not found!!\n");
}
tp->next = NULL;
tp->state = TIMER_STOPPED;
}
@ -103,6 +138,9 @@ TimerService()
{
struct pppTimer *tp, *exp, *wt;
#ifdef DEBUG
ShowTimers();
#endif
if (tp = TimerList) {
tp->rest--;
if (tp->rest == 0) {
@ -135,7 +173,12 @@ TimerService()
#endif
if (exp->func)
(*exp->func)(exp->arg);
exp = exp->enext;
/*
* Just Removing each item from expired list
* And exp->enext will be intialized at next expire
* in this funtion.
*/
exp = exp->enext;
}
}
}
@ -146,6 +189,75 @@ ShowTimers()
{
struct pppTimer *pt;
logprintf("---- Begin of Timer Service List---\n");
for (pt = TimerList; pt; pt = pt->next)
fprintf(stderr, "%x: load = %d, rest = %d\r\n", pt, pt->load, pt->rest);
logprintf("%x: load = %d, rest = %d, state =%x\n",
pt, pt->load, pt->rest, pt->state);
logprintf("---- End of Timer Service List ---\n");
}
#ifdef SIGALRM
u_int sleep( u_int sec )
{
struct timeval to,st,et;
long sld, nwd, std;
gettimeofday( &st, NULL );
to.tv_sec = sec;
to.tv_usec = 0;
std = st.tv_sec * 1000000 + st.tv_usec;
for (;;) {
if ( select ( 0, NULL, NULL, NULL, &to) == 0 ||
errno != EINTR ) {
break;
} else {
gettimeofday( &et, NULL );
sld = to.tv_sec * 1000000 + to.tv_sec;
nwd = et.tv_sec * 1000000 + et.tv_usec - std;
if ( sld > nwd )
sld -= nwd;
else
sld = 1; /* Avoid both tv_sec/usec is 0 */
/* Calculate timeout value for select */
to.tv_sec = sld / 1000000;
to.tv_usec = sld % 1000000;
/* Forwarding signal as normal */
kill(getpid(), SIGALRM);
}
}
}
void usleep( u_int usec)
{
struct timeval to,st,et;
long sld, nwd, std;
gettimeofday( &st, NULL );
to.tv_sec = 0;
to.tv_usec = usec;
std = st.tv_sec * 1000000 + st.tv_usec;
for (;;) {
if ( select ( 0, NULL, NULL, NULL, &to) == 0 ||
errno != EINTR ) {
break;
} else {
gettimeofday( &et, NULL );
sld = to.tv_sec * 1000000 + to.tv_sec;
nwd = et.tv_sec * 1000000 + et.tv_usec - std;
if ( sld > nwd )
sld -= nwd;
else
sld = 1; /* Avoid both tv_sec/usec is 0 */
/* Calculate timeout value for select */
to.tv_sec = sld / 1000000;
to.tv_usec = sld % 1000000;
/* Forwarding signal as normal */
kill(getpid(), SIGALRM);
}
}
}
#endif

View File

@ -29,9 +29,9 @@
* 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:$
*
*
*/
#ifndef lint

View File

@ -18,14 +18,16 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*/
#include "fsm.h"
#include "command.h"
#include "hdlc.h"
#include "termios.h"
#include "vars.h"
#include "auth.h"
char VarVersion[] = "Version 0.93";
char VarVersion[] = "Version 0.94";
/*
* Order of conf option is important. See vars.h.
@ -38,15 +40,13 @@ struct confdesc pppConfs[] = {
{ "acfcomp", CONF_ENABLE, CONF_ACCEPT },
{ "protocomp", CONF_ENABLE, CONF_ACCEPT },
{ "pred1", CONF_ENABLE, CONF_ACCEPT },
#ifdef notdef
{ "ipaddress", CONF_ENABLE, CONF_ACCEPT },
#endif
{ "proxy", CONF_DISABLE, CONF_DENY },
{ NULL },
};
struct pppvars pppVars = {
DEF_MRU, 0, MODEM_SPEED, CS8, 180, 30,
MODEM_DEV, OPEN_PASSIVE,
DEF_MRU, 0, MODEM_SPEED, CS8, 180, 30, 3,
MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH,
};
int
@ -151,3 +151,34 @@ char **argv;
} while (argc > 0);
return(1);
}
int
LocalAuthCommand(list, argc, argv)
struct cmdtab *list;
int argc;
char **argv;
{
char *p;
if (argc < 1) {
printf("Please Enter passwd for manupilating.\n");
return(1);
}
switch ( LocalAuthValidate( SECRETFILE, VarShortHost, *argv ) ) {
case INVALID:
pppVars.lauth = LOCAL_NO_AUTH;
break;
case VALID:
pppVars.lauth = LOCAL_AUTH;
break;
case NOT_FOUND:
pppVars.lauth = LOCAL_AUTH;
printf("WARING: No Entry for this system\n");
break;
default:
pppVars.lauth = LOCAL_NO_AUTH;
printf("Ooops?\n");
break;
}
return(1);
}

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
* $Id: vars.h,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
*
* TODO:
*/
@ -23,6 +23,8 @@
#ifndef _VARS_H_
#define _VARS_H_
#include <sys/param.h>
struct confdesc {
char *name;
int myside, hisside;
@ -41,8 +43,8 @@ struct confdesc {
#define ConfAcfcomp 4
#define ConfProtocomp 5
#define ConfPred1 6
#define ConfIpAddress 6
#define MAXCONFS 7
#define ConfProxy 7
#define MAXCONFS 8
#define Enabled(x) (pppConfs[x].myside & CONF_ENABLE)
#define Acceptable(x) (pppConfs[x].hisside & CONF_ACCEPT)
@ -56,13 +58,18 @@ struct pppvars {
int modem_parity; /* Parity setting */
int idle_timeout; /* Idle timeout value */
int lqr_timeout; /* LQR timeout value */
int retry_timeout; /* Retry timeout value */
char modem_dev[20]; /* Name of device */
int open_mode; /* LCP open mode */
#define LOCAL_AUTH 0x01
#define LOCAL_NO_AUTH 0x02
u_char lauth; /* Local Authorized status */
char dial_script[200]; /* Dial script */
char login_script[200]; /* Login script */
char auth_key[50]; /* PAP/CHAP key */
char auth_name[50]; /* PAP/CHAP system name */
char phone_number[50]; /* Telephone Number */
char shostname[MAXHOSTNAMELEN];/* Local short Host Name */
};
#define VarAccmap pppVars.var_accmap
@ -71,16 +78,21 @@ struct pppvars {
#define VarSpeed pppVars.modem_speed
#define VarParity pppVars.modem_parity
#define VarOpenMode pppVars.open_mode
#define VarLocalAuth pppVars.lauth
#define VarDialScript pppVars.dial_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 VarPhone pppVars.phone_number
#define VarShortHost pppVars.shostname
#define DEV_IS_SYNC (VarSpeed == 0)
extern struct pppvars pppVars;
int ipInOctets, ipOutOctets;
int ipInOctets, ipOutOctets, ipKeepAlive;
int ipConnectSecs, ipIdleSecs;
#endif

View File

@ -18,7 +18,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id:$
*
*
* TODO:
*/
#include "fsm.h"
@ -40,7 +40,7 @@ VjInit()
}
void
SendPppFlame(pri, bp)
SendPppFrame(pri, bp)
int pri;
struct mbuf *bp;
{
@ -49,10 +49,10 @@ struct mbuf *bp;
int cproto = IpcpInfo.his_compproto >> 16;
#ifdef DEBUG
logprintf("SendPppFlame: proto = %x\n", IpcpInfo.his_compproto);
logprintf("SendPppFrame: proto = %x\n", IpcpInfo.his_compproto);
#endif
if (cproto== PROTO_VJCOMP) {
type = sl_compress_tcp(bp, MBUF_CTOP(bp), &cslc, IpcpInfo.his_compproto & 0xff);
type = sl_compress_tcp(bp, (struct ip *)MBUF_CTOP(bp), &cslc, IpcpInfo.his_compproto & 0xff);
#ifdef DEBUG
logprintf("type = %x\n", type);
@ -95,6 +95,10 @@ u_char type;
*/
bufp = MBUF_CTOP(bp);
len = sl_uncompress_tcp(&bufp, len, type, &cslc);
if (len <= 0) {
pfree(bp);
bp = NULLBUFF;
}
return(bp);
}
/*
@ -109,6 +113,10 @@ u_char type;
bufp = work + MAX_HDR;
bp = mbread(bp, bufp, rlen);
len = sl_uncompress_tcp(&bufp, olen, type, &cslc);
if (len <= 0) {
pfree(bp);
return NULLBUFF;
}
len -= olen;
len += rlen;
nbp = mballoc(len, MB_VJCOMP);