/*
* main.c - Point-to-Point Protocol main module
*
- * Copyright (c) 1989 Carnegie Mellon University.
- * All rights reserved.
+ * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For permission or any legal
+ * details, please contact
+ * Office of Technology Transfer
+ * Carnegie Mellon University
+ * 5000 Forbes Avenue
+ * Pittsburgh, PA 15213-3890
+ * (412) 268-4387, fax: (412) 268-7395
+ * tech-transfer@andrew.cmu.edu
+ *
+ * 4. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by Computing Services
+ * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
+ *
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define RCSID "$Id: main.c,v 1.112 2002/02/12 20:07:09 dfs Exp $"
+#define RCSID "$Id: main.c,v 1.120 2002/12/04 23:03:32 paulus Exp $"
#include <stdio.h>
#include <ctype.h>
#endif
#include "upap.h"
#include "chap.h"
+#include "eap.h"
#include "ccp.h"
+#include "ecp.h"
#include "pathnames.h"
#ifdef USE_TDB
static char pidfilename[MAXPATHLEN]; /* name of pid file */
static char linkpidfile[MAXPATHLEN]; /* name of linkname pid file */
char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
-char remote_number[MAXNAMELEN]; /* Remote telephone number, if available */
uid_t uid; /* Our real user-id */
struct notifier *pidchange = NULL;
struct notifier *phasechange = NULL;
static struct timeval start_time; /* Time when link was started. */
struct pppd_stats link_stats;
-int link_connect_time;
+unsigned link_connect_time;
int link_stats_valid;
/*
&ipv6cp_protent,
#endif
&ccp_protent,
+ &ecp_protent,
#ifdef IPX_CHANGE
&ipxcp_protent,
#endif
#ifdef AT_CHANGE
&atcp_protent,
#endif
+ &eap_protent,
NULL
};
init_pr_log(NULL, LOG_INFO);
print_options(pr_log, NULL);
end_pr_log();
- if (dryrun)
- die(0);
}
+ /*
+ * Early check for remote number authorization.
+ */
+ if (!auth_number()) {
+ warn("calling number %q is not authorized", remote_number);
+ exit(EXIT_CNID_AUTH_FAILED);
+ }
+
+ if (dryrun)
+ die(0);
+
/*
* Initialize system-dependent stuff.
*/
* Toss all non-LCP packets unless LCP is OPEN.
*/
if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) {
- MAINDEBUG(("get_input: Received non-LCP packet when LCP not open."));
+ dbglog("Discarded non-LCP packet when LCP not open");
return;
}
*/
if (phase <= PHASE_AUTHENTICATE
&& !(protocol == PPP_LCP || protocol == PPP_LQR
- || protocol == PPP_PAP || protocol == PPP_CHAP)) {
- MAINDEBUG(("get_input: discarding proto 0x%x in phase %d",
- protocol, phase));
+ || protocol == PPP_PAP || protocol == PPP_CHAP ||
+ protocol == PPP_EAP)) {
+ dbglog("discarding proto 0x%x in phase %d",
+ protocol, phase);
return;
}
link_connect_time = now.tv_sec - start_time.tv_sec;
link_stats_valid = 1;
- slprintf(numbuf, sizeof(numbuf), "%d", link_connect_time);
+ slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
script_setenv("CONNECT_TIME", numbuf, 0);
- slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_out);
+ slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
script_setenv("BYTES_SENT", numbuf, 0);
- slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_in);
+ slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
script_setenv("BYTES_RCVD", numbuf, 0);
}
}
/*
- * notify - call a set of functions registered with add_notify.
+ * notify - call a set of functions registered with add_notifier.
*/
void
notify(notif, val)