summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1998-06-15 19:06:58 +0000
committerbrian <brian@FreeBSD.org>1998-06-15 19:06:58 +0000
commit67efb0adddd5c04e645535e5454772d1da2b7105 (patch)
tree31d8e8fa6ed4fbfe3381d37f32142615c81eec99 /usr.sbin
parent13defc3317e75eb1c300da13d71fcfca0afa9fea (diff)
downloadFreeBSD-src-67efb0adddd5c04e645535e5454772d1da2b7105.zip
FreeBSD-src-67efb0adddd5c04e645535e5454772d1da2b7105.tar.gz
o De-staticise things that don't need to be static.
o Bring the static ``ttystate'' into struct prompt so that the tilde context is per prompt and not global. o Comment the remaining static variables so that it's clear why they're static. o Add some XXX comments suggesting that our interface list and our hostname should be re-generated after a signal (say SIGUSR1) so that a machine with PCCARDs has a chance.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/auth.c4
-rw-r--r--usr.sbin/ppp/ccp.h6
-rw-r--r--usr.sbin/ppp/chat.c4
-rw-r--r--usr.sbin/ppp/deflate.c4
-rw-r--r--usr.sbin/ppp/defs.c4
-rw-r--r--usr.sbin/ppp/fsm.c3
-rw-r--r--usr.sbin/ppp/ip.c4
-rw-r--r--usr.sbin/ppp/iplist.c4
-rw-r--r--usr.sbin/ppp/log.c4
-rw-r--r--usr.sbin/ppp/main.c4
-rw-r--r--usr.sbin/ppp/mp.c4
-rw-r--r--usr.sbin/ppp/prompt.c11
-rw-r--r--usr.sbin/ppp/prompt.h3
-rw-r--r--usr.sbin/ppp/route.c12
-rw-r--r--usr.sbin/ppp/timer.c6
-rw-r--r--usr.sbin/ppp/vjcomp.c4
16 files changed, 45 insertions, 36 deletions
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index ecc26f3..2442017 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -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.26 1998/05/01 19:23:52 brian Exp $
+ * $Id: auth.c,v 1.29 1998/05/21 21:44:00 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
@@ -181,7 +181,7 @@ auth_GetSecret(struct bundle *bundle, const char *system, int len,
FILE *fp;
int n;
char *vector[5];
- static char buff[LINE_LEN];
+ char buff[LINE_LEN];
fp = OpenSecret(SECRETFILE);
if (fp == NULL)
diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h
index 8b1787b..f778885 100644
--- a/usr.sbin/ppp/ccp.h
+++ b/usr.sbin/ppp/ccp.h
@@ -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.15 1998/05/21 21:44:23 brian Exp $
+ * $Id: ccp.h,v 1.16 1998/05/23 13:38:02 brian Exp $
*
* TODO:
*/
@@ -93,8 +93,8 @@ struct ccp {
struct ccp_algorithm {
int id;
- int Neg; /* ccp_config neg array item */
- const char *(*Disp)(struct lcp_opt *);
+ int Neg; /* ccp_config neg array item */
+ const char *(*Disp)(struct lcp_opt *); /* Use result immediately ! */
struct {
int (*Set)(struct lcp_opt *, const struct ccp_config *);
void *(*Init)(struct lcp_opt *);
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index db7356f..662b7fd 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: chat.c,v 1.46 1998/05/23 22:24:32 brian Exp $
+ * $Id: chat.c,v 1.47 1998/05/28 23:17:38 brian Exp $
*/
#include <sys/types.h>
@@ -133,7 +133,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
struct chat *c = descriptor2chat(d);
int special, gotabort, gottimeout, needcr;
int TimedOut = c->TimedOut;
- static char arg_term;
+ static char arg_term; /* An empty string */
if (c->pause.state == TIMER_RUNNING)
return 0;
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c
index 08e5f85..4bc8bce 100644
--- a/usr.sbin/ppp/deflate.c
+++ b/usr.sbin/ppp/deflate.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: deflate.c,v 1.6.4.16 1998/05/15 18:21:03 brian Exp $
+ * $Id: deflate.c,v 1.8 1998/05/21 21:45:00 brian Exp $
*/
#include <sys/types.h>
@@ -433,7 +433,7 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi)
static const char *
DeflateDispOpts(struct lcp_opt *o)
{
- static char disp[7];
+ static char disp[7]; /* Must be used immediately */
sprintf(disp, "win %d", (o->data[0]>>4) + 8);
return disp;
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index d228eb3..95177de 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: defs.c,v 1.14 1998/05/29 00:03:00 brian Exp $
+ * $Id: defs.c,v 1.15 1998/05/29 18:32:11 brian Exp $
*/
@@ -39,7 +39,7 @@ void
randinit()
{
#if __FreeBSD__ >= 3
- static int initdone;
+ static int initdone; /* srandomdev() call is only required once */
if (!initdone) {
initdone = 1;
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c
index 1e0f6cb..3a3b1f4 100644
--- a/usr.sbin/ppp/fsm.c
+++ b/usr.sbin/ppp/fsm.c
@@ -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.35 1998/05/01 19:24:32 brian Exp $
+ * $Id: fsm.c,v 1.28 1998/05/21 21:45:20 brian Exp $
*
* TODO:
*/
@@ -914,6 +914,7 @@ fsm_Input(struct fsm *fp, struct mbuf *bp)
* MUST send a unique id for each REQ....
*/
static u_char id;
+
fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt);
mbuf_Free(bp);
return;
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index f08031f..3bb75aa 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -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.41 1998/05/21 21:45:37 brian Exp $
+ * $Id: ip.c,v 1.42 1998/06/14 01:21:24 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -252,7 +252,7 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
int mask, len, n;
int pri = PRI_NORMAL;
int logit, loglen;
- static char logbuf[200];
+ char logbuf[200];
logit = log_IsKept(LogTCPIP) && filter->logok;
loglen = 0;
diff --git a/usr.sbin/ppp/iplist.c b/usr.sbin/ppp/iplist.c
index 319f130..48e4b5e 100644
--- a/usr.sbin/ppp/iplist.c
+++ b/usr.sbin/ppp/iplist.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: iplist.c,v 1.4.4.3 1998/05/01 19:24:54 brian Exp $
+ * $Id: iplist.c,v 1.5 1998/05/21 21:45:53 brian Exp $
*/
#include <sys/types.h>
@@ -40,7 +40,7 @@
static int
do_inet_aton(const char *start, const char *end, struct in_addr *ip)
{
- static char ipstr[16];
+ char ipstr[16];
if (end - start > 15) {
log_Printf(LogWARN, "%.*s: Invalid IP address\n", end-start, start);
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c
index 01de47a..0c9c276b 100644
--- a/usr.sbin/ppp/log.c
+++ b/usr.sbin/ppp/log.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: log.c,v 1.29 1998/05/28 23:17:42 brian Exp $
+ * $Id: log.c,v 1.30 1998/06/15 19:06:15 brian Exp $
*/
#include <sys/types.h>
@@ -290,7 +290,7 @@ log_Printf(int lev, const char *fmt,...)
va_start(ap, fmt);
if (log_IsKept(lev)) {
- static char nfmt[200];
+ char nfmt[200];
if ((log_IsKept(lev) & LOG_KEPT_LOCAL) && promptlist) {
if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1)
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 65f62d1..4ef527a 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -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.131 1998/06/15 19:05:22 brian Exp $
+ * $Id: main.c,v 1.132 1998/06/15 19:05:46 brian Exp $
*
* TODO:
*/
@@ -155,7 +155,7 @@ BringDownServer(int signo)
static const char *
ex_desc(int ex)
{
- static char num[12];
+ static char num[12]; /* Used immediately if returned */
static const char *desc[] = {
"normal", "start", "sock", "modem", "dial", "dead", "done",
"reboot", "errdead", "hangup", "term", "nodial", "nologin"
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index d68d61e..bdedb63 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp.c,v 1.6 1998/05/25 02:22:38 brian Exp $
+ * $Id: mp.c,v 1.7 1998/06/15 19:06:22 brian Exp $
*/
#include <sys/types.h>
@@ -710,7 +710,7 @@ mp_ShowStatus(struct cmdargs const *arg)
const char *
mp_Enddisc(u_char c, const char *address, int len)
{
- static char result[100];
+ static char result[100]; /* Used immediately after it's returned */
int f, header;
switch (c) {
diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c
index bb10f4b..98bcbe4 100644
--- a/usr.sbin/ppp/prompt.c
+++ b/usr.sbin/ppp/prompt.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.c,v 1.3 1998/05/23 22:24:48 brian Exp $
+ * $Id: prompt.c,v 1.4 1998/05/27 22:43:37 brian Exp $
*/
#include <sys/param.h>
@@ -72,6 +72,7 @@
static void
prompt_Display(struct prompt *p)
{
+ /* XXX: See Index2Nam() - should we only figure this out once ? */
static char shostname[MAXHOSTNAMELEN];
const char *pconnect, *pauth;
@@ -170,7 +171,6 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
struct prompt *p = descriptor2prompt(d);
int n;
char ch;
- static int ttystate;
char linebuff[LINE_LEN];
if (p->TermMode == NULL) {
@@ -221,10 +221,10 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
log_Printf(LogDEBUG, "Got %d bytes (reading from the terminal)\n", n);
if (n > 0) {
- switch (ttystate) {
+ switch (p->readtilde) {
case 0:
if (ch == '~')
- ttystate++;
+ p->readtilde = 1;
else
if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno));
@@ -259,7 +259,7 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
break;
}
- ttystate = 0;
+ p->readtilde = 0;
break;
}
}
@@ -311,6 +311,7 @@ prompt_Create(struct server *s, struct bundle *bundle, int fd)
p->TermMode = NULL;
p->nonewline = 1;
p->needprompt = 1;
+ p->readtilde = 0;
p->bundle = bundle;
log_RegisterPrompt(p);
}
diff --git a/usr.sbin/ppp/prompt.h b/usr.sbin/ppp/prompt.h
index cda800b..13a5fcc 100644
--- a/usr.sbin/ppp/prompt.h
+++ b/usr.sbin/ppp/prompt.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.h,v 1.2 1998/05/21 21:48:02 brian Exp $
+ * $Id: prompt.h,v 1.3 1998/05/23 22:24:49 brian Exp $
*/
#define LOCAL_AUTH 0x01
@@ -48,6 +48,7 @@ struct prompt {
unsigned nonewline : 1; /* need a newline before our prompt ? */
unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */
unsigned active : 1; /* Is the prompt active (^Z) */
+ unsigned readtilde : 1; /* We've read a ``~'' from fd_in */
struct {
const char *type; /* Type of connection */
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index d4ac9ed..328c047 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -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.46 1998/06/10 00:16:07 brian Exp $
+ * $Id: route.c,v 1.47 1998/06/15 19:06:23 brian Exp $
*
*/
@@ -194,8 +194,14 @@ p_flags(struct prompt *prompt, u_long f, int max)
const char *
Index2Nam(int idx)
{
- static char **ifs;
- static int nifs, debug_done;
+ /*
+ * XXX: Maybe we should select() on the routing socket so that we can
+ * notice interfaces that come & go (PCCARD support).
+ * Or we could even support a signal that resets these so that
+ * the PCCARD insert/remove events can signal ppp.
+ */
+ static char **ifs; /* Figure these out once */
+ static int nifs, debug_done; /* Figure out how many once, and debug once */
if (!nifs) {
int mib[6], have, had;
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index c8e41f1..be8a8b2 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.c,v 1.27.2.11 1998/05/08 01:15:18 brian Exp $
+ * $Id: timer.c,v 1.28 1998/05/21 21:48:46 brian Exp $
*
* TODO:
*/
@@ -149,8 +149,8 @@ TimerService(void)
struct pppTimer *tp, *exp, *wt;
if (log_IsKept(LogTIMER)) {
- static time_t t;
- time_t n = time(NULL); /* Only show timers every second */
+ static time_t t; /* Only show timers globally every second */
+ time_t n = time(NULL);
if (n > t)
timer_Show(LogTIMER, NULL);
diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c
index 615ffa9..6fd0d59 100644
--- a/usr.sbin/ppp/vjcomp.c
+++ b/usr.sbin/ppp/vjcomp.c
@@ -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.17 1998/05/21 21:49:06 brian Exp $
+ * $Id: vjcomp.c,v 1.18 1998/06/14 00:56:13 brian Exp $
*
* TODO:
*/
@@ -165,7 +165,7 @@ vj_Input(struct ipcp *ipcp, struct mbuf *bp, int proto)
const char *
vj2asc(u_int32_t val)
{
- static char asc[50];
+ static char asc[50]; /* The return value is used immediately */
if (val)
snprintf(asc, sizeof asc, "%d VJ slots %s slot compression",
OpenPOWER on IntegriCloud