cleaning unused stuff in pppd.h, syslog() is no more used

This commit is contained in:
Sylvain Rochet 2012-06-02 18:47:53 +02:00
parent a5dd1ccfaa
commit 323aebf1f5
6 changed files with 235 additions and 26 deletions

View File

@ -110,7 +110,9 @@ char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
int idle_time_limit = 0; /* Disconnect if idle for this many seconds */ int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
int holdoff = 30; /* # seconds to pause before reconnecting */ int holdoff = 30; /* # seconds to pause before reconnecting */
bool holdoff_specified; /* true if a holdoff value has been given */ bool holdoff_specified; /* true if a holdoff value has been given */
#if 0
int log_to_fd = 1; /* send log messages to this fd too */ int log_to_fd = 1; /* send log messages to this fd too */
#endif
bool log_default = 1; /* log_to_fd is default (stdout) */ bool log_default = 1; /* log_to_fd is default (stdout) */
int maxfail = 10; /* max # of unsuccessful connection attempts */ int maxfail = 10; /* max # of unsuccessful connection attempts */
char linkname[MAXPATHLEN]; /* logical name for link */ char linkname[MAXPATHLEN]; /* logical name for link */

View File

@ -44,6 +44,8 @@
#include "lwip/opt.h" #include "lwip/opt.h"
#include "pppmy.h"
/* /*
* TODO: * TODO:
*/ */
@ -72,6 +74,7 @@
#include "eui64.h" #include "eui64.h"
#endif #endif
#if 0
/* /*
* Limits. * Limits.
*/ */
@ -81,7 +84,9 @@
#define MAXARGS 1 /* max # args to a command */ #define MAXARGS 1 /* max # args to a command */
#define MAXNAMELEN 256 /* max length of hostname or name for auth */ #define MAXNAMELEN 256 /* max length of hostname or name for auth */
#define MAXSECRETLEN 256 /* max length of password or secret */ #define MAXSECRETLEN 256 /* max length of password or secret */
#endif
#if 0
/* /*
* Option descriptor structure. * Option descriptor structure.
*/ */
@ -89,6 +94,7 @@
#ifndef bool #ifndef bool
typedef unsigned char bool; typedef unsigned char bool;
#endif #endif
#endif
#if 0 #if 0
enum opt_type { enum opt_type {
@ -183,12 +189,15 @@ struct pppd_stats {
}; };
#endif #endif
#if 0
/* Used for storing a sequence of words. Usually malloced. */ /* Used for storing a sequence of words. Usually malloced. */
struct wordlist { struct wordlist {
struct wordlist *next; struct wordlist *next;
char *word; char *word;
}; };
#endif
#if 0
/* An endpoint discriminator, used with multilink. */ /* An endpoint discriminator, used with multilink. */
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ #define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
struct epdisc { struct epdisc {
@ -204,6 +213,7 @@ struct epdisc {
#define EPD_MAC 3 #define EPD_MAC 3
#define EPD_MAGIC 4 #define EPD_MAGIC 4
#define EPD_PHONENUM 5 #define EPD_PHONENUM 5
#endif
#if 0 /* UNUSED */ #if 0 /* UNUSED */
typedef void (*notify_func) __P((void *, int)); typedef void (*notify_func) __P((void *, int));
@ -363,6 +373,7 @@ extern bool ms_lanman; /* Use LanMan password instead of NT */
/* Has meaning only with MS-CHAP challenges */ /* Has meaning only with MS-CHAP challenges */
#endif #endif
#if 0
/* Values for auth_pending, auth_done */ /* Values for auth_pending, auth_done */
#if PAP_SUPPORT #if PAP_SUPPORT
#define PAP_WITHPEER 0x1 #define PAP_WITHPEER 0x1
@ -389,12 +400,16 @@ extern bool ms_lanman; /* Use LanMan password instead of NT */
#define CHAP_MS2_PEER 0x800 #define CHAP_MS2_PEER 0x800
#endif /* MSCHAP_SUPPORT */ #endif /* MSCHAP_SUPPORT */
#endif /* CHAP_SUPPORT */ #endif /* CHAP_SUPPORT */
#endif
#if 0
extern char *current_option; /* the name of the option being parsed */ extern char *current_option; /* the name of the option being parsed */
extern int privileged_option; /* set iff the current option came from root */ extern int privileged_option; /* set iff the current option came from root */
extern char *option_source; /* string saying where the option came from */ extern char *option_source; /* string saying where the option came from */
extern int option_priority; /* priority of current options */ extern int option_priority; /* priority of current options */
#endif
#if 0
/* /*
* Values for phase. * Values for phase.
*/ */
@ -411,6 +426,7 @@ extern int option_priority; /* priority of current options */
#define PHASE_DISCONNECT 10 #define PHASE_DISCONNECT 10
#define PHASE_HOLDOFF 11 #define PHASE_HOLDOFF 11
#define PHASE_MASTER 12 #define PHASE_MASTER 12
#endif
#if 0 #if 0
/* /*
@ -508,13 +524,16 @@ extern struct channel *the_channel;
* Prototypes. * Prototypes.
*/ */
#if 0
/* Procedures exported from main.c. */ /* Procedures exported from main.c. */
void set_ifunit __P((int)); /* set stuff that depends on ifunit */ void set_ifunit __P((int)); /* set stuff that depends on ifunit */
#endif
#if 0 #if 0
void detach __P((void)); /* Detach from controlling tty */ void detach __P((void)); /* Detach from controlling tty */
#endif #endif
#if 0
void die __P((int)); /* Cleanup and exit */ void die __P((int)); /* Cleanup and exit */
void quit __P((void)); /* like die(1) */ void quit __P((void)); /* like die(1) */
void novm __P((char *)); /* Say we ran out of memory, and die */ void novm __P((char *)); /* Say we ran out of memory, and die */
@ -522,6 +541,7 @@ void timeout __P((void (*func)(void *), void *arg, int s, int us));
/* Call func(arg) after s.us seconds */ /* Call func(arg) after s.us seconds */
void untimeout __P((void (*func)(void *), void *arg)); void untimeout __P((void (*func)(void *), void *arg));
/* Cancel call to func(arg) */ /* Cancel call to func(arg) */
#endif
#if 0 #if 0
void record_child __P((int, char *, void (*) (void *), void *, int)); void record_child __P((int, char *, void (*) (void *), void *, int));
#endif #endif
@ -553,11 +573,15 @@ void notify __P((struct notifier *, int));
//int ppp_send_config __P((int, int, u_int32_t, int, int)); //int ppp_send_config __P((int, int, u_int32_t, int, int));
//int ppp_recv_config __P((int, int, u_int32_t, int, int)); //int ppp_recv_config __P((int, int, u_int32_t, int, int));
//void remove_pidfiles __P((void)); //void remove_pidfiles __P((void));
#if 0
void lock_db __P((void)); void lock_db __P((void));
void unlock_db __P((void)); void unlock_db __P((void));
#endif
#if 0
/* Procedures exported from tty.c. */ /* Procedures exported from tty.c. */
void tty_init __P((void)); void tty_init __P((void));
#endif
/* Procedures exported from utils.c. */ /* Procedures exported from utils.c. */
void log_packet __P((u_char *, int, char *, int)); void log_packet __P((u_char *, int, char *, int));
@ -794,6 +818,7 @@ extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
extern void (*snoop_send_hook) __P((unsigned char *p, int len)); extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#endif #endif
#if 0
/* /*
* Inline versions of get/put char/short/long. * Inline versions of get/put char/short/long.
* Pointer is advanced; we assume that both arguments * Pointer is advanced; we assume that both arguments
@ -836,13 +861,8 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
/* /*
* System dependent definitions for user-level 4.3BSD UNIX implementation. * System dependent definitions for user-level 4.3BSD UNIX implementation.
*/ */
/*
#define TIMEOUT(r, f, t) timeout((r), (f), (t), 0) #define TIMEOUT(r, f, t) timeout((r), (f), (t), 0)
#define UNTIMEOUT(r, f) untimeout((r), (f)) #define UNTIMEOUT(r, f) untimeout((r), (f))
*/
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
#define BZERO(s, n) memset(s, 0, n) #define BZERO(s, n) memset(s, 0, n)
#define BCMP(s1, s2, l) memcmp(s1, s2, l) #define BCMP(s1, s2, l) memcmp(s1, s2, l)
@ -884,7 +904,10 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#define EXIT_TRAFFIC_LIMIT 20 #define EXIT_TRAFFIC_LIMIT 20
#endif #endif
#define EXIT_CNID_AUTH_FAILED 21 #define EXIT_CNID_AUTH_FAILED 21
#endif
#if 0
/* /*
* Debug macros. Slightly useful for finding bugs in pppd, not particularly * Debug macros. Slightly useful for finding bugs in pppd, not particularly
* useful for finding out why your connection isn't being established. * useful for finding out why your connection isn't being established.
@ -899,6 +922,7 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#define DEBUGCHAP 1 #define DEBUGCHAP 1
#endif #endif
#if 0
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */ #ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \ #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \ || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
@ -908,6 +932,7 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#define LOG_PPP LOG_DAEMON #define LOG_PPP LOG_DAEMON
#endif #endif
#endif /* LOG_PPP */ #endif /* LOG_PPP */
#endif
#ifdef DEBUGMAIN #ifdef DEBUGMAIN
#define MAINDEBUG(x) if (debug) dbglog x #define MAINDEBUG(x) if (debug) dbglog x
@ -963,6 +988,9 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#define IPXCPDEBUG(x) #define IPXCPDEBUG(x)
#endif #endif
#endif
#if 0
#ifndef SIGTYPE #ifndef SIGTYPE
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
#define SIGTYPE void #define SIGTYPE void
@ -970,9 +998,12 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
#define SIGTYPE int #define SIGTYPE int
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */ #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
#endif /* SIGTYPE */ #endif /* SIGTYPE */
#endif
#if 0
#ifndef offsetof #ifndef offsetof
#define offsetof(type, member) ((size_t) &((type *)0)->member) #define offsetof(type, member) ((size_t) &((type *)0)->member)
#endif #endif
#endif
#endif /* __PPP_H__ */ #endif /* __PPP_H__ */

View File

@ -45,26 +45,28 @@
#define LOG_DETAIL (PPP_DEBUG) #define LOG_DETAIL (PPP_DEBUG)
#define LOG_DEBUG (PPP_DEBUG) #define LOG_DEBUG (PPP_DEBUG)
#define TRACELCP PPP_DEBUG
#if PPP_DEBUG #if PPP_DEBUG
//#define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) #define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
//#define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) #define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
//#define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) #define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
//#define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) #define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
//#define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) #define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
//#define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) #define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
#define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
#define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b)
#else /* PPP_DEBUG */ #else /* PPP_DEBUG */
//#define AUTHDEBUG(a, b) #define MAINDEBUG(a)
//#define IPCPDEBUG(a, b) #define SYSDEBUG(a)
//#define UPAPDEBUG(a, b) #define FSMDEBUG(a)
//#define LCPDEBUG(a, b) #define LCPDEBUG(a)
//#define FSMDEBUG(a, b) #define IPCPDEBUG(a)
//#define CHAPDEBUG(a, b) #define IPV6CPDEBUG(a)
#define UPAPDEBUG(a)
#define CHAPDEBUG(a)
#define PPPDEBUG(a, b) #define PPPDEBUG(a, b)
#endif /* PPP_DEBUG */ #endif /* PPP_DEBUG */

View File

@ -512,9 +512,11 @@ int ppp_init(void) {
debug = 1; debug = 1;
ifunit = 1; /* FIXME: remove ifunit */ ifunit = 1; /* FIXME: remove ifunit */
openlog("LWIP-PPP", LOG_PID | LOG_NDELAY, LOG_PPP); /*
openlog("LWIP-PPP", LOG_PID | LOG_NDELAY, LOG_DAEMON);
setlogmask(LOG_UPTO(LOG_DEBUG)); setlogmask(LOG_UPTO(LOG_DEBUG));
syslog(LOG_DEBUG, "hello, this is gradator lwIP PPP!"); syslog(LOG_DEBUG, "hello, this is gradator lwIP PPP!");
*/
memset(&ppp_settings, 0, sizeof(ppp_settings)); memset(&ppp_settings, 0, sizeof(ppp_settings));
ppp_settings.usepeerdns = 1; ppp_settings.usepeerdns = 1;

View File

@ -10,17 +10,51 @@
#ifndef PPPMY_H_ #ifndef PPPMY_H_
#define PPPMY_H_ #define PPPMY_H_
#include <syslog.h> /* FIXME: temporary */ #include "lwip/netif.h"
#include "lwip/def.h"
#include "pppdebug.h"
#include <net/ppp_defs.h> /* FIXME: merge linux/ppp_defs.h content here */ #include <net/ppp_defs.h> /* FIXME: merge linux/ppp_defs.h content here */
#include "lwip/netif.h" #ifdef INET6
#include "lwip/def.h" #include "eui64.h"
#endif
/*
* Limits.
*/
#define NUM_PPP 1 /* One PPP interface supported (per process) */
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
#define MAXARGS 1 /* max # args to a command */
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
#define MAXSECRETLEN 256 /* max length of password or secret */
#ifndef bool #ifndef bool
typedef unsigned char bool; typedef unsigned char bool;
#endif #endif
/* FIXME: make endpoint discriminator optional */
/* An endpoint discriminator, used with multilink. */
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
struct epdisc {
unsigned char class;
unsigned char length;
unsigned char value[MAX_ENDP_LEN];
};
/* values for epdisc.class */
#define EPD_NULL 0 /* null discriminator, no data */
#define EPD_LOCAL 1
#define EPD_IP 2
#define EPD_MAC 3
#define EPD_MAGIC 4
#define EPD_PHONENUM 5
/* FIXME: global variables per PPP session */ /* FIXME: global variables per PPP session */
/* /*
@ -88,6 +122,51 @@ struct protent {
extern struct protent *protocols[]; extern struct protent *protocols[];
/* Values for auth_pending, auth_done */
#if PAP_SUPPORT
#define PAP_WITHPEER 0x1
#define PAP_PEER 0x2
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
#define CHAP_WITHPEER 0x4
#define CHAP_PEER 0x8
#endif /* CHAP_SUPPORT */
#if EAP_SUPPORT
#define EAP_WITHPEER 0x10
#define EAP_PEER 0x20
#endif /* EAP_SUPPORT */
/* Values for auth_done only */
#if CHAP_SUPPORT
#define CHAP_MD5_WITHPEER 0x40
#define CHAP_MD5_PEER 0x80
#if MSCHAP_SUPPORT
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
#define CHAP_MS_WITHPEER 0x100
#define CHAP_MS_PEER 0x200
#define CHAP_MS2_WITHPEER 0x400
#define CHAP_MS2_PEER 0x800
#endif /* MSCHAP_SUPPORT */
#endif /* CHAP_SUPPORT */
/*
* Values for phase.
*/
#define PHASE_DEAD 0
#define PHASE_INITIALIZE 1
#define PHASE_SERIALCONN 2
#define PHASE_DORMANT 3
#define PHASE_ESTABLISH 4
#define PHASE_AUTHENTICATE 5
#define PHASE_CALLBACK 6
#define PHASE_NETWORK 7
#define PHASE_RUNNING 8
#define PHASE_TERMINATE 9
#define PHASE_DISCONNECT 10
#define PHASE_HOLDOFF 11
#define PHASE_MASTER 12
/************************* /*************************
*** PUBLIC DEFINITIONS *** *** PUBLIC DEFINITIONS ***
*************************/ *************************/
@ -288,3 +367,92 @@ void update_link_stats(int u); /* Get stats at link termination */
#endif /* PPP_STATS_SUPPORT */ #endif /* PPP_STATS_SUPPORT */
#endif /* PPPMY_H_ */ #endif /* PPPMY_H_ */
/*
* Inline versions of get/put char/short/long.
* Pointer is advanced; we assume that both arguments
* are lvalues and will already be in registers.
* cp MUST be u_char *.
*/
#define GETCHAR(c, cp) { \
(c) = *(cp)++; \
}
#define PUTCHAR(c, cp) { \
*(cp)++ = (u_char) (c); \
}
#define GETSHORT(s, cp) { \
(s) = *(cp)++ << 8; \
(s) |= *(cp)++; \
}
#define PUTSHORT(s, cp) { \
*(cp)++ = (u_char) ((s) >> 8); \
*(cp)++ = (u_char) (s); \
}
#define GETLONG(l, cp) { \
(l) = *(cp)++ << 8; \
(l) |= *(cp)++; (l) <<= 8; \
(l) |= *(cp)++; (l) <<= 8; \
(l) |= *(cp)++; \
}
#define PUTLONG(l, cp) { \
*(cp)++ = (u_char) ((l) >> 24); \
*(cp)++ = (u_char) ((l) >> 16); \
*(cp)++ = (u_char) ((l) >> 8); \
*(cp)++ = (u_char) (l); \
}
#define INCPTR(n, cp) ((cp) += (n))
#define DECPTR(n, cp) ((cp) -= (n))
/*
* System dependent definitions for user-level 4.3BSD UNIX implementation.
*/
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
#define BZERO(s, n) memset(s, 0, n)
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
/*
* MAKEHEADER - Add Header fields to a packet.
*/
#define MAKEHEADER(p, t) { \
PUTCHAR(PPP_ALLSTATIONS, p); \
PUTCHAR(PPP_UI, p); \
PUTSHORT(t, p); }
/*
* Exit status values.
*/
#define EXIT_OK 0
#define EXIT_FATAL_ERROR 1
#define EXIT_OPTION_ERROR 2
#define EXIT_NOT_ROOT 3
#define EXIT_NO_KERNEL_SUPPORT 4
#define EXIT_USER_REQUEST 5
#define EXIT_LOCK_FAILED 6
#define EXIT_OPEN_FAILED 7
#define EXIT_CONNECT_FAILED 8
#define EXIT_PTYCMD_FAILED 9
#define EXIT_NEGOTIATION_FAILED 10
#define EXIT_PEER_AUTH_FAILED 11
#define EXIT_IDLE_TIMEOUT 12
#define EXIT_CONNECT_TIME 13
#define EXIT_CALLBACK 14
#define EXIT_PEER_DEAD 15
#define EXIT_HANGUP 16
#define EXIT_LOOPBACK 17
#define EXIT_INIT_FAILED 18
#define EXIT_AUTH_TOPEER_FAILED 19
#ifdef MAXOCTETS
#define EXIT_TRAFFIC_LIMIT 20
#endif
#define EXIT_CNID_AUTH_FAILED 21

View File

@ -40,7 +40,7 @@
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <syslog.h> //#include <syslog.h>
#include <netdb.h> #include <netdb.h>
#include <time.h> #include <time.h>
#include <utmp.h> #include <utmp.h>
@ -557,7 +557,7 @@ end_pr_log()
} }
/* /*
* pr_log - printer routine for outputting to syslog * pr_log - printer routine for outputting to log
*/ */
void void
pr_log __V((void *arg, char *fmt, ...)) pr_log __V((void *arg, char *fmt, ...))
@ -674,7 +674,10 @@ log_write(level, buf)
int level; int level;
char *buf; char *buf;
{ {
syslog(level, "%s", buf); /* FIXME: replace this with a log callback */
// if(level >= min_log_level) /* FIXME: add a minimum log level */
printf("LOG: %s\n", buf);
#if 0
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) { if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
int n = strlen(buf); int n = strlen(buf);
@ -684,6 +687,7 @@ log_write(level, buf)
|| write(log_to_fd, "\n", 1) != 1) || write(log_to_fd, "\n", 1) != 1)
log_to_fd = -1; log_to_fd = -1;
} }
#endif
} }
/* /*