[Javanetsim-cvs] javaNetSim/core CommandProcessor.java, 1.29, 1.30 DeviceConfig.java, 1.23, 1.24 Pr
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-22 16:16:07
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21408/core Modified Files: CommandProcessor.java DeviceConfig.java Printer.java Log Message: some little bugs was trapped Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** CommandProcessor.java 20 Oct 2008 23:46:56 -0000 1.29 --- CommandProcessor.java 22 Oct 2008 16:15:30 -0000 1.30 *************** *** 21,24 **** --- 21,25 ---- import core.protocolsuite.tcp_ip.SNMP; import core.protocolsuite.tcp_ip.TCP_session; + import core.protocolsuite.tcp_ip.Tcp; import core.protocolsuite.tcp_ip.Telnet_server; import core.protocolsuite.tcp_ip.UDP_session; *************** *** 1264,1270 **** if(params.size()==1){ try { ! if(device.getNetworkInterface(params.get(0))!=null){ ! dhcpc.StartDHCPC(params.get(0), "169.254.0.1"); ! } } catch (InvalidNetworkInterfaceNameException ex) { out += "Invalid interface name\n"; --- 1265,1270 ---- if(params.size()==1){ try { ! device.getNetworkInterface(params.get(0)); ! dhcpc.StartDHCPC(params.get(0), "169.254.0.1"); } catch (InvalidNetworkInterfaceNameException ex) { out += "Invalid interface name\n"; *************** *** 1527,1531 **** class interface__switchport_access_vlan_CommandClass extends CommandInterface{ public interface__switchport_access_vlan_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<vlanid>"; no_call_params = "<cr>"; --- 1527,1531 ---- class interface__switchport_access_vlan_CommandClass extends CommandInterface{ public interface__switchport_access_vlan_CommandClass(){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<vlanid>"; no_call_params = "<cr>"; *************** *** 1579,1583 **** class interface__switchport_mode_access_CommandClass extends CommandInterface{ public interface__switchport_mode_access_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } --- 1579,1583 ---- class interface__switchport_mode_access_CommandClass extends CommandInterface{ public interface__switchport_mode_access_CommandClass(){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } *************** *** 1612,1616 **** class interface__switchport_mode_trunk_CommandClass extends CommandInterface{ public interface__switchport_mode_trunk_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } --- 1612,1616 ---- class interface__switchport_mode_trunk_CommandClass extends CommandInterface{ public interface__switchport_mode_trunk_CommandClass(){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } *************** *** 2941,2945 **** if(params.size()==0){ try{ ! device.NodeProtocolStack.TCP().setWindowSize(10); out += "TCP window size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; } --- 2941,2945 ---- if(params.size()==0){ try{ ! device.NodeProtocolStack.TCP().setWindowSize(Tcp.DEFAULT_WINDOW_SIZE); out += "TCP window size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; } Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** DeviceConfig.java 20 Oct 2008 23:46:56 -0000 1.23 --- DeviceConfig.java 22 Oct 2008 16:15:30 -0000 1.24 *************** *** 27,30 **** --- 27,31 ---- import core.protocolsuite.tcp_ip.Route_entry; import core.protocolsuite.tcp_ip.SNMP; + import core.protocolsuite.tcp_ip.Tcp; import core.protocolsuite.tcp_ip.Telnet_server; *************** *** 43,48 **** private NetworkLayerDevice device; private CommandProcessor cmdproc; ! private LinkedList running_config = new LinkedList(); ! private LinkedList startup_config = new LinkedList(); Modes mode; --- 44,49 ---- private NetworkLayerDevice device; private CommandProcessor cmdproc; ! private LinkedList<String> running_config = new LinkedList<String>(); ! private LinkedList<String> startup_config = new LinkedList<String>(); Modes mode; *************** *** 77,82 **** } ! public LinkedList getConfig(int config_name){ ! LinkedList config = null; switch(config_name){ case RUNNING_CONFIG: config = prepareConfig(running_config, true); break; --- 78,83 ---- } ! public LinkedList<String> getConfig(int config_name){ ! LinkedList<String> config = null; switch(config_name){ case RUNNING_CONFIG: config = prepareConfig(running_config, true); break; *************** *** 96,101 **** } ! protected LinkedList getRealConfig(int config_name){ ! LinkedList config = null; switch(config_name){ case RUNNING_CONFIG: config = running_config; break; --- 97,102 ---- } ! protected LinkedList<String> getRealConfig(int config_name){ ! LinkedList<String> config = null; switch(config_name){ case RUNNING_CONFIG: config = running_config; break; *************** *** 155,159 **** public boolean addBefore(String command, int config_name, String beforeCommand){ boolean result = false; ! LinkedList config = getRealConfig(config_name); boolean found = false; int index = -1; --- 156,160 ---- public boolean addBefore(String command, int config_name, String beforeCommand){ boolean result = false; ! LinkedList<String> config = getRealConfig(config_name); boolean found = false; int index = -1; *************** *** 199,203 **** try{ Pattern p = Pattern.compile(command); ! LinkedList config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext()){ --- 200,204 ---- try{ Pattern p = Pattern.compile(command); ! LinkedList<String> config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext()){ *************** *** 226,230 **** try{ Pattern p = Pattern.compile(command); ! LinkedList config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ --- 227,231 ---- try{ Pattern p = Pattern.compile(command); ! LinkedList<String> config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ *************** *** 263,269 **** } ! private LinkedList prepareConfig(LinkedList in, boolean fullConfig){ ! LinkedList out = new LinkedList(); ! Iterator it = in.iterator(); while(it.hasNext()){ String nc = (String)it.next(); --- 264,270 ---- } ! private LinkedList<String> prepareConfig(LinkedList<String> in, boolean fullConfig){ ! LinkedList<String> out = new LinkedList<String>(); ! Iterator<String> it = in.iterator(); while(it.hasNext()){ String nc = (String)it.next(); *************** *** 311,315 **** } ! protected void fillConfigACLS(LinkedList conf){ final int ERROR = 0; final int STANDART = 1; --- 312,316 ---- } ! protected void fillConfigACLS(LinkedList<String> conf){ final int ERROR = 0; final int STANDART = 1; *************** *** 322,326 **** Hashtable acl = (Hashtable)acls.get((Integer)aclkeys.nextElement()); ! Enumeration rulekeys = acl.keys(); while(rulekeys.hasMoreElements()){ access_list rule = (access_list)acl.get((Integer)rulekeys.nextElement()); --- 323,327 ---- Hashtable acl = (Hashtable)acls.get((Integer)aclkeys.nextElement()); ! Enumeration<Integer> rulekeys = acl.keys(); while(rulekeys.hasMoreElements()){ access_list rule = (access_list)acl.get((Integer)rulekeys.nextElement()); *************** *** 338,345 **** String permit_deny = "unsupported_action"; ! if(rule.action==rule.DENY){ permit_deny = "deny "; } ! else if(rule.action==rule.PERMIT){ permit_deny = "permit"; } --- 339,346 ---- String permit_deny = "unsupported_action"; ! if(rule.action==access_list.DENY){ permit_deny = "deny "; } ! else if(rule.action==access_list.PERMIT){ permit_deny = "permit"; } *************** *** 370,383 **** String protocol = "unsupported_protocol"; ! if(rule.protocol==rule.IP){ protocol = "ip "; } ! else if(rule.protocol==rule.TCP){ protocol = "tcp "; } ! else if(rule.protocol==rule.UDP){ protocol = "udp "; } ! else if(rule.protocol==rule.ICMP){ protocol = "icmp"; } --- 371,384 ---- String protocol = "unsupported_protocol"; ! if(rule.protocol==access_list.IP){ protocol = "ip "; } ! else if(rule.protocol==access_list.TCP){ protocol = "tcp "; } ! else if(rule.protocol==access_list.UDP){ protocol = "udp "; } ! else if(rule.protocol==access_list.ICMP){ protocol = "icmp"; } *************** *** 406,410 **** } ! protected void fillInterfaces(LinkedList conf){ if(device instanceof NetworkLayerDevice){ Object[] ins = device.getAllInterfaces(); --- 407,411 ---- } ! protected void fillInterfaces(LinkedList<String> conf){ if(device instanceof NetworkLayerDevice){ Object[] ins = device.getAllInterfaces(); *************** *** 437,441 **** if((eni!=null || sni!=null || wfi!=null) && device.getIPAddress((String)ins[i])!=null && !device.getIPAddress((String)ins[i]).equals("") && ni.isActive()) conf.add("interface "+intName+" ip address "+device.getIPAddress((String)ins[i])+" "+device.getSubnetMask((String)ins[i])); ! if(sni!=null && sni.getClockRate()!=sni.DEFAULT_CLOCKRATE) conf.add("interface "+intName+" clock-rate "+sni.getClockRate()); if(wfi!=null){ --- 438,442 ---- if((eni!=null || sni!=null || wfi!=null) && device.getIPAddress((String)ins[i])!=null && !device.getIPAddress((String)ins[i]).equals("") && ni.isActive()) conf.add("interface "+intName+" ip address "+device.getIPAddress((String)ins[i])+" "+device.getSubnetMask((String)ins[i])); ! if(sni!=null && sni.getClockRate()!=SerialNetworkInterface.DEFAULT_CLOCKRATE) conf.add("interface "+intName+" clock-rate "+sni.getClockRate()); if(wfi!=null){ *************** *** 500,504 **** if(device instanceof ApplicationLayerDevice){ DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); ! if(dhcpc!=null && dhcpc.running){ conf.add("interface "+intName+" ip dhcp client"); } --- 501,505 ---- if(device instanceof ApplicationLayerDevice){ DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); ! if(dhcpc!=null && dhcpc.running && dhcpc.getInterface().equalsIgnoreCase(intName)){ conf.add("interface "+intName+" ip dhcp client"); } *************** *** 512,516 **** } ! protected void fillARP(LinkedList conf){ if(device instanceof NetworkLayerDevice){ Vector<Vector<String>> ArpTable = device.getARPTable(); --- 513,517 ---- } ! protected void fillARP(LinkedList<String> conf){ if(device instanceof NetworkLayerDevice){ Vector<Vector<String>> ArpTable = device.getARPTable(); *************** *** 525,529 **** } ! protected void fillCommon(LinkedList conf){ conf.add("hostname "+device.getName()); if(device.location!=null && !device.location.equals("")) --- 526,530 ---- } ! protected void fillCommon(LinkedList<String> conf){ conf.add("hostname "+device.getName()); if(device.location!=null && !device.location.equals("")) *************** *** 531,538 **** } ! ! ! ! protected void fillIP(LinkedList conf){ if(device instanceof NetworkLayerDevice){ NetworkLayerDevice ndev = (NetworkLayerDevice)device; --- 532,536 ---- } ! protected void fillIP(LinkedList<String> conf){ if(device instanceof NetworkLayerDevice){ NetworkLayerDevice ndev = (NetworkLayerDevice)device; *************** *** 576,582 **** String poolname = pools.nextElement(); DHCPD.pool pool = (DHCPD.pool) dhcpd.pools.get(poolname); ! conf.add("ip dhcp pool "+poolname+" default-router "+pool.Gateway); ! conf.add("ip dhcp pool "+poolname+" network "+pool.IP+" "+pool.Genmask); ! conf.add("ip dhcp pool "+poolname+" hardware-address "+pool.MAC); } Vector<Pair> exclude = dhcpd.getExcludeAddresses(); --- 574,583 ---- String poolname = pools.nextElement(); DHCPD.pool pool = (DHCPD.pool) dhcpd.pools.get(poolname); ! if(pool.Gateway!="") ! conf.add("ip dhcp pool "+poolname+" default-router "+pool.Gateway); ! if(pool.Genmask!="") ! conf.add("ip dhcp pool "+poolname+" network "+pool.IP+" "+pool.Genmask); ! if(pool.MAC!="") ! conf.add("ip dhcp pool "+poolname+" hardware-address "+pool.MAC); } Vector<Pair> exclude = dhcpd.getExcludeAddresses(); *************** *** 586,594 **** } } ! conf.add("ip tcp window-size "+device.NodeProtocolStack.TCP().getWindowSize()); } } ! protected void fillExtended(LinkedList conf){ conf.add("clock set "+device.getClock()); --- 587,596 ---- } } ! if(device.NodeProtocolStack.TCP().getWindowSize() != Tcp.DEFAULT_WINDOW_SIZE) ! conf.add("ip tcp window-size "+device.NodeProtocolStack.TCP().getWindowSize()); } } ! protected void fillExtended(LinkedList<String> conf){ conf.add("clock set "+device.getClock()); *************** *** 598,602 **** SNMP snmpa = (SNMP) appdevice.getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null && snmpa.running){ ! if(snmpa.getPort()!=snmpa.DEFAULT_PORT){ conf.add("snmp-server port "+snmpa.getPort()); } --- 600,604 ---- SNMP snmpa = (SNMP) appdevice.getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null && snmpa.running){ ! if(snmpa.getPort()!=SNMP.DEFAULT_PORT){ conf.add("snmp-server port "+snmpa.getPort()); } *************** *** 689,693 **** } ! protected void fillRoute(LinkedList conf){ if(device instanceof NetworkLayerDevice){ String routes[] = device.getRouteTableEntries(); --- 691,695 ---- } ! protected void fillRoute(LinkedList<String> conf){ if(device instanceof NetworkLayerDevice){ String routes[] = device.getRouteTableEntries(); Index: Printer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Printer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Printer.java 6 Oct 2008 13:20:39 -0000 1.4 --- Printer.java 22 Oct 2008 16:15:30 -0000 1.5 *************** *** 31,37 **** DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.Simulation.UIDGen++); - addApp(snmpAgent, SNMP_AGENT_ID); addApp(dhcpc, DHCP_CLIENT_ID); } --- 31,40 ---- DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.Simulation.UIDGen++); addApp(snmpAgent, SNMP_AGENT_ID); addApp(dhcpc, DHCP_CLIENT_ID); + + getConfig().executeCommand("no interface eth0 shutdown"); + getConfig().executeCommand("interface eth0 ip dhcp client"); + getConfig().executeCommand("write memory"); } |