linux wan连接cgi代码目录
./install.sh iwifi
make package/network/utils/iproute2/compile V=99
make package/install V=99
cd /var;
tftp -gr cms_9_ramips_24kec.ipk 192.168.2.18
rm -rf /etc/resolv.conf
opkg install cms_9_ramips_24kec.ipk
tftp -gr kmod-board_3.10.36-1_ramips_24kec.ipk 192.168.1.18
opkg install kmod-board_3.10.36-1_ramips_24kec.ipk
tftp -gr userDeviceManagement.html 192.168.1.18
tftp -gr wanCfg.html 192.168.1.18
wanethernet wancomm
cgiCtwanCfg()
一.dalCtWan_addInterface(&glbWebVar))
1.1 dalWan_addL2Interface
LinkType 为ethernet的时候 不需要添加L2 interface
if 0
遍历MDMOID_WAN_GPON_LINK_CFG IGDWANDevice.{i}.WANGPONLinkConfig, 如果mdm有gponlinkcfg instance且vlanIdmark相等, 则enable gponLinkCfg.
如果没有则添加MDMOID_WAN_CONN_DEVICE. "InternetGatewayDevice.WANDevice.{i}.WANConnectionDevice.{i}后进行相应赋值。
gponLinkCfg->VLANIDMark vlan, gponLinkCfg->mark vlanMuxPr 优先级。
endif
1.2 dynamic|static...
addCtWanIpConnection(webVar, &iidStack);
1.2.1 添加MDMOID_WAN_IP_CONN IGD.WANDevice.{i}.WANConnectionDevice.{i}.WANIPConnection.{i}
case CMS_WAN_TYPE_STATIC_IPOE:
case CMS_WAN_TYPE_DYNAMIC_IPOE:
/* used by both ethWan and mocaWan, no need to put in ifdef */
case CMS_WAN_TYPE_DYNAMIC_ETHERNET_IP:
wanIpConn->connectionType = cmsMem_strdup(MDMVS_IP_ROUTED);
wanIpConn->IPProMode = generateIpProMode(webVar->enblv4, webVar->enblv6); //wanIpConn->IPProMode= ipv4, ipv6
ctBindLanListMaskToString(bindLanList, webVar->lanInterfaceMask);
CMSMEM_REPLACE_STRING(wanIpConn->X_CT_COM_LanInterface, bindLanList); //wanIpConn->X_CT_COM_LanInterface 绑定的lan侧端口, lan1-lan4, ssid1-ssid4.
ctServModeListMaskToString(servModeList, webVar->servModeMask);
CMSMEM_REPLACE_STRING(wanIpConn->X_CT_COM_ServiceList, servModeList); //wanIpConn->X_CT_COM_ServiceLis, INTERNET, VOIP. OTHER.
wanIpConn->enable = TRUE;
wanIpConn->vlanMuxID = vlanMuxEnab? webVar->vlanMuxId : VLANMUX_DISABLE; //wanIpConn->vlanMuxID 1-4094
wanIpConn->vlanMux8021p = vlanMuxEnab? webVar->vlanMuxPr : VLANMUX_DISABLE; wanIpConn->vlanMux8021p 0-7
cmsObj_set(wanIpConn, iidStack);
1.3 bridge||pppoe||ethpppoe||pppoa
addCtWanPppConnection(webVar, &iidStack);
二: 由1.2.1 添加MDMOID_WAN_IP_CONN IGD.WANDevice.{i}.WANConnectionDevice.{i}.WANIPConnection.{i}
rcl_wanIpConnObject
//对ipconobj-name(TR069_...) ipconnobj->ifname veip0, ipconnobj->connecionId 0,1,2进行赋值
rutWan_fillWanL3IfNameAndServiceName(newObj, iidStack);
添加MDMOID_L2_BRIDGING_INTF IGD.Layer2Bridging.AvailableInterface.{i}.实例, 并将availInterfaceReference(ifName的fullPath)赋值给availIntfObj->interfaceReference
rutPMap_addAvailableInterface(newObj->ifName, isWanIntf); //isWanIntf TRUE
添加MDMOID_L2_BRIDGING_FILTER实例 IGDLayer2Bridging.Filter.{i}.
rutPMap_addFilter(newObj->ifName, isWanIntf, bridgeRef); // bridgeRef default 0.
2.1 //goto prepare_wanipconnection;
rutwan_doWanEnableActions(FALSE/*isPpp*/, IS_IPV4_ENABLED(newObj), IS_IPV6_ENABLED(newObj), newObj, iidStack);
2.1.1 rutwan_doWanActions(RUT_WAN_ENABLE, wanL3Oid, newObj, NULL, iidStack, TRUE);
case RUT_WAN_ENABLE:
/* 如果servicelist中有tr069,. 更新MDMOID_MANAGEMENT_SERVER的 boundIfname为IpConnObj->ifName,veip0 */
rutwan_updateTr069BoundIfName(TRUE, newWanIpObj->ifName)) != CMSRET_SUCCESS )
/* 如果servicelist中有internet, 且connectionType为routed, 更新MDMOID_NETWORK_CONFIG IGD.NetworkConfig.DNSIfName 为ipconnObj->ifName*/
rutNtwk_updateSystemDNSIfnames(TRUE, isIpv4, newWanIpObj->ifName);
2.1.1.1 /* 如果servicelist中有internet, 且connectionType为other, 更新MDMOID_CT_LAN_PORTS_BIND_CFG IGD.CtLanPortsBindCfg->bindedLanList 5.4.1.2 */
rut_updateLanPortsBindInfo(TRUE, rutPmap_parseLanList(newWanIpObj->X_CT_COM_LanInterface));
rcl_ctLanPortsBindCfgObject IGD.CtLanPortsBindCfg
{
ipRt2 echo 200 deft >> /etc/iproute2/rt_tables //cmd default
ipRt2 ip rule add fwmark 0xf0000000/0xffff0000 table deft 2>/dev/null
ipRt2 echo 201 tr069 >> /etc/iproute2/rt_tables //cmd tr069
ipRt2 ip rule add fwmark 0xe0000000/0xffff0000 table tr069 2>/dev/null //tr069
ipRt2 echo 202 voip >> /etc/iproute2/rt_tables //cmd voip
ipRt2 ip rule add fwmark 0xd0000000/0xffff0000 table voip 2>/dev/null //voip
ipRt2 echo 203 ping >> /etc/iproute2/rt_tables //cmd ping
ipRt2 ip rule add fwmark 0xc0000000/0xffff0000 table ping 2>/dev/null //ping
ipRt2 echo 204 other >> /etc/iproute2/rt_tables //cmd other
ipRt2 ip rule add fwmark 0xb0000000/0xffff0000 table other 2>/dev/null //other
ipRt2 echo 205 drop >> /etc/iproute2/rt_tables //cmd other
ipRt2 ip rule add fwmark 0xa0000000/0xffff0000 table drop 2>/dev/null //drop
ipRt2 echo 206+(0-7) tbl(1-8) >> /etc/iproute2/rt_tables
/* 根据端口是否绑定, 添加ebtables规则
ebtables -t broute -A BROUTING -i eth0(eth0-eth3, wlan0, wlan0-va0-wlan0-va2) -j mark --mark-or 0xf0000000 --mark-target CONTINUE 2>/dev/null */
rutPMap_addUnbinedLanPortsRoutingRules(TRUE, TRUE, newObj->bindedLanList, newObj->internetBridgeIfName);
}
/* 如果connectionType为route 且 servicelist中有internet或other */
/* fwMark 0-8 route_internet_0, 若返回值为-1, 则fwMark为0xf0000000 */
newWanIpObj->fwMark = rutwan_getConInstanceIdFromServiceName(newWanIpObj->name);
2.1.1.2 策略路由添加
rutPmap_doPoliceRoutingOnWanIfc(RUT_WAN_ENABLE, newWanIpObj->connectionId, newWanIpObj->ifName, newWanIpObj->defaultGateway,
newWanIpObj->subnetMask, newWanIpObj->X_CT_COM_LanInterface, newWanIpObj->fwMark);
/* RUT_WAN_ENABLE 0 */
rutPmap_doPoliceRoutingOnWanIfc(WanConfigAction action, SINT32 connectionId, const char *wanIfName, const char *defaultGateway, const char *netMask,
const char *bindLanLst, SINT32 mark)
add = true;
/* table name= tbl%d, mark 即为0-7 nf_mark_leftbit 24*/
ip rule add fwmark 0x%x/0x%x table %s 2>/dev/null", add? "add":"del", (mark<<nf_mark_leftbit), 0xffff0000, table_name) ;
ebtables -t broute -A BROUTING -i (bcm_name eth0-3, wlan0, wlan0-va0-wlan0-va2 ) -j mark --mark-or (mark<<nf_mark_leftbit) --mark-target CONTINUE 2
ebtables -A FORWARD -i (bcm_name) -p 0x0800 --ip-proto 17 --ip-sport 68 -j DROP 2>/dev/null
2.1.2 rutWan_sendConnectionUpdateMsg(wanL3Oid, iidStack, TRUE/*isAddPvc*/, isStatic, FALSE, FALSE);
2.2 /* from "Unconfigured"/Disconnected(curObj)" to "Connecting(newObj)" */
rutCfg_startWanIpConnection(iidStack, newObj)
2.2.1 /* IPOE and bridge connection */
2.1.1.1 /* start L3 Interface only needed for PPPOE */
rutWan_startL3Interface(MDMOID_WAN_IP_CONN, iidStack, newObj->ifName, newObj->vlanMuxID, newObj->vlanMux8021p, newObj->connectionId, isBridge)) !=
CMSRET_SUCCESS)
{
}
2.2.2 rutwan_doWanActions(RUT_WAN_START, MDMOID_WAN_IP_CONN, newObj, NULL, iidStack, TRUE);
{
/* ifconfig ifName mtu mtunum */
rutwan_setInterfaceMtu(newWanIpObj->ifName, newWanIpObj->interfaceMtu)
}
2.2.3 pid = rutWan_ctStartDhcpc(newObj->ifName, NULL, newObj->op61DUID, newObj->op61IAID, newObj->op125Enabled,
iidStack, newObj->X_CT_COM_ServiceList)
{
cmdLine = -i Ifname -d venderid -D duid -I iaid -O manufacturer -S serialNumber -P productClass
rut_sendMsgToSmd(CMS_MSG_START_APP, EID_DHCPC, cmdLine, cmsUtl_strlen(cmdLine)+1);
}
2.4 /* From "Unconfigured", "Connecting" or "Disconnected(curObj)" to "Connected(newObj)", OR * from "Connected" to "Connected" where Wan connection is already tearDown above.
* Just setup the Wan Ip connection. */
rutCfg_setupWanIpConnection(iidStack, newObj)
{
ultWan ifconfig l2IfName up.
}