Cleanups in PPP: C++ comments removed, make it compile for unixsim too. Does not work yet only compiles

This commit is contained in:
jani 2003-05-30 08:49:34 +00:00
parent 4c7290fed0
commit ff63557d39
14 changed files with 36 additions and 43 deletions

View File

@ -22,4 +22,5 @@ loopif.c
slipif.c
A generic implementation of the SLIP (Serial Line IP)
protocol. It requires a sio (serial I/O) module to work.
ppp/ Point-to-Point Protocol stack

View File

@ -575,7 +575,7 @@ static void ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len
code = CHAP_FAILURE;
if (!get_secret(cstate->unit, rhostname, cstate->chal_name,
secret, &secret_len, 1)) {
// CHAPDEBUG((LOG_WARNING, TL_CHAP, "No CHAP secret found for authenticating %s\n", rhostname));
/* CHAPDEBUG((LOG_WARNING, TL_CHAP, "No CHAP secret found for authenticating %s\n", rhostname)); */
ppp_trace(LOG_WARNING, "No CHAP secret found for authenticating %s\n",
rhostname);
} else {

View File

@ -1203,7 +1203,7 @@ static void ipcp_up(fsm *f)
}
if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) {
//pppGotDNSAddrs(go->dnsaddr[0], go->dnsaddr[1]);
/*pppGotDNSAddrs(go->dnsaddr[0], go->dnsaddr[1]);*/
}
/*

View File

@ -91,7 +91,6 @@ static void lcp_up (fsm*); /* We're UP */
static void lcp_down (fsm*); /* We're DOWN */
static void lcp_starting (fsm*); /* We need lower layer up */
static void lcp_finished (fsm*); /* We need lower layer down */
//static int lcp_extcode (fsm*, int, int, u_char*, int);
static int lcp_extcode (fsm*, int, u_char, u_char*, int);
static void lcp_rprotrej (fsm*, u_char*, int);
@ -371,7 +370,6 @@ static void lcp_input(int unit, u_char *p, int len)
/*
* lcp_extcode - Handle a LCP-specific code.
*/
//static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len)
static int lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
{
u_char *magp;

View File

@ -129,9 +129,11 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
int mdi;
unsigned int i, ii;
// ppp_trace(LOG_INFO, "MD5Update: %u:%.*H\n", inLen, MIN(inLen, 20) * 2, inBuf);
// ppp_trace(LOG_INFO, "MD5Update: %u:%s\n", inLen, inBuf);
#if 0
ppp_trace(LOG_INFO, "MD5Update: %u:%.*H\n", inLen, MIN(inLen, 20) * 2, inBuf);
ppp_trace(LOG_INFO, "MD5Update: %u:%s\n", inLen, inBuf);
#endif
/* compute number of bytes mod 64 */
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);

View File

