Linux ioctl() gone, ECP support optional, CCP support optional

Removed all the used Linux ioctl(), sys_linux.c is entirely disabled.

Replaced unecessary functions to set up a PPP link to null fonctions,
however all stuff necessary to shutdown a PPP link should be done.

Some utils functions related to I/O files are disabled too.

ECP and CCP support only set PPP attributes into the PPP kernel support,
they are now compile-time options and are disabled by default and
obviously not supported (yet? :p)
This commit is contained in:
Sylvain Rochet 2012-06-02 00:19:40 +02:00
parent a17ea13453
commit fc074937f5
13 changed files with 244 additions and 14 deletions

View File

@ -913,7 +913,12 @@ start_networks(unit)
{
int i;
struct protent *protp;
int ecp_required, mppe_required;
#if ECP_SUPPORT
int ecp_required;
#endif /* ECP_SUPPORT */
#ifdef MPPE
int mppe_required;
#endif /* MPPE */
new_phase(PHASE_NETWORK);
@ -933,18 +938,40 @@ start_networks(unit)
if (!demand)
set_filters(&pass_filter, &active_filter);
#endif
#if CCP_SUPPORT || ECP_SUPPORT
/* Start CCP and ECP */
for (i = 0; (protp = protocols[i]) != NULL; ++i)
if ((protp->protocol == PPP_ECP || protp->protocol == PPP_CCP)
if (
(0
#if ECP_SUPPORT
|| protp->protocol == PPP_ECP
#endif /* ECP_SUPPORT */
#if CCP_SUPPORT
|| protp->protocol == PPP_CCP
#endif /* CCP_SUPPORT */
)
&& protp->enabled_flag && protp->open != NULL)
(*protp->open)(0);
#endif /* CCP_SUPPORT || ECP_SUPPORT */
/*
* Bring up other network protocols iff encryption is not required.
*/
#if ECP_SUPPORT
ecp_required = ecp_gotoptions[unit].required;
#endif /* ECP_SUPPORT */
#ifdef MPPE
mppe_required = ccp_gotoptions[unit].mppe;
if (!ecp_required && !mppe_required)
#endif /* MPPE */
if (1
#if ECP_SUPPORT
&& !ecp_required
#endif /* ECP_SUPPORT */
#ifdef MPPE
&& !mppe_required
#endif /* MPPE */
)
continue_networks(unit);
}
@ -1166,11 +1193,13 @@ np_up(unit, proto)
TIMEOUT(check_maxoctets, NULL, maxoctets_timeout);
#endif
#if 0 /* Unused */
/*
* Detach now, if the updetach option was given.
*/
if (updetach && !nodetach)
detach();
#endif /* Unused */
}
++num_np_up;
}

View File

@ -29,6 +29,7 @@
*/
#include "lwip/opt.h"
#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#define RCSID "$Id: ccp.c,v 1.50 2005/06/26 19:34:41 carlsonj Exp $"
@ -1682,3 +1683,4 @@ ccp_rack_timeout(arg)
ccp_localstate[f->unit] &= ~RACK_PENDING;
}
#endif /* PPP_SUPPORT && CCP_SUPPORT */

View File

@ -30,6 +30,9 @@
* $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
*/
#include "lwip/opt.h"
#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
typedef struct ccp_options {
bool bsd_compress; /* do BSD Compress? */
bool deflate; /* do Deflate? */
@ -50,3 +53,5 @@ extern ccp_options ccp_allowoptions[];
extern ccp_options ccp_hisoptions[];
extern struct protent ccp_protent;
#endif /* PPP_SUPPORT && CCP_SUPPORT */

View File

@ -115,8 +115,12 @@ demand_conf()
*/
for (i = 0; (protp = protocols[i]) != NULL; ++i)
if (protp->enabled_flag && protp->demand_conf != NULL)
((*protp->demand_conf)(0));
/* FIXME: find a way to die() here */
#if 0
if (!((*protp->demand_conf)(0)))
die(1);
#endif
}

View File

@ -58,6 +58,7 @@
*/
#include "lwip/opt.h"
#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#define RCSID "$Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp $"
@ -177,3 +178,4 @@ ecp_printpkt(p, plen, printer, arg)
return 0;
}
#endif /* PPP_SUPPORT && ECP_SUPPORT */

View File

