o Move global/static IPCP data into IpcpInfo.

o Use INADDR_ANY and INADDR_BROADCAST instead of 0 and 0xffffffff
  for IP addresses & masks.
o Move struct compreq into ipcp.c (it's none of anyone elses
  business).
o Rename MAX_STATES to MAX_VJ_STATES.
This commit is contained in:
Brian Somers 1998-01-29 23:11:44 +00:00
parent 247ab36d28
commit 29e275cee4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=32878
16 changed files with 197 additions and 156 deletions

View File

@ -2,7 +2,7 @@
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
* who places it in the public domain without restriction.
*
* $Id: alias_cmd.c,v 1.11 1997/12/24 10:28:37 brian Exp $
* $Id: alias_cmd.c,v 1.12 1998/01/21 02:15:07 brian Exp $
*/
#include <sys/param.h>
@ -76,7 +76,7 @@ AliasRedirectPort(struct cmdargs const *arg)
}
return 1;
}
null_addr.s_addr = 0;
null_addr.s_addr = INADDR_ANY;
link = VarPacketAliasRedirectPort(local_addr, local_port,
null_addr, 0,

View File

@ -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 1998/01/21 02:15:09 brian Exp $
* $Id: auth.c,v 1.27.2.1 1998/01/29 00:49:11 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
@ -35,6 +35,8 @@
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "loadalias.h"
#include "vars.h"
@ -160,9 +162,8 @@ AuthGetSecret(const char *fname, const char *system, int len, int setaddr,
continue;
if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) {
ExpandString(vector[1], passwd, sizeof passwd, 0);
if (setaddr) {
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
}
if (setaddr)
memset(&IpcpInfo.DefHisAddress, '\0', sizeof IpcpInfo.DefHisAddress);
if (n > 2 && setaddr)
if (UseHisaddr(vector[2], 1))
IpcpInit(physical);

View File

@ -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 1998/01/27 23:14:49 brian Exp $
* $Id: command.c,v 1.131.2.1 1998/01/29 00:49:15 brian Exp $
*
*/
#include <sys/param.h>
@ -54,6 +54,7 @@
#include "phase.h"
#include "lcp.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "modem.h"
#include "filter.h"
@ -586,10 +587,14 @@ ShowMSExt(struct cmdargs const *arg)
{
if (VarTerm) {
fprintf(VarTerm, " MS PPP extention values \n");
fprintf(VarTerm, " Primary NS : %s\n", inet_ntoa(ns_entries[0]));
fprintf(VarTerm, " Secondary NS : %s\n", inet_ntoa(ns_entries[1]));
fprintf(VarTerm, " Primary NBNS : %s\n", inet_ntoa(nbns_entries[0]));
fprintf(VarTerm, " Secondary NBNS : %s\n", inet_ntoa(nbns_entries[1]));
fprintf(VarTerm, " Primary NS : %s\n",
inet_ntoa(IpcpInfo.ns_entries[0]));
fprintf(VarTerm, " Secondary NS : %s\n",
inet_ntoa(IpcpInfo.ns_entries[1]));
fprintf(VarTerm, " Primary NBNS : %s\n",
inet_ntoa(IpcpInfo.nbns_entries[0]));
fprintf(VarTerm, " Secondary NBNS : %s\n",
inet_ntoa(IpcpInfo.nbns_entries[1]));
}
return 0;
}
@ -1242,26 +1247,27 @@ SetInterfaceAddr(struct cmdargs const *arg)
const char *hisaddr;
hisaddr = NULL;
DefMyAddress.ipaddr.s_addr = DefHisAddress.ipaddr.s_addr = 0L;
IpcpInfo.DefMyAddress.ipaddr.s_addr = INADDR_ANY;
IpcpInfo.DefHisAddress.ipaddr.s_addr = INADDR_ANY;
if (arg->argc > 4)
return -1;
HaveTriggerAddress = 0;
IpcpInfo.HaveTriggerAddress = 0;
ifnetmask.s_addr = 0;
iplist_reset(&DefHisChoice);
iplist_reset(&IpcpInfo.DefHisChoice);
if (arg->argc > 0) {
if (!ParseAddr(arg->argc, arg->argv, &DefMyAddress.ipaddr,
&DefMyAddress.mask, &DefMyAddress.width))
if (!ParseAddr(arg->argc, arg->argv, &IpcpInfo.DefMyAddress.ipaddr,
&IpcpInfo.DefMyAddress.mask, &IpcpInfo.DefMyAddress.width))
return 1;
if (arg->argc > 1) {
hisaddr = arg->argv[1];
if (arg->argc > 2) {
ifnetmask = GetIpAddr(arg->argv[2]);
if (arg->argc > 3) {
TriggerAddress = GetIpAddr(arg->argv[3]);
HaveTriggerAddress = 1;
IpcpInfo.TriggerAddress = GetIpAddr(arg->argv[3]);
IpcpInfo.HaveTriggerAddress = 1;
}
}
}
@ -1270,14 +1276,15 @@ SetInterfaceAddr(struct cmdargs const *arg)
/*
* For backwards compatibility, 0.0.0.0 means any address.
*/
if (DefMyAddress.ipaddr.s_addr == 0) {
DefMyAddress.mask.s_addr = 0;
DefMyAddress.width = 0;
if (IpcpInfo.DefMyAddress.ipaddr.s_addr == INADDR_ANY) {
IpcpInfo.DefMyAddress.mask.s_addr = INADDR_ANY;
IpcpInfo.DefMyAddress.width = 0;
}
IpcpInfo.want_ipaddr.s_addr = DefMyAddress.ipaddr.s_addr;
if (DefHisAddress.ipaddr.s_addr == 0) {
DefHisAddress.mask.s_addr = 0;
DefHisAddress.width = 0;
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.DefMyAddress.ipaddr.s_addr;
if (IpcpInfo.DefHisAddress.ipaddr.s_addr == INADDR_ANY) {
IpcpInfo.DefHisAddress.mask.s_addr = INADDR_ANY;
IpcpInfo.DefHisAddress.width = 0;
}
if (hisaddr && !UseHisaddr(hisaddr, mode & MODE_AUTO))
@ -1319,14 +1326,16 @@ SetMSEXT(struct in_addr * pri_addr,
static int
SetNS(struct cmdargs const *arg)
{
SetMSEXT(&ns_entries[0], &ns_entries[1], arg->argc, arg->argv);
SetMSEXT(&IpcpInfo.ns_entries[0], &IpcpInfo.ns_entries[1],
arg->argc, arg->argv);
return 0;
}
static int
SetNBNS(struct cmdargs const *arg)
{
SetMSEXT(&nbns_entries[0], &nbns_entries[1], arg->argc, arg->argv);
SetMSEXT(&IpcpInfo.nbns_entries[0], &IpcpInfo.nbns_entries[1],
arg->argc, arg->argv);
return 0;
}

View File

@ -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.21 1997/12/24 09:28:57 brian Exp $
* $Id: filter.c,v 1.22 1998/01/21 02:15:14 brian Exp $
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
@ -37,6 +37,9 @@
#include "loadalias.h"
#include "defs.h"
#include "vars.h"
#include "iplist.h"
#include "timer.h"
#include "throughput.h"
#include "ipcp.h"
#include "filter.h"
@ -76,7 +79,7 @@ ParseAddr(int argc,
}
if (pmask)
pmask->s_addr = 0xffffffff; /* Assume 255.255.255.255 as default */
pmask->s_addr = INADDR_BROADCAST; /* Assume 255.255.255.255 as default */
cp = pmask || pwidth ? strchr(*argv, '/') : NULL;
len = cp ? cp - *argv : strlen(*argv);

View File

@ -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 1998/01/21 02:15:15 brian Exp $
* $Id: hdlc.c,v 1.28.2.1 1998/01/29 00:49:21 brian Exp $
*
* TODO:
*/
@ -36,6 +36,8 @@
#include "fsm.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "ip.h"
#include "vjcomp.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.c,v 1.38 1998/01/21 02:15:16 brian Exp $
* $Id: ip.c,v 1.38.2.1 1998/01/29 00:49:22 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@ -57,6 +57,8 @@
#include "vars.h"
#include "filter.h"
#include "os.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "vjcomp.h"
#include "lcp.h"

View File

@ -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 1998/01/21 02:15:17 brian Exp $
* $Id: ipcp.c,v 1.50.2.1 1998/01/29 00:49:23 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@ -44,6 +44,7 @@
#include "lcpproto.h"
#include "lcp.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "slcompress.h"
#include "os.h"
@ -52,22 +53,17 @@
#include "vars.h"
#include "vjcomp.h"
#include "ip.h"
#include "throughput.h"
#include "route.h"
#include "filter.h"
#include "physical.h"
#ifndef NOMSEXT
struct in_addr ns_entries[2];
struct in_addr nbns_entries[2];
#endif
struct compreq {
u_short proto;
u_char slots;
u_char compcid;
};
struct ipcpstate IpcpInfo;
struct in_range DefMyAddress;
struct in_range DefHisAddress;
struct iplist DefHisChoice;
struct in_addr TriggerAddress;
int HaveTriggerAddress;
struct ipcpstate IpcpInfo = { MAX_VJ_STATES, 1 };
static void IpcpSendConfigReq(struct fsm *);
static void IpcpSendTerminateAck(struct fsm *);
@ -126,18 +122,16 @@ static const char *cftypes128[] = {
#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0])
static struct pppThroughput throughput;
void
IpcpAddInOctets(int n)
{
throughput_addin(&throughput, n);
throughput_addin(&IpcpInfo.throughput, n);
}
void
IpcpAddOutOctets(int n)
{
throughput_addout(&throughput, n);
throughput_addout(&IpcpInfo.throughput, n);
}
int
@ -157,19 +151,21 @@ ReportIpcpStatus(struct cmdargs const *arg)
fprintf(VarTerm, "Defaults:\n");
fprintf(VarTerm, " My Address: %s/%d\n",
inet_ntoa(DefMyAddress.ipaddr), DefMyAddress.width);
if (iplist_isvalid(&DefHisChoice))
fprintf(VarTerm, " His Address: %s\n", DefHisChoice.src);
inet_ntoa(IpcpInfo.DefMyAddress.ipaddr), IpcpInfo.DefMyAddress.width);
if (iplist_isvalid(&IpcpInfo.DefHisChoice))
fprintf(VarTerm, " His Address: %s\n", IpcpInfo.DefHisChoice.src);
else
fprintf(VarTerm, " His Address: %s/%d\n",
inet_ntoa(DefHisAddress.ipaddr), DefHisAddress.width);
if (HaveTriggerAddress)
fprintf(VarTerm, " Negotiation(trigger): %s\n", inet_ntoa(TriggerAddress));
inet_ntoa(IpcpInfo.DefHisAddress.ipaddr),
IpcpInfo.DefHisAddress.width);
if (IpcpInfo.HaveTriggerAddress)
fprintf(VarTerm, " Negotiation(trigger): %s\n",
inet_ntoa(IpcpInfo.TriggerAddress));
else
fprintf(VarTerm, " Negotiation(trigger): MYADDR\n");
fprintf(VarTerm, "\n");
throughput_disp(&throughput, VarTerm);
throughput_disp(&IpcpInfo.throughput, VarTerm);
return 0;
}
@ -180,21 +176,16 @@ IpcpDefAddress()
struct hostent *hp;
char name[200];
memset(&DefMyAddress, '\0', sizeof DefMyAddress);
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
TriggerAddress.s_addr = 0;
HaveTriggerAddress = 0;
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(&DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length);
}
if (hp && hp->h_addrtype == AF_INET)
memcpy(&IpcpInfo.DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length);
}
}
static int VJInitSlots = MAX_STATES;
static int VJInitComp = 1;
int
SetInitVJ(struct cmdargs const *args)
{
@ -206,13 +197,13 @@ SetInitVJ(struct cmdargs const *args)
slots = atoi(args->argv[1]);
if (slots < 4 || slots > 16)
return 1;
VJInitSlots = slots;
IpcpInfo.VJInitSlots = slots;
return 0;
} else if (!strcasecmp(args->argv[0], "slotcomp")) {
if (!strcasecmp(args->argv[1], "on"))
VJInitComp = 1;
IpcpInfo.VJInitComp = 1;
else if (!strcasecmp(args->argv[1], "off"))
VJInitComp = 0;
IpcpInfo.VJInitComp = 0;
else
return 2;
return 0;
@ -224,8 +215,9 @@ int
ShowInitVJ(struct cmdargs const *args)
{
if (VarTerm) {
fprintf(VarTerm, "Initial slots: %d\n", VJInitSlots);
fprintf(VarTerm, "Initial compression: %s\n", VJInitComp ? "on" : "off");
fprintf(VarTerm, "Initial slots: %d\n", IpcpInfo.VJInitSlots);
fprintf(VarTerm, "Initial compression: %s\n",
IpcpInfo.VJInitComp ? "on" : "off");
}
return 0;
}
@ -233,15 +225,18 @@ ShowInitVJ(struct cmdargs const *args)
void
IpcpInit(struct physical *physical)
{
if (iplist_isvalid(&DefHisChoice))
iplist_setrandpos(&DefHisChoice);
if (iplist_isvalid(&IpcpInfo.DefHisChoice))
iplist_setrandpos(&IpcpInfo.DefHisChoice);
FsmInit(&IpcpFsm, physical);
memset(&IpcpInfo, '\0', sizeof IpcpInfo);
IpcpInfo.his_compproto = 0;
IpcpInfo.his_reject = IpcpInfo.my_reject = 0;
if ((mode & MODE_DEDICATED) && !GetLabel()) {
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr = 0;
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 = DefMyAddress.ipaddr.s_addr;
IpcpInfo.his_ipaddr.s_addr = DefHisAddress.ipaddr.s_addr;
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.DefMyAddress.ipaddr.s_addr;
IpcpInfo.his_ipaddr.s_addr = IpcpInfo.DefHisAddress.ipaddr.s_addr;
}
/*
@ -249,18 +244,22 @@ IpcpInit(struct physical *physical)
* *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 (HaveTriggerAddress) {
IpcpInfo.want_ipaddr.s_addr = TriggerAddress.s_addr;
LogPrintf(LogIPCP, "Using trigger address %s\n", inet_ntoa(TriggerAddress));
if (IpcpInfo.HaveTriggerAddress) {
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.TriggerAddress.s_addr;
LogPrintf(LogIPCP, "Using trigger address %s\n",
inet_ntoa(IpcpInfo.TriggerAddress));
}
if (Enabled(ConfVjcomp))
IpcpInfo.want_compproto = (PROTO_VJCOMP << 16) | ((VJInitSlots - 1) << 8) |
VJInitComp;
IpcpInfo.want_compproto = (PROTO_VJCOMP << 16) +
((IpcpInfo.VJInitSlots - 1) << 8) +
IpcpInfo.VJInitComp;
else
IpcpInfo.want_compproto = 0;
IpcpInfo.heis1172 = 0;
IpcpFsm.maxconfig = 10;
throughput_init(&throughput);
throughput_init(&IpcpInfo.throughput);
}
static void
@ -306,7 +305,7 @@ IpcpSendConfigReq(struct fsm * fp)
static void
IpcpSendTerminateReq(struct fsm * fp)
{
/* XXX: No code yet */
/* Fsm has just send a terminate request */
}
static void
@ -335,8 +334,8 @@ static void
IpcpLayerDown(struct fsm * fp)
{
LogPrintf(LogIPCP, "IpcpLayerDown.\n");
throughput_stop(&throughput);
throughput_log(&throughput, LogIPCP, NULL);
throughput_stop(&IpcpInfo.throughput);
throughput_log(&IpcpInfo.throughput, LogIPCP, NULL);
}
/*
@ -367,7 +366,7 @@ IpcpLayerUp(struct fsm * fp)
VarPacketAliasSetAddress(IpcpInfo.want_ipaddr);
#endif
OsLinkup();
throughput_start(&throughput);
throughput_start(&IpcpInfo.throughput);
StartIdleTimer();
}
@ -428,13 +427,13 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
switch (mode_type) {
case MODE_REQ:
if (iplist_isvalid(&DefHisChoice)) {
if (iplist_isvalid(&IpcpInfo.DefHisChoice)) {
if (ipaddr.s_addr == INADDR_ANY ||
iplist_ip2pos(&DefHisChoice, ipaddr) < 0 ||
OsTrySetIpaddress(DefMyAddress.ipaddr, ipaddr) != 0) {
iplist_ip2pos(&IpcpInfo.DefHisChoice, ipaddr) < 0 ||
OsTrySetIpaddress(IpcpInfo.DefMyAddress.ipaddr, ipaddr) != 0) {
LogPrintf(LogIPCP, "%s: Address invalid or already in use\n",
inet_ntoa(ipaddr));
IpcpInfo.his_ipaddr = ChooseHisAddr(DefMyAddress.ipaddr);
IpcpInfo.his_ipaddr = ChooseHisAddr(IpcpInfo.DefMyAddress.ipaddr);
if (IpcpInfo.his_ipaddr.s_addr == INADDR_ANY) {
memcpy(rejp, cp, length);
rejp += length;
@ -445,7 +444,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
}
break;
}
} else if (!AcceptableAddr(&DefHisAddress, ipaddr)) {
} else if (!AcceptableAddr(&IpcpInfo.DefHisAddress, ipaddr)) {
/*
* If destination address is not acceptable, insist to use what we
* want to use.
@ -460,7 +459,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
ackp += length;
break;
case MODE_NAK:
if (AcceptableAddr(&DefMyAddress, ipaddr)) {
if (AcceptableAddr(&IpcpInfo.DefMyAddress, ipaddr)) {
/* Use address suggested by peer */
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s ", tbuff,
inet_ntoa(IpcpInfo.want_ipaddr));
@ -505,7 +504,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
break;
case 6: /* RFC1332 */
if (ntohs(pcomp->proto) == PROTO_VJCOMP
&& pcomp->slots < MAX_STATES && pcomp->slots > 2) {
&& pcomp->slots < MAX_VJ_STATES && pcomp->slots > 2) {
IpcpInfo.his_compproto = compproto;
IpcpInfo.heis1172 = 0;
memcpy(ackp, cp, length);
@ -513,7 +512,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
} else {
memcpy(nakp, cp, 2);
pcomp->proto = htons(PROTO_VJCOMP);
pcomp->slots = MAX_STATES - 1;
pcomp->slots = MAX_VJ_STATES - 1;
pcomp->compcid = 0;
memcpy(nakp+2, &pcomp, sizeof pcomp);
nakp += length;
@ -582,7 +581,8 @@ IpcpDecodeConfig(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 = ns_entries[((type - TY_PRIMARY_DNS) ? 1 : 0)].s_addr;
ms_info_req.s_addr = IpcpInfo.ns_entries
[(type - TY_PRIMARY_DNS) ? 1 : 0].s_addr;
if (dnsstuff.s_addr != ms_info_req.s_addr) {
/*
@ -631,7 +631,8 @@ IpcpDecodeConfig(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 = nbns_entries[((type - TY_PRIMARY_NBNS) ? 1 : 0)].s_addr;
ms_info_req.s_addr = IpcpInfo.nbns_entries
[(type - TY_PRIMARY_NBNS) ? 1 : 0].s_addr;
if (dnsstuff.s_addr != ms_info_req.s_addr) {
memcpy(nakp, cp, 2);
memcpy(nakp+2, &ms_info_req.s_addr, length);
@ -679,31 +680,33 @@ IpcpInput(struct mbuf * bp)
int
UseHisaddr(const char *hisaddr, int setaddr)
{
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
iplist_reset(&DefHisChoice);
memset(&IpcpInfo.DefHisAddress, '\0', sizeof IpcpInfo.DefHisAddress);
iplist_reset(&IpcpInfo.DefHisChoice);
if (strpbrk(hisaddr, ",-")) {
iplist_setsrc(&DefHisChoice, hisaddr);
if (iplist_isvalid(&DefHisChoice)) {
iplist_setrandpos(&DefHisChoice);
iplist_setsrc(&IpcpInfo.DefHisChoice, hisaddr);
if (iplist_isvalid(&IpcpInfo.DefHisChoice)) {
iplist_setrandpos(&IpcpInfo.DefHisChoice);
IpcpInfo.his_ipaddr = ChooseHisAddr(IpcpInfo.want_ipaddr);
if (IpcpInfo.his_ipaddr.s_addr == INADDR_ANY) {
LogPrintf(LogWARN, "%s: None available !\n", DefHisChoice.src);
LogPrintf(LogWARN, "%s: None available !\n", IpcpInfo.DefHisChoice.src);
return(0);
}
DefHisAddress.ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr;
DefHisAddress.mask.s_addr = 0xffffffff;
DefHisAddress.width = 32;
IpcpInfo.DefHisAddress.ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr;
IpcpInfo.DefHisAddress.mask.s_addr = INADDR_BROADCAST;
IpcpInfo.DefHisAddress.width = 32;
} else {
LogPrintf(LogWARN, "%s: Invalid range !\n", hisaddr);
return 0;
}
} else if (ParseAddr(1, &hisaddr, &DefHisAddress.ipaddr,
&DefHisAddress.mask, &DefHisAddress.width) != 0) {
IpcpInfo.his_ipaddr.s_addr = DefHisAddress.ipaddr.s_addr;
} 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;
if (setaddr && OsSetIpaddress
(DefMyAddress.ipaddr, DefHisAddress.ipaddr) < 0) {
DefMyAddress.ipaddr.s_addr = DefHisAddress.ipaddr.s_addr = 0L;
(IpcpInfo.DefMyAddress.ipaddr, IpcpInfo.DefHisAddress.ipaddr) < 0) {
IpcpInfo.DefMyAddress.ipaddr.s_addr = INADDR_ANY;
IpcpInfo.DefHisAddress.ipaddr.s_addr = INADDR_ANY;
return 0;
}
} else

View File

@ -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 1998/01/18 20:49:19 brian Exp $
* $Id: ipcp.h,v 1.18.2.1 1998/01/29 00:49:24 brian Exp $
*
* TODO:
*/
@ -26,42 +26,50 @@
#define TY_COMPPROTO 2
#define TY_IPADDR 3
/* MS PPP NameServer and NetBIOS NameServer stuff */
/* Domain NameServer and NetBIOS NameServer options */
#ifndef NOMSEXT
#define TY_PRIMARY_DNS 129
#define TY_PRIMARY_NBNS 130
#define TY_SECONDARY_DNS 131
#define TY_SECONDARY_NBNS 132
extern struct in_addr ns_entries[2];
extern struct in_addr nbns_entries[2];
#endif
struct ipcpstate {
struct in_addr his_ipaddr; /* IP address he is willing to use */
u_int32_t his_compproto;
struct in_addr want_ipaddr; /* IP address I'm willing to use */
u_int32_t want_compproto;
u_int32_t his_reject; /* Request codes rejected by peer */
u_int32_t my_reject; /* Request codes I have rejected */
int heis1172; /* True if he is speaking rfc1172 */
};
struct compreq {
u_short proto;
u_char slots;
u_char compcid;
};
struct in_range {
struct in_addr ipaddr;
struct in_addr mask;
int width;
};
struct ipcpstate {
int VJInitSlots; /* Maximum VJ slots */
int VJInitComp : 1; /* Slot compression */
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 want_ipaddr; /* IP address I'm willing to use */
u_int32_t want_compproto; /* VJ params I'm willing to use */
u_int32_t his_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 pppThroughput throughput; /* throughput statistics */
};
extern struct ipcpstate IpcpInfo;
extern struct in_range DefMyAddress;
extern struct in_range DefHisAddress;

View File

@ -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 1998/01/21 02:15:18 brian Exp $
* $Id: lcp.c,v 1.55.2.1 1998/01/29 00:49:24 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@ -47,6 +47,8 @@
#include "timer.h"
#include "fsm.h"
#include "lcp.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "lcpproto.h"
#include "os.h"

View File

@ -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 1998/01/29 00:42:05 brian Exp $
* $Id: main.c,v 1.121.2.1 1998/01/29 00:49:26 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@ -58,6 +58,8 @@
#include "hdlc.h"
#include "lcp.h"
#include "ccp.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "loadalias.h"
#include "vars.h"
@ -466,7 +468,7 @@ main(int argc, char **argv)
*/
SetLabel(label);
if (mode & MODE_OUTGOING_DAEMON &&
DefHisAddress.ipaddr.s_addr == INADDR_ANY) {
IpcpInfo.DefHisAddress.ipaddr.s_addr == INADDR_ANY) {
LogPrintf(LogWARN, "You must \"set ifaddr\" in label %s for"
" auto, background or ddial mode.\n", label);
Cleanup(EX_START);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: os.c,v 1.41 1998/01/19 02:59:33 brian Exp $
* $Id: os.c,v 1.42 1998/01/21 02:15:23 brian Exp $
*
*/
#include <sys/param.h>
@ -42,6 +42,8 @@
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "os.h"
#include "loadalias.h"
@ -79,7 +81,7 @@ SetIpDevice(struct in_addr myaddr,
if (how == SET_DOWN) {
if (Enabled(ConfProxy))
cifproxyarp(s, oldhis);
if (oldmine.s_addr == 0 && oldhis.s_addr == 0) {
if (oldmine.s_addr == INADDR_ANY && oldhis.s_addr == INADDR_ANY) {
close(s);
return (0);
}
@ -92,7 +94,7 @@ SetIpDevice(struct in_addr myaddr,
close(s);
return (-1);
}
oldmine.s_addr = oldhis.s_addr = 0;
oldmine.s_addr = oldhis.s_addr = INADDR_ANY;
} else {
/* If given addresses are alreay set, then ignore this request */
if (oldmine.s_addr == myaddr.s_addr && oldhis.s_addr == hisaddr.s_addr) {
@ -299,7 +301,7 @@ OsInterfaceDown(int final)
close(s);
return (-1);
}
zeroaddr.s_addr = 0;
zeroaddr.s_addr = INADDR_ANY;
SetIpDevice(zeroaddr, zeroaddr, zeroaddr, SET_DOWN);
close(s);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: phase.c,v 1.6 1997/12/21 12:11:07 brian Exp $
* $Id: phase.c,v 1.6.4.1 1998/01/29 00:49:28 brian Exp $
*/
#include <sys/param.h>
@ -41,6 +41,8 @@
#include "pap.h"
#include "chap.h"
#include "defs.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "ccp.h"
#include "main.h"

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: route.c,v 1.41 1998/01/19 02:59:33 brian Exp $
* $Id: route.c,v 1.42 1998/01/21 02:15:26 brian Exp $
*
*/
@ -48,8 +48,10 @@
#include "vars.h"
#include "id.h"
#include "os.h"
#include "ipcp.h"
#include "iplist.h"
#include "timer.h"
#include "throughput.h"
#include "ipcp.h"
#include "route.h"
static int IfIndex;
@ -557,8 +559,8 @@ ChooseHisAddr(const struct in_addr gw)
struct in_addr try;
int f;
for (f = 0; f < DefHisChoice.nItems; f++) {
try = iplist_next(&DefHisChoice);
for (f = 0; f < IpcpInfo.DefHisChoice.nItems; f++) {
try = iplist_next(&IpcpInfo.DefHisChoice);
LogPrintf(LogDEBUG, "ChooseHisAddr: Check item %d (%s)\n",
f, inet_ntoa(try));
if (OsTrySetIpaddress(gw, try) == 0) {
@ -568,7 +570,7 @@ ChooseHisAddr(const struct in_addr gw)
}
}
if (f == DefHisChoice.nItems) {
if (f == IpcpInfo.DefHisChoice.nItems) {
LogPrintf(LogDEBUG, "ChooseHisAddr: All addresses in use !\n");
try.s_addr = INADDR_ANY;
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: slcompress.c,v 1.14 1997/11/22 03:37:50 brian Exp $
* $Id: slcompress.c,v 1.15 1997/12/24 09:29:17 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
@ -414,7 +414,7 @@ sl_uncompress_tcp(u_char ** bufp,
case TYPE_UNCOMPRESSED_TCP:
ip = (struct ip *) * bufp;
if (ip->ip_p >= MAX_STATES)
if (ip->ip_p >= MAX_VJ_STATES)
goto bad;
cs = &comp->rstate[comp->last_recv = ip->ip_p];
comp->flags &= ~SLF_TOSS;
@ -454,7 +454,7 @@ sl_uncompress_tcp(u_char ** bufp,
* 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 || comp->last_recv == 255)
if (*cp >= MAX_VJ_STATES || comp->last_recv == 255)
goto bad;
comp->flags &= ~SLF_TOSS;

View File

@ -1,7 +1,7 @@
/*
* Definitions for tcp compression routines.
*
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.9 1997/10/26 01:03:46 brian Exp $
* $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.10 1997/11/22 03:37:50 brian Exp $
*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved.
@ -18,13 +18,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: slcompress.h,v 1.9 1997/10/26 01:03:46 brian Exp $
* $Id: slcompress.h,v 1.10 1997/11/22 03:37:50 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
#define MAX_STATES 16 /* must be > 2 and < 256 */
#define MAX_VJ_STATES 16 /* must be > 2 and < 256 */
#define MAX_HDR 128 /* XXX 4bsd-ism: should really be 128 */
/*
@ -120,8 +120,8 @@ struct slcompress {
u_char last_recv; /* last rcvd conn. id */
u_char last_xmit; /* last sent conn. id */
u_short flags;
struct cstate tstate[MAX_STATES]; /* xmit connection states */
struct cstate rstate[MAX_STATES]; /* receive connection states */
struct cstate tstate[MAX_VJ_STATES]; /* xmit connection states */
struct cstate rstate[MAX_VJ_STATES]; /* receive connection states */
};
/* flag values */

View File

@ -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 1998/01/21 02:15:33 brian Exp $
* $Id: vjcomp.c,v 1.16.2.1 1998/01/29 00:49:32 brian Exp $
*
* TODO:
*/
@ -37,6 +37,9 @@
#include "lcpproto.h"
#include "slcompress.h"
#include "hdlc.h"
#include "defs.h"
#include "iplist.h"
#include "throughput.h"
#include "ipcp.h"
#include "vjcomp.h"