From ff63557d3980918933e0be1ff57d9da57483a248 Mon Sep 17 00:00:00 2001 From: jani Date: Fri, 30 May 2003 08:49:34 +0000 Subject: [PATCH] Cleanups in PPP: C++ comments removed, make it compile for unixsim too. Does not work yet only compiles --- src/netif/FILES | 3 ++- src/netif/ppp/chap.c | 2 +- src/netif/ppp/ipcp.c | 2 +- src/netif/ppp/lcp.c | 2 -- src/netif/ppp/md5.c | 8 +++++--- src/netif/ppp/ppp.c | 11 +++++------ src/netif/ppp/ppp.h | 8 ++++---- src/netif/ppp/pppdebug.h | 1 - src/netif/ppp/randm.c | 20 ++++++++++---------- src/netif/ppp/randm.h | 7 ------- src/netif/ppp/target.c | 2 +- src/netif/ppp/target.h | 2 ++ src/netif/ppp/vj.c | 1 - src/netif/ppp/vjbsdhdr.h | 10 +++++----- 14 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/netif/FILES b/src/netif/FILES index 76b9583d..c0757309 100644 --- a/src/netif/FILES +++ b/src/netif/FILES @@ -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 diff --git a/src/netif/ppp/chap.c b/src/netif/ppp/chap.c index 195a831d..3860b671 100644 --- a/src/netif/ppp/chap.c +++ b/src/netif/ppp/chap.c @@ -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 { diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index c8d470d1..96fd9230 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -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]);*/ } /* diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index c1a5cf15..69d0c8da 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -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; diff --git a/src/netif/ppp/md5.c b/src/netif/ppp/md5.c index 74dc006a..e077cdea 100644 --- a/src/netif/ppp/md5.c +++ b/src/netif/ppp/md5.c @@ -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); diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index c62cade9..81943789 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -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(); } /* diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 33d8cdcb..05015663 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -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 *** diff --git a/src/netif/ppp/pppdebug.h b/src/netif/ppp/pppdebug.h index b038c8e7..5761bbc7 100644 --- a/src/netif/ppp/pppdebug.h +++ b/src/netif/ppp/pppdebug.h @@ -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 diff --git a/src/netif/ppp/randm.c b/src/netif/ppp/randm.c index 0060d582..6335440d 100644 --- a/src/netif/ppp/randm.c +++ b/src/netif/ppp/randm.c @@ -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(); diff --git a/src/netif/ppp/randm.h b/src/netif/ppp/randm.h index 29822a5c..baa42f0c 100644 --- a/src/netif/ppp/randm.h +++ b/src/netif/ppp/randm.h @@ -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 */ diff --git a/src/netif/ppp/target.c b/src/netif/ppp/target.c index 31f4a521..0d5d1fac 100644 --- a/src/netif/ppp/target.c +++ b/src/netif/ppp/target.c @@ -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), diff --git a/src/netif/ppp/target.h b/src/netif/ppp/target.h index 86167de5..57690e7e 100644 --- a/src/netif/ppp/target.h +++ b/src/netif/ppp/target.h @@ -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 diff --git a/src/netif/ppp/vj.c b/src/netif/ppp/vj.c index 1c316122..82f3e341 100644 --- a/src/netif/ppp/vj.c +++ b/src/netif/ppp/vj.c @@ -602,4 +602,3 @@ bad: #endif -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/netif/ppp/vjbsdhdr.h b/src/netif/ppp/vjbsdhdr.h index 211a9a67..a089352a 100644 --- a/src/netif/ppp/vjbsdhdr.h +++ b/src/netif/ppp/vjbsdhdr.h @@ -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