@ -31,6 +31,9 @@
* $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $
*/
#include "lwip/opt.h"
#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */
typedef struct ecp_options {
bool required; /* Is ECP required? */
unsigned enctype; /* Encryption type */
@ -43,3 +46,5 @@ extern ecp_options ecp_allowoptions[];
extern ecp_options ecp_hisoptions[];
extern struct protent ecp_protent;
#endif /* PPP_SUPPORT && ECP_SUPPORT */

View File

@ -118,7 +118,7 @@ int req_unit = -1; /* requested interface unit */
bool multilink = 0; /* Enable multilink operation */
char *bundle_name = NULL; /* bundle name for multilink */
bool dump_options; /* print out option values */
bool dryrun; /* print out option values and exit */
//bool dryrun; /* print out option values and exit */
char *domain; /* domain name set by domain option */
int child_wait = 5; /* # seconds to wait for children at exit */

View File

@ -228,10 +228,10 @@ static struct subprocess *children;
/* Prototypes for procedures local to this file. */
static void setup_signals __P((void));
//static void setup_signals __P((void));
static void create_pidfile __P((int pid));
static void create_linkpidfile __P((int pid));
static void cleanup __P((void));
//static void cleanup __P((void));
static void get_input __P((void));
static void calltimeout __P((void));
static struct timeval *timeleft __P((struct timeval *));
@ -283,8 +283,12 @@ struct protent *protocols[] = {
#ifdef INET6
&ipv6cp_protent,
#endif
#if CCP_SUPPORT
&ccp_protent,
#endif /* CCP_SUPPORT */
#if ECP_SUPPORT
&ecp_protent,
#endif /* ECP_SUPPORT */
#ifdef AT_CHANGE
&atcp_protent,
#endif
@ -301,6 +305,7 @@ struct protent *protocols[] = {
#define PPP_DRV_NAME "ppp"
#endif /* !defined(PPP_DRV_NAME) */
#if 0
int ppp_oldmain() {
int argc = 0;
char *argv[0];
@ -348,10 +353,12 @@ int ppp_oldmain() {
for (i = 0; (protp = protocols[i]) != NULL; ++i)
(*protp->init)(0);
#if 0
/*
* Initialize the default channel.
*/
tty_init();
#endif
progname = *argv;
@ -416,8 +423,10 @@ int ppp_oldmain() {
}
#endif /* PPP_OPTIONS */
#if 0
if (dryrun)
die(0);
#endif
/* Make sure fds 0, 1, 2 are open to somewhere. */
fd_devnull = open(_PATH_DEVNULL, O_RDWR);
@ -430,12 +439,15 @@ int ppp_oldmain() {
fd_devnull = i;
}
#if 0 /* Unused */
/*
* Detach ourselves from the terminal, if required,
* and identify who is running us.
*/
if (!nodetach && !updetach)
detach();
#endif /* Unused */
p = getlogin();
if (p == NULL) {
pw = getpwuid(uid);
@ -452,7 +464,7 @@ int ppp_oldmain() {
slprintf(numbuf, sizeof(numbuf), "%d", getpid());
script_setenv("PPPD_PID", numbuf, 1);
setup_signals();
//setup_signals();
create_linkpidfile(getpid());
@ -465,8 +477,8 @@ int ppp_oldmain() {
/*
* Open the loopback channel and set it up to be the ppp interface.
*/
fd_loop = open_ppp_loopback();
set_ifunit(1);
//fd_loop = open_ppp_loopback();
//set_ifunit(1);
/*
* Configure the interface and mark it up, etc.
*/
@ -580,7 +592,9 @@ int ppp_oldmain() {
die(status);
return 0;
}
#endif
#if 0
/*
* handle_events - wait for something to happen and respond to it.
*/
@ -626,7 +640,9 @@ handle_events()
got_sigusr2 = 0;
}
}
#endif
#if 0
/*
* setup_signals - initialize signal handling.
*/
@ -709,6 +725,7 @@ setup_signals()
*/
signal(SIGPIPE, SIG_IGN);
}
#endif
/*
* set_ifunit - do things we need to do once we know which ppp
@ -727,6 +744,7 @@ set_ifunit(iskey)
}
}
#if 0
/*
* detach - detach us from the controlling terminal.
*/
@ -771,6 +789,7 @@ detach()
complete_read(pipefd[0], numbuf, 1);
close(pipefd[0]);
}
#endif
/*
* reopen_log - (re)open our connection to syslog.
@ -1147,6 +1166,7 @@ new_phase(p)
notify(phasechange, p);
}
#if 0
/*
* die - clean up state and exit with the specified status.
*/
@ -1161,7 +1181,9 @@ die(status)
syslog(LOG_INFO, "Exit.");
exit(status);
}
#endif
#if 0
/*
* cleanup - restore anything which needs to be restored before we exit
*/
@ -1177,6 +1199,7 @@ cleanup()
(*the_channel->cleanup)();
remove_pidfiles();
}
#endif
void
print_link_stats()
@ -1200,8 +1223,10 @@ void
reset_link_stats(u)
int u;
{
#if 0
if (!get_ppp_stats(u, &old_link_stats))
return;
#endif
gettimeofday(&start_time, NULL);
}
@ -1215,9 +1240,11 @@ update_link_stats(u)
struct timeval now;
char numbuf[32];
#if 0
if (!get_ppp_stats(u, &link_stats)
|| gettimeofday(&now, NULL) < 0)
return;
#endif
link_connect_time = now.tv_sec - start_time.tv_sec;
link_stats_valid = 1;
@ -1492,7 +1519,7 @@ open_ccp(sig)
siglongjmp(sigjmp, 1);
}
#if 0
/*
* bad_signal - We've caught a fatal signal. Clean up state and exit.
*/
@ -1511,7 +1538,9 @@ bad_signal(sig)
notify(sigreceived, sig);
die(127);
}
#endif
#if 0
/*
* safe_fork - Create a child process. The child closes all the
* file descriptors that we don't want to leak to a script.
@ -1593,6 +1622,7 @@ safe_fork(int infd, int outfd, int errfd)
return 0;
}
#endif
/*
* device_script - run a program to talk to the specified fds
@ -1615,7 +1645,8 @@ device_script(program, in, out, dont_wait)
errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
++conn_running;
pid = safe_fork(in, out, errfd);
//pid = safe_fork(in, out, errfd);
pid = -1;
if (pid != 0 && log_to_fd < 0)
close(errfd);

View File

@ -487,7 +487,11 @@ extern struct channel *the_channel;
/* Procedures exported from main.c. */
void set_ifunit __P((int)); /* set stuff that depends on ifunit */
#if 0
void detach __P((void)); /* Detach from controlling tty */
#endif
void die __P((int)); /* Cleanup and exit */
void quit __P((void)); /* like die(1) */
void novm __P((char *)); /* Say we ran out of memory, and die */
@ -496,7 +500,11 @@ void timeout __P((void (*func)(void *), void *arg, int s, int us));
void untimeout __P((void (*func)(void *), void *arg));
/* Cancel call to func(arg) */
void record_child __P((int, char *, void (*) (void *), void *, int));
#if 0
pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */
#endif
int device_script __P((char *cmd, int in, int out, int dont_wait));
/* Run `cmd' with given stdin and stdout */
void reopen_log __P((void)); /* (re)open the connection to syslog */
@ -539,8 +547,11 @@ void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
void end_pr_log __P((void)); /* finish up after using pr_log */
void dump_packet __P((const char *, u_char *, int));
/* dump packet to debug log if interesting */
#if 0 /* Unused */
ssize_t complete_read __P((int, void *, size_t));
/* read a complete buffer */
#endif /* Unused */
/* Procedures exported from auth.c */
void link_required __P((int)); /* we are starting to use the link */
@ -668,9 +679,11 @@ int sifproxyarp __P((int, u_int32_t));
int cifproxyarp __P((int, u_int32_t));
/* Delete proxy ARP entry for peer */
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
#if 0 /* Unused */
int lock __P((char *)); /* Create lock file for device */
int relock __P((int)); /* Rewrite lock file with new pid */
void unlock __P((void)); /* Delete previously-created lock file */
#endif /* Unused */
void logwtmp __P((const char *, const char *, const char *));
/* Write entry to wtmp file */
int get_host_seed __P((void)); /* Get host-dependent random number seed */

