本节将介绍CL的构造函数以及Netd的测试工具ndc。
**1.CL构造函数**
在前文的2.2.3节中已经介绍了CL构造函数的前半部分,下面接着介绍CL构造函数的后半
部分,代码如下所示。
**CommandListener::CommandListener构造函数**
~~~
CommandListener::CommandListener() :
FrameworkListener("netd", true) {
......// 创建命令和命令控制对象
// 初始化iptables中的各个Table及相应Chain和Rules
// createChildChains第一个参数用于指明针对IPv4还是IPv6
createChildChains(V4V6, "filter", "INPUT", FILTER_INPUT);
createChildChains(V4V6, "filter", "FORWARD", FILTER_FORWARD);
createChildChains(V4V6, "filter", "OUTPUT", FILTER_OUTPUT);
createChildChains(V4V6, "raw", "PREROUTING", RAW_PREROUTING);
createChildChains(V4V6, "mangle", "POSTROUTING", MANGLE_POSTROUTING);
createChildChains(V4, "nat", "PREROUTING", NAT_PREROUTIN