@ -351,14 +351,12 @@ int pppOpen(ppp_sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void
* so the arg passed to sio_open means nothing
*/
fd = sio_open(2);
/* Find a free PPP session descriptor. */
//OS_ENTER_CRITICAL();
/* Find a free PPP session descriptor. Critical region? */
for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++);
if (pd >= NUM_PPP)
pd = PPPERR_OPEN;
else
pppControl[pd].openFlag = !0;
//OS_EXIT_CRITICAL();
/* Launch a deamon thread. */
if (pd >= 0) {
@ -876,7 +874,6 @@ u32_t GetMask(u32_t addr)
else
nmask = IN_CLASSC_NET;
/* class D nets are disallowed by bad_ip_adrs */
// mask = netMask | htonl(nmask);
mask = subnetMask | htonl(nmask);
/* XXX
@ -1310,7 +1307,9 @@ out:
static void pppDrop(PPPControl *pc)
{
if (pc->inHead != NULL) {
// PPPDEBUG((LOG_INFO, "pppDrop: %d:%.*H\n", pc->inHead->len, min(60, pc->inHead->len * 2), pc->inHead->payload));
#if 0
PPPDEBUG((LOG_INFO, "pppDrop: %d:%.*H\n", pc->inHead->len, min(60, pc->inHead->len * 2), pc->inHead->payload));
#endif
PPPDEBUG((LOG_INFO, "pppDrop: nBuf len=%d\n", pc->inHead->len));
pbuf_free(pc->inHead);
pc->inHead = NULL;
@ -1516,7 +1515,7 @@ static void pppInProc(int pd, u_char *s, int l)
pc->inFCS = PPP_FCS(pc->inFCS, curChar);
}
}
// avRandomize();
avRandomize();
}
/*

View File

@ -253,10 +253,10 @@ enum NPmode {
* Get the up status - 0 for down, non-zero for up. The argument must
* point to an int.
*/
#define PPPCTLG_UPSTATUS 100 // Get the up status - 0 down else up
#define PPPCTLS_ERRCODE 101 // Set the error code
#define PPPCTLG_ERRCODE 102 // Get the error code
#define PPPCTLG_FD 103 // Get the fd associated with the ppp
#define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
#define PPPCTLS_ERRCODE 101 /* Set the error code */
#define PPPCTLG_ERRCODE 102 /* Get the error code */
#define PPPCTLG_FD 103 /* Get the fd associated with the ppp */
/************************
*** PUBLIC DATA TYPES ***

View File

@ -58,7 +58,6 @@ typedef enum {
* ppp_trace - a form of printf to send tracing information to stderr
*/
void ppp_trace(int level, const char *format,...);
/////////////////////////////////////////////////////////////////////////////
#if PPP_DEBUG > 0

View File

@ -78,23 +78,23 @@ void avChurnRand(char *randData, u32_t randLen)
{
MD5_CTX md5;
// ppp_trace(LOG_INFO, "churnRand: %u@%P\n", randLen, randData);
/* ppp_trace(LOG_INFO, "churnRand: %u@%P\n", randLen, randData); */
MD5Init(&md5);
MD5Update(&md5, (u_char *)randPool, sizeof(randPool));
if (randData)
MD5Update(&md5, (u_char *)randData, randLen);
else {
struct {
// INCLUDE fields for any system sources of randomness
/* INCLUDE fields for any system sources of randomness */
char foobar;
} sysData;
// Load sysData fields here.
/* Load sysData fields here. */
;
MD5Update(&md5, (u_char *)&sysData, sizeof(sysData));
}
MD5Final((u_char *)randPool, &md5);
// ppp_trace(LOG_INFO, "churnRand: -> 0\n");
/* ppp_trace(LOG_INFO, "churnRand: -> 0\n"); */
}
/*
@ -150,8 +150,8 @@ u32_t avRandom()
/*****************************/
/*** LOCAL DATA STRUCTURES ***/
/*****************************/
static int avRandomized = 0; // Set when truely randomized.
static u32_t avRandomSeed = 0; // Seed used for random number generation.
static int avRandomized = 0; /* Set when truely randomized. */
static u32_t avRandomSeed = 0; /* Seed used for random number generation. */
/***********************************/
@ -173,10 +173,10 @@ static u32_t avRandomSeed = 0; // Seed used for random number generation.
*/
void avRandomInit()
{
#if 0
/* Get a pointer into the last 4 bytes of clockBuf. */
u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]);
#if 0
/*
* Initialize our seed using the real-time clock, the idle
* counter, the millisecond timer, and the hardware timer
@ -188,8 +188,8 @@ void avRandomInit()
* randomize the lower 16 bits of the seed.
*/
readClk();
// avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr
// + ppp_mtime() + ((u32_t)TM1 << 16) + TM1;
avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr
+ ppp_mtime() + ((u32_t)TM1 << 16) + TM1;
#else
avRandomSeed += ppp_jiffies(); /* XXX */
#endif
@ -214,7 +214,7 @@ void avRandomize(void)
avRandomInit();
/* The initialization function also updates the seed. */
} else {
// avRandomSeed += (avRandomSeed << 16) + TM1;
/* avRandomSeed += (avRandomSeed << 16) + TM1; */
avRandomSeed += (ppp_jiffies() - last_jiffies); /* XXX */
}
last_jiffies = ppp_jiffies();

View File

@ -77,12 +77,5 @@ void avGenRand(char *buf, u32_t bufLen);
*/
u32_t avRandom(void);
/*
* Initialize Borland's random number generator. This is a library function
* but we declare it here rather than including the entire header file
* for it.
*/
//void srand(unsigned seed);
#endif /* RANDM_H */

View File

@ -25,7 +25,7 @@ char *ip_ntoa(u32_t ipaddr)
ipaddr = ntohl(ipaddr);
#if 0
// FIXME
FIXME
sprintf(b, "%d.%d.%d.%d",
(u_char)(ipaddr >> 24),
(u_char)(ipaddr >> 16),

View File

@ -21,6 +21,7 @@
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
# ifndef __u_char_defined
/* Type definitions for BSD code. */
typedef unsigned long u_long;
@ -28,6 +29,7 @@ typedef unsigned int u_int;
typedef unsigned short u_short;
typedef unsigned char u_char;
#endif
/*
* Sleep ms milliseconds. Note that this only has a (close to) 1 Jiffy

View File

@ -602,4 +602,3 @@ bad:
#endif
////////////////////////////////////////////////////////////////////////////////

View File

@ -15,13 +15,13 @@ PACK_STRUCT_BEGIN
struct ip
{
#if defined(NO_CHAR_BITFIELDS)
u_char ip_hl_v; // bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead...
u_char ip_hl_v; /* bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead... */
#else
#if BYTE_ORDER == LITTLE_ENDIAN
u_char ip_hl:4, /* header length */
unsigned ip_hl:4, /* header length */
ip_v:4; /* version */
#elif BYTE_ORDER == BIG_ENDIAN
u_char ip_v:4, /* version */
unsigned ip_v:4, /* version */
ip_hl:4; /* header length */
#else
COMPLAIN - NO BYTE ORDER SELECTED!
@ -58,11 +58,11 @@ struct tcphdr
u_char th_x2_off;
#else
#if BYTE_ORDER == LITTLE_ENDIAN
u_char th_x2:4, /* (unused) */
unsigned th_x2:4, /* (unused) */
th_off:4; /* data offset */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char th_off:4, /* data offset */
unsigned th_off:4, /* data offset */
th_x2:4; /* (unused) */
#endif
#endif