included, so the default build is unchanged.
#
# pppd makefile for Linux
#
# pppd makefile for Linux
-# $Id: Makefile.linux,v 1.42 2001/05/23 03:39:50 paulus Exp $
+# $Id: Makefile.linux,v 1.43 2002/01/14 14:25:09 dfs Exp $
#
# Default installation locations
#
# Default installation locations
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
- demand.c utils.c multilink.c tdb.c tty.c
HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
ipxcp.h cbcp.h tdb.h
MANPAGES = pppd.8
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
ipxcp.h cbcp.h tdb.h
MANPAGES = pppd.8
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
- auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \
- tdb.o tty.o
+ auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o
+# Uncomment the next line to enable multilink PPP (enabled by default)
+# Linux distributions: Please leave multilink ENABLED in your builds
+# of pppd!
+HAVE_MULTILINK=y
+
+# Uncomment the next line to enable the TDB database (enabled by default.)
+# If you enable multilink, then TDB is automatically enabled also.
+# Linux distributions: Please leave TDB ENABLED in your builds.
+USE_TDB=y
+
HAS_SHADOW=y
#USE_PAM=y
#HAVE_INET6=y
HAS_SHADOW=y
#USE_PAM=y
#HAVE_INET6=y
INCLUDE_DIRS= -I../include
INCLUDE_DIRS= -I../include
-COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MULTILINK -DHAVE_MMAP
+COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
LIBS := -lpam -ldl $(LIBS)
endif
LIBS := -lpam -ldl $(LIBS)
endif
+# Multi-linnk
+ifdef HAVE_MULTILINK
+ USE_TDB=y
+ CFLAGS += -DHAVE_MULTILINK
+ PPPDSRCS += multilink.c
+ PPPDOBJS += multilink.o
+endif
+
+# TDB
+ifdef USE_TDB
+ CFLAGS += -DUSE_TDB=1
+ PPPDSRCS += tdb.c
+ PPPDOBJS += tdb.o
+endif
+
# Lock library binary for Linux is included in 'linux' subdirectory.
ifdef LOCKLIB
LIBS := -llock $(LIBS)
# Lock library binary for Linux is included in 'linux' subdirectory.
ifdef LOCKLIB
LIBS := -llock $(LIBS)
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define RCSID "$Id: main.c,v 1.109 2002/01/11 18:10:16 etbe Exp $"
+#define RCSID "$Id: main.c,v 1.110 2002/01/14 14:25:10 dfs Exp $"
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <ctype.h>
#include "chap.h"
#include "ccp.h"
#include "pathnames.h"
#include "chap.h"
#include "ccp.h"
#include "pathnames.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
int unsuccess; /* # unsuccessful connection attempts */
int do_callback; /* != 0 if we should do callback next */
int doing_callback; /* != 0 if we are doing callback */
int unsuccess; /* # unsuccessful connection attempts */
int do_callback; /* != 0 if we should do callback next */
int doing_callback; /* != 0 if we are doing callback */
TDB_CONTEXT *pppdb; /* database for storing status etc. */
TDB_CONTEXT *pppdb; /* database for storing status etc. */
char db_key[32];
int (*holdoff_hook) __P((void)) = NULL;
char db_key[32];
int (*holdoff_hook) __P((void)) = NULL;
static void bad_signal __P((int));
static void holdoff_end __P((void *));
static int reap_kids __P((int waitfor));
static void bad_signal __P((int));
static void holdoff_end __P((void *));
static int reap_kids __P((int waitfor));
static void update_db_entry __P((void));
static void add_db_key __P((const char *));
static void delete_db_key __P((const char *));
static void cleanup_db __P((void));
static void update_db_entry __P((void));
static void add_db_key __P((const char *));
static void delete_db_key __P((const char *));
static void cleanup_db __P((void));
static void handle_events __P((void));
static void print_link_stats __P((void));
static void handle_events __P((void));
static void print_link_stats __P((void));
pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644);
if (pppdb != NULL) {
slprintf(db_key, sizeof(db_key), "pppd%d", getpid());
pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644);
if (pppdb != NULL) {
slprintf(db_key, sizeof(db_key), "pppd%d", getpid());
/*
* Detach ourselves from the terminal, if required,
/*
* Detach ourselves from the terminal, if required,
/*
* Open the loopback channel and set it up to be the ppp interface.
*/
/*
* 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.
*/
/*
* Configure the interface and mark it up, etc.
*/
goto fail;
/* set up the serial device as a ppp interface */
goto fail;
/* set up the serial device as a ppp interface */
fd_ppp = the_channel->establish_ppp(devfd);
if (fd_ppp < 0) {
fd_ppp = the_channel->establish_ppp(devfd);
if (fd_ppp < 0) {
status = EXIT_FATAL_ERROR;
goto disconnect;
}
if (!demand && ifunit >= 0)
set_ifunit(1);
status = EXIT_FATAL_ERROR;
goto disconnect;
}
if (!demand && ifunit >= 0)
set_ifunit(1);
/*
* Start opening the connection and wait for
/*
* Start opening the connection and wait for
warn("unable to delete pid file %s: %m", linkpidfile);
linkpidfile[0] = 0;
warn("unable to delete pid file %s: %m", linkpidfile);
linkpidfile[0] = 0;
if (pppdb != NULL)
cleanup_db();
if (pppdb != NULL)
cleanup_db();
if (script_env != 0) {
for (i = 0; (p = script_env[i]) != 0; ++i) {
if (strncmp(p, var, varl) == 0 && p[varl] == '=') {
if (script_env != 0) {
for (i = 0; (p = script_env[i]) != 0; ++i) {
if (strncmp(p, var, varl) == 0 && p[varl] == '=') {
if (p[-1] && pppdb != NULL)
delete_db_key(p);
if (p[-1] && pppdb != NULL)
delete_db_key(p);
free(p-1);
script_env[i] = newstring;
free(p-1);
script_env[i] = newstring;
if (iskey && pppdb != NULL)
add_db_key(newstring);
update_db_entry();
if (iskey && pppdb != NULL)
add_db_key(newstring);
update_db_entry();
script_env[i] = newstring;
script_env[i+1] = 0;
script_env[i] = newstring;
script_env[i+1] = 0;
if (pppdb != NULL) {
if (iskey)
add_db_key(newstring);
update_db_entry();
}
if (pppdb != NULL) {
if (iskey)
add_db_key(newstring);
update_db_entry();
}
return;
for (i = 0; (p = script_env[i]) != 0; ++i) {
if (strncmp(p, var, vl) == 0 && p[vl] == '=') {
return;
for (i = 0; (p = script_env[i]) != 0; ++i) {
if (strncmp(p, var, vl) == 0 && p[vl] == '=') {
if (p[-1] && pppdb != NULL)
delete_db_key(p);
if (p[-1] && pppdb != NULL)
delete_db_key(p);
free(p-1);
while ((script_env[i] = script_env[i+1]) != 0)
++i;
break;
}
}
free(p-1);
while ((script_env[i] = script_env[i+1]) != 0)
++i;
break;
}
}
if (pppdb != NULL)
update_db_entry();
if (pppdb != NULL)
update_db_entry();
/*
* update_db_entry - update our entry in the database.
*/
/*
* update_db_entry - update our entry in the database.
*/
if (p[-1])
delete_db_key(p);
}
if (p[-1])
delete_db_key(p);
}