Make things work when sizeof(long) != 32 (hopefully)

This commit is contained in:
Brian Somers 1998-01-11 17:50:49 +00:00
parent 92d7687ee6
commit 3a70c9f7bf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=32439
10 changed files with 89 additions and 86 deletions

View File

@ -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.12 1998/01/04 20:25:41 brian Exp $
* $Id: ccp.h,v 1.13 1998/01/10 01:55:09 brian Exp $
*
* TODO:
*/
@ -36,14 +36,14 @@
#define TY_DEFLATE 26 /* Deflate (gzip) - rfc 1979 */
struct ccpstate {
u_long his_proto; /* peer's compression protocol */
u_long my_proto; /* our compression protocol */
int his_proto; /* peer's compression protocol */
int my_proto; /* our compression protocol */
int reset_sent; /* If != -1, ignore compressed 'till ack */
int last_reset; /* We can receive more (dups) w/ this id */
u_long his_reject; /* Request codes rejected by peer */
u_long my_reject; /* Request codes I have rejected */
u_int32_t his_reject; /* Request codes rejected by peer */
u_int32_t my_reject; /* Request codes I have rejected */
int out_init; /* Init called for out algorithm */
int in_init; /* Init called for in algorithm */

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.125 1998/01/05 01:35:18 brian Exp $
* $Id: command.c,v 1.126 1998/01/10 21:51:31 brian Exp $
*
*/
#include <sys/param.h>
@ -520,7 +520,7 @@ static int
ShowInitialMRU(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, " Initial MRU: %ld\n", VarMRU);
fprintf(VarTerm, " Initial MRU: %d\n", VarMRU);
return 0;
}
@ -529,7 +529,7 @@ ShowPreferredMTU(struct cmdargs const *arg)
{
if (VarTerm)
if (VarPrefMTU)
fprintf(VarTerm, " Preferred MTU: %ld\n", VarPrefMTU);
fprintf(VarTerm, " Preferred MTU: %d\n", VarPrefMTU);
else
fprintf(VarTerm, " Preferred MTU: unspecified\n");
return 0;

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.15 1997/12/13 02:37:24 brian Exp $
* $Id: ipcp.h,v 1.16 1998/01/05 01:35:19 brian Exp $
*
* TODO:
*/
@ -40,13 +40,13 @@ extern struct in_addr nbns_entries[2];
struct ipcpstate {
struct in_addr his_ipaddr; /* IP address he is willing to use */
u_long his_compproto;
u_int32_t his_compproto;
struct in_addr want_ipaddr; /* IP address I'm willing to use */
u_long want_compproto;
u_int32_t want_compproto;
u_long his_reject; /* Request codes rejected by peer */
u_long my_reject; /* Request codes I have rejected */
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 */
};

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.50 1997/12/07 23:55:27 brian Exp $
* $Id: lcp.c,v 1.51 1997/12/24 09:29:05 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@ -171,24 +171,26 @@ ReportLcpStatus(struct cmdargs const *arg)
fprintf(VarTerm, "%s [%s]\n", fp->name, StateNames[fp->state]);
fprintf(VarTerm,
" his side: MRU %ld, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d, MAGIC %08lx,\n"
" REJECT %04lx\n",
lcp->his_mru, lcp->his_accmap, lcp->his_protocomp, lcp->his_acfcomp,
lcp->his_magic, lcp->his_reject);
" his side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n"
" MAGIC %08lx, REJECT %04x\n",
lcp->his_mru, (u_long)lcp->his_accmap, lcp->his_protocomp,
lcp->his_acfcomp, (u_long)lcp->his_magic, lcp->his_reject);
fprintf(VarTerm,
" my side: MRU %ld, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d, MAGIC %08lx,\n"
" REJECT %04lx\n",
lcp->want_mru, lcp->want_accmap, lcp->want_protocomp, lcp->want_acfcomp,
lcp->want_magic, lcp->my_reject);
fprintf(VarTerm, "\nDefaults: MRU = %ld, ACCMAP = %08x\t", VarMRU, VarAccmap);
fprintf(VarTerm, "Open Mode: %s\n", (VarOpenMode == OPEN_ACTIVE) ? "active" : "passive");
" my side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n"
" MAGIC %08lx, REJECT %04x\n",
lcp->want_mru, (u_long)lcp->want_accmap, lcp->want_protocomp,
lcp->want_acfcomp, (u_long)lcp->want_magic, lcp->my_reject);
fprintf(VarTerm, "\nDefaults: MRU = %d, ACCMAP = %08lx\t",
VarMRU, (u_long)VarAccmap);
fprintf(VarTerm, "Open Mode: %s\n",
(VarOpenMode == OPEN_ACTIVE) ? "active" : "passive");
return 0;
}
/*
* Generate random number which will be used as magic number.
*/
static u_long
static u_int32_t
GenerateMagic(void)
{
randinit();
@ -257,23 +259,23 @@ do { \
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], NULL); \
} while (0)
#define PUTHEXL(ty, arg) \
#define PUTHEX32(ty, arg) \
do { \
o.id = ty; \
o.len = 6; \
*(u_long *)o.data = htonl(arg); \
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "0x%08x", (u_int)arg);\
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "0x%08lx", (u_long)arg);\
} while (0)
#define PUTACCMAP(arg) PUTHEXL(TY_ACCMAP, arg)
#define PUTMAGIC(arg) PUTHEXL(TY_MAGICNUM, arg)
#define PUTACCMAP(arg) PUTHEX32(TY_ACCMAP, arg)
#define PUTMAGIC(arg) PUTHEX32(TY_MAGICNUM, arg)
#define PUTMRU(arg) \
do { \
o.id = TY_MRU; \
o.len = 4; \
*(u_short *)o.data = htons(arg); \
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "%lu", arg); \
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "%u", arg); \
} while (0)
#define PUTLQR(period) \
@ -282,7 +284,8 @@ do { \
o.len = 8; \
*(u_short *)o.data = htons(PROTO_LQR); \
*(u_long *)(o.data+2) = htonl(period); \
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "period %ld", period);\
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], \
"period %ld", (u_long)period); \
} while (0)
#define PUTPAP() \
@ -474,9 +477,9 @@ LcpClose()
static void
LcpDecodeConfig(u_char *cp, int plen, int mode_type)
{
int type, length, mru, mtu, sz, pos;
u_long *lp, magic, accmap;
u_short *sp, proto;
int type, length, sz, pos;
u_int32_t *lp, magic, accmap;
u_short mtu, mru, *sp, proto;
struct lqrreq *req;
char request[20], desc[22];
@ -529,9 +532,9 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type)
break;
case TY_ACCMAP:
lp = (u_long *) (cp + 2);
lp = (u_int32_t *) (cp + 2);
accmap = htonl(*lp);
LogPrintf(LogLCP, "%s 0x%08x\n", request, accmap);
LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)accmap);
switch (mode_type) {
case MODE_REQ:
@ -680,17 +683,17 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type)
break;
case TY_MAGICNUM:
lp = (u_long *) (cp + 2);
lp = (u_int32_t *) (cp + 2);
magic = ntohl(*lp);
LogPrintf(LogLCP, "%s 0x%08x\n", request, magic);
LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)magic);
switch (mode_type) {
case MODE_REQ:
if (LcpInfo.want_magic) {
/* Validate magic number */
if (magic == LcpInfo.want_magic) {
LogPrintf(LogLCP, "Magic is same (%08x) - %d times\n",
magic, ++LcpFailedMagic);
LogPrintf(LogLCP, "Magic is same (%08lx) - %d times\n",
(u_long)magic, ++LcpFailedMagic);
LcpInfo.want_magic = GenerateMagic();
memcpy(nakp, cp, 6);
nakp += 6;
@ -708,7 +711,7 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type)
}
break;
case MODE_NAK:
LogPrintf(LogLCP, " Magic 0x%08x is NAKed!\n", magic);
LogPrintf(LogLCP, " Magic 0x%08lx is NAKed!\n", (u_long)magic);
LcpInfo.want_magic = GenerateMagic();
break;
case MODE_REJ:

View File

@ -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.14 1997/12/03 10:23:49 brian Exp $
* $Id: lcp.h,v 1.15 1997/12/04 18:49:28 brian Exp $
*
* TODO:
*/
@ -23,24 +23,24 @@
#define REJECTED(p, x) ((p)->his_reject & (1<<(x)))
struct lcpstate {
u_long his_mru;
u_long his_accmap;
u_long his_magic;
u_long his_lqrperiod;
u_int16_t his_mru;
u_int32_t his_accmap;
u_int32_t his_magic;
u_int32_t his_lqrperiod;
u_char his_protocomp;
u_char his_acfcomp;
u_short his_auth;
u_long want_mru;
u_long want_accmap;
u_long want_magic;
u_long want_lqrperiod;
u_short want_mru;
u_int32_t want_accmap;
u_int32_t want_magic;
u_int32_t want_lqrperiod;
u_char want_protocomp;
u_char want_acfcomp;
u_short want_auth;
u_long his_reject; /* Request codes rejected by peer */
u_long my_reject; /* Request codes I have rejected */
u_int32_t his_reject; /* Request codes rejected by peer */
u_int32_t my_reject; /* Request codes I have rejected */
u_short auth_iwait;
u_short auth_ineed;

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lqr.c,v 1.19 1997/10/26 01:03:08 brian Exp $
* $Id: lqr.c,v 1.20 1997/11/22 03:37:37 brian Exp $
*
* o LQR based on RFC1333
*
@ -49,14 +49,14 @@ struct pppTimer LqrTimer;
static u_long lastpeerin = (u_long) - 1;
static int lqmmethod;
static int echoseq;
static int gotseq;
static u_int32_t echoseq;
static u_int32_t gotseq;
static int lqrsendcnt;
struct echolqr {
u_long magic;
u_long signature;
u_long sequence;
u_int32_t magic;
u_int32_t signature;
u_int32_t sequence;
};
#define SIGNATURE 0x594e4f54
@ -82,7 +82,7 @@ void
RecvEchoLqr(struct mbuf * bp)
{
struct echolqr *lqr;
u_long seq;
u_int32_t seq;
if (plength(bp) == sizeof(struct echolqr)) {
lqr = (struct echolqr *) MBUF_CTOP(bp);

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lqr.h,v 1.9 1997/10/26 12:42:12 brian Exp $
* $Id: lqr.h,v 1.10 1997/11/22 03:37:38 brian Exp $
*
* TODO:
*/
@ -24,26 +24,26 @@
* Structure of LQR packet defined in RFC1333
*/
struct lqrdata {
u_long MagicNumber;
u_long LastOutLQRs;
u_long LastOutPackets;
u_long LastOutOctets;
u_long PeerInLQRs;
u_long PeerInPackets;
u_long PeerInDiscards;
u_long PeerInErrors;
u_long PeerInOctets;
u_long PeerOutLQRs;
u_long PeerOutPackets;
u_long PeerOutOctets;
u_int32_t MagicNumber;
u_int32_t LastOutLQRs;
u_int32_t LastOutPackets;
u_int32_t LastOutOctets;
u_int32_t PeerInLQRs;
u_int32_t PeerInPackets;
u_int32_t PeerInDiscards;
u_int32_t PeerInErrors;
u_int32_t PeerInOctets;
u_int32_t PeerOutLQRs;
u_int32_t PeerOutPackets;
u_int32_t PeerOutOctets;
};
struct lqrsave {
u_long SaveInLQRs;
u_long SaveInPackets;
u_long SaveInDiscards;
u_long SaveInErrors;
u_long SaveInOctets;
u_int32_t SaveInLQRs;
u_int32_t SaveInPackets;
u_int32_t SaveInDiscards;
u_int32_t SaveInErrors;
u_int32_t SaveInOctets;
};
struct lqrdata MyLqrData, HisLqrData;

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.h,v 1.38 1997/12/21 03:16:19 brian Exp $
* $Id: vars.h,v 1.39 1997/12/29 22:23:13 brian Exp $
*
* TODO:
*/
@ -55,8 +55,8 @@ struct confdesc {
extern struct confdesc pppConfs[MAXCONFS + 1];
struct pppvars {
u_long var_mru; /* Initial MRU value */
u_long pref_mtu; /* Preferred MTU value */
u_short var_mru; /* Initial MRU value */
u_short pref_mtu; /* Preferred MTU value */
int var_accmap; /* Initial ACCMAP value */
int modem_speed; /* Current modem speed */
int modem_parity; /* Parity setting */

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.13 1997/11/22 03:37:54 brian Exp $
* $Id: vjcomp.c,v 1.14 1997/12/03 10:23:54 brian Exp $
*
* TODO:
*/
@ -155,11 +155,11 @@ VjCompInput(struct mbuf * bp, int proto)
}
const char *
vj2asc(u_long val)
vj2asc(u_int32_t val)
{
static char asc[50];
sprintf(asc, "%ld VJ slots %s slot compression",
((val>>8)&15)+1, val & 1 ? "with" : "without");
sprintf(asc, "%d VJ slots %s slot compression",
(int)((val>>8)&15)+1, val & 1 ? "with" : "without");
return asc;
}

View File

@ -23,10 +23,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: vjcomp.h,v 1.4 1997/12/21 12:11:10 brian Exp $
*/
extern void VjInit(int);
extern void SendPppFrame(struct mbuf *);
extern struct mbuf *VjCompInput(struct mbuf *, int);
extern const char *vj2asc(u_long);
extern const char *vj2asc(u_int32_t);