filter vlan


/* * Copyright (c) 2002, 2003 by cisco Systems, Inc. * All rights reserved. */ function ifNameObject(text, value){ this.text = text; this.value = value; } function getInterfaceName(showRun, showInt) { var i = 0, slot; var resultsName, patternName; var interfaceName = new Array(); var pattern = /![\r\n]+interface (FastEthernet\d+|Dot11Radio\d+)[\r\n]+/; var results; results = showRun.match(pattern); while (results != null) { patternName = new RegExp(results[1] + " [^\\r\\n]+[\\r\\n]+ Hardware is (\\S+) *(\\S*),"); resultsName = showInt.match(patternName); if (resultsName != null) { if (resultsName[2] == "Radio") { slot = results[1].match(/Dot11Radio(\d+)/); interfaceName[1+i] = new ifNameObject(resultsName[2] + slot[1] + "-" + resultsName[1], results[1]); i++; } else { interfaceName[0] = new ifNameObject('FastEthernet', results[1]); } } results = results.input.substring(results[0].length + results.index).match(pattern); } return interfaceName; } function getInterfaces(showRun) { var results, count = 0; var pattern = /![\r\n]+interface (FastEthernet\d|Dot11Radio\d)[\r\n]+( [^\r\n]+[\r\n]+)+ bridge-group (\d+)[\r\n]+/; var vlanArray = new Array(); var subIf = new Array(); var bridge; results = showRun.match(pattern); while (results != null) { subIf[count++] = results[1]; bridge = results[3]; results = results.input.substring(results[0].length + results.index).match(pattern); } vlanArray[0] = new vlanObject("", null, bridge, subIf, null); return vlanArray; } var filterList = new Array(new Array(), new Array(), new Array()); var MAC = 0; var ETHERTYPE = 1; var IP = 2; function filterAclListName(filterNb, filterPage){ var form = document.forms[0], count = 0; var pattern = null, results, filterPattern, filterNumber; if (filterPage) { filterList[filterNb][count++] = null; } if (filterNb == ETHERTYPE) { pattern = /access-list (2\d\d) (permit|deny) +\S+ \S+[\r\n]+/ results = form.showRun.value.match(pattern); } if (filterNb == MAC) { pattern = /access-list (7\d\d) (permit|deny) +\S+ +\S+[\r\n]+/ results = form.showRun.value.match(pattern); } if (filterNb == IP) { pattern = /ip access-list extended (\S+)[\r\n]+(( (permit|deny) [^\r\n]+[\r\n]+)+)/ results = form.showRun.value.match(pattern); } if (pattern == null) { return false; } while (results != null) { if (filterNb == IP) { if (isValidName(results[1])) { if (isGoodIpFilter(results[2])) { filterList[filterNb][count++] = results[1]; } } } else { filterNumber = results[1]; filterPattern = "(access-list " + filterNumber + " (permit|deny) +(\\S+) +(\\S+)[\\r\\n]+)+"; results = results.input.match(filterPattern); if (isGoodFilter(filterNb, results[0])) { filterList[filterNb][count++] = filterNumber; } } results = results.input.substring(results[0].length + results.index).match(pattern); } return true; } function isValidName(name){ if (name.search(/\D/) != -1) { return true; } else { return false; } } function isGoodIpElementFilter(string){ var pattern, results; pattern = / (permit|deny) +(tcp|udp) any any eq \S+[\r\n]+/; results = string.match(pattern); if (results) { return true; } pattern = / (permit|deny) +\S+ any any[\r\n]+/; results = string.match(pattern); if (results) { return true; } pattern = / (permit|deny) +ip [^\r\n]+[\r\n]+/; results = string.match(pattern); if (results) { return true; } return false; } function isGoodIpFilter(descString){ var form = window.document.forms[0]; var pattern, results, count = 0; pattern = / (permit|deny) [^\r\n]+[\r\n]+/ results = descString.match(pattern); while (results != null) { if (results.input.substring(results[0].length + results.index) != "") { if (!isGoodIpElementFilter(results[0])) { return false; } } else { if (results[0].search(/ (permit|deny) +ip any any[\r\n]+/) == -1) { return false; } } count++; results = results.input.substring(results[0].length + results.index).match(pattern); } if (count == 0) { return false; } else { return true; } } function isGoodFilter(filterNb, filter){ var form = window.document.forms[0]; var pattern, results, count = 0; if (filterNb == ETHERTYPE) { defaultMask = "0xFFFF"; } else { defaultMask = "ffff.ffff.ffff"; } pattern = /access-list \d+ (permit|deny) +(\S+) +(\S+)[\r\n]+/; results = filter.match(pattern); while (results != null) { if ((results.input.substring(results[0].length + results.index) == "") && (results[3] != defaultMask)) { return false; } count++; results = results.input.substring(results[0].length + results.index).match(pattern); } if (count == 0) { return false; } else { return true; } }



Wyszukiwarka