{
    "name"  : "检测内网是否存在三层网络环境",
    "problems" : {
        "notSameIpseg" : {
            "desc"      : "【问题】内网存在三层网络环境",
            "advice"    : "【建议】请检查内网交换机或安全设备的配置是否正常，确认无法上的PC能否ping通自己的网关，tracert –d 8.8.8.8数据能到达网关设备，ping www.baidu.con能否解析"
        },
        "noRoute" : {
            "desc"      : "【问题】设备未配置回指路由",
            "advice"    : "【建议】请配置目的地址为内网网段的回指路由"
        },
        "hasRoute" : {
            "desc"      : "【问题】内网存在三层网络环境",
            "advice"    : "【建议】请检查内网交换机或安全设备的配置是否正常，确认无法上的PC能否ping通自己的网关， ping www.baidu.con能否解析，tracert –d 8.8.8.8数据能到达网关设备"
        }
    }
}

---------------------------code-------------------------------
ipCheck = precondition('ipCheck')

reg = /LAN:\s([^\r\n]+)/i
response = cli('show sys-mode')
result = response.match(reg)
result = result[1]
reg = /([a-zA-Z]+\s[\d\/\.]+)/g
lanArr = result.match(reg)

response = cli('show ip in brief')
sameIpsegFlag = false
ipseg = null
foreach lan in lanArr :
    reg = format('%s\\s+([\\d\\/\\.]+)',lan)
    ipAndMask = response.match(reg)
    if ipAndMask != null :
        ipAndMask = ipAndMask[1]
        ipAndMask = ipAndMask.split(/\//)
        ip = ipAndMask[0]
        mask = ipAndMask[1]
        #print ip
        #print mask
        if isSameIpseg(ip, ipCheck, mask) == true :
            sameIpsegFlag = true
            ipseg = getIpseg(ip, mask)
            break
        end
    end
end

if sameIpsegFlag == true :
    return 'success'
end

reg = /[\r\n]\s*ip\sroute\s[\d\.]+\s[\d\.]+/g
hasRoute = false
response = cli('show run | include ip route')
result = response.match(reg)
if result != null :
    foreach routeStr in result :
        reg = /[\r\n]\s*ip\sroute\s([\d\.]+)\s([\d\.]+)/
        ipArr = routeStr.match(reg)
        ip = ipArr[1]
        mask = ipArr[2]
        if ip != '0.0.0.0' && isSameIpseg(ip, ipCheck, mask) == true :
            hasRoute = true
            break
end 
    end
end

if hasRoute == true :
    add_problem("hasRoute")
    return 'warn'
else :
    add_problem("noRoute")
    return 'warn'
end