* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define RCSID "$Id: options.c,v 1.80 2001/03/12 22:56:12 paulus Exp $"
+#define RCSID "$Id: options.c,v 1.3 2006/09/06 11:01:34 wilson Exp $"
#include <ctype.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <pwd.h>
+// Jack Suen
+#include <signal.h>
#ifdef PLUGIN
#include <dlfcn.h>
#endif
#include "pppd.h"
#include "pathnames.h"
+#include "fsm.h"
+#include "lcp.h"
extern int DEB_DISC,DEB_DISC2;
int srvdisc=0;
char req_name[MAXPATHLEN] = ""; /* logical name for link */
static char ip_addr[MAXPATHLEN] = ""; /* IP address */
+//Andy Lin
+int ppp_session=0;
+
extern option_t auth_options[];
extern struct stat devstat;
extern int setipaddr(char *arg, char **argv, int doit);
extern int setdevname_pppoe(const char *cp);
extern int setdevname_pppoatm(const char *cp);
+//Charles 11/30/2003, add for unnumbered PPP (declared in ipcp.c)
+extern bool unnumbered;
+extern char wan_IP[];
+extern char wan_submask[];
#ifdef PPP_FILTER
struct bpf_program pass_filter;/* Filter program for packets to pass */
static int logfile_fd = -1; /* fd opened for log file */
static char logfile_name[MAXPATHLEN]; /* name of log file */
+#if defined(INCLUDE_MTU_LAN_PPP)
+int glb_CONFIG_PPP_MTU = 0;
+#endif
+
+#ifdef BUILD_DOMAIN_LOCK
+int wsnCheckStrTail(char *username, char *validDomain);
+int wsnIsValidPppUser(char *pppUser);
+#endif
+
/*
* Prototypes
*/
See pppd(8) for more options.\n\
";
+#ifdef SUPPORT_PPP_SCHEDULE
+ extern int ppp_runonce;
+#endif
+extern int isp_1n1;
+
// cwu
int
parse_args(argc, argv)
int opt;
int retval, num[3];
- while ((opt = getopt(argc, argv, "s:xda:i:ku:p:o:lc:m:f:r:RA:")) != -1) {
+ while ((opt = getopt(argc, argv, "nbsxda:e:g:i:ku:p:o:lc:m:f:r:q:RA:w:zjh")) != -1) {
switch (opt) {
+#ifdef SUPPORT_PPP_SCHEDULE
+ case 'h':
+ ppp_runonce = 1;
+ break;
+#endif
+ //ODM Charles, add for manual conn/disconn
+ case 'n':
+ demand=1;
+ ppp_manual=1;
+ break;
+ //end
+ //Charles 11/30/2003, add unnumbered PPP
+ case 'b':
+ unnumbered=1;
+ break;
+ //IP for unnumbered PPP, in a.b.c.d format
+ case 'e':
+ strncpy(wan_IP, optarg, 16);
+ break;
+ //subnet mask for unnumbered PPP, in a.b.c.d format
+ case 'g':
+ strncpy(wan_submask, optarg, 16);
+ break;
case 's':
autoscan = 1;
auth_required = 0;
- autoscanP2 = atoi(optarg);
+ //autoscanP2 = atoi(optarg);
break;
case 'x':
ipext = 1;
debug = nodetach = 1;
break;
case 'a':
+ ppp_session=PPPOA;
setdevname_pppoatm(optarg);
break;
case 'i':
+ ppp_session=PPPOE;
setdevname_pppoe(optarg);
break;
case 'k':
case 'u':
strncpy(user, optarg, MAXNAMELEN);
strncpy(our_name, optarg, MAXNAMELEN);
+#ifdef BUILD_DOMAIN_LOCK
+ if(wsnIsValidPppUser(user)==0){ // 0: FALSE
+ printf("PPP username is out of valid domains.\n");
+ //strcpy(user, "");
+ //strcpy(our_name, "");
+ }
+#endif
break;
case 'p':
strncpy(passwd, optarg, MAXSECRETLEN);
opflag = atoi(optarg);
break;
case 'r':
- strncpy(pppoe_srv_name, optarg, MAXSRVNAMELEN);
+ strncpy(pppoe_srv_name, optarg, MAXPATHLEN);
+ break;
+ case 'q':
+ strncpy(pppoe_ac_name, optarg, MAXPATHLEN);
break;
case 'R':
srvdisc=1;
break;
+#if defined(INCLUDE_MTU_LAN_PPP)
+ case 'w':
+ lcp_allowoptions[0].mru = atoi(optarg);
+ glb_CONFIG_PPP_MTU = atoi(optarg);
+ break;
+#endif
+ case 'z':
+ ppp_addgw = 1;
+ break;
+ case 'j':
+ isp_1n1 = 1;
+ break;
case 'A':
strncpy(ip_addr, optarg, MAXPATHLEN);
ip_addr[strlen(ip_addr)] = ':';
return 0;
}
#endif /* PLUGIN */
+
+#ifdef BUILD_DOMAIN_LOCK
+int wsnCheckStrTail(char *username, char *validDomain){
+ char *ptr=NULL;
+ unsigned int domainLen=strlen(validDomain);
+
+ if(strlen(username) < domainLen){
+ //printf("Length of ppp username [%s] is less than valid domain name [%s].\n", username, validDomain);
+ return 0; // 0: FALSE
+ }
+
+ ptr = username + strlen(username) - domainLen;
+ //printf("check string..., orig = [%s], tail = [%s]\n", username, ptr);
+
+ if(strcmp(ptr, validDomain)==0)
+ return 1; // 1: TRUE
+ else
+ return 0; // 0: FALSE
+
+}
+
+/***************************************************************************
+// Function Name: wsnIsValidPppUser().
+// Description : check whether the ppp username is valid or not.
+// Valid domain: @hgxx.btclick.com
+ @hgxx.btinternet.com
+ @hgx.btinternet.com
+ @hgx.btclick.com
+ @btbroadband.com
+ @btinternet.com
+ ras@teleworker
+ @speedtest_domain
+ @startup_domain
+// Parameters : ppp username.
+// Returns : TRUE: valid FALSE:invalid
+****************************************************************************/
+int wsnIsValidPppUser(char *pppUser){
+ char *domainPtr=NULL;
+ char *chrDigit;
+
+ if(wsnCheckStrTail(pppUser, "@dataone"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "@touchtelindia.net"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "@startup_domain"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "@speedtest_domain"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "ras@teleworker"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "@btinternet.com"))
+ return 1; // 1: TRUE
+ if(wsnCheckStrTail(pppUser, "@btbroadband.com"))
+ return 1; // 1: TRUE
+
+ if(wsnCheckStrTail(pppUser, ".btclick.com")){
+ domainPtr = pppUser + strlen(pppUser) - strlen(".btclick.com");
+ chrDigit = domainPtr-1;
+ if(isdigit(chrDigit[0])==0){
+ //printf("char [%c] is not a digit.\n", chrDigit[0]);
+ return 0; // 0: FALSE
+ }
+ chrDigit--;
+ if(isdigit(chrDigit[0])==0){
+ domainPtr = chrDigit - strlen("@hg") + 1;
+ if(strncmp(domainPtr, "@hg", strlen("@hg"))==0)
+ return 1; // 1: TRUE
+ }else{
+ domainPtr = chrDigit - strlen("@hg");
+ if(strncmp(domainPtr, "@hg", strlen("@hg"))==0)
+ return 1; // 1: TRUE
+ }
+ }
+
+ if(wsnCheckStrTail(pppUser, ".btinternet.com")){
+ domainPtr = pppUser + strlen(pppUser) - strlen(".btinternet.com");
+ chrDigit = domainPtr - 1;
+ if(isdigit(chrDigit[0])==0){
+ //printf("char [%c] is not a digit.\n", chrDigit[0]);
+ return 0; // 0: FALSE
+ }
+ chrDigit--;
+ if(isdigit(chrDigit[0])==0){
+ domainPtr = chrDigit - strlen("@hg") + 1;
+ if(strncmp(domainPtr, "@hg", strlen("@hg"))==0)
+ return 1; // 1: TRUE
+ }else{
+ domainPtr = chrDigit - strlen("@hg");
+ if(strncmp(domainPtr, "@hg", strlen("@hg"))==0)
+ return 1; // 1: TRUE
+ }
+ }
+
+ //printf("Invalid domain = [%s]\n", pppUser);
+ return 0; // 0: FALSE
+}
+#endif