View File

@ -1093,6 +1093,27 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
return st;
}
/********************************************************************
*
* cifaddr - Clear the interface IP addresses, and delete routes
* through the interface if possible.
*/
int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) {
/* FIXME: do the code which clear a IP on a PPP interface */
return 0;
}
/********************************************************************
*
* sifdown - Disable the indicated protocol and config the interface
* down if there are no remaining protocols.
*/
int sifdown (int u) {
/* FIXME: do the code which shutdown a PPP interface */
return 1;
}
/*
* pppifNetifInit - netif init callback
*/
@ -1156,3 +1177,102 @@ sifnpmode(int u, int proto, enum NPmode mode)
return 0;
}
/*
* netif_set_mtu - set the MTU on the PPP network interface.
*/
void netif_set_mtu(int unit, int mtu) {
/* FIXME: set lwIP MTU */
}
/********************************************************************
*
* sifdefaultroute - assign a default route through the address given.
*
* If the global default_rt_repl_rest flag is set, then this function
* already replaced the original system defaultroute with some other
* route and it should just replace the current defaultroute with
* another one, without saving the current route. Use: demand mode,
* when pppd sets first a defaultroute it it's temporary ppp0 addresses
* and then changes the temporary addresses to the addresses for the real
* ppp connection when it has come up.
*/
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace) {
/* FIXME: do the code which add the default route */
return 0;
}
/********************************************************************
*
* cifdefaultroute - delete a default route through the address given.
*/
int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) {
/* FIXME: do the code which remove the default route */
return 0;
}
/********************************************************************
*
* sifproxyarp - Make a proxy ARP entry for the peer.
*/
int sifproxyarp (int unit, u_int32_t his_adr) {
/* FIXME: do we really need that in IPCP ? */
return 0;
}
/********************************************************************
*
* cifproxyarp - Delete the proxy ARP entry for the peer.
*/
int cifproxyarp (int unit, u_int32_t his_adr) {
/* FIXME: do we really need that in IPCP ? */
return 0;
}
/********************************************************************
*
* sifvjcomp - config tcp header compression
*/
int sifvjcomp (int u, int vjcomp, int cidcomp, int maxcid) {
/* FIXME: add VJ support */
return 1;
}
/********************************************************************
*
* get_idle_time - return how long the link has been idle.
*/
int get_idle_time(int u, struct ppp_idle *ip) {
/* FIXME: add idle time support */
return 1;
}
/********************************************************************
*
* get_loop_output - get outgoing packets from the ppp device,
* and detect when we want to bring the real link up.
* Return value is 1 if we need to bring up the link, 0 otherwise.
*/
int get_loop_output(void) {
/* FIXME: necessary for "demand", do we really need to support on-demand ? */
return 0;
}
/********************************************************************
*
* Return user specified netmask, modified by any mask we might determine
* for address `addr' (in network byte order).
* Here we scan through the system's list of interfaces, looking for
* any non-point-to-point interfaces which might appear to be on the same
* network as `addr'. If we find any, we OR in their netmask to the
* user-specified netmask.
*/
u_int32_t GetMask (u_int32_t addr) {
/* FIXME: do we really need that in IPCP ? */
return 0;
}

