linux pppd源码下载_PPPD源码分析
File: options.c
默认调用参数值: 1 0 1
int options_from_file(filename, must_exist, check_prot, priv)
char *filename; #NOTE: 参数文件地址
int must_exist; #NOTE: 参数文件是否必须存在
int check_prot;
int priv;
{
FILE *f;
int i, newline, ret, err;
option_t *opt;
int oldpriv, n;
char *oldsource;
uid_t euid;
char *argv[MAXARGS];
char args[MAXARGS][MAXWORDLEN];
char cmd[MAXWORDLEN];
euid = geteuid();
if (check_prot && seteuid(getuid()) == -1) { #NOTE:check_prot为0,不执行此分支
option_error("unable to drop privileges to open %s: %m", filename);
return 0;
}
f = fopen(filename, "r"); #NOTE:打开配置文件
err = errno;
if (check_prot && seteuid(euid) == -1) #NOTE: check_prot为0,不执行此分支
fatal("unable to regain privileges");
if (f == NULL) { #NOTE: 配置文件打开失败
errno = err;
if (!must_exist) { #NOTE: 当必须存在标记为1时,不执行此分支,此解析函数返回0,pppd结束执行
#必须存在标记为0时,执行此分支,忽略找不到文件错误,返回1,pppd继续解析执行
if (err != ENOENT && err != ENOTDIR)
warn("Warning: can't open options file %s: %m", filename);
return 1;
}
option_error("Can't open options file %s: %m", filename);
return 0;
}
oldpriv = privileged_option;
privileged_option = priv;
oldsource = option_source;
option_source = strdup(filename);
if (option_source == NULL)
option_source = "file";
ret = 0;
while (getword(f, cmd, &newline, filename)) { #NOTE:读取配置文件,并将命令字存储在cmd变量中
opt = find_option(cmd);
if (opt == NULL) {
option_error("In file %s: unrecognized option '%s'",
filename, cmd);
goto err;
}
n = n_arguments(opt);
for (i = 0; i < n; ++i) {
if (!getword(f, args[i], &newline, filename)) {
option_error(
"In file %s: too few parameters for option '%s'",
filename, cmd);
goto err;
}
argv[i] = args[i];
}
if (!process_option(opt, cmd, argv)) #NOTE:处理命令字选项
goto err;
}
ret = 1;
err:
fclose(f);
privileged_option = oldpriv;
option_source = oldsource;
return ret;
}
static option_t * find_option(name)
const char *name;
{
option_t *opt;
struct option_list *list;
int i, dowild;
for (dowild = 0; dowild <= 1; ++dowild) {
for (opt = general_options; opt->name != NULL; ++opt)
if (match_option(name, opt, dowild))
return opt;
for (opt = auth_options; opt->name != NULL; ++opt)
if (match_option(name, opt, dowild))
return opt;
for (list = extra_options; list != NULL; list = list->next)
for (opt = list->options; opt->name != NULL; ++opt)
if (match_option(name, opt, dowild))
return opt;
for (opt = the_channel->options; opt->name != NULL; ++opt)
if (match_option(name, opt, dowild))
return opt;
for (i = 0; protocols[i] != NULL; ++i)
if ((opt = protocols[i]->options) != NULL)
for (; opt->name != NULL; ++opt)
if (match_option(name, opt, dowild))
return opt;
}
return NULL;
}
先看看配置选项相关的基础数据结构:
File: pppd.h
enum opt_type {
o_special_noarg = 0, #NOTE:无参数
o_special = 1, #NOTE:特殊参数
o_bool,
o_int,
o_uint32,
o_string,
o_wild
};typedef struct {
char *name; #NOTE:参数选项名
enum opt_type type; #NOTE:参数选项类型
void *addr; #NOTE:参数选项变量地址
char *description; #NOTE:参数选项描述
unsigned int flags; #NOTE:参数选项标识
void *addr2;
int upper_limit;
int lower_limit;
const char *source;
short int priority;
short int winner;
} option_t;
#define OPT_VALUE 0xff /* mask for presupplied value,flag的低8位为设置该标识后,该变量的值 */
#define OPT_HEX 0x100 /* int option is in hex */
#defineOPT_NOARG 0x200 /* option doesn't take argument */
#define OPT_OR 0x400 /* for u32, OR in argument to value */
#define OPT_INC 0x400 /* for o_int, increment value */
#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */
#define OPT_PRIV 0x1000 /* privileged option */
#define OPT_STATIC 0x2000 /* string option goes into static array */
#define OPT_NOINCR 0x2000 /* for o_int, value mustn't be increased */
#define OPT_LLIMIT 0x4000 /* check value against lower limit */
#define OPT_ULIMIT 0x8000 /* check value against upper limit */
#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */
#define OPT_A2LIST 0x20000 /* for o_special, keep list of values */
#define OPT_A2CLRB 0x20000 /* o_bool, clr val bits in *(u_char *)addr2 */
#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
#define OPT_PRIO 0x80000 /* process option priorities for this option */
#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */
#define OPT_ALIAS 0x200000 /* option is alias for previous option */
#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */
#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */
#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */
#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */
#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */
#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */
#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV)
#define OPT_A2PRINTER 0x10000000 /* *addr2 printer_func to print option */
#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */
#define OPT_NOPRINT 0x40000000 /* don't print this option at all */
上述进行了5次遍历,进行匹配,分别看看这些变量的容器:
option_t general_options[] = {
{ "debug", o_int, &debug, "Increase debugging level", OPT_INC | OPT_NOARG | 1 },
{ "-d", o_int, &debug,"Increase debugging level",OPT_ALIAS | OPT_INC | OPT_NOARG | 1 },
{ "kdebug", o_int, &kdebugflag,"Set kernel driver debug level", OPT_PRIO },
{ "nodetach", o_bool, &nodetach,"Don't detach from controlling tty", OPT_PRIO | 1 },
{ "-detach", o_bool, &nodetach,"Don't detach from controlling tty", OPT_ALIAS | OPT_PRIOSUB | 1 },
{ "updetach", o_bool, &updetach,"Detach from controlling tty once link is up",OPT_PRIOSUB | OPT_A2CLR | 1, &nodetach },
{ "master_detach", o_bool, &master_detach,"Detach when we're multilink master but have no link", 1 },
{ "holdoff", o_int, &holdoff,"Set time in seconds before retrying connection",OPT_PRIO, &holdoff_specified },
{ "idle", o_int, &idle_time_limit,"Set time in seconds before disconnecting idle link", OPT_PRIO },
{ "maxconnect", o_int, &maxconnect,"Set connection time limit",OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
{ "domain", o_special, (void *)setdomain,"Add given domain name to hostname",OPT_PRIO | OPT_PRIV | OPT_A2STRVAL, &domain },
{ "file", o_special, (void *)readfile,"Take options from a file", OPT_NOPRINT },
{ "call", o_special, (void *)callfile,"Take options from a privileged file", OPT_NOPRINT },
{ "persist", o_bool, &persist,"Keep on reopening connection after close", OPT_PRIO | 1 },
{ "nopersist", o_bool, &persist,"Turn off persist option", OPT_PRIOSUB },
{ "demand", o_bool, &demand,"Dial on demand", OPT_INITONLY | 1, &persist },
{ "--version", o_special_noarg, (void *)showversion,"Show version number" },
{ "--help", o_special_noarg, (void *)showhelp,"Show brief listing of options" },
{ "-h", o_special_noarg, (void *)showhelp,"Show brief listing of options", OPT_ALIAS },
{ "logfile", o_special, (void *)setlogfile,"Append log messages to this file",OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, &logfile_name },
{ "logfd", o_int, &log_to_fd,"Send log messages to this file descriptor",OPT_PRIOSUB | OPT_A2CLR, &log_default },
{ "nolog", o_int, &log_to_fd,"Don't send log messages to any file",OPT_PRIOSUB | OPT_NOARG | OPT_VAL(-1) },
{ "nologfd", o_int, &log_to_fd,"Don't send log messages to any file descriptor",OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
{ "linkname", o_string, linkname,"Set logical name for link",OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
{ "ifname", o_string, use_ifname,"Set physical name for PPP interface",OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
{ "maxfail", o_int, &maxfail,"Maximum number of unsuccessful connection attempts to allow",OPT_PRIO },
{ "ktune", o_bool, &tune_kernel,"Alter kernel settings as necessary", OPT_PRIO | 1 },
{ "noktune", o_bool, &tune_kernel,"Don't alter kernel settings", OPT_PRIOSUB },
{ "connect-delay", o_int, &connect_delay,"Maximum time (in ms) to wait after connect script finishes",OPT_PRIO },
{ "unit", o_int, &req_unit,"PPP interface unit number to use if possible",OPT_PRIO | OPT_LLIMIT, 0, 0 },
{ "dump", o_bool, &dump_options,"Print out option values after parsing all options", 1 },
{ "dryrun", o_bool, &dryrun,"Stop after parsing, printing, and checking options", 1 },
{ "child-timeout", o_int, &child_wait,"Number of seconds to wait for child processes at exit",OPT_PRIO },
{ "set", o_special, (void *)user_setenv,"Set user environment variable",OPT_A2PRINTER | OPT_NOPRINT, (void *)user_setprint },
{ "unset", o_special, (void *)user_unsetenv,"Unset user environment variable",OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint },
{ "ip-up-script", o_string, path_ipup,"Set pathname of ip-up script",OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "ip-down-script", o_string, path_ipdown,"Set pathname of ip-down script",OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "ipv6-up-script", o_string, path_ipv6up,"Set pathname of ipv6-up script",OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "ipv6-down-script", o_string, path_ipv6down,"Set pathname of ipv6-down script",OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
#ifdef HAVE_MULTILINK
{ "multilink", o_bool, &multilink,"Enable multilink operation", OPT_PRIO | 1 },
{ "mp", o_bool, &multilink,"Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 },
{ "nomultilink", o_bool, &multilink,"Disable multilink operation", OPT_PRIOSUB | 0 },
{ "bundle", o_string, &bundle_name,"Bundle name for multilink", OPT_PRIO },
#endif /* HAVE_MULTILINK */
{ "nomp", o_bool, &multilink,"Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
#ifdef PLUGIN
{ "plugin", o_special, (void *)loadplugin,"Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST },
#endif
#ifdef PPP_FILTER
{ "pass-filter", o_special, setpassfilter,"set filter for packets to pass", OPT_PRIO },
{ "active-filter", o_special, setactivefilter,"set filter for active pkts", OPT_PRIO },
#endif
#ifdef PPP_PRECOMPILED_FILTER
{ "precompiled-pass-filter", 1, setprecompiledpassfilter,"set precompiled filter for packets to pass", OPT_PRIO },
{ "precompiled-active-filter", 1, setprecompiledactivefilter,"set precompiled filter for active pkts", OPT_PRIO },
#endif
#ifdef MAXOCTETS
{ "maxoctets", o_int, &maxoctets,"Set connection traffic limit",OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
{ "mo", o_int, &maxoctets,"Set connection traffic limit",OPT_ALIAS | OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
{ "mo-direction", o_special, setmodir,"Set direction for limit traffic (sum,in,out,max)" },
{ "mo-timeout", o_int, &maxoctets_timeout,"Check for traffic limit every N seconds", OPT_PRIO | OPT_LLIMIT | 1 },
#endif
{ NULL }
};
option_t auth_options[] = {
{ "auth", o_bool, &auth_required,"Require authentication from peer", OPT_PRIO | 1 },
{ "noauth", o_bool, &auth_required,"Don't require peer to authenticate", OPT_PRIOSUB | OPT_PRIV,&allow_any_ip },
{ "require-pap", o_bool, &lcp_wantoptions[0].neg_upap,"Require PAP authentication from peer",OPT_PRIOSUB | 1, &auth_required },
{ "+pap", o_bool, &lcp_wantoptions[0].neg_upap,"Require PAP authentication from peer",OPT_ALIAS | OPT_PRIOSUB | 1, &auth_required },
{ "require-chap", o_bool, &auth_required,"Require CHAP authentication from peer",OPT_PRIOSUB | OPT_A2OR | MDTYPE_MD5,&lcp_wantoptions[0].chap_mdtype },
{ "+chap", o_bool, &auth_required,"Require CHAP authentication from peer",OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MD5,&lcp_wantoptions[0].chap_mdtype },
#ifdef CHAPMS
{ "require-mschap", o_bool, &auth_required,"Require MS-CHAP authentication from peer",OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT,&lcp_wantoptions[0].chap_mdtype },
{ "+mschap", o_bool, &auth_required,"Require MS-CHAP authentication from peer",OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT,&lcp_wantoptions[0].chap_mdtype },
{ "require-mschap-v2", o_bool, &auth_required,"Require MS-CHAPv2 authentication from peer",OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT_V2,&lcp_wantoptions[0].chap_mdtype },
{ "+mschap-v2", o_bool, &auth_required,"Require MS-CHAPv2 authentication from peer",OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT_V2,&lcp_wantoptions[0].chap_mdtype },
#endif
{ "refuse-pap", o_bool, &refuse_pap,"Don't agree to auth to peer with PAP", 1 },
{ "-pap", o_bool, &refuse_pap,"Don't allow PAP authentication with peer", OPT_ALIAS | 1 },
{ "refuse-chap", o_bool, &refuse_chap,"Don't agree to auth to peer with CHAP",OPT_A2CLRB | MDTYPE_MD5,&lcp_allowoptions[0].chap_mdtype },
{ "-chap", o_bool, &refuse_chap,"Don't allow CHAP authentication with peer",OPT_ALIAS | OPT_A2CLRB | MDTYPE_MD5,&lcp_allowoptions[0].chap_mdtype },
#ifdef CHAPMS
{ "refuse-mschap", o_bool, &refuse_mschap,"Don't agree to auth to peer with MS-CHAP",OPT_A2CLRB | MDTYPE_MICROSOFT,&lcp_allowoptions[0].chap_mdtype },
{ "-mschap", o_bool, &refuse_mschap,"Don't allow MS-CHAP authentication with peer",OPT_ALIAS | OPT_A2CLRB | MDTYPE_MICROSOFT,&lcp_allowoptions[0].chap_mdtype },
{ "refuse-mschap-v2", o_bool, &refuse_mschap_v2,"Don't agree to auth to peer with MS-CHAPv2",OPT_A2CLRB | MDTYPE_MICROSOFT_V2,&lcp_allowoptions[0].chap_mdtype },
{ "-mschap-v2", o_bool, &refuse_mschap_v2,"Don't allow MS-CHAPv2 authentication with peer",OPT_ALIAS | OPT_A2CLRB | MDTYPE_MICROSOFT_V2,&lcp_allowoptions[0].chap_mdtype },
#endif
{ "require-eap", o_bool, &lcp_wantoptions[0].neg_eap,"Require EAP authentication from peer", OPT_PRIOSUB | 1,&auth_required },
{ "refuse-eap", o_bool, &refuse_eap,"Don't agree to authenticate to peer with EAP", 1 },
{ "name", o_string, our_name,"Set local name for authentication",OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXNAMELEN },
{ "+ua", o_special, (void *)setupapfile,"Get PAP user and password from file",OPT_PRIO | OPT_A2STRVAL, &uafname },
{ "user", o_string, user,"Set name for auth with peer", OPT_PRIO | OPT_STATIC,&explicit_user, MAXNAMELEN },
{ "password", o_string, passwd,"Password for authenticating us to the peer",OPT_PRIO | OPT_STATIC | OPT_HIDE,&explicit_passwd, MAXSECRETLEN },
{ "usehostname", o_bool, &usehostname,"Must use hostname for authentication", 1 },
{ "remotename", o_string, remote_name,"Set remote name for authentication", OPT_PRIO | OPT_STATIC,&explicit_remote, MAXNAMELEN },
{ "login", o_bool, &uselogin,"Use system password database for PAP", OPT_A2COPY | 1 ,&session_mgmt },
{ "enable-session", o_bool, &session_mgmt,"Enable session accounting for remote peers", OPT_PRIV | 1 },
{ "papcrypt", o_bool, &cryptpap,"PAP passwords are encrypted", 1 },
{ "privgroup", o_special, (void *)privgroup,"Allow group members to use privileged options", OPT_PRIV | OPT_A2LIST },
{ "allow-ip", o_special, (void *)set_noauth_addr,"Set IP address(es) which can be used without authentication",OPT_PRIV | OPT_A2LIST },
{ "remotenumber", o_string, remote_number,"Set remote telephone number for authentication", OPT_PRIO | OPT_STATIC,NULL, MAXNAMELEN },
{ "allow-number", o_special, (void *)set_permitted_number,"Set telephone number(s) which are allowed to connect",OPT_PRIV | OPT_A2LIST },
{ NULL }
};
static option_t lcp_option_list[] = {
/* LCP options */
{ "-all", o_special_noarg, (void *)noopt,"Don't request/allow any LCP options" },
{ "noaccomp", o_bool, &lcp_wantoptions[0].neg_accompression,"Disable address/control compression",OPT_A2CLR, &lcp_allowoptions[0].neg_accompression },
{ "-ac", o_bool, &lcp_wantoptions[0].neg_accompression,"Disable address/control compression",OPT_ALIAS | OPT_A2CLR, &lcp_allowoptions[0].neg_accompression },
{ "asyncmap", o_uint32, &lcp_wantoptions[0].asyncmap,"Set asyncmap (for received packets)",OPT_OR, &lcp_wantoptions[0].neg_asyncmap },
{ "-as", o_uint32, &lcp_wantoptions[0].asyncmap,"Set asyncmap (for received packets)",OPT_ALIAS | OPT_OR, &lcp_wantoptions[0].neg_asyncmap },
{ "default-asyncmap", o_uint32, &lcp_wantoptions[0].asyncmap,"Disable asyncmap negotiation",OPT_OR | OPT_NOARG | OPT_VAL(~0U) | OPT_A2CLR,&lcp_allowoptions[0].neg_asyncmap },
{ "-am", o_uint32, &lcp_wantoptions[0].asyncmap,"Disable asyncmap negotiation",OPT_ALIAS | OPT_OR | OPT_NOARG | OPT_VAL(~0U) | OPT_A2CLR,&lcp_allowoptions[0].neg_asyncmap },
{ "nomagic", o_bool, &lcp_wantoptions[0].neg_magicnumber,"Disable magic number negotiation (looped-back line detection)",OPT_A2CLR, &lcp_allowoptions[0].neg_magicnumber },
{ "-mn", o_bool, &lcp_wantoptions[0].neg_magicnumber,"Disable magic number negotiation (looped-back line detection)",OPT_ALIAS | OPT_A2CLR, &lcp_allowoptions[0].neg_magicnumber },
{ "mru", o_int, &lcp_wantoptions[0].mru,"Set MRU (maximum received packet size) for negotiation",OPT_PRIO, &lcp_wantoptions[0].neg_mru },
{ "default-mru", o_bool, &lcp_wantoptions[0].neg_mru,"Disable MRU negotiation (use default 1500)",OPT_PRIOSUB | OPT_A2CLR, &lcp_allowoptions[0].neg_mru },
{ "-mru", o_bool, &lcp_wantoptions[0].neg_mru,"Disable MRU negotiation (use default 1500)",OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR, &lcp_allowoptions[0].neg_mru },
{ "mtu", o_int, &lcp_allowoptions[0].mru,"Set our MTU", OPT_LIMITS, NULL, MAXMRU, MINMRU },
{ "nopcomp", o_bool, &lcp_wantoptions[0].neg_pcompression,"Disable protocol field compression",OPT_A2CLR, &lcp_allowoptions[0].neg_pcompression },
{ "-pc", o_bool, &lcp_wantoptions[0].neg_pcompression,"Disable protocol field compression",OPT_ALIAS | OPT_A2CLR, &lcp_allowoptions[0].neg_pcompression },
{ "passive", o_bool, &lcp_wantoptions[0].passive,"Set passive mode", 1 },
{ "-p", o_bool, &lcp_wantoptions[0].passive,"Set passive mode", OPT_ALIAS | 1 },
{ "silent", o_bool, &lcp_wantoptions[0].silent,"Set silent mode", 1 },
{ "lcp-echo-failure", o_int, &lcp_echo_fails,"Set number of consecutive echo failures to indicate link failure",OPT_PRIO },
{ "lcp-echo-interval", o_int, &lcp_echo_interval,"Set time in seconds between LCP echo requests", OPT_PRIO },
{ "lcp-echo-adaptive", o_bool, &lcp_echo_adaptive,"Suppress LCP echo requests if traffic was received", 1 },
{ "lcp-restart", o_int, &lcp_fsm[0].timeouttime,"Set time in seconds between LCP retransmissions", OPT_PRIO },
{ "lcp-max-terminate", o_int, &lcp_fsm[0].maxtermtransmits,"Set maximum number of LCP terminate-request transmissions", OPT_PRIO },
{ "lcp-max-configure", o_int, &lcp_fsm[0].maxconfreqtransmits,"Set maximum number of LCP configure-request transmissions", OPT_PRIO },
{ "lcp-max-failure", o_int, &lcp_fsm[0].maxnakloops,"Set limit on number of LCP configure-naks", OPT_PRIO },
{ "receive-all", o_bool, &lax_recv,"Accept all received control characters", 1 },
#ifdef HAVE_MULTILINK
{ "mrru", o_int, &lcp_wantoptions[0].mrru,"Maximum received packet size for multilink bundle",OPT_PRIO, &lcp_wantoptions[0].neg_mrru },
{ "mpshortseq", o_bool, &lcp_wantoptions[0].neg_ssnhf,"Use short sequence numbers in multilink headers",OPT_PRIO | 1, &lcp_allowoptions[0].neg_ssnhf },
{ "nompshortseq", o_bool, &lcp_wantoptions[0].neg_ssnhf,"Don't use short sequence numbers in multilink headers",OPT_PRIOSUB | OPT_A2CLR, &lcp_allowoptions[0].neg_ssnhf },
{ "endpoint", o_special, (void *) setendpoint,"Endpoint discriminator for multilink",OPT_PRIO | OPT_A2PRINTER, (void *) printendpoint },
#endif /* HAVE_MULTILINK */
{ "noendpoint", o_bool, &noendpoint,"Don't send or accept multilink endpoint discriminator", 1 },
{NULL}
};
static option_t pap_option_list[] = {
{ "hide-password", o_bool, &hide_password,"Don't output passwords to log", OPT_PRIO | 1 },
{ "show-password", o_bool, &hide_password,"Show password string in debug log messages", OPT_PRIOSUB | 0 },
{ "pap-restart", o_int, &upap[0].us_timeouttime,"Set retransmit timeout for PAP", OPT_PRIO },
{ "pap-max-authreq", o_int, &upap[0].us_maxtransmits,"Set max number of transmissions for auth-reqs", OPT_PRIO },
{ "pap-timeout", o_int, &upap[0].us_reqtimeout,"Set time limit for peer PAP authentication", OPT_PRIO },
{ NULL }
};
static option_t chap_option_list[] = {
{ "chap-restart", o_int, &chap_timeout_time,"Set timeout for CHAP", OPT_PRIO },
{ "chap-max-challenge", o_int, &chap_max_transmits,"Set max #xmits for challenge", OPT_PRIO },
{ "chap-interval", o_int, &chap_rechallenge_time,"Set interval for rechallenge", OPT_PRIO },
{ "chapms-strip-domain", o_bool, &chapms_strip_domain,"Strip the domain prefix before the Username", 1 },
{ NULL }
};
static option_t ipcp_option_list[] = {
{ "noip", o_bool, &ipcp_protent.enabled_flag,"Disable IP and IPCP" },
{ "-ip", o_bool, &ipcp_protent.enabled_flag,"Disable IP and IPCP", OPT_ALIAS },
{ "novj", o_bool, &ipcp_wantoptions[0].neg_vj,"Disable VJ compression", OPT_A2CLR, &ipcp_allowoptions[0].neg_vj },
{ "-vj", o_bool, &ipcp_wantoptions[0].neg_vj,"Disable VJ compression", OPT_ALIAS | OPT_A2CLR,&ipcp_allowoptions[0].neg_vj },
{ "novjccomp", o_bool, &ipcp_wantoptions[0].cflag,"Disable VJ connection-ID compression", OPT_A2CLR,&ipcp_allowoptions[0].cflag },
{ "-vjccomp", o_bool, &ipcp_wantoptions[0].cflag,"Disable VJ connection-ID compression", OPT_ALIAS | OPT_A2CLR,&ipcp_allowoptions[0].cflag },
{ "vj-max-slots", o_special, (void *)setvjslots,"Set maximum VJ header slots",OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, vj_value },
{ "ipcp-accept-local", o_bool, &ipcp_wantoptions[0].accept_local,"Accept peer's address for us", 1 },
{ "ipcp-accept-remote", o_bool, &ipcp_wantoptions[0].accept_remote,"Accept peer's address for it", 1 },
{ "ipparam", o_string, &ipparam,"Set ip script parameter", OPT_PRIO },
{ "noipdefault", o_bool, &disable_defaultip,"Don't use name for default IP adrs", 1 },
{ "ms-dns", 1, (void *)setdnsaddr,"DNS address for the peer's use" },
{ "ms-wins", 1, (void *)setwinsaddr,"Nameserver for SMB over TCP/IP for peer" },
{ "ipcp-restart", o_int, &ipcp_fsm[0].timeouttime,"Set timeout for IPCP", OPT_PRIO },
{ "ipcp-max-terminate", o_int, &ipcp_fsm[0].maxtermtransmits,"Set max #xmits for term-reqs", OPT_PRIO },
{ "ipcp-max-configure", o_int, &ipcp_fsm[0].maxconfreqtransmits,"Set max #xmits for conf-reqs", OPT_PRIO },
{ "ipcp-max-failure", o_int, &ipcp_fsm[0].maxnakloops,"Set max #conf-naks for IPCP", OPT_PRIO },
{ "defaultroute", o_bool, &ipcp_wantoptions[0].default_route,"Add default route", OPT_ENABLE|1, &ipcp_allowoptions[0].default_route },
{ "nodefaultroute", o_bool, &ipcp_allowoptions[0].default_route,"disable defaultroute option", OPT_A2CLR,&ipcp_wantoptions[0].default_route },
{ "-defaultroute", o_bool, &ipcp_allowoptions[0].default_route,"disable defaultroute option", OPT_ALIAS | OPT_A2CLR,&ipcp_wantoptions[0].default_route },
{ "replacedefaultroute", o_bool,&ipcp_wantoptions[0].replace_default_route,"Replace default route", 1},
{ "noreplacedefaultroute", o_bool,&ipcp_allowoptions[0].replace_default_route,"Never replace default route", OPT_A2COPY,&ipcp_wantoptions[0].replace_default_route },
{ "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,"Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
{ "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,"disable proxyarp option", OPT_A2CLR,&ipcp_wantoptions[0].proxy_arp },
{ "-proxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,"disable proxyarp option", OPT_ALIAS | OPT_A2CLR,&ipcp_wantoptions[0].proxy_arp },
{ "usepeerdns", o_bool, &usepeerdns,"Ask peer for DNS address(es)", 1 },
{ "netmask", o_special, (void *)setnetmask,"set netmask", OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, netmask_str },
{ "ipcp-no-addresses", o_bool, &ipcp_wantoptions[0].old_addrs,"Disable old-style IP-Addresses usage", OPT_A2CLR,&ipcp_allowoptions[0].old_addrs },
{ "ipcp-no-address", o_bool, &ipcp_wantoptions[0].neg_addr,"Disable IP-Address usage", OPT_A2CLR,&ipcp_allowoptions[0].neg_addr },
#ifdef __linux__
{ "noremoteip", o_bool, &noremoteip,"Allow peer to have no IP address", 1 },
#endif
{ "nosendip", o_bool, &ipcp_wantoptions[0].neg_addr,"Don't send our IP address to peer", OPT_A2CLR,&ipcp_wantoptions[0].old_addrs},
{ "IP addresses", o_wild, (void *) &setipaddr,"set local and remote IP addresses",OPT_NOARG | OPT_A2PRINTER, (void *) &printipaddr },
{ NULL }
};
static option_t ccp_option_list[] = {
{ "noccp", o_bool, &ccp_protent.enabled_flag,"Disable CCP negotiation" },
{ "-ccp", o_bool, &ccp_protent.enabled_flag,"Disable CCP negotiation", OPT_ALIAS },
{ "bsdcomp", o_special, (void *)setbsdcomp,"Request BSD-Compress packet compression",OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, bsd_value },
{ "nobsdcomp", o_bool, &ccp_wantoptions[0].bsd_compress,"don't allow BSD-Compress", OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].bsd_compress },
{ "-bsdcomp", o_bool, &ccp_wantoptions[0].bsd_compress,"don't allow BSD-Compress", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].bsd_compress },
{ "deflate", o_special, (void *)setdeflate,"request Deflate compression",OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, deflate_value },
{ "nodeflate", o_bool, &ccp_wantoptions[0].deflate,"don't allow Deflate compression", OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].deflate },
{ "-deflate", o_bool, &ccp_wantoptions[0].deflate,"don't allow Deflate compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].deflate },
{ "nodeflatedraft", o_bool, &ccp_wantoptions[0].deflate_draft,"don't use draft deflate #", OPT_A2COPY,&ccp_allowoptions[0].deflate_draft },
{ "predictor1", o_bool, &ccp_wantoptions[0].predictor_1,"request Predictor-1", OPT_PRIO | 1 },
{ "nopredictor1", o_bool, &ccp_wantoptions[0].predictor_1,"don't allow Predictor-1", OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].predictor_1 },
{ "-predictor1", o_bool, &ccp_wantoptions[0].predictor_1,"don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].predictor_1 },
{ "lzs", o_bool, &ccp_wantoptions[0].lzs,"request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
{ "+lzs", o_bool, &ccp_wantoptions[0].lzs,"request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
{ "nolzs", o_bool, &ccp_wantoptions[0].lzs,"don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].lzs },
{ "-lzs", o_bool, &ccp_wantoptions[0].lzs,"don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].lzs },
#ifdef MPPE
{ "mppc", o_bool, &ccp_wantoptions[0].mppc,"request MPPC compression", 1, &ccp_allowoptions[0].mppc },
{ "+mppc", o_bool, &ccp_wantoptions[0].mppc,"request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
{ "nomppc", o_bool, &ccp_wantoptions[0].mppc,"don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].mppc },
{ "-mppc", o_bool, &ccp_wantoptions[0].mppc,"don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,&ccp_allowoptions[0].mppc },
{ "mppe", o_special, (void *)setmppe,"request MPPE encryption" },
{ "+mppe", o_special, (void *)setmppe,"request MPPE encryption" },
{ "nomppe", o_special_noarg, (void *)setnomppe,"don't allow MPPE encryption" },
{ "-mppe", o_special_noarg, (void *)setnomppe,"don't allow MPPE encryption" },
#endif /* MPPE */
{ NULL }
};
static option_t ecp_option_list[] = {
{ "noecp", o_bool, &ecp_protent.enabled_flag,"Disable ECP negotiation" },
{ "-ecp", o_bool, &ecp_protent.enabled_flag,"Disable ECP negotiation", OPT_ALIAS },
{ NULL }
};
static option_t eap_option_list[] = {
{ "eap-restart", o_int, &eap_states[0].es_server.ea_timeout,"Set retransmit timeout for EAP Requests (server)" },
{ "eap-max-sreq", o_int, &eap_states[0].es_server.ea_maxrequests,"Set max number of EAP Requests sent (server)" },
{ "eap-timeout", o_int, &eap_states[0].es_client.ea_timeout,"Set time limit for peer EAP authentication" },
{ "eap-max-rreq", o_int, &eap_states[0].es_client.ea_maxrequests,"Set max number of EAP Requests allows (client)" },
{ "eap-interval", o_int, &eap_states[0].es_rechallenge,"Set interval for EAP rechallenge" },
#ifdef USE_SRP
{ "srp-interval", o_int, &eap_states[0].es_lwrechallenge,"Set interval for SRP lightweight rechallenge" },
{ "srp-pn-secret", o_string, &pn_secret,"Long term pseudonym generation secret" },
{ "srp-use-pseudonym", o_bool, &eap_states[0].es_usepseudo,
"Use pseudonym if offered one by server", 1 },
#endif
{ NULL }
};
----------------------------------------------------------------------------------------------------
File:options.c
int options_from_user()
{
char *user, *path, *file;
int ret;
struct passwd *pw;
size_t pl;
pw = getpwuid(getuid());
if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
return 1;
file = _PATH_USEROPT; #NOTE:#define _PATH_USEROPT ".ppprc"
pl = strlen(user) + strlen(file) + 2;
path = malloc(pl);
if (path == NULL)
novm("init file name");
slprintf(path, pl, "%s/%s", user, file);
option_priority = OPRIO_CFGFILE;
ret = options_from_file(path, 0, 1, privileged);#NOTE: 从用户配置文件.ppprc中读取配置选项
free(path);
return ret;
}
----------------------------------------------------------------------------------------------------------------
File: options.c
int parse_args(argc, argv)
int argc;
char **argv;
{
char *arg;
option_t *opt;
int n;
privileged_option = privileged;
option_source = "command line";
option_priority = OPRIO_CMDLINE;
while (argc > 0) {
arg = *argv++;
--argc;
opt = find_option(arg); #NOTE:查找选项
if (opt == NULL) {
option_error("unrecognized option '%s'", arg);
usage();
return 0;
}
n = n_arguments(opt);
if (argc < n) {
option_error("too few parameters for option %s", arg);
return 0;
}
if (!process_option(opt, arg, argv))
return 0;
argc -= n;
argv += n;
}
return 1;
}
linux pppd源码下载_PPPD源码分析相关推荐
- linux应用程序逆向,Linux下查看并下载命令源码包(根据命令/应用程序逆向获取并且安装其所属源码包)...
使用linux的过程中,我们会熟悉各种命令,偶尔我们不禁会问,这些命令是怎么实现的,学习他们其实是学习linux高级系统编程很快捷的方法. 这些命令的源码肯定是存放在相应的包里面,但是是哪些包呢? 发 ...
- 在线教育专业建站工具 EduWind ,源码下载,源码分享网整理
在线教育专业建站工具 EduWind ,源码下载, Eduwind是由北京水木信步网络科技有限公司开发的网校服务,公司位于清华科技园.目前,EduWind的产品系列包括以下两大版本: EduWind网 ...
- 站长下载 - 源码下载,网站源码,站长工具 - 中国站长站
站长下载 - 源码下载,网站源码,站长工具 - 中国站长站 http://down.chinaz.com/
- RTOS之uCOS-II源码下载及源码目录结构、常见的RTOS!
RTOS有众多种,用得最火的是FreeRTOS,因为它即使用于商业途径,也是开源免费的:其次是就是uCOS-II和uCOS-III.uCOS-II用于商业途径是需要付费的,但是对于学习研究却是免费的. ...
- 9款精致HTML5/jQuery日历时钟控件源码下载(源码请见百度云) 链接:http://pan.baidu.com/s/1geIXe75 密码:7m4a...
现在的网页应用越来越丰富,我们在网页中填写日期和时间已经再也不用手动输入了,而是使用各种各样的日期时间选择控件,大部分样式华丽的日期选择和日历控件都是基于jQuery和HTML5的,比如今天要分享的这 ...
- android 6.0.1原生系统源码下载以及源码编译----framework修改
1.源码下载前参数配置 1️⃣配置usb所需 sudo apt-get update sudo apt-get install git-core gnupg flex bison gperf buil ...
- vue-生成二维码+下载二维码
<div class="img" ref="code"><qrcode-vue :value="link" size=&q ...
- centos7 更新网络源,下载扩展源时出现“one of the configured repositories failed”提示,解决方案
平常都是用本地源,今天下某软件时需要用到网络源,启用网络源下载时突然报障,yum clean all 接着yum makecache 也出现"one of the configured re ...
- linux pppd源码下载_pppd源代码分析
会进一步调用函数 ppp_send_frame( ) 去发送单个数据包.函数 ppp_send_frame( ) 根据前面 pppd 对 PPP 协议模块的设置调用压缩等扩展功能之后, 又经函数 pp ...
最新文章
- CarTool 使用,获取图片资源
- Microbiome:中科院微生物所蔡磊组揭示病害影响植物微生物组群落构建与功能适应...
- supervisor 守护多个进程_supervisor守护进程管理实操笔记
- 【人物】徐小平:远离创业的3个死亡陷阱
- opencv学习笔记12:图像腐蚀和图像膨胀
- 网络IPC非阻塞和异步I/O
- 马云下死命令留人?阿里辟谣:不会高薪聘请黑掉阿里网站的人
- Thinking in Java 4th(Java编程思想第四版)文档、源码、习题答案
- 【劲峰论道时空分析技术-学习笔记】3 时空演化树
- java simpedateformat_java中Date,SimpleDateFormat
- 单点登录的CAS实践
- IDEA中JDBC连接MYSQL数据库步骤超详细总结
- mysql分页limit (currentPage-1)*pageSize,pageSize
- 当前有哪些流行的前端开发框架?
- nodeJS 第一篇
- 树莓派2model B 通过蓝牙实现A2DP协议连接手机播放音乐
- HTML(进阶核心标签)
- DDR,DDR2,DDR3,DDR4,LPDDR区别讲解
- 【论文精读】AVP-Loc: Surround View Localization and Relocalization Based on HD VectorMap for AVP
- 现在又出来一个数字经济的概念,听说下半年要火起来
热门文章
- 4K、高清、无水印视频素材库
- 无线路由器常用的五种工作模式详细介绍
- 《 Matlab_Simulink动力学系统建模仿真》及 ‘///’动力学 达朗贝尔原理、虚位移原理、朗格朗日方程...
- 内网穿透保姆级教程——内网穿透建立个人网站、远程控制
- 第十三弹 服务数据的定义与使用
- Access denied for user ‘root‘@‘localhost‘
- MySQL 日志的类型
- CS和IP寄存器的作用及执行分析
- Linux中的rm指令
- w10系统打不开服务器共享打印机,win10系统无法共享打印机的方案