扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
对于一个网络协议来说,我们不仅仅要了解它的定义和概念,更要清楚它的设置与应用。那么今天我们就主要讲解一下关于PPP Options 的相关内容,来帮助大家了解一下具体的选项配置。
Selecting PPP Options Using an Options Structure
PPP options may be set at run-time by filling in a PPP options structure and passing the structure location to the ppp Init( ) routine. This routine is the standard entry point for initializing a PPP link (see Initializing a PPP Link).
The PPP options structure is typedefed to PPP_OPTIONS, and its definition is located in h/netinet/ppp/options.h, which is included through h/pppLib.h.
PPP选项可以在运行的时候设置,设置PPP选项结构体并将这个结构体传给pppInit()函数。这个函数是初始化PPP连接的标准入口点(请参考初始化PPP连接)。
The first field of the structure is an integer, flags, which is a bit field that holds the ORed value of the OPT_option macros displayed in column 2 of Table 3-3. Definitions for OPT_option are located in h/netinet/ppp/options.h. The remaining structure fields in column 2 are character pointers to the various PPP options specified by a string.
选项结构体的第一个域是整型数,一个标志位,是几个 OPT_xxx或运算之后的值,所有的OPT_xxx可以在Table 3-3中找到。OPT_xxx的定义在h/netinet/ppp/options.h中。。。。(不知所云)
The following code fragment is one way to set configuration options using the PPP options structure. It initializes a PPP interface that uses the target's second serial port (/tyCo/1). The local IP address is 90.0.0.1; the IP address of the remote peer is 90.0.0.10. The baud rate is the default rate for the tty device. The VJ compression and authentication options have been disabled, and LCP (Link Control Protocol) echo requests have been enabled.
下面的代码段说明了使用PPP选项结构体配置连接的一种方式。用目标机的第二个串口(/tyCo/1)初始化一个PPP连接,本地IP是90.90.0.1,远程机器的IP是90.90.0.10,波特率是tty设备缺省的速率。VJ压缩和认证选项是禁用的,链路控制协议的echo请求是启用的。
1.PPP_OPTIONS pppOpt; /* PPP configuration options */
2.
3.void routine ()
4. {
5. pppOpt.flags = OPT_PASSIVE_MODE | OPT_NO_PAP | OPT_NO_CHAP |
6. OPT_NO_VJ;
7. pppOpt.lcp_echo_interval = "30";
8. pppOpt.lcp_echo_failure = "10";
9.
10. pppInit (0, "/tyCo/1", "90.0.0.1", "90.0.0.10", 0, &pppOpt, NULL);
11. }
Setting PPP Options Using an Options File
PPP options are most conveniently set using an options file. There is one restriction: the options file must be readable by the target without there being an active PPP link. Therefore the target must either have a local disk or RAM disk or an additional network connection. For more information about using file systems, see VxWorks Programmer's Guide: Local File Systems.
使用选项文件设置PPP选项是最方便的。有一个限制:选项文件必须在没有PPP连接的时候也能够访问的到。因此目标机必须有一个本地磁盘、RAM或者另外一条网络连接。关于使用文件系统的更多信息,请参考VxWorks程序员指南:本地文件系统。
This configuration method can be used with either usrPPPInit( ) or pppInit( ). It also can be used to modify the selection of PPP options previously configured using configuration constants in config.h or the option structure PPP_OPTION.
When using usrPPPInit( ) to initialize PPP, define the configuration constant PPP_OPTIONS_FILE to be the absolute path name of the options file (NULL by default). When using pppInit( ), pass in a character string that specifies the absolute path name of the options file.
可以使用usrPPPInit()或pppInit()来设置选项文件。它也可以用来修改之前通过config.h或者PPP_OPTION配置好的选项。
当你使用usrPPPInit()初始化一条连接的时候,要定义PPP_OPTIONS_FILE为选项文件的绝对路径(缺省的是NULL)。使用pppInit()初始化的时候,要传入一个参数指定选项文件的绝对路径。
The options file format is one option per line; comment lines begin with #. For a description of option syntax, see the manual entry for pppInit( ).
The following code fragment generates the same results as the code example in Selecting PPP Options Using an Options Structure. The difference is that the configuration options are obtained from a file rather than a structure.
选项文件的格式是,一个选项占据一行; 注释的部分以#开头。具体的细节,请参考手册中的pppInit()。
下面的代码段的作用和Selecting PPP Options Using an Options Structure中的例子的效果是一样的。不同的地方是,这里从一个文件获取配置选项。
1.pppFile = "mars:/tmp/ppp_options"; /* PPP config. options file */
2.
3.void routine ()
4. {
5. pppInit (0, "/tyCo/1", "90.0.0.1", "90.0.0.10", 0, NULL, pppFile);
6. }
7.In this example, mars:/tmp/ppp_options is a file that contains the following:
在这里例子里,mars:/tmp/ppp_options包含以下内容:
1.passive
2.no_pap
3.no_chap
4.no_vj
5.lcp_echo_interval 30
6.lcp_echo_failure 10
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者