[Javanetsim-cvs] javaNetSim/core AccessListEngine.java, 1.3, 1.4 CommandProcessor.java, 1.10, 1.11
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21116/core Modified Files: AccessListEngine.java CommandProcessor.java DeviceConfig.java NetworkLayerDevice.java Simulation.java Log Message: commands "write mem", "ip access-list" was corrected turnOff/turnOn function was fixed Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NetworkLayerDevice.java 23 Oct 2007 20:14:48 -0000 1.13 --- NetworkLayerDevice.java 14 Sep 2008 20:51:29 -0000 1.14 *************** *** 75,78 **** --- 75,79 ---- public void turnOff(){ + acls.clear(); super.turnOff(); } Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CommandProcessor.java 10 Sep 2008 21:35:37 -0000 1.10 --- CommandProcessor.java 14 Sep 2008 20:51:29 -0000 1.11 *************** *** 569,644 **** public String call(Vector<String> params){ String out = ""; ! if(device instanceof ApplicationLayerDevice){ ! if(params.size()==3){ ! try { ! int iacl = Integer.parseInt(params.get(1)); ! if(iacl>=1 && iacl<=2699){ ! if(params.get(2).equalsIgnoreCase("in")){ ! device.getNetworkInterface(params.get(0)).setACLin(iacl); ! // device.getConfig().remove("^interface "+params.get(0)+" ip access-group \\d+ in"); ! // device.getConfig().add("interface "+params.get(0)+" ip access-group "+params.get(1)+" in"); ! } ! else if(params.get(2).equalsIgnoreCase("out")){ ! device.getNetworkInterface(params.get(0)).setACLout(iacl); ! // device.getConfig().remove("^interface "+params.get(0)+" ip access-group \\d+ out"); ! // device.getConfig().add("interface "+params.get(0)+" ip access-group "+params.get(1)+" out"); ! } ! else{ ! out += "error: invalid ACL direction '"+params.get(2)+"'\n"; ! } } else{ ! out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; } ! } catch (NumberFormatException ex) { out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; - } catch (InvalidNetworkInterfaceNameException ex) { - out += "error: invalid inferface\n"; } ! } ! else{ ! out += "error: invalid parameters\n"; } } else{ ! out += "This instruction not supported by device\n"; ! } return out; } public String no_call(Vector<String> params){ String out = ""; ! if(device instanceof ApplicationLayerDevice){ ! if(params.size()==3){ ! try { ! int iacl = Integer.parseInt(params.get(1)); ! if(iacl>=1 && iacl<=2699){ ! if(params.get(2).equalsIgnoreCase("in")){ ! device.getNetworkInterface(params.get(0)).setACLin(0); ! // device.getConfig().remove("^interface "+params.get(0)+" ip access-group \\d+ in"); ! } ! else if(params.get(2).equalsIgnoreCase("out")){ ! device.getNetworkInterface(params.get(0)).setACLout(0); ! // device.getConfig().remove("^interface "+params.get(0)+" ip access-group \\d+ out"); ! } ! else{ ! out += "error: invalid ACL direction '"+params.get(2)+"'\n"; ! } } else{ ! out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; } ! } catch (NumberFormatException ex) { out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; - } catch (InvalidNetworkInterfaceNameException ex) { - out += "error: invalid inferface\n"; } ! } ! else{ ! out += "error: invalid parameters\n"; } } else{ ! out += "This instruction not supported by device\n"; ! } return out; } --- 569,628 ---- public String call(Vector<String> params){ String out = ""; ! if(params.size()==3){ ! try { ! int iacl = Integer.parseInt(params.get(1)); ! if(iacl>=1 && iacl<=2699){ ! if(params.get(2).equalsIgnoreCase("in")){ ! device.getNetworkInterface(params.get(0)).setACLin(iacl); ! } ! else if(params.get(2).equalsIgnoreCase("out")){ ! device.getNetworkInterface(params.get(0)).setACLout(iacl); } else{ ! out += "error: invalid ACL direction '"+params.get(2)+"'\n"; } ! } ! else{ out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; } ! } catch (NumberFormatException ex) { ! out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; ! } catch (InvalidNetworkInterfaceNameException ex) { ! out += "error: invalid inferface\n"; } } else{ ! out += "error: invalid parameters\n"; ! } return out; } public String no_call(Vector<String> params){ String out = ""; ! if(params.size()==3){ ! try { ! int iacl = Integer.parseInt(params.get(1)); ! if(iacl>=1 && iacl<=2699){ ! if(params.get(2).equalsIgnoreCase("in")){ ! device.getNetworkInterface(params.get(0)).setACLin(0); ! } ! else if(params.get(2).equalsIgnoreCase("out")){ ! device.getNetworkInterface(params.get(0)).setACLout(0); } else{ ! out += "error: invalid ACL direction '"+params.get(2)+"'\n"; } ! } ! else{ out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; } ! } catch (NumberFormatException ex) { ! out += "error: invalid ACL name '"+params.get(1)+"', ACL name must be number from 1 to 2699\n"; ! } catch (InvalidNetworkInterfaceNameException ex) { ! out += "error: invalid inferface\n"; } } else{ ! out += "error: invalid parameters\n"; ! } return out; } *************** *** 1048,1052 **** modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<1-99> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>) [log]"; ! no_call_params = "<1-99> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>) [log]"; } public String call(Vector<String> params){ --- 1032,1036 ---- modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<1-99> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>) [log]"; ! no_call_params = "<1-99> (<line>|[<line>] (permit|deny) (any|host <ip>|<ip> <mask>) [log])"; } public String call(Vector<String> params){ *************** *** 1065,1127 **** try{ iline = Integer.parseInt(params.get(index)); ! index = 2; } catch(NumberFormatException e){ } ! String permit_deny = params.get(index); ! short action=-1; ! if(permit_deny.equalsIgnoreCase("permit")){ ! action = AccessListEngine.access_list.PERMIT; ! } ! else if(permit_deny.equalsIgnoreCase("deny")){ ! action = AccessListEngine.access_list.DENY; ! } ! ! if(action>-1){ ! index+=1; ! String ip; ! String mask; ! String hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip = "0.0.0.0"; ! mask = "0.0.0.0"; ! index+=1; ! } ! else if(hosts.equals("host")){ ! ip = params.get(index+1); ! mask = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip = hosts; ! mask = params.get(index+1); ! index+=2; ! } ! ! boolean log = false; ! if(params.size()>index){ ! if(params.get(index).equalsIgnoreCase("log")) ! log = true; ! } ! //device.getConfig().add("ip access-list "+iacl+" "+permit_deny+" "+hosts); ! if(IPV4Address.validateDecIP(ip) && IPV4Address.validateDecSubnetMask(mask, ip)){ ! if(add){ ! device.getACL().addACL(iacl, iline, action, ip, mask, log); ! } ! else{ ! if(iline==-1){ ! device.getACL().removeACL(iacl, action, ip, mask); ! } ! else{ ! device.getACL().removeACL(iacl, iline); ! } ! } ! } ! else{ ! out += "error: invalid IP address or subnet mask\n"; ! } } else{ ! out += "error: invalid parameter: '"+permit_deny+"'\n"; ! } } else{ --- 1049,1116 ---- try{ iline = Integer.parseInt(params.get(index)); ! index++; } catch(NumberFormatException e){ } ! if(iline>0 && !add){ ! device.getACL().removeACL(iacl, iline); } else{ ! String permit_deny = params.get(index); ! short action=-1; ! if(permit_deny.equalsIgnoreCase("permit")){ ! action = AccessListEngine.access_list.PERMIT; ! } ! else if(permit_deny.equalsIgnoreCase("deny")){ ! action = AccessListEngine.access_list.DENY; ! } ! ! if(action>-1){ ! index+=1; ! String ip; ! String mask; ! String hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip = "0.0.0.0"; ! mask = "0.0.0.0"; ! index+=1; ! } ! else if(hosts.equals("host")){ ! ip = params.get(index+1); ! mask = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip = hosts; ! mask = params.get(index+1); ! index+=2; ! } ! ! boolean log = false; ! if(params.size()>index){ ! if(params.get(index).equalsIgnoreCase("log")) ! log = true; ! } ! //device.getConfig().add("ip access-list "+iacl+" "+permit_deny+" "+hosts); ! if((IPV4Address.validateDecIP(ip) || ip.compareTo("0.0.0.0")==0) && IPV4Address.validateDecSubnetMask(mask, ip)){ ! if(add){ ! device.getACL().addACL(iacl, iline, action, ip, mask, log); ! } ! else{ ! if(iline==-1){ ! device.getACL().removeACL(iacl, action, ip, mask); ! } ! else{ ! device.getACL().removeACL(iacl, iline); ! } ! } ! } ! else{ ! out += "error: invalid IP address or subnet mask\n"; ! } ! } ! else{ ! out += "error: invalid parameter: '"+permit_deny+"'\n"; ! } ! } } else{ *************** *** 1143,1147 **** //call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>]"; call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [eq <port>] [log]"; ! no_call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [eq <port>] [log]"; } public String call(Vector<String> params){ --- 1132,1136 ---- //call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>]"; call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [eq <port>] [log]"; ! no_call_params = "<100-2699> (<line>|[<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [eq <port>] [log])"; } public String call(Vector<String> params){ *************** *** 1160,1294 **** try{ iline = Integer.parseInt(params.get(index)); ! index = 2; } catch(NumberFormatException e){ } ! String permit_deny = params.get(index); ! short action=-1; ! if(permit_deny.equalsIgnoreCase("permit")){ ! action = AccessListEngine.access_list.PERMIT; ! } ! else if(permit_deny.equalsIgnoreCase("deny")){ ! action = AccessListEngine.access_list.DENY; ! } ! ! if(action>-1){ ! int protocol = -1; ! index++; ! String sprotocol = params.get(index); ! if(sprotocol.equalsIgnoreCase("ip")){ ! protocol = AccessListEngine.access_list.IP; ! } ! else if(sprotocol.equalsIgnoreCase("tcp")){ ! protocol = AccessListEngine.access_list.TCP; ! } ! else if(sprotocol.equalsIgnoreCase("udp")){ ! protocol = AccessListEngine.access_list.UDP; ! } ! else if(sprotocol.equalsIgnoreCase("icmp")){ ! protocol = AccessListEngine.access_list.ICMP; ! } ! if(protocol>-1){ ! ! String ip1; ! String mask1; ! String ip2; ! String mask2; ! index++; ! String hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip1 = "0.0.0.0"; ! mask1 = "0.0.0.0"; ! index++; ! } ! else if(hosts.equals("host")){ ! ip1 = params.get(index+1); ! mask1 = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip1 = hosts; ! mask1 = params.get(index+1); ! index+=2; ! } ! ! hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip2 = "0.0.0.0"; ! mask2 = "0.0.0.0"; ! index++; ! } ! else if(hosts.equals("host")){ ! ip2 = params.get(index+1); ! mask2 = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip2 = hosts; ! mask2 = params.get(index+1); ! index+=2; ! } ! ! int port = 0; ! boolean log = false; ! if(params.size()>index){ ! if(params.get(index).equalsIgnoreCase("eq")){ ! try{ ! port = Integer.parseInt(params.get(index+1)); ! index += 2; ! } ! catch(NumberFormatException e){ ! out += "error: invalid parameter port = '"+params.get(index+1)+"'\n"; ! port = -1; ! } ! } ! else if(params.get(index).equalsIgnoreCase("log")){ ! log = true; ! index += 1; ! } ! else{ ! out += "error: invalid parameter: '"+params.get(index)+"'\n"; ! port = -1; ! } ! } ! ! if(!log && params.size()>index){ ! if(params.get(index).equalsIgnoreCase("log")) ! log = true; ! } ! ! //device.getConfig().add("ip access-list "+iacl+" "+permit_deny+" "+hosts); ! if(port >= 0){ ! if(IPV4Address.validateDecIP(ip1) && IPV4Address.validateDecSubnetMask(mask1, ip1) && ! IPV4Address.validateDecIP(ip2) && IPV4Address.validateDecSubnetMask(mask2, ip2)){ ! if(port==0 || (protocol == AccessListEngine.access_list.TCP || protocol == AccessListEngine.access_list.UDP)){ ! if(add){ ! device.getACL().addACL(iacl, iline, action, protocol, ip1, mask1, ip2, mask2, port, log); ! } ! else{ ! if(iline==-1){ ! device.getACL().removeACL(iacl, action, protocol, ip1, mask1, ip2, mask2, port); ! } ! else{ ! device.getACL().removeACL(iacl, iline); ! } ! } ! } ! else{ ! out += "error: invalid parameter 'eq "+port+"'\n"; ! port = -1; ! } ! } ! else{ ! out += "error: invalid IP address or subnet mask\n"; ! } ! } ! } ! else{ ! out += "error: invalid protocol: '"+sprotocol+"'\n"; ! } } else{ ! out += "error: invalid action: '"+permit_deny+"'\n"; ! } } else{ --- 1149,1288 ---- try{ iline = Integer.parseInt(params.get(index)); ! index++; } catch(NumberFormatException e){ } ! if(iline>0 && !add){ ! device.getACL().removeACL(iacl, iline); } else{ ! String permit_deny = params.get(index); ! short action=-1; ! if(permit_deny.equalsIgnoreCase("permit")){ ! action = AccessListEngine.access_list.PERMIT; ! } ! else if(permit_deny.equalsIgnoreCase("deny")){ ! action = AccessListEngine.access_list.DENY; ! } ! ! if(action>-1){ ! int protocol = -1; ! index++; ! String sprotocol = params.get(index); ! if(sprotocol.equalsIgnoreCase("ip")){ ! protocol = AccessListEngine.access_list.IP; ! } ! else if(sprotocol.equalsIgnoreCase("tcp")){ ! protocol = AccessListEngine.access_list.TCP; ! } ! else if(sprotocol.equalsIgnoreCase("udp")){ ! protocol = AccessListEngine.access_list.UDP; ! } ! else if(sprotocol.equalsIgnoreCase("icmp")){ ! protocol = AccessListEngine.access_list.ICMP; ! } ! if(protocol>-1){ ! ! String ip1; ! String mask1; ! String ip2; ! String mask2; ! index++; ! String hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip1 = "0.0.0.0"; ! mask1 = "0.0.0.0"; ! index++; ! } ! else if(hosts.equals("host")){ ! ip1 = params.get(index+1); ! mask1 = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip1 = hosts; ! mask1 = params.get(index+1); ! index+=2; ! } ! ! hosts = params.get(index); ! if(hosts.equalsIgnoreCase("any")){ ! ip2 = "0.0.0.0"; ! mask2 = "0.0.0.0"; ! index++; ! } ! else if(hosts.equals("host")){ ! ip2 = params.get(index+1); ! mask2 = "255.255.255.255"; ! index+=2; ! } ! else{ ! ip2 = hosts; ! mask2 = params.get(index+1); ! index+=2; ! } ! ! int port = 0; ! boolean log = false; ! if(params.size()>index){ ! if(params.get(index).equalsIgnoreCase("eq")){ ! try{ ! port = Integer.parseInt(params.get(index+1)); ! index += 2; ! } ! catch(NumberFormatException e){ ! out += "error: invalid parameter port = '"+params.get(index+1)+"'\n"; ! port = -1; ! } ! } ! else if(params.get(index).equalsIgnoreCase("log")){ ! log = true; ! index += 1; ! } ! else{ ! out += "error: invalid parameter: '"+params.get(index)+"'\n"; ! port = -1; ! } ! } ! ! if(!log && params.size()>index){ ! if(params.get(index).equalsIgnoreCase("log")) ! log = true; ! } ! ! //device.getConfig().add("ip access-list "+iacl+" "+permit_deny+" "+hosts); ! if(port >= 0){ ! if((IPV4Address.validateDecIP(ip1) || ip1.compareTo("0.0.0.0")==0) && IPV4Address.validateDecSubnetMask(mask1, ip1) && ! (IPV4Address.validateDecIP(ip2) || ip2.compareTo("0.0.0.0")==0) && IPV4Address.validateDecSubnetMask(mask2, ip2)){ ! if(port==0 || (protocol == AccessListEngine.access_list.TCP || protocol == AccessListEngine.access_list.UDP)){ ! if(add){ ! device.getACL().addACL(iacl, iline, action, protocol, ip1, mask1, ip2, mask2, port, log); ! } ! else{ ! if(iline==-1){ ! device.getACL().removeACL(iacl, action, protocol, ip1, mask1, ip2, mask2, port); ! } ! else{ ! device.getACL().removeACL(iacl, iline); ! } ! } ! } ! else{ ! out += "error: invalid parameter 'eq "+port+"'\n"; ! port = -1; ! } ! } ! else{ ! out += "error: invalid IP address or subnet mask\n"; ! } ! } ! } ! else{ ! out += "error: invalid protocol: '"+sprotocol+"'\n"; ! } ! } ! else{ ! out += "error: invalid action: '"+permit_deny+"'\n"; ! } ! } } else{ Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DeviceConfig.java 20 Nov 2007 19:53:03 -0000 1.10 --- DeviceConfig.java 14 Sep 2008 20:51:29 -0000 1.11 *************** *** 69,74 **** //running_config.add(nextcmd); } ! clearStartupConfig(); ! writeMemory(); } --- 69,74 ---- //running_config.add(nextcmd); } ! // clearStartupConfig(); ! // writeMemory(); } *************** *** 120,124 **** boolean result = false; if(startup_config.isEmpty()){ ! Iterator<String> it = prepareConfig(running_config, false).iterator(); while(it.hasNext()){ startup_config.add(it.next()); --- 120,124 ---- boolean result = false; if(startup_config.isEmpty()){ ! Iterator<String> it = prepareConfig(running_config, true).iterator(); while(it.hasNext()){ startup_config.add(it.next()); *************** *** 451,455 **** for(int i=0;i<ArpTable.size();i++) { ! conf.add("arp "+ArpTable.get(i).get(0)+" "+ArpTable.get(i).get(1)); } } --- 451,456 ---- for(int i=0;i<ArpTable.size();i++) { ! if(ArpTable.get(i).get(2).compareTo("Static")==0) ! conf.add("arp "+ArpTable.get(i).get(0)+" "+ArpTable.get(i).get(1)); } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Simulation.java 9 Sep 2008 09:16:10 -0000 1.27 --- Simulation.java 14 Sep 2008 20:51:29 -0000 1.28 *************** *** 348,354 **** NetworkLayerDevice nld = (NetworkLayerDevice)temp; //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); ! // nld.getConfig().remove("interface "+inInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! // nld.getConfig().add("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask, DeviceConfig.STARTUP_CONFIG); } else --- 348,353 ---- NetworkLayerDevice nld = (NetworkLayerDevice)temp; //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); ! nld.getConfig().executeCommand("write mem"); } else *************** *** 387,394 **** NetworkLayerDevice t = (NetworkLayerDevice)temp; //t.setDefaultGateway(inGatewayIPAddress); ! t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); ! // t.getConfig().remove("^ip route 0.0.0.0 0.0.0.0 ", DeviceConfig.STARTUP_CONFIG); ! // t.getConfig().add("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0", DeviceConfig.STARTUP_CONFIG); ! //t.getConfig().executeCommand("ip route default 0.0.0.0 "+inGatewayIPAddress+" eth0"); } else --- 386,391 ---- NetworkLayerDevice t = (NetworkLayerDevice)temp; //t.setDefaultGateway(inGatewayIPAddress); ! t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); ! t.getConfig().executeCommand("write mem"); } else *************** *** 469,477 **** if (temp instanceof NetworkLayerDevice){ //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! //t.setIPAddress(inNodeInterface,inIPAddress); ! t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); ! // t.getConfig().remove("^interface "+inNodeInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! // t.getConfig().add("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface), DeviceConfig.STARTUP_CONFIG); ! macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); //t.addToARP(inIPAddress, macAddress); --- 466,473 ---- if (temp instanceof NetworkLayerDevice){ //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! //t.setIPAddress(inNodeInterface,inIPAddress); ! t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); ! t.getConfig().executeCommand("write mem"); ! macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); //t.addToARP(inIPAddress, macAddress); *************** *** 556,562 **** NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; //tempNet.addToARPStatic(inIPAddress, inMACAddress); ! tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); ! // tempNet.getConfig().remove("^arp "+inIPAddress+" ", DeviceConfig.STARTUP_CONFIG); ! // tempNet.getConfig().add("arp "+inIPAddress+" "+inMACAddress, DeviceConfig.STARTUP_CONFIG); } --- 552,557 ---- NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; //tempNet.addToARPStatic(inIPAddress, inMACAddress); ! tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); ! tempNet.getConfig().executeCommand("write mem"); } *************** *** 578,583 **** NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; //tempNet.removeARP(inIPAddress); ! tempNet.getConfig().executeCommand("no arp "+inIPAddress); ! // tempNet.getConfig().add("no arp "+inIPAddress, DeviceConfig.STARTUP_CONFIG); } --- 573,578 ---- NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; //tempNet.removeARP(inIPAddress); ! tempNet.getConfig().executeCommand("no arp "+inIPAddress); ! tempNet.getConfig().executeCommand("write mem"); } Index: AccessListEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/AccessListEngine.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AccessListEngine.java 17 Nov 2007 21:38:57 -0000 1.3 --- AccessListEngine.java 14 Sep 2008 20:51:29 -0000 1.4 *************** *** 3,6 **** --- 3,8 ---- import java.util.Enumeration; import java.util.Hashtable; + + import core.protocolsuite.tcp_ip.ICMP_packet; import core.protocolsuite.tcp_ip.IPV4Address; import core.protocolsuite.tcp_ip.IP_packet; *************** *** 194,197 **** --- 196,202 ---- port2 = ((UDP_packet)ippacket).get_destPort(); } + else if(ippacket instanceof ICMP_packet){ + protocol = AccessListEngine.access_list.ICMP; + } String binIP1 = IPV4Address.toBinaryString(IP1); String binNetwork1 = ""; *************** *** 250,253 **** --- 255,263 ---- } + public void clear(){ + ACLs.clear(); + + } + protected void printLayerInfo(String s) { LayerInfo protInfo = new LayerInfo(getClass().getName()); |