Shuffle around our FSMs a bit. This'll make it
easier to remove the CcpInfo, LcpInfo and IpcpInfo globals.
This commit is contained in:
parent
7e80369b76
commit
503a7782d8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=33702
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.c,v 1.27.2.2 1998/02/07 20:49:14 brian Exp $
|
||||
* $Id: arp.c,v 1.27.2.3 1998/02/08 11:04:37 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -57,7 +57,6 @@
|
||||
#include "throughput.h"
|
||||
#include "defs.h"
|
||||
#include "iplist.h"
|
||||
#include "ipcp.h"
|
||||
#include "arp.h"
|
||||
|
||||
static int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
|
||||
@ -87,7 +86,7 @@ static struct {
|
||||
static int arpmsg_valid;
|
||||
|
||||
int
|
||||
sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
int routes;
|
||||
|
||||
@ -96,7 +95,7 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
* address.
|
||||
*/
|
||||
memset(&arpmsg, 0, sizeof arpmsg);
|
||||
if (!get_ether_addr(s, ipcp->if_peer, &arpmsg.hwa)) {
|
||||
if (!get_ether_addr(s, addr, &arpmsg.hwa)) {
|
||||
LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
|
||||
return 0;
|
||||
}
|
||||
@ -114,7 +113,7 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
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 = ipcp->if_peer.s_addr;
|
||||
arpmsg.dst.sin_addr.s_addr = addr.s_addr;
|
||||
arpmsg.dst.sin_other = SIN_PROXY;
|
||||
|
||||
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
|
||||
@ -133,7 +132,7 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
cifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
int routes;
|
||||
|
||||
@ -165,7 +164,7 @@ cifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
* sifproxyarp - Make a proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
struct arpreq arpreq;
|
||||
struct {
|
||||
@ -179,7 +178,7 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
* Get the hardware address of an interface on the same subnet as our local
|
||||
* address.
|
||||
*/
|
||||
if (!get_ether_addr(s, ipcp->if_peer, &dls.sdl)) {
|
||||
if (!get_ether_addr(s, addr, &dls.sdl)) {
|
||||
LogPrintf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
|
||||
return 0;
|
||||
}
|
||||
@ -187,8 +186,7 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
arpreq.arp_ha.sa_family = AF_UNSPEC;
|
||||
memcpy(arpreq.arp_ha.sa_data, LLADDR(&dls.sdl), dls.sdl.sdl_alen);
|
||||
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr =
|
||||
ipcp->if_peer.s_addr;
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr = addr.s_addr;
|
||||
arpreq.arp_flags = ATF_PERM | ATF_PUBL;
|
||||
if (ID0ioctl(s, SIOCSARP, (caddr_t) & arpreq) < 0) {
|
||||
LogPrintf(LogERROR, "sifproxyarp: ioctl(SIOCSARP): %s\n", strerror(errno));
|
||||
@ -201,14 +199,13 @@ sifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
cifproxyarp(struct bundle *bundle, struct ipcp *ipcp, int s)
|
||||
cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
struct arpreq arpreq;
|
||||
|
||||
memset(&arpreq, '\0', sizeof arpreq);
|
||||
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr =
|
||||
ipcp->if_peer.s_addr;
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr = addr.s_addr;
|
||||
if (ID0ioctl(s, SIOCDARP, (caddr_t) & arpreq) < 0) {
|
||||
LogPrintf(LogERROR, "cifproxyarp: ioctl(SIOCDARP): %s\n", strerror(errno));
|
||||
return 0;
|
||||
|
@ -17,11 +17,9 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.h,v 1.7.2.2 1998/02/07 20:49:16 brian Exp $
|
||||
* $Id: arp.h,v 1.7.2.3 1998/02/08 11:04:38 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
struct ipcp;
|
||||
|
||||
extern int cifproxyarp(struct bundle *, struct ipcp *, int);
|
||||
extern int sifproxyarp(struct bundle *, struct ipcp *, int);
|
||||
extern int cifproxyarp(struct bundle *, struct in_addr, int);
|
||||
extern int sifproxyarp(struct bundle *, struct in_addr, int);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.c,v 1.27.2.7 1998/02/09 19:20:32 brian Exp $
|
||||
* $Id: auth.c,v 1.27.2.8 1998/02/13 05:10:05 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Implement check against with registered IP addresses.
|
||||
@ -151,7 +151,7 @@ AuthValidate(struct bundle *bundle, const char *fname, const char *system,
|
||||
if (n > 2 && !UseHisaddr(bundle, vector[2], 1))
|
||||
return (0);
|
||||
/* XXX This should be deferred - we may join an existing bundle ! */
|
||||
IpcpInit(bundle, physical2link(physical));
|
||||
ipcp_Setup(&IpcpInfo);
|
||||
if (n > 3)
|
||||
SetLabel(vector[3]);
|
||||
return (1); /* Valid */
|
||||
@ -186,11 +186,11 @@ AuthGetSecret(struct bundle *bundle, const char *fname, const char *system,
|
||||
if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) {
|
||||
chat_ExpandString(NULL, vector[1], passwd, sizeof passwd, 0);
|
||||
if (setaddr)
|
||||
memset(&IpcpInfo.DefHisAddress, '\0', sizeof IpcpInfo.DefHisAddress);
|
||||
memset(&IpcpInfo.cfg.peer_range, '\0', sizeof IpcpInfo.cfg.peer_range);
|
||||
if (n > 2 && setaddr)
|
||||
if (UseHisaddr(bundle, vector[2], 1))
|
||||
/* XXX This should be deferred - we may join an existing bundle ! */
|
||||
IpcpInit(bundle, physical2link(physical));
|
||||
ipcp_Setup(&IpcpInfo);
|
||||
else
|
||||
return NULL;
|
||||
if (n > 3)
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.c,v 1.1.2.13 1998/02/17 19:28:19 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.14 1998/02/18 00:27:44 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -126,7 +126,7 @@ bundle_NewPhase(struct bundle *bundle, struct physical *physical, u_int new)
|
||||
|
||||
case PHASE_NETWORK:
|
||||
tun_configure(bundle, LcpInfo.his_mru, modem_Speed(physical));
|
||||
IpcpInit(bundle, &physical->link);
|
||||
ipcp_Setup(&IpcpInfo);
|
||||
IpcpUp();
|
||||
IpcpOpen();
|
||||
CcpUp();
|
||||
@ -356,8 +356,6 @@ bundle_Create(const char *prefix)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IpcpInit(&bundle, &bundle.links->physical->link);
|
||||
|
||||
return &bundle;
|
||||
}
|
||||
|
||||
@ -660,6 +658,12 @@ bundle2physical(struct bundle *bundle, const char *name)
|
||||
return dl ? dl->physical : NULL;
|
||||
}
|
||||
|
||||
struct ccp *
|
||||
bundle2ccp(struct bundle *bundle, const char *name)
|
||||
{
|
||||
return &CcpInfo;
|
||||
}
|
||||
|
||||
struct link *
|
||||
bundle2link(struct bundle *bundle, const char *name)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.h,v 1.1.2.8 1998/02/15 23:59:40 brian Exp $
|
||||
* $Id: bundle.h,v 1.1.2.9 1998/02/17 19:27:49 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHASE_DEAD 0 /* Link is dead */
|
||||
@ -66,10 +66,12 @@ extern void bundle_LayerDown(struct bundle *, struct fsm *);
|
||||
extern void bundle_LayerFinish(struct bundle *, struct fsm *);
|
||||
extern void bundle_LinkClosed(struct bundle *, struct datalink *);
|
||||
|
||||
extern struct link *bundle2link(struct bundle *, const char *);
|
||||
extern struct physical *bundle2physical(struct bundle *, const char *);
|
||||
extern struct datalink *bundle2datalink(struct bundle *, const char *);
|
||||
extern int bundle_UpdateSet(struct bundle *, fd_set *, fd_set *, fd_set *,
|
||||
int *);
|
||||
extern int bundle_FillQueues(struct bundle *);
|
||||
extern int bundle_ShowLinks(struct cmdargs const *);
|
||||
|
||||
extern struct link *bundle2link(struct bundle *, const char *);
|
||||
extern struct physical *bundle2physical(struct bundle *, const char *);
|
||||
extern struct datalink *bundle2datalink(struct bundle *, const char *);
|
||||
extern struct ccp *bundle2ccp(struct bundle *, const char *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.c,v 1.30.2.10 1998/02/18 19:36:09 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.11 1998/02/19 19:56:53 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -45,6 +45,11 @@
|
||||
#include "bundle.h"
|
||||
#include "descriptor.h"
|
||||
#include "prompt.h"
|
||||
#include "hdlc.h"
|
||||
#include "throughput.h"
|
||||
#include "link.h"
|
||||
#include "chat.h"
|
||||
#include "datalink.h"
|
||||
|
||||
static void CcpSendConfigReq(struct fsm *);
|
||||
static void CcpSendTerminateReq(struct fsm *);
|
||||
@ -55,6 +60,8 @@ static void CcpLayerFinish(struct fsm *);
|
||||
static void CcpLayerUp(struct fsm *);
|
||||
static void CcpLayerDown(struct fsm *);
|
||||
static void CcpInitRestartCounter(struct fsm *);
|
||||
static void CcpRecvResetReq(struct fsm *);
|
||||
static void CcpRecvResetAck(struct fsm *, u_char);
|
||||
|
||||
static struct fsm_callbacks ccp_Callbacks = {
|
||||
CcpLayerUp,
|
||||
@ -65,27 +72,12 @@ static struct fsm_callbacks ccp_Callbacks = {
|
||||
CcpSendConfigReq,
|
||||
CcpSendTerminateReq,
|
||||
CcpSendTerminateAck,
|
||||
CcpDecodeConfig
|
||||
CcpDecodeConfig,
|
||||
CcpRecvResetReq,
|
||||
CcpRecvResetAck
|
||||
};
|
||||
|
||||
struct ccp CcpInfo = {
|
||||
{
|
||||
"CCP",
|
||||
PROTO_CCP,
|
||||
CCP_MAXCODE,
|
||||
0,
|
||||
ST_INITIAL,
|
||||
0, 0, 0,
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* FSM timer */
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* Open timer */
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* Stopped timer */
|
||||
LogCCP,
|
||||
NULL, /* link */
|
||||
NULL, /* bundle */
|
||||
&ccp_Callbacks
|
||||
},
|
||||
-1, -1, -1, -1, -1, -1
|
||||
};
|
||||
struct ccp CcpInfo;
|
||||
|
||||
static char const *cftypes[] = {
|
||||
/* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */
|
||||
@ -129,30 +121,41 @@ static const struct ccp_algorithm *algorithm[] = {
|
||||
#define NALGORITHMS (sizeof algorithm/sizeof algorithm[0])
|
||||
|
||||
int
|
||||
ReportCcpStatus(struct cmdargs const *arg)
|
||||
ccp_ReportStatus(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "%s [%s]\n", CcpInfo.fsm.name,
|
||||
StateNames[CcpInfo.fsm.state]);
|
||||
struct ccp *ccp = bundle2ccp(arg->bundle, arg->cx ? arg->cx->name : NULL);
|
||||
|
||||
prompt_Printf(&prompt, "%s [%s]\n", ccp->fsm.name,
|
||||
StateNames[ccp->fsm.state]);
|
||||
prompt_Printf(&prompt, "My protocol = %s, His protocol = %s\n",
|
||||
protoname(CcpInfo.my_proto), protoname(CcpInfo.his_proto));
|
||||
protoname(ccp->my_proto), protoname(ccp->his_proto));
|
||||
prompt_Printf(&prompt, "Output: %ld --> %ld, Input: %ld --> %ld\n",
|
||||
CcpInfo.uncompout, CcpInfo.compout,
|
||||
CcpInfo.compin, CcpInfo.uncompin);
|
||||
ccp->uncompout, ccp->compout,
|
||||
ccp->compin, ccp->uncompin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CcpInit(struct bundle *bundle, struct link *l)
|
||||
ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l)
|
||||
{
|
||||
/* Initialise ourselves */
|
||||
FsmInit(&CcpInfo.fsm, bundle, l, 10);
|
||||
CcpInfo.his_proto = CcpInfo.my_proto = -1;
|
||||
CcpInfo.reset_sent = CcpInfo.last_reset = -1;
|
||||
CcpInfo.in_algorithm = CcpInfo.out_algorithm = -1;
|
||||
CcpInfo.his_reject = CcpInfo.my_reject = 0;
|
||||
CcpInfo.out_init = CcpInfo.in_init = 0;
|
||||
CcpInfo.uncompout = CcpInfo.compout = 0;
|
||||
CcpInfo.uncompin = CcpInfo.compin = 0;
|
||||
fsm_Init(&CcpInfo.fsm, "CCP", PROTO_CCP, CCP_MAXCODE, 10, LogCCP,
|
||||
bundle, l, &ccp_Callbacks);
|
||||
ccp_Setup(ccp);
|
||||
}
|
||||
|
||||
void
|
||||
ccp_Setup(struct ccp *ccp)
|
||||
{
|
||||
/* Set ourselves up for a startup */
|
||||
ccp->fsm.open_mode = 0;
|
||||
ccp->his_proto = ccp->my_proto = -1;
|
||||
ccp->reset_sent = ccp->last_reset = -1;
|
||||
ccp->in_algorithm = ccp->out_algorithm = -1;
|
||||
ccp->his_reject = ccp->my_reject = 0;
|
||||
ccp->out_init = ccp->in_init = 0;
|
||||
ccp->uncompout = ccp->compout = 0;
|
||||
ccp->uncompin = ccp->compin = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -213,7 +216,7 @@ CcpSendTerminateAck(struct fsm *fp)
|
||||
FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
CcpRecvResetReq(struct fsm *fp)
|
||||
{
|
||||
/* Got a reset REQ, reset outgoing dictionary */
|
||||
@ -417,8 +420,8 @@ CcpInput(struct bundle *bundle, struct mbuf *bp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CcpResetInput(u_char id)
|
||||
static void
|
||||
CcpRecvResetAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
/* Got a reset ACK, reset incoming dictionary */
|
||||
if (CcpInfo.reset_sent != -1) {
|
||||
@ -442,35 +445,36 @@ CcpResetInput(u_char id)
|
||||
}
|
||||
|
||||
int
|
||||
CcpOutput(struct link *l, int pri, u_short proto, struct mbuf *m)
|
||||
ccp_Output(struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
struct mbuf *m)
|
||||
{
|
||||
/* Compress outgoing data */
|
||||
if (CcpInfo.out_init)
|
||||
return (*algorithm[CcpInfo.out_algorithm]->o.Write)(l, pri, proto, m);
|
||||
/* Compress outgoing Network Layer data */
|
||||
if ((proto & 0xfff1) == 0x21 && ccp->fsm.state == ST_OPENED && ccp->out_init)
|
||||
return (*algorithm[ccp->out_algorithm]->o.Write)(l, pri, proto, m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
ccp_Decompress(u_short *proto, struct mbuf *bp)
|
||||
ccp_Decompress(struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
{
|
||||
/*
|
||||
* If proto isn't PROTO_COMPD, we still want to pass it to the
|
||||
* decompression routines so that the dictionary's updated
|
||||
*/
|
||||
if (CcpInfo.fsm.state == ST_OPENED)
|
||||
if (ccp->fsm.state == ST_OPENED)
|
||||
if (*proto == PROTO_COMPD) {
|
||||
/* Decompress incoming data */
|
||||
if (CcpInfo.reset_sent != -1) {
|
||||
if (ccp->reset_sent != -1) {
|
||||
/* Send another REQ and put the packet in the bit bucket */
|
||||
LogPrintf(LogCCP, "ReSendResetReq(%d)\n", CcpInfo.reset_sent);
|
||||
FsmOutput(&CcpInfo.fsm, CODE_RESETREQ, CcpInfo.reset_sent, NULL, 0);
|
||||
} else if (CcpInfo.in_init)
|
||||
return (*algorithm[CcpInfo.in_algorithm]->i.Read)(proto, bp);
|
||||
LogPrintf(LogCCP, "ReSendResetReq(%d)\n", ccp->reset_sent);
|
||||
FsmOutput(&ccp->fsm, CODE_RESETREQ, ccp->reset_sent, NULL, 0);
|
||||
} else if (ccp->in_init)
|
||||
return (*algorithm[ccp->in_algorithm]->i.Read)(proto, bp);
|
||||
pfree(bp);
|
||||
bp = NULL;
|
||||
} else if ((*proto & 0xfff1) == 0x21 && CcpInfo.in_init)
|
||||
} else if ((*proto & 0xfff1) == 0x21 && ccp->in_init)
|
||||
/* Add incoming Network Layer traffic to our dictionary */
|
||||
(*algorithm[CcpInfo.in_algorithm]->i.DictSetup)(*proto, bp);
|
||||
(*algorithm[ccp->in_algorithm]->i.DictSetup)(*proto, bp);
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.14.2.8 1998/02/08 11:04:49 brian Exp $
|
||||
* $Id: ccp.h,v 1.14.2.9 1998/02/18 19:36:11 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -84,13 +84,13 @@ struct ccp_algorithm {
|
||||
} o;
|
||||
};
|
||||
|
||||
extern void CcpRecvResetReq(struct fsm *);
|
||||
extern void ccp_Init(struct ccp *, struct bundle *, struct link *);
|
||||
extern void ccp_Setup(struct ccp *);
|
||||
|
||||
extern void CcpSendResetReq(struct fsm *);
|
||||
extern void CcpInput(struct bundle *, struct mbuf *);
|
||||
extern void CcpUp(void);
|
||||
extern void CcpOpen(void);
|
||||
extern void CcpInit(struct bundle *, struct link *);
|
||||
extern int ReportCcpStatus(struct cmdargs const *);
|
||||
extern void CcpResetInput(u_char);
|
||||
extern int CcpOutput(struct link *, int, u_short, struct mbuf *);
|
||||
extern struct mbuf *ccp_Decompress(u_short *, struct mbuf *);
|
||||
extern int ccp_ReportStatus(struct cmdargs const *);
|
||||
extern int ccp_Output(struct ccp *, struct link *, int, u_short, struct mbuf *);
|
||||
extern struct mbuf *ccp_Decompress(struct ccp *, u_short *, struct mbuf *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.c,v 1.131.2.26 1998/02/18 19:35:14 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.27 1998/02/18 19:35:32 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -278,11 +278,11 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
argv[0] = strdup(arg->argv[0]);
|
||||
for (argc = 1; argc < arg->argc; argc++) {
|
||||
if (strcasecmp(arg->argv[argc], "HISADDR") == 0)
|
||||
argv[argc] = strdup(inet_ntoa(IpcpInfo.his_ipaddr));
|
||||
argv[argc] = strdup(inet_ntoa(IpcpInfo.peer_ip));
|
||||
else if (strcasecmp(arg->argv[argc], "INTERFACE") == 0)
|
||||
argv[argc] = strdup(arg->bundle->ifname);
|
||||
else if (strcasecmp(arg->argv[argc], "MYADDR") == 0)
|
||||
argv[argc] = strdup(inet_ntoa(IpcpInfo.want_ipaddr));
|
||||
argv[argc] = strdup(inet_ntoa(IpcpInfo.my_ip));
|
||||
else
|
||||
argv[argc] = strdup(arg->argv[argc]);
|
||||
}
|
||||
@ -556,13 +556,13 @@ ShowMSExt(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, " MS PPP extention values \n");
|
||||
prompt_Printf(&prompt, " Primary NS : %s\n",
|
||||
inet_ntoa(IpcpInfo.ns_entries[0]));
|
||||
inet_ntoa(IpcpInfo.cfg.ns_entries[0]));
|
||||
prompt_Printf(&prompt, " Secondary NS : %s\n",
|
||||
inet_ntoa(IpcpInfo.ns_entries[1]));
|
||||
inet_ntoa(IpcpInfo.cfg.ns_entries[1]));
|
||||
prompt_Printf(&prompt, " Primary NBNS : %s\n",
|
||||
inet_ntoa(IpcpInfo.nbns_entries[0]));
|
||||
inet_ntoa(IpcpInfo.cfg.nbns_entries[0]));
|
||||
prompt_Printf(&prompt, " Secondary NBNS : %s\n",
|
||||
inet_ntoa(IpcpInfo.nbns_entries[1]));
|
||||
inet_ntoa(IpcpInfo.cfg.nbns_entries[1]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -574,7 +574,7 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show keep-alive filters", "show afilter option .."},
|
||||
{"auth", NULL, ShowAuthKey, LOCAL_AUTH,
|
||||
"Show auth details", "show auth"},
|
||||
{"ccp", NULL, ReportCcpStatus, LOCAL_AUTH,
|
||||
{"ccp", NULL, ccp_ReportStatus, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Show CCP status", "show cpp"},
|
||||
{"compress", NULL, ReportCompress, LOCAL_AUTH,
|
||||
"Show compression stats", "show compress"},
|
||||
@ -1201,27 +1201,27 @@ SetInterfaceAddr(struct cmdargs const *arg)
|
||||
const char *hisaddr;
|
||||
|
||||
hisaddr = NULL;
|
||||
IpcpInfo.DefMyAddress.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.DefHisAddress.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.my_range.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.peer_range.ipaddr.s_addr = INADDR_ANY;
|
||||
|
||||
if (arg->argc > 4)
|
||||
return -1;
|
||||
|
||||
IpcpInfo.HaveTriggerAddress = 0;
|
||||
IpcpInfo.cfg.HaveTriggerAddress = 0;
|
||||
ifnetmask.s_addr = 0;
|
||||
iplist_reset(&IpcpInfo.DefHisChoice);
|
||||
iplist_reset(&IpcpInfo.cfg.peer_list);
|
||||
|
||||
if (arg->argc > 0) {
|
||||
if (!ParseAddr(arg->argc, arg->argv, &IpcpInfo.DefMyAddress.ipaddr,
|
||||
&IpcpInfo.DefMyAddress.mask, &IpcpInfo.DefMyAddress.width))
|
||||
if (!ParseAddr(arg->argc, arg->argv, &IpcpInfo.cfg.my_range.ipaddr,
|
||||
&IpcpInfo.cfg.my_range.mask, &IpcpInfo.cfg.my_range.width))
|
||||
return 1;
|
||||
if (arg->argc > 1) {
|
||||
hisaddr = arg->argv[1];
|
||||
if (arg->argc > 2) {
|
||||
ifnetmask = GetIpAddr(arg->argv[2]);
|
||||
if (arg->argc > 3) {
|
||||
IpcpInfo.TriggerAddress = GetIpAddr(arg->argv[3]);
|
||||
IpcpInfo.HaveTriggerAddress = 1;
|
||||
IpcpInfo.cfg.TriggerAddress = GetIpAddr(arg->argv[3]);
|
||||
IpcpInfo.cfg.HaveTriggerAddress = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1230,15 +1230,15 @@ SetInterfaceAddr(struct cmdargs const *arg)
|
||||
/*
|
||||
* For backwards compatibility, 0.0.0.0 means any address.
|
||||
*/
|
||||
if (IpcpInfo.DefMyAddress.ipaddr.s_addr == INADDR_ANY) {
|
||||
IpcpInfo.DefMyAddress.mask.s_addr = INADDR_ANY;
|
||||
IpcpInfo.DefMyAddress.width = 0;
|
||||
if (IpcpInfo.cfg.my_range.ipaddr.s_addr == INADDR_ANY) {
|
||||
IpcpInfo.cfg.my_range.mask.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.my_range.width = 0;
|
||||
}
|
||||
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.DefMyAddress.ipaddr.s_addr;
|
||||
IpcpInfo.my_ip.s_addr = IpcpInfo.cfg.my_range.ipaddr.s_addr;
|
||||
|
||||
if (IpcpInfo.DefHisAddress.ipaddr.s_addr == INADDR_ANY) {
|
||||
IpcpInfo.DefHisAddress.mask.s_addr = INADDR_ANY;
|
||||
IpcpInfo.DefHisAddress.width = 0;
|
||||
if (IpcpInfo.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
|
||||
IpcpInfo.cfg.peer_range.mask.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.peer_range.width = 0;
|
||||
}
|
||||
|
||||
if (hisaddr && !UseHisaddr(arg->bundle, hisaddr, mode & MODE_AUTO))
|
||||
@ -1280,7 +1280,7 @@ SetMSEXT(struct in_addr * pri_addr,
|
||||
static int
|
||||
SetNS(struct cmdargs const *arg)
|
||||
{
|
||||
SetMSEXT(&IpcpInfo.ns_entries[0], &IpcpInfo.ns_entries[1],
|
||||
SetMSEXT(&IpcpInfo.cfg.ns_entries[0], &IpcpInfo.cfg.ns_entries[1],
|
||||
arg->argc, arg->argv);
|
||||
return 0;
|
||||
}
|
||||
@ -1288,7 +1288,7 @@ SetNS(struct cmdargs const *arg)
|
||||
static int
|
||||
SetNBNS(struct cmdargs const *arg)
|
||||
{
|
||||
SetMSEXT(&IpcpInfo.nbns_entries[0], &IpcpInfo.nbns_entries[1],
|
||||
SetMSEXT(&IpcpInfo.cfg.nbns_entries[0], &IpcpInfo.cfg.nbns_entries[1],
|
||||
arg->argc, arg->argv);
|
||||
return 0;
|
||||
}
|
||||
@ -1511,16 +1511,16 @@ AddCommand(struct cmdargs const *arg)
|
||||
}
|
||||
else {
|
||||
if (strcasecmp(arg->argv[0], "MYADDR") == 0)
|
||||
dest = IpcpInfo.want_ipaddr;
|
||||
dest = IpcpInfo.my_ip;
|
||||
else if (strcasecmp(arg->argv[0], "HISADDR") == 0)
|
||||
dest = IpcpInfo.his_ipaddr;
|
||||
dest = IpcpInfo.peer_ip;
|
||||
else
|
||||
dest = GetIpAddr(arg->argv[0]);
|
||||
netmask = GetIpAddr(arg->argv[1]);
|
||||
gw = 2;
|
||||
}
|
||||
if (strcasecmp(arg->argv[gw], "HISADDR") == 0)
|
||||
gateway = IpcpInfo.his_ipaddr;
|
||||
gateway = IpcpInfo.peer_ip;
|
||||
else if (strcasecmp(arg->argv[gw], "INTERFACE") == 0)
|
||||
gateway.s_addr = INADDR_ANY;
|
||||
else
|
||||
@ -1540,7 +1540,7 @@ DeleteCommand(struct cmdargs const *arg)
|
||||
DeleteIfRoutes(arg->bundle, 0);
|
||||
else {
|
||||
if (strcasecmp(arg->argv[0], "MYADDR") == 0)
|
||||
dest = IpcpInfo.want_ipaddr;
|
||||
dest = IpcpInfo.my_ip;
|
||||
else if (strcasecmp(arg->argv[0], "default") == 0)
|
||||
dest.s_addr = INADDR_ANY;
|
||||
else
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.1.2.10 1998/02/17 19:29:09 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.11 1998/02/18 00:27:47 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -143,10 +143,10 @@ datalink_LoginDone(struct datalink *dl)
|
||||
LogPrintf(LogPHASE, "%s: Entering OPEN state\n", dl->name);
|
||||
dl->state = DATALINK_OPEN;
|
||||
|
||||
LcpInit(dl->bundle, dl->physical);
|
||||
CcpInit(dl->bundle, &dl->physical->link);
|
||||
lcp_Setup(&LcpInfo, dl->state == DATALINK_READY ? 0 : VarOpenMode);
|
||||
ccp_Setup(&CcpInfo);
|
||||
|
||||
FsmUp(&LcpInfo.fsm);
|
||||
LcpInfo.fsm.open_mode = dl->state == DATALINK_READY ? 0 : VarOpenMode;
|
||||
FsmOpen(&LcpInfo.fsm);
|
||||
}
|
||||
}
|
||||
@ -352,16 +352,16 @@ datalink_Create(const char *name, struct bundle *bundle)
|
||||
dl->cfg.reconnect_timeout = RECONNECT_TIMEOUT;
|
||||
|
||||
dl->name = strdup(name);
|
||||
if ((dl->physical = modem_Create(dl->name)) == NULL) {
|
||||
if ((dl->physical = modem_Create(dl->name, &CcpInfo)) == NULL) {
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
return NULL;
|
||||
}
|
||||
chat_Init(&dl->chat, dl->physical, NULL, 1);
|
||||
|
||||
IpcpDefAddress();
|
||||
LcpInit(dl->bundle, dl->physical);
|
||||
CcpInit(dl->bundle, &dl->physical->link);
|
||||
ipcp_Init(&IpcpInfo, dl->bundle, &dl->physical->link);
|
||||
lcp_Init(&LcpInfo, dl->bundle, dl->physical);
|
||||
ccp_Init(&CcpInfo, dl->bundle, &dl->physical->link);
|
||||
|
||||
LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: filter.c,v 1.22.2.3 1998/01/31 02:48:17 brian Exp $
|
||||
* $Id: filter.c,v 1.22.2.4 1998/02/10 03:23:18 brian Exp $
|
||||
*
|
||||
* TODO: Shoud send ICMP error message when we discard packets.
|
||||
*/
|
||||
@ -91,9 +91,9 @@ ParseAddr(int argc,
|
||||
len = cp ? cp - *argv : strlen(*argv);
|
||||
|
||||
if (strncasecmp(*argv, "HISADDR", len) == 0)
|
||||
*paddr = IpcpInfo.his_ipaddr;
|
||||
*paddr = IpcpInfo.peer_ip;
|
||||
else if (strncasecmp(*argv, "MYADDR", len) == 0)
|
||||
*paddr = IpcpInfo.want_ipaddr;
|
||||
*paddr = IpcpInfo.my_ip;
|
||||
else if (len > 15)
|
||||
LogPrintf(LogWARN, "ParseAddr: %s: Bad address\n", *argv);
|
||||
else {
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.c,v 1.27.2.11 1998/02/18 19:35:38 brian Exp $
|
||||
* $Id: fsm.c,v 1.27.2.12 1998/02/19 19:56:54 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Refer loglevel for log output
|
||||
@ -84,16 +84,24 @@ StoppedTimeout(void *v)
|
||||
}
|
||||
|
||||
void
|
||||
FsmInit(struct fsm *fp, struct bundle *bundle, struct link *l, int maxcfg)
|
||||
fsm_Init(struct fsm *fp, const char *name, u_short proto, int maxcode,
|
||||
int maxcfg, int LogLevel, struct bundle *bundle, struct link *l,
|
||||
struct fsm_callbacks *fn)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "FsmInit\n");
|
||||
fp->name = name;
|
||||
fp->proto = proto;
|
||||
fp->max_code = maxcode;
|
||||
fp->state = ST_INITIAL;
|
||||
fp->reqid = 1;
|
||||
fp->restart = 1;
|
||||
fp->maxconfig = 3;
|
||||
fp->maxconfig = maxcfg;
|
||||
memset(&fp->FsmTimer, '\0', sizeof fp->FsmTimer);
|
||||
memset(&fp->OpenTimer, '\0', sizeof fp->OpenTimer);
|
||||
memset(&fp->StoppedTimer, '\0', sizeof fp->StoppedTimer);
|
||||
fp->LogLevel = LogLevel;
|
||||
fp->link = l;
|
||||
fp->bundle = bundle;
|
||||
fp->maxconfig = maxcfg;
|
||||
fp->fn = fn;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -783,10 +791,10 @@ FsmRecvTimeRemain(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvResetReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
FsmRecvResetReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "RecvResetReq(%d)\n", lhp->id);
|
||||
CcpRecvResetReq(fp);
|
||||
(*fp->fn->RecvResetReq)(fp);
|
||||
/*
|
||||
* All sendable compressed packets are queued in the PRI_NORMAL modem
|
||||
* output queue.... dump 'em to the priority queue so that they arrive
|
||||
@ -799,10 +807,10 @@ FsmRecvResetReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvResetAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
FsmRecvResetAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "RecvResetAck(%d)\n", lhp->id);
|
||||
CcpResetInput(lhp->id);
|
||||
(*fp->fn->RecvResetAck)(fp, lhp->id);
|
||||
fp->reqid++;
|
||||
pfree(bp);
|
||||
}
|
||||
@ -858,3 +866,15 @@ FsmInput(struct fsm * fp, struct mbuf * bp)
|
||||
if (LogIsKept(LogDEBUG))
|
||||
LogMemory();
|
||||
}
|
||||
|
||||
void
|
||||
NullRecvResetReq(struct fsm *fp)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "Oops - received unexpected reset req\n");
|
||||
}
|
||||
|
||||
void
|
||||
NullRecvResetAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "Oops - received unexpected reset ack\n");
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.16.2.5 1998/02/06 02:24:16 brian Exp $
|
||||
* $Id: fsm.h,v 1.16.2.6 1998/02/19 19:56:57 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -57,6 +57,9 @@ struct fsm_callbacks {
|
||||
void (*SendTerminateReq) (struct fsm *); /* Term REQ just sent */
|
||||
void (*SendTerminateAck) (struct fsm *); /* Send Term ACK please */
|
||||
void (*DecodeConfig) (struct fsm *, u_char *, int, int);
|
||||
/* Deal with incoming data */
|
||||
void (*RecvResetReq) (struct fsm *fp); /* Reset output */
|
||||
void (*RecvResetAck) (struct fsm *fp, u_char); /* Reset input */
|
||||
};
|
||||
|
||||
struct fsm {
|
||||
@ -131,10 +134,14 @@ extern u_char *rejp;
|
||||
|
||||
extern char const *StateNames[];
|
||||
|
||||
extern void FsmInit(struct fsm *, struct bundle *, struct link *, int);
|
||||
extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int,
|
||||
struct bundle *, struct link *, struct fsm_callbacks *);
|
||||
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 FsmClose(struct fsm *);
|
||||
|
||||
extern void NullRecvResetReq(struct fsm *fp);
|
||||
extern void NullRecvResetAck(struct fsm *fp, u_char);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.c,v 1.28.2.11 1998/02/18 19:35:41 brian Exp $
|
||||
* $Id: hdlc.c,v 1.28.2.12 1998/02/18 19:36:13 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -56,6 +56,7 @@
|
||||
#include "prompt.h"
|
||||
#include "chat.h"
|
||||
#include "datalink.h"
|
||||
#include "bundle.h"
|
||||
|
||||
static u_short const fcstab[256] = {
|
||||
/* 00 */ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
@ -139,10 +140,8 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
u_char *cp;
|
||||
u_short fcs;
|
||||
|
||||
if ((proto & 0xfff1) == 0x21) /* Network Layer protocol */
|
||||
if (CcpInfo.fsm.state == ST_OPENED)
|
||||
if (CcpOutput(l, pri, proto, bp))
|
||||
return;
|
||||
if (ccp_Output(l->ccp, l, pri, proto, bp))
|
||||
return;
|
||||
|
||||
if (!p) {
|
||||
/*
|
||||
@ -360,12 +359,13 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
|
||||
struct link *l)
|
||||
{
|
||||
struct physical *p = link2physical(l);
|
||||
struct ccp *ccp = bundle2ccp(bundle, l->name);
|
||||
u_char *cp;
|
||||
|
||||
LogPrintf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto);
|
||||
|
||||
/* decompress everything. CCP needs uncompressed data too */
|
||||
if ((bp = ccp_Decompress(&proto, bp)) == NULL)
|
||||
if ((bp = ccp_Decompress(ccp, &proto, bp)) == NULL)
|
||||
return;
|
||||
|
||||
switch (proto) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.50.2.13 1998/02/10 03:23:20 brian Exp $
|
||||
* $Id: ipcp.c,v 1.50.2.14 1998/02/19 19:56:59 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -69,6 +69,9 @@
|
||||
#include "systems.h"
|
||||
#include "prompt.h"
|
||||
|
||||
#undef REJECTED
|
||||
#define REJECTED(p, x) ((p)->peer_reject & (1<<(x)))
|
||||
|
||||
struct compreq {
|
||||
u_short proto;
|
||||
u_char slots;
|
||||
@ -95,27 +98,11 @@ static struct fsm_callbacks ipcp_Callbacks = {
|
||||
IpcpSendTerminateReq,
|
||||
IpcpSendTerminateAck,
|
||||
IpcpDecodeConfig,
|
||||
NullRecvResetReq,
|
||||
NullRecvResetAck
|
||||
};
|
||||
|
||||
struct ipcp IpcpInfo = {
|
||||
{
|
||||
"IPCP",
|
||||
PROTO_IPCP,
|
||||
IPCP_MAXCODE,
|
||||
0,
|
||||
ST_INITIAL,
|
||||
0, 0, 0,
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* FSM timer */
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* Open timer */
|
||||
{0, 0, 0, NULL, NULL, NULL}, /* Stopped timer */
|
||||
LogIPCP,
|
||||
NULL, /* link */
|
||||
NULL, /* bundle */
|
||||
&ipcp_Callbacks,
|
||||
},
|
||||
MAX_VJ_STATES,
|
||||
1
|
||||
};
|
||||
struct ipcp IpcpInfo;
|
||||
|
||||
static const char *cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
@ -157,29 +144,30 @@ ReportIpcpStatus(struct cmdargs const *arg)
|
||||
StateNames[IpcpInfo.fsm.state]);
|
||||
if (IpcpInfo.fsm.state == ST_OPENED) {
|
||||
prompt_Printf(&prompt, " His side: %s, %s\n",
|
||||
inet_ntoa(IpcpInfo.his_ipaddr), vj2asc(IpcpInfo.his_compproto));
|
||||
inet_ntoa(IpcpInfo.peer_ip), vj2asc(IpcpInfo.peer_compproto));
|
||||
prompt_Printf(&prompt, " My side: %s, %s\n",
|
||||
inet_ntoa(IpcpInfo.want_ipaddr), vj2asc(IpcpInfo.want_compproto));
|
||||
inet_ntoa(IpcpInfo.my_ip), vj2asc(IpcpInfo.my_compproto));
|
||||
}
|
||||
|
||||
prompt_Printf(&prompt, "\nDefaults:\n");
|
||||
prompt_Printf(&prompt, " My Address: %s/%d\n",
|
||||
inet_ntoa(IpcpInfo.DefMyAddress.ipaddr), IpcpInfo.DefMyAddress.width);
|
||||
if (iplist_isvalid(&IpcpInfo.DefHisChoice))
|
||||
inet_ntoa(IpcpInfo.cfg.my_range.ipaddr), IpcpInfo.cfg.my_range.width);
|
||||
if (iplist_isvalid(&IpcpInfo.cfg.peer_list))
|
||||
prompt_Printf(&prompt, " His Address: %s\n",
|
||||
IpcpInfo.DefHisChoice.src);
|
||||
IpcpInfo.cfg.peer_list.src);
|
||||
else
|
||||
prompt_Printf(&prompt, " His Address: %s/%d\n",
|
||||
inet_ntoa(IpcpInfo.DefHisAddress.ipaddr),
|
||||
IpcpInfo.DefHisAddress.width);
|
||||
if (IpcpInfo.HaveTriggerAddress)
|
||||
inet_ntoa(IpcpInfo.cfg.peer_range.ipaddr),
|
||||
IpcpInfo.cfg.peer_range.width);
|
||||
if (IpcpInfo.cfg.HaveTriggerAddress)
|
||||
prompt_Printf(&prompt, " Negotiation(trigger): %s\n",
|
||||
inet_ntoa(IpcpInfo.TriggerAddress));
|
||||
inet_ntoa(IpcpInfo.cfg.TriggerAddress));
|
||||
else
|
||||
prompt_Printf(&prompt, " Negotiation(trigger): MYADDR\n");
|
||||
prompt_Printf(&prompt, " Initial VJ slots: %d\n", IpcpInfo.VJInitSlots);
|
||||
prompt_Printf(&prompt, " Initial VJ slots: %d\n",
|
||||
IpcpInfo.cfg.VJInitSlots);
|
||||
prompt_Printf(&prompt, " Initial VJ compression: %s\n",
|
||||
IpcpInfo.VJInitComp ? "on" : "off");
|
||||
IpcpInfo.cfg.VJInitComp ? "on" : "off");
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
throughput_disp(&IpcpInfo.throughput);
|
||||
@ -187,24 +175,6 @@ ReportIpcpStatus(struct cmdargs const *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
IpcpDefAddress()
|
||||
{
|
||||
/* Setup default IP addresses (`hostname` -> 0.0.0.0) */
|
||||
struct hostent *hp;
|
||||
char name[200];
|
||||
|
||||
memset(&IpcpInfo.DefMyAddress, '\0', sizeof IpcpInfo.DefMyAddress);
|
||||
memset(&IpcpInfo.DefHisAddress, '\0', sizeof IpcpInfo.DefHisAddress);
|
||||
IpcpInfo.HaveTriggerAddress = 0;
|
||||
if (gethostname(name, sizeof name) == 0) {
|
||||
hp = gethostbyname(name);
|
||||
if (hp && hp->h_addrtype == AF_INET)
|
||||
memcpy(&IpcpInfo.DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length);
|
||||
}
|
||||
IpcpInfo.if_mine.s_addr = IpcpInfo.if_peer.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
int
|
||||
SetInitVJ(struct cmdargs const *args)
|
||||
{
|
||||
@ -216,13 +186,13 @@ SetInitVJ(struct cmdargs const *args)
|
||||
slots = atoi(args->argv[1]);
|
||||
if (slots < 4 || slots > 16)
|
||||
return 1;
|
||||
IpcpInfo.VJInitSlots = slots;
|
||||
IpcpInfo.cfg.VJInitSlots = slots;
|
||||
return 0;
|
||||
} else if (!strcasecmp(args->argv[0], "slotcomp")) {
|
||||
if (!strcasecmp(args->argv[1], "on"))
|
||||
IpcpInfo.VJInitComp = 1;
|
||||
IpcpInfo.cfg.VJInitComp = 1;
|
||||
else if (!strcasecmp(args->argv[1], "off"))
|
||||
IpcpInfo.VJInitComp = 0;
|
||||
IpcpInfo.cfg.VJInitComp = 0;
|
||||
else
|
||||
return 2;
|
||||
return 0;
|
||||
@ -231,44 +201,86 @@ SetInitVJ(struct cmdargs const *args)
|
||||
}
|
||||
|
||||
void
|
||||
IpcpInit(struct bundle *bundle, struct link *l)
|
||||
ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l)
|
||||
{
|
||||
/* Initialise ourselves */
|
||||
FsmInit(&IpcpInfo.fsm, bundle, l, 10);
|
||||
if (iplist_isvalid(&IpcpInfo.DefHisChoice))
|
||||
iplist_setrandpos(&IpcpInfo.DefHisChoice);
|
||||
IpcpInfo.his_compproto = 0;
|
||||
IpcpInfo.his_reject = IpcpInfo.my_reject = 0;
|
||||
struct hostent *hp;
|
||||
char name[MAXHOSTNAMELEN];
|
||||
|
||||
if ((mode & MODE_DEDICATED) && !GetLabel()) {
|
||||
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.his_ipaddr.s_addr = INADDR_ANY;
|
||||
} else {
|
||||
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.DefMyAddress.ipaddr.s_addr;
|
||||
IpcpInfo.his_ipaddr.s_addr = IpcpInfo.DefHisAddress.ipaddr.s_addr;
|
||||
fsm_Init(&ipcp->fsm, "IPCP", PROTO_IPCP, IPCP_MAXCODE, 10, LogIPCP,
|
||||
bundle, l, &ipcp_Callbacks);
|
||||
|
||||
ipcp->cfg.VJInitSlots = DEF_VJ_STATES;
|
||||
ipcp->cfg.VJInitComp = 1;
|
||||
memset(&ipcp->cfg.my_range, '\0', sizeof ipcp->cfg.my_range);
|
||||
if (gethostname(name, sizeof name) == 0) {
|
||||
hp = gethostbyname(name);
|
||||
if (hp && hp->h_addrtype == AF_INET) {
|
||||
memcpy(&ipcp->cfg.my_range.ipaddr.s_addr, hp->h_addr, hp->h_length);
|
||||
ipcp->cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
|
||||
ipcp->cfg.peer_range.width = 32;
|
||||
}
|
||||
}
|
||||
memset(&ipcp->cfg.peer_range, '\0', sizeof ipcp->cfg.peer_range);
|
||||
iplist_setsrc(&ipcp->cfg.peer_list, "");
|
||||
ipcp->cfg.HaveTriggerAddress = 0;
|
||||
|
||||
ipcp->cfg.ns_entries[0].s_addr = INADDR_ANY;
|
||||
ipcp->cfg.ns_entries[1].s_addr = INADDR_ANY;
|
||||
ipcp->cfg.nbns_entries[0].s_addr = INADDR_ANY;
|
||||
ipcp->cfg.nbns_entries[1].s_addr = INADDR_ANY;
|
||||
|
||||
ipcp->my_ifip.s_addr = INADDR_ANY;
|
||||
ipcp->peer_ifip.s_addr = INADDR_ANY;
|
||||
|
||||
ipcp_Setup(ipcp);
|
||||
}
|
||||
|
||||
void
|
||||
ipcp_Setup(struct ipcp *ipcp)
|
||||
{
|
||||
int pos;
|
||||
|
||||
ipcp->fsm.open_mode = 0;
|
||||
|
||||
if (iplist_isvalid(&ipcp->cfg.peer_list)) {
|
||||
if (ipcp->my_ifip.s_addr != INADDR_ANY &&
|
||||
(pos = iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->my_ifip)) != -1)
|
||||
ipcp->cfg.peer_range.ipaddr = iplist_setcurpos(&ipcp->cfg.peer_list, pos);
|
||||
else
|
||||
ipcp->cfg.peer_range.ipaddr = iplist_setrandpos(&ipcp->cfg.peer_list);
|
||||
ipcp->cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
|
||||
ipcp->cfg.peer_range.width = 32;
|
||||
}
|
||||
|
||||
ipcp->heis1172 = 0;
|
||||
|
||||
ipcp->peer_ip = ipcp->cfg.peer_range.ipaddr;
|
||||
ipcp->peer_compproto = 0;
|
||||
|
||||
/*
|
||||
* Some implementations of PPP require that we send a
|
||||
* *special* value as our address, even though the rfc specifies
|
||||
* full negotiation (e.g. "0.0.0.0" or Not "0.0.0.0").
|
||||
*/
|
||||
if (IpcpInfo.HaveTriggerAddress) {
|
||||
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.TriggerAddress.s_addr;
|
||||
if (ipcp->cfg.HaveTriggerAddress) {
|
||||
ipcp->my_ip = ipcp->cfg.TriggerAddress;
|
||||
LogPrintf(LogIPCP, "Using trigger address %s\n",
|
||||
inet_ntoa(IpcpInfo.TriggerAddress));
|
||||
}
|
||||
inet_ntoa(ipcp->cfg.TriggerAddress));
|
||||
} else
|
||||
ipcp->my_ip = ipcp->cfg.my_range.ipaddr;
|
||||
|
||||
if (Enabled(ConfVjcomp))
|
||||
IpcpInfo.want_compproto = (PROTO_VJCOMP << 16) +
|
||||
((IpcpInfo.VJInitSlots - 1) << 8) +
|
||||
IpcpInfo.VJInitComp;
|
||||
ipcp->my_compproto = (PROTO_VJCOMP << 16) +
|
||||
((ipcp->cfg.VJInitSlots - 1) << 8) +
|
||||
ipcp->cfg.VJInitComp;
|
||||
else
|
||||
IpcpInfo.want_compproto = 0;
|
||||
VjInit(IpcpInfo.VJInitSlots - 1);
|
||||
ipcp->my_compproto = 0;
|
||||
VjInit(ipcp->cfg.VJInitSlots - 1);
|
||||
|
||||
IpcpInfo.heis1172 = 0;
|
||||
throughput_init(&IpcpInfo.throughput);
|
||||
ipcp->peer_reject = 0;
|
||||
ipcp->my_reject = 0;
|
||||
|
||||
throughput_init(&ipcp->throughput);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -282,8 +294,8 @@ ipcp_SetIPaddress(struct bundle *bundle, struct ipcp *ipcp,
|
||||
struct ifaliasreq ifra;
|
||||
|
||||
/* If given addresses are alreay set, then ignore this request */
|
||||
if (ipcp->if_mine.s_addr == myaddr.s_addr &&
|
||||
ipcp->if_peer.s_addr == hisaddr.s_addr)
|
||||
if (ipcp->my_ifip.s_addr == myaddr.s_addr &&
|
||||
ipcp->peer_ifip.s_addr == hisaddr.s_addr)
|
||||
return 0;
|
||||
|
||||
IpcpCleanInterface(&ipcp->fsm);
|
||||
@ -335,11 +347,11 @@ ipcp_SetIPaddress(struct bundle *bundle, struct ipcp *ipcp,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ipcp->if_peer.s_addr = hisaddr.s_addr;
|
||||
ipcp->if_mine.s_addr = myaddr.s_addr;
|
||||
ipcp->peer_ifip.s_addr = hisaddr.s_addr;
|
||||
ipcp->my_ifip.s_addr = myaddr.s_addr;
|
||||
|
||||
if (Enabled(ConfProxy))
|
||||
sifproxyarp(bundle, ipcp, s);
|
||||
sifproxyarp(bundle, ipcp->peer_ifip, s);
|
||||
|
||||
close(s);
|
||||
return (0);
|
||||
@ -352,8 +364,8 @@ ChooseHisAddr(struct bundle *bundle, struct ipcp *ipcp,
|
||||
struct in_addr try;
|
||||
int f;
|
||||
|
||||
for (f = 0; f < IpcpInfo.DefHisChoice.nItems; f++) {
|
||||
try = iplist_next(&IpcpInfo.DefHisChoice);
|
||||
for (f = 0; f < IpcpInfo.cfg.peer_list.nItems; f++) {
|
||||
try = iplist_next(&IpcpInfo.cfg.peer_list);
|
||||
LogPrintf(LogDEBUG, "ChooseHisAddr: Check item %d (%s)\n",
|
||||
f, inet_ntoa(try));
|
||||
if (ipcp_SetIPaddress(bundle, ipcp, gw, try, ifnetmask, 1) == 0) {
|
||||
@ -363,7 +375,7 @@ ChooseHisAddr(struct bundle *bundle, struct ipcp *ipcp,
|
||||
}
|
||||
}
|
||||
|
||||
if (f == IpcpInfo.DefHisChoice.nItems) {
|
||||
if (f == IpcpInfo.cfg.peer_list.nItems) {
|
||||
LogPrintf(LogDEBUG, "ChooseHisAddr: All addresses in use !\n");
|
||||
try.s_addr = INADDR_ANY;
|
||||
}
|
||||
@ -393,12 +405,12 @@ IpcpSendConfigReq(struct fsm *fp)
|
||||
if ((p && !Physical_IsSync(p)) || !REJECTED(ipcp, TY_IPADDR)) {
|
||||
o.id = TY_IPADDR;
|
||||
o.len = 6;
|
||||
*(u_long *)o.data = ipcp->want_ipaddr.s_addr;
|
||||
*(u_long *)o.data = ipcp->my_ip.s_addr;
|
||||
cp += LcpPutConf(LogIPCP, cp, &o, cftypes[o.id],
|
||||
inet_ntoa(ipcp->want_ipaddr));
|
||||
inet_ntoa(ipcp->my_ip));
|
||||
}
|
||||
|
||||
if (ipcp->want_compproto && !REJECTED(ipcp, TY_COMPPROTO)) {
|
||||
if (ipcp->my_compproto && !REJECTED(ipcp, TY_COMPPROTO)) {
|
||||
const char *args;
|
||||
o.id = TY_COMPPROTO;
|
||||
if (ipcp->heis1172) {
|
||||
@ -407,8 +419,8 @@ IpcpSendConfigReq(struct fsm *fp)
|
||||
args = "";
|
||||
} else {
|
||||
o.len = 6;
|
||||
*(u_long *)o.data = htonl(ipcp->want_compproto);
|
||||
args = vj2asc(ipcp->want_compproto);
|
||||
*(u_long *)o.data = htonl(ipcp->my_compproto);
|
||||
args = vj2asc(ipcp->my_compproto);
|
||||
}
|
||||
cp += LcpPutConf(LogIPCP, cp, &o, cftypes[o.id], args);
|
||||
}
|
||||
@ -460,10 +472,10 @@ IpcpCleanInterface(struct fsm *fp)
|
||||
}
|
||||
|
||||
if (Enabled(ConfProxy))
|
||||
cifproxyarp(fp->bundle, ipcp, s);
|
||||
cifproxyarp(fp->bundle, ipcp->peer_ifip, s);
|
||||
|
||||
if (ipcp->if_mine.s_addr != INADDR_ANY ||
|
||||
ipcp->if_peer.s_addr != INADDR_ANY) {
|
||||
if (ipcp->my_ifip.s_addr != INADDR_ANY ||
|
||||
ipcp->peer_ifip.s_addr != INADDR_ANY) {
|
||||
memset(&ifra, '\0', sizeof ifra);
|
||||
strncpy(ifra.ifra_name, fp->bundle->ifname, sizeof ifra.ifra_name - 1);
|
||||
ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0';
|
||||
@ -471,14 +483,14 @@ IpcpCleanInterface(struct fsm *fp)
|
||||
peer = (struct sockaddr_in *)&ifra.ifra_broadaddr;
|
||||
me->sin_family = peer->sin_family = AF_INET;
|
||||
me->sin_len = peer->sin_len = sizeof(struct sockaddr_in);
|
||||
me->sin_addr = ipcp->if_mine;
|
||||
peer->sin_addr = ipcp->if_peer;
|
||||
me->sin_addr = ipcp->my_ifip;
|
||||
peer->sin_addr = ipcp->peer_ifip;
|
||||
if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
|
||||
LogPrintf(LogERROR, "IpcpCleanInterface: ioctl(SIOCDIFADDR): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
}
|
||||
ipcp->if_mine.s_addr = ipcp->if_peer.s_addr = INADDR_ANY;
|
||||
ipcp->my_ifip.s_addr = ipcp->peer_ifip.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
close(s);
|
||||
@ -491,7 +503,7 @@ IpcpLayerDown(struct fsm *fp)
|
||||
struct ipcp *ipcp = fsm2ipcp(fp);
|
||||
const char *s;
|
||||
|
||||
s = inet_ntoa(ipcp->if_peer);
|
||||
s = inet_ntoa(ipcp->peer_ifip);
|
||||
LogPrintf(LogIsKept(LogLINK) ? LogLINK : LogIPCP, "IpcpLayerDown: %s\n", s);
|
||||
|
||||
throughput_stop(&ipcp->throughput);
|
||||
@ -520,32 +532,32 @@ IpcpLayerUp(struct fsm *fp)
|
||||
char tbuff[100];
|
||||
|
||||
LogPrintf(LogIPCP, "IpcpLayerUp(%d).\n", fp->state);
|
||||
snprintf(tbuff, sizeof tbuff, "myaddr = %s ", inet_ntoa(ipcp->want_ipaddr));
|
||||
snprintf(tbuff, sizeof tbuff, "myaddr = %s ", inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIsKept(LogIPCP) ? LogIPCP : LogLINK, " %s hisaddr = %s\n",
|
||||
tbuff, inet_ntoa(ipcp->his_ipaddr));
|
||||
tbuff, inet_ntoa(ipcp->peer_ip));
|
||||
|
||||
if (ipcp->his_compproto >> 16 == PROTO_VJCOMP)
|
||||
VjInit((ipcp->his_compproto >> 8) & 255);
|
||||
if (ipcp->peer_compproto >> 16 == PROTO_VJCOMP)
|
||||
VjInit((ipcp->peer_compproto >> 8) & 255);
|
||||
|
||||
if (ipcp_SetIPaddress(fp->bundle, ipcp, ipcp->want_ipaddr,
|
||||
ipcp->his_ipaddr, ifnetmask, 0) < 0) {
|
||||
if (ipcp_SetIPaddress(fp->bundle, ipcp, ipcp->my_ip,
|
||||
ipcp->peer_ip, ifnetmask, 0) < 0) {
|
||||
LogPrintf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (mode & MODE_ALIAS)
|
||||
VarPacketAliasSetAddress(ipcp->want_ipaddr);
|
||||
VarPacketAliasSetAddress(ipcp->my_ip);
|
||||
#endif
|
||||
|
||||
LogPrintf(LogIsKept(LogLINK) ? LogLINK : LogIPCP, "IpcpLayerUp: %s\n",
|
||||
inet_ntoa(ipcp->if_peer));
|
||||
inet_ntoa(ipcp->peer_ifip));
|
||||
|
||||
/*
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (SelectSystem(fp->bundle, inet_ntoa(ipcp->if_mine), LINKUPFILE) < 0)
|
||||
if (SelectSystem(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE) < 0)
|
||||
if (GetLabel()) {
|
||||
if (SelectSystem(fp->bundle, GetLabel(), LINKUPFILE) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE);
|
||||
@ -619,53 +631,53 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
if (iplist_isvalid(&ipcp->DefHisChoice)) {
|
||||
if (iplist_isvalid(&ipcp->cfg.peer_list)) {
|
||||
if (ipaddr.s_addr == INADDR_ANY ||
|
||||
iplist_ip2pos(&ipcp->DefHisChoice, ipaddr) < 0 ||
|
||||
ipcp_SetIPaddress(fp->bundle, ipcp, ipcp->DefMyAddress.ipaddr,
|
||||
iplist_ip2pos(&ipcp->cfg.peer_list, ipaddr) < 0 ||
|
||||
ipcp_SetIPaddress(fp->bundle, ipcp, ipcp->cfg.my_range.ipaddr,
|
||||
ipaddr, ifnetmask, 1)) {
|
||||
LogPrintf(LogIPCP, "%s: Address invalid or already in use\n",
|
||||
inet_ntoa(ipaddr));
|
||||
ipcp->his_ipaddr = ChooseHisAddr
|
||||
(fp->bundle, ipcp, ipcp->DefMyAddress.ipaddr);
|
||||
if (ipcp->his_ipaddr.s_addr == INADDR_ANY) {
|
||||
ipcp->peer_ip = ChooseHisAddr
|
||||
(fp->bundle, ipcp, ipcp->cfg.my_range.ipaddr);
|
||||
if (ipcp->peer_ip.s_addr == INADDR_ANY) {
|
||||
memcpy(rejp, cp, length);
|
||||
rejp += length;
|
||||
} else {
|
||||
memcpy(nakp, cp, 2);
|
||||
memcpy(nakp+2, &ipcp->his_ipaddr.s_addr, length - 2);
|
||||
memcpy(nakp+2, &ipcp->peer_ip.s_addr, length - 2);
|
||||
nakp += length;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (!AcceptableAddr(&ipcp->DefHisAddress, ipaddr)) {
|
||||
} else if (!AcceptableAddr(&ipcp->cfg.peer_range, ipaddr)) {
|
||||
/*
|
||||
* If destination address is not acceptable, insist to use what we
|
||||
* want to use.
|
||||
*/
|
||||
memcpy(nakp, cp, 2);
|
||||
memcpy(nakp+2, &ipcp->his_ipaddr.s_addr, length - 2);
|
||||
memcpy(nakp+2, &ipcp->peer_ip.s_addr, length - 2);
|
||||
nakp += length;
|
||||
break;
|
||||
}
|
||||
ipcp->his_ipaddr = ipaddr;
|
||||
ipcp->peer_ip = ipaddr;
|
||||
memcpy(ackp, cp, length);
|
||||
ackp += length;
|
||||
break;
|
||||
case MODE_NAK:
|
||||
if (AcceptableAddr(&ipcp->DefMyAddress, ipaddr)) {
|
||||
if (AcceptableAddr(&ipcp->cfg.my_range, ipaddr)) {
|
||||
/* Use address suggested by peer */
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s ", tbuff,
|
||||
inet_ntoa(ipcp->want_ipaddr));
|
||||
inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
ipcp->want_ipaddr = ipaddr;
|
||||
ipcp->my_ip = ipaddr;
|
||||
} else {
|
||||
LogPrintf(LogIPCP, "%s: Unacceptable address!\n", inet_ntoa(ipaddr));
|
||||
FsmClose(&ipcp->fsm);
|
||||
}
|
||||
break;
|
||||
case MODE_REJ:
|
||||
ipcp->his_reject |= (1 << type);
|
||||
ipcp->peer_reject |= (1 << type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -686,7 +698,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
if (ntohs(pcomp->proto) == PROTO_VJCOMP) {
|
||||
LogPrintf(LogWARN, "Peer is speaking RFC1172 compression protocol !\n");
|
||||
ipcp->heis1172 = 1;
|
||||
ipcp->his_compproto = compproto;
|
||||
ipcp->peer_compproto = compproto;
|
||||
memcpy(ackp, cp, length);
|
||||
ackp += length;
|
||||
} else {
|
||||
@ -698,15 +710,16 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
break;
|
||||
case 6: /* RFC1332 */
|
||||
if (ntohs(pcomp->proto) == PROTO_VJCOMP
|
||||
&& pcomp->slots < MAX_VJ_STATES && pcomp->slots > 2) {
|
||||
ipcp->his_compproto = compproto;
|
||||
&& pcomp->slots <= MAX_VJ_STATES
|
||||
&& pcomp->slots >= MIN_VJ_STATES) {
|
||||
ipcp->peer_compproto = compproto;
|
||||
ipcp->heis1172 = 0;
|
||||
memcpy(ackp, cp, length);
|
||||
ackp += length;
|
||||
} else {
|
||||
memcpy(nakp, cp, 2);
|
||||
pcomp->proto = htons(PROTO_VJCOMP);
|
||||
pcomp->slots = MAX_VJ_STATES - 1;
|
||||
pcomp->slots = DEF_VJ_STATES;
|
||||
pcomp->compcid = 0;
|
||||
memcpy(nakp+2, &pcomp, sizeof pcomp);
|
||||
nakp += length;
|
||||
@ -721,11 +734,11 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
break;
|
||||
case MODE_NAK:
|
||||
LogPrintf(LogIPCP, "%s changing compproto: %08x --> %08x\n",
|
||||
tbuff, ipcp->want_compproto, compproto);
|
||||
ipcp->want_compproto = compproto;
|
||||
tbuff, ipcp->my_compproto, compproto);
|
||||
ipcp->my_compproto = compproto;
|
||||
break;
|
||||
case MODE_REJ:
|
||||
ipcp->his_reject |= (1 << type);
|
||||
ipcp->peer_reject |= (1 << type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -739,20 +752,20 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
ipcp->his_ipaddr = ipaddr;
|
||||
ipcp->want_ipaddr = dstipaddr;
|
||||
ipcp->peer_ip = ipaddr;
|
||||
ipcp->my_ip = dstipaddr;
|
||||
memcpy(ackp, cp, length);
|
||||
ackp += length;
|
||||
break;
|
||||
case MODE_NAK:
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s", tbuff,
|
||||
inet_ntoa(ipcp->want_ipaddr));
|
||||
inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
ipcp->want_ipaddr = ipaddr;
|
||||
ipcp->his_ipaddr = dstipaddr;
|
||||
ipcp->my_ip = ipaddr;
|
||||
ipcp->peer_ip = dstipaddr;
|
||||
break;
|
||||
case MODE_REJ:
|
||||
ipcp->his_reject |= (1 << type);
|
||||
ipcp->peer_reject |= (1 << type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -775,7 +788,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
case MODE_REQ:
|
||||
lp = (u_long *) (cp + 2);
|
||||
dnsstuff.s_addr = *lp;
|
||||
ms_info_req.s_addr = ipcp->ns_entries
|
||||
ms_info_req.s_addr = ipcp->cfg.ns_entries
|
||||
[(type - TY_PRIMARY_DNS) ? 1 : 0].s_addr;
|
||||
if (dnsstuff.s_addr != ms_info_req.s_addr) {
|
||||
|
||||
@ -825,7 +838,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type)
|
||||
case MODE_REQ:
|
||||
lp = (u_long *) (cp + 2);
|
||||
dnsstuff.s_addr = *lp;
|
||||
ms_info_req.s_addr = ipcp->nbns_entries
|
||||
ms_info_req.s_addr = ipcp->cfg.nbns_entries
|
||||
[(type - TY_PRIMARY_NBNS) ? 1 : 0].s_addr;
|
||||
if (dnsstuff.s_addr != ms_info_req.s_addr) {
|
||||
memcpy(nakp, cp, 2);
|
||||
@ -876,36 +889,36 @@ int
|
||||
UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
|
||||
{
|
||||
/* Use `hisaddr' for the peers address (set iface if `setaddr') */
|
||||
memset(&IpcpInfo.DefHisAddress, '\0', sizeof IpcpInfo.DefHisAddress);
|
||||
iplist_reset(&IpcpInfo.DefHisChoice);
|
||||
memset(&IpcpInfo.cfg.peer_range, '\0', sizeof IpcpInfo.cfg.peer_range);
|
||||
iplist_reset(&IpcpInfo.cfg.peer_list);
|
||||
if (strpbrk(hisaddr, ",-")) {
|
||||
iplist_setsrc(&IpcpInfo.DefHisChoice, hisaddr);
|
||||
if (iplist_isvalid(&IpcpInfo.DefHisChoice)) {
|
||||
iplist_setrandpos(&IpcpInfo.DefHisChoice);
|
||||
IpcpInfo.his_ipaddr = ChooseHisAddr
|
||||
(bundle, &IpcpInfo, IpcpInfo.want_ipaddr);
|
||||
if (IpcpInfo.his_ipaddr.s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogWARN, "%s: None available !\n", IpcpInfo.DefHisChoice.src);
|
||||
iplist_setsrc(&IpcpInfo.cfg.peer_list, hisaddr);
|
||||
if (iplist_isvalid(&IpcpInfo.cfg.peer_list)) {
|
||||
iplist_setrandpos(&IpcpInfo.cfg.peer_list);
|
||||
IpcpInfo.peer_ip = ChooseHisAddr
|
||||
(bundle, &IpcpInfo, IpcpInfo.my_ip);
|
||||
if (IpcpInfo.peer_ip.s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogWARN, "%s: None available !\n", IpcpInfo.cfg.peer_list.src);
|
||||
return(0);
|
||||
}
|
||||
IpcpInfo.DefHisAddress.ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr;
|
||||
IpcpInfo.DefHisAddress.mask.s_addr = INADDR_BROADCAST;
|
||||
IpcpInfo.DefHisAddress.width = 32;
|
||||
IpcpInfo.cfg.peer_range.ipaddr.s_addr = IpcpInfo.peer_ip.s_addr;
|
||||
IpcpInfo.cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
|
||||
IpcpInfo.cfg.peer_range.width = 32;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: Invalid range !\n", hisaddr);
|
||||
return 0;
|
||||
}
|
||||
} else if (ParseAddr(1, &hisaddr, &IpcpInfo.DefHisAddress.ipaddr,
|
||||
&IpcpInfo.DefHisAddress.mask,
|
||||
&IpcpInfo.DefHisAddress.width) != 0) {
|
||||
IpcpInfo.his_ipaddr.s_addr = IpcpInfo.DefHisAddress.ipaddr.s_addr;
|
||||
} else if (ParseAddr(1, &hisaddr, &IpcpInfo.cfg.peer_range.ipaddr,
|
||||
&IpcpInfo.cfg.peer_range.mask,
|
||||
&IpcpInfo.cfg.peer_range.width) != 0) {
|
||||
IpcpInfo.peer_ip.s_addr = IpcpInfo.cfg.peer_range.ipaddr.s_addr;
|
||||
|
||||
if (setaddr && ipcp_SetIPaddress(bundle, &IpcpInfo,
|
||||
IpcpInfo.DefMyAddress.ipaddr,
|
||||
IpcpInfo.DefHisAddress.ipaddr, ifnetmask,
|
||||
IpcpInfo.cfg.my_range.ipaddr,
|
||||
IpcpInfo.cfg.peer_range.ipaddr, ifnetmask,
|
||||
0) < 0) {
|
||||
IpcpInfo.DefMyAddress.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.DefHisAddress.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.my_range.ipaddr.s_addr = INADDR_ANY;
|
||||
IpcpInfo.cfg.peer_range.ipaddr.s_addr = INADDR_ANY;
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.18.2.11 1998/02/08 11:04:52 brian Exp $
|
||||
* $Id: ipcp.h,v 1.18.2.12 1998/02/08 19:29:44 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -42,35 +42,36 @@ struct in_range {
|
||||
struct ipcp {
|
||||
struct fsm fsm; /* The finite state machine */
|
||||
|
||||
int VJInitSlots; /* Maximum VJ slots */
|
||||
int VJInitComp : 1; /* Slot compression */
|
||||
struct {
|
||||
int VJInitSlots; /* Maximum VJ slots */
|
||||
int VJInitComp : 1; /* Slot compression */
|
||||
|
||||
struct in_range my_range; /* MYADDR spec */
|
||||
struct in_range peer_range; /* HISADDR spec */
|
||||
struct iplist peer_list; /* Ranges of HISADDR values */
|
||||
|
||||
struct in_addr TriggerAddress; /* Address to suggest in REQ */
|
||||
int HaveTriggerAddress : 1; /* Trigger address specified */
|
||||
|
||||
#ifndef NOMSEXT
|
||||
struct in_addr ns_entries[2]; /* DNS addresses offered */
|
||||
struct in_addr nbns_entries[2]; /* NetBIOS NS addresses offered */
|
||||
#endif
|
||||
} cfg;
|
||||
|
||||
int heis1172 : 1; /* True if he is speaking rfc1172 */
|
||||
|
||||
struct in_addr his_ipaddr; /* IP address he's willing to use */
|
||||
u_int32_t his_compproto; /* VJ params he's willing to use */
|
||||
struct in_addr peer_ip; /* IP address he's willing to use */
|
||||
u_int32_t peer_compproto; /* VJ params he's willing to use */
|
||||
|
||||
struct in_addr want_ipaddr; /* IP address I'm willing to use */
|
||||
u_int32_t want_compproto; /* VJ params I'm willing to use */
|
||||
struct in_addr my_ip; /* IP address I'm willing to use */
|
||||
u_int32_t my_compproto; /* VJ params I'm willing to use */
|
||||
|
||||
u_int32_t his_reject; /* Request codes rejected by peer */
|
||||
u_int32_t peer_reject; /* Request codes rejected by peer */
|
||||
u_int32_t my_reject; /* Request codes I have rejected */
|
||||
|
||||
#ifndef NOMSEXT
|
||||
struct in_addr ns_entries[2]; /* DNS addresses offered */
|
||||
struct in_addr nbns_entries[2]; /* NetBIOS NS addresses offered */
|
||||
#endif
|
||||
|
||||
struct in_range DefMyAddress; /* MYADDR spec */
|
||||
|
||||
struct in_range DefHisAddress; /* HISADDR spec */
|
||||
struct iplist DefHisChoice; /* Ranges of HISADDR values */
|
||||
|
||||
struct in_addr TriggerAddress; /* Address to suggest in REQ */
|
||||
int HaveTriggerAddress : 1; /* Trigger address specified */
|
||||
|
||||
struct in_addr if_mine; /* My configured interface address */
|
||||
struct in_addr if_peer; /* My congigured destination address */
|
||||
struct in_addr my_ifip; /* My configured interface address */
|
||||
struct in_addr peer_ifip; /* My congigured destination address */
|
||||
|
||||
struct pppThroughput throughput; /* throughput statistics */
|
||||
};
|
||||
@ -79,8 +80,9 @@ extern struct ipcp IpcpInfo;
|
||||
|
||||
#define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL)
|
||||
|
||||
extern void IpcpInit(struct bundle *, struct link *l);
|
||||
extern void IpcpDefAddress(void);
|
||||
extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *l);
|
||||
extern void ipcp_Setup(struct ipcp *);
|
||||
|
||||
extern void IpcpUp(void);
|
||||
extern void IpcpOpen(void);
|
||||
extern int ReportIpcpStatus(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.c,v 1.55.2.17 1998/02/18 19:35:48 brian Exp $
|
||||
* $Id: lcp.c,v 1.55.2.18 1998/02/19 19:57:01 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Limit data field length by MRU
|
||||
@ -96,7 +96,9 @@ static struct fsm_callbacks lcp_Callbacks = {
|
||||
LcpSendConfigReq,
|
||||
LcpSendTerminateReq,
|
||||
LcpSendTerminateAck,
|
||||
LcpDecodeConfig
|
||||
LcpDecodeConfig,
|
||||
NullRecvResetReq,
|
||||
NullRecvResetAck
|
||||
};
|
||||
|
||||
struct lcp LcpInfo = {
|
||||
@ -183,32 +185,43 @@ GenerateMagic(void)
|
||||
}
|
||||
|
||||
void
|
||||
LcpInit(struct bundle *bundle, struct physical *physical)
|
||||
lcp_Init(struct lcp *lcp, struct bundle *bundle, struct physical *physical)
|
||||
{
|
||||
/* Initialise ourselves */
|
||||
FsmInit(&LcpInfo.fsm, bundle, physical2link(physical), 10);
|
||||
hdlc_Init(&physical->hdlc);
|
||||
async_Init(&physical->async);
|
||||
fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, LCP_MAXCODE, 10, LogLCP, bundle,
|
||||
&physical->link, &lcp_Callbacks);
|
||||
lcp_Setup(lcp, 1);
|
||||
}
|
||||
|
||||
LcpInfo.his_mru = DEF_MRU;
|
||||
LcpInfo.his_accmap = 0xffffffff;
|
||||
LcpInfo.his_magic = 0;
|
||||
LcpInfo.his_lqrperiod = 0;
|
||||
LcpInfo.his_protocomp = 0;
|
||||
LcpInfo.his_acfcomp = 0;
|
||||
LcpInfo.his_auth = 0;
|
||||
void
|
||||
lcp_Setup(struct lcp *lcp, int openmode)
|
||||
{
|
||||
struct physical *p = link2physical(lcp->fsm.link);
|
||||
|
||||
LcpInfo.want_mru = VarMRU;
|
||||
LcpInfo.want_accmap = VarAccmap;
|
||||
LcpInfo.want_magic = GenerateMagic();
|
||||
LcpInfo.want_auth = Enabled(ConfChap) ? PROTO_CHAP :
|
||||
Enabled(ConfPap) ? PROTO_PAP : 0;
|
||||
LcpInfo.want_lqrperiod = Enabled(ConfLqr) ? VarLqrTimeout * 100 : 0;
|
||||
LcpInfo.want_protocomp = Enabled(ConfProtocomp) ? 1 : 0;
|
||||
LcpInfo.want_acfcomp = Enabled(ConfAcfcomp) ? 1 : 0;
|
||||
lcp->fsm.open_mode = openmode;
|
||||
|
||||
LcpInfo.his_reject = LcpInfo.my_reject = 0;
|
||||
LcpInfo.auth_iwait = LcpInfo.auth_ineed = 0;
|
||||
hdlc_Init(&p->hdlc);
|
||||
async_Init(&p->async);
|
||||
|
||||
lcp->his_mru = DEF_MRU;
|
||||
lcp->his_accmap = 0xffffffff;
|
||||
lcp->his_magic = 0;
|
||||
lcp->his_lqrperiod = 0;
|
||||
lcp->his_protocomp = 0;
|
||||
lcp->his_acfcomp = 0;
|
||||
lcp->his_auth = 0;
|
||||
|
||||
lcp->want_mru = VarMRU;
|
||||
lcp->want_accmap = VarAccmap;
|
||||
lcp->want_magic = GenerateMagic();
|
||||
lcp->want_auth = Enabled(ConfChap) ? PROTO_CHAP :
|
||||
Enabled(ConfPap) ? PROTO_PAP : 0;
|
||||
lcp->want_lqrperiod = Enabled(ConfLqr) ? VarLqrTimeout * 100 : 0;
|
||||
lcp->want_protocomp = Enabled(ConfProtocomp) ? 1 : 0;
|
||||
lcp->want_acfcomp = Enabled(ConfAcfcomp) ? 1 : 0;
|
||||
|
||||
lcp->his_reject = lcp->my_reject = 0;
|
||||
lcp->auth_iwait = lcp->auth_ineed = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.16.2.9 1998/02/17 19:29:14 brian Exp $
|
||||
* $Id: lcp.h,v 1.16.2.10 1998/02/19 19:56:39 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -75,7 +75,9 @@ extern struct lcp LcpInfo;
|
||||
|
||||
#define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL)
|
||||
|
||||
extern void LcpInit(struct bundle *, struct physical *);
|
||||
extern void lcp_Init(struct lcp *, struct bundle *, struct physical *);
|
||||
extern void lcp_Setup(struct lcp *, int);
|
||||
|
||||
extern void LcpSendProtoRej(u_char *, int);
|
||||
extern int LcpPutConf(int, u_char *, const struct lcp_opt *, const char *,
|
||||
const char *, ...);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: link.h,v 1.1.2.3 1998/02/07 20:49:48 brian Exp $
|
||||
* $Id: link.h,v 1.1.2.4 1998/02/16 00:00:25 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#define NPROTOSTAT 11
|
||||
|
||||
struct bundle;
|
||||
struct ccp;
|
||||
|
||||
struct link {
|
||||
int type; /* _LINK type */
|
||||
@ -43,6 +44,7 @@ struct link {
|
||||
struct pppThroughput throughput; /* Link throughput statistics */
|
||||
struct pppTimer Timer; /* inactivity timeout */
|
||||
struct mqueue Queue[LINK_QUEUES]; /* Our output queue of mbufs */
|
||||
struct ccp *ccp; /* Link compression */
|
||||
|
||||
u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */
|
||||
u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.121.2.25 1998/02/17 19:28:29 brian Exp $
|
||||
* $Id: main.c,v 1.121.2.26 1998/02/18 00:27:49 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Add commands for traffic summary, version display, etc.
|
||||
@ -407,7 +407,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
SetLabel(label);
|
||||
if (mode & MODE_AUTO &&
|
||||
IpcpInfo.DefHisAddress.ipaddr.s_addr == INADDR_ANY) {
|
||||
IpcpInfo.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogWARN, "You must \"set ifaddr\" in label %s for auto mode.\n",
|
||||
label);
|
||||
Cleanup(EX_START);
|
||||
@ -590,7 +590,7 @@ DoLoop(struct bundle *bundle)
|
||||
}
|
||||
if (!tun_check_header(tun, AF_INET))
|
||||
continue;
|
||||
if (((struct ip *) rbuff)->ip_dst.s_addr == IpcpInfo.want_ipaddr.s_addr) {
|
||||
if (((struct ip *) rbuff)->ip_dst.s_addr == IpcpInfo.my_ip.s_addr) {
|
||||
/* we've been asked to send something addressed *to* us :( */
|
||||
if (VarLoopback) {
|
||||
pri = PacketCheck(rbuff, n, FL_IN);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.c,v 1.77.2.22 1998/02/17 19:29:00 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.23 1998/02/19 02:08:51 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -84,31 +84,50 @@ static int modem_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,
|
||||
int *);
|
||||
|
||||
struct physical *
|
||||
modem_Create(const char *name)
|
||||
modem_Create(const char *name, struct ccp *ccp)
|
||||
{
|
||||
struct physical *p;
|
||||
|
||||
p = (struct physical *)malloc(sizeof(struct physical));
|
||||
if (!p)
|
||||
return NULL;
|
||||
memset(p, '\0', sizeof *p);
|
||||
|
||||
p->link.type = PHYSICAL_LINK;
|
||||
p->link.name = strdup(name);
|
||||
p->link.len = sizeof *p;
|
||||
memset(&p->link.throughput, '\0', sizeof p->link.throughput);
|
||||
memset(&p->link.Timer, '\0', sizeof p->link.Timer);
|
||||
memset(p->link.Queue, '\0', sizeof p->link.Queue);
|
||||
p->link.ccp = ccp;
|
||||
memset(p->link.proto_in, '\0', sizeof p->link.proto_in);
|
||||
memset(p->link.proto_out, '\0', sizeof p->link.proto_out);
|
||||
p->link.StartOutput = modem_StartOutput;
|
||||
p->link.IsActive = modem_IsActive;
|
||||
p->link.Close = modem_Hangup;
|
||||
p->link.Destroy = modem_Destroy;
|
||||
p->fd = -1;
|
||||
p->cfg.rts_cts = MODEM_CTSRTS;
|
||||
p->cfg.speed = MODEM_SPEED;
|
||||
p->cfg.parity = CS8;
|
||||
|
||||
p->desc.type = PHYSICAL_DESCRIPTOR;
|
||||
p->desc.UpdateSet = modem_UpdateSet;
|
||||
p->desc.IsSet = Physical_IsSet;
|
||||
p->desc.Read = modem_DescriptorRead;
|
||||
p->desc.Write = Physical_DescriptorWrite;
|
||||
|
||||
hdlc_Init(&p->hdlc);
|
||||
async_Init(&p->async);
|
||||
|
||||
p->fd = -1;
|
||||
p->mbits = 0;
|
||||
p->abort = 0;
|
||||
p->dev_is_modem = 0;
|
||||
p->out = NULL;
|
||||
p->connect_count = 0;
|
||||
|
||||
p->cfg.is_direct = 0; /* not yet used */
|
||||
p->cfg.is_dedicated = 0; /* not yet used */
|
||||
p->cfg.rts_cts = MODEM_CTSRTS;
|
||||
p->cfg.speed = MODEM_SPEED;
|
||||
p->cfg.parity = CS8;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -15,15 +15,16 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.h,v 1.16.2.7 1998/02/16 00:00:51 brian Exp $
|
||||
* $Id: modem.h,v 1.16.2.8 1998/02/17 19:27:58 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
struct physical;
|
||||
struct ccp;
|
||||
|
||||
extern int modem_Raw(struct physical *, struct bundle *);
|
||||
extern struct physical *modem_Create(const char *);
|
||||
extern struct physical *modem_Create(const char *, struct ccp *);
|
||||
extern int modem_Open(struct physical *, struct bundle *);
|
||||
extern int modem_Speed(struct physical *);
|
||||
extern speed_t IntToSpeed(int);
|
||||
|
@ -16,7 +16,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.h,v 1.1.2.9 1998/02/17 19:29:03 brian Exp $
|
||||
* $Id: physical.h,v 1.1.2.10 1998/02/18 19:35:58 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -40,8 +40,8 @@ struct physical {
|
||||
belong in the generic physical struct. It comes from modem.c. */
|
||||
|
||||
struct {
|
||||
unsigned is_dedicated : 1; /* Dedicated mode? XXX-ML - not yet init'd */
|
||||
unsigned is_direct : 1; /* Direct mode? XXX-ML - not yet initialized */
|
||||
unsigned is_dedicated : 1; /* Dedicated mode? XXX-ML - not yet used */
|
||||
unsigned is_direct : 1; /* Direct mode? XXX-ML - not yet used */
|
||||
unsigned rts_cts : 1; /* Is rts/cts enabled? */
|
||||
unsigned int parity; /* What parity is enabled? (TTY flags) */
|
||||
unsigned int speed; /* Modem speed */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.10 1997/11/22 03:37:50 brian Exp $
|
||||
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.10.2.1 1998/01/29 23:11:44 brian Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@ -18,13 +18,15 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: slcompress.h,v 1.10 1997/11/22 03:37:50 brian Exp $
|
||||
* $Id: slcompress.h,v 1.10.2.1 1998/01/29 23:11:44 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#define MAX_VJ_STATES 16 /* must be > 2 and < 256 */
|
||||
#define MIN_VJ_STATES 3
|
||||
#define MAX_VJ_STATES 255
|
||||
#define DEF_VJ_STATES 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR 128 /* XXX 4bsd-ism: should really be 128 */
|
||||
|
||||
/*
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: vjcomp.c,v 1.16.2.2 1998/01/29 23:11:44 brian Exp $
|
||||
* $Id: vjcomp.c,v 1.16.2.3 1998/01/30 19:46:06 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -58,13 +58,13 @@ SendPppFrame(struct link *l, struct mbuf * bp)
|
||||
{
|
||||
int type;
|
||||
u_short proto;
|
||||
u_short cproto = IpcpInfo.his_compproto >> 16;
|
||||
u_short cproto = IpcpInfo.peer_compproto >> 16;
|
||||
|
||||
LogPrintf(LogDEBUG, "SendPppFrame: proto = %x\n", IpcpInfo.his_compproto);
|
||||
LogPrintf(LogDEBUG, "SendPppFrame: proto = %x\n", IpcpInfo.peer_compproto);
|
||||
if (((struct ip *) MBUF_CTOP(bp))->ip_p == IPPROTO_TCP
|
||||
&& cproto == PROTO_VJCOMP) {
|
||||
type = sl_compress_tcp(bp, (struct ip *)MBUF_CTOP(bp), &cslc,
|
||||
IpcpInfo.his_compproto & 0xff);
|
||||
IpcpInfo.peer_compproto & 0xff);
|
||||
LogPrintf(LogDEBUG, "SendPppFrame: type = %x\n", type);
|
||||
switch (type) {
|
||||
case TYPE_IP:
|
||||
|
Loading…
Reference in New Issue
Block a user