View File

@ -69,7 +69,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "lwip/opt.h"
#if 0 /* BAH */
#include <sys/ioctl.h>
#include <sys/types.h>
@ -2694,3 +2694,5 @@ ether_to_eui64(eui64_t *p_eui64)
return 1;
}
#endif
#endif /* BAH */

View File

@ -68,7 +68,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "lwip/opt.h"
#if 0 /* NEED OUR OWN PORT */
#define RCSID "$Id: tty.c,v 1.27 2008/07/01 12:27:56 paulus Exp $"
@ -123,7 +123,10 @@ static void charshunt __P((int, int, char *));
static int record_write __P((FILE *, int code, u_char *buf, int nb,
struct timeval *));
static int open_socket __P((char *));
#if 0
static void maybe_relock __P((void *, int));
#endif
static int pty_master; /* fd for master side of pty */
static int pty_slave; /* fd for slave side of pty */
@ -407,6 +410,7 @@ printescape(opt, printer, arg)
}
#endif /* UNUSED */
#if 0
/*
* tty_init - do various tty-related initializations.
*/
@ -416,6 +420,7 @@ void tty_init()
the_channel = &tty_channel;
xmit_accm[3] = 0x60000000;
}
#endif
/*
* tty_process_extra_options - work out which tty device we are using
@ -815,10 +820,12 @@ void cleanup_tty()
if (real_ttyfd >= 0)
finish_tty();
tty_close_fds();
#if 0
if (locked) {
unlock();
locked = 0;
}
#endif
}
/*
@ -864,6 +871,7 @@ finish_tty()
real_ttyfd = -1;
}
#if 0
/*
* maybe_relock - our PID has changed, maybe update the lock file.
*/
@ -875,6 +883,7 @@ maybe_relock(arg, pid)
if (locked)
relock(pid);
}
#endif
/*
* open_socket - establish a stream socket connection to the nominated
@ -940,7 +949,7 @@ start_charshunt(ifd, ofd)
{
int cpid;
cpid = safe_fork(ifd, ofd, (log_to_fd >= 0? log_to_fd: 2));
cpid = -1; // safe_fork(ifd, ofd, (log_to_fd >= 0? log_to_fd: 2));
if (cpid == -1) {
error("Can't fork process for character shunt: %m");
return 0;
@ -1276,3 +1285,5 @@ record_write(f, code, buf, nb, tp)
}
return 1;
}
#endif /* NEED OUR OWN PORT */

View File

@ -698,7 +698,10 @@ fatal __V((char *fmt, ...))
logit(LOG_ERR, fmt, pvar);
va_end(pvar);
/* FIXME: find a way to die */
#if 0
die(1); /* as promised */
#endif
}
/*
@ -832,6 +835,8 @@ dump_packet(const char *tag, unsigned char *p, int len)
dbglog("%s %P", tag, p, len);
}
#if 0 /* Unused */
/*
* complete_read - read a full `count' bytes from fd,
* unless end-of-file or an error other than EINTR is encountered.
@ -1054,3 +1059,4 @@ unlock()
}
}
#endif /* Unused */