[Javanetsim-cvs] javaNetSim/core CommandProcessor.java, 1.30, 1.31 MultilayerSwitch.java, 1.7, 1.8
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-22 22:16:38
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10964/core Modified Files: CommandProcessor.java MultilayerSwitch.java NetworkInterface.java NetworkLayerDevice.java Log Message: cosmetic changes Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** NetworkLayerDevice.java 22 Oct 2008 20:26:03 -0000 1.28 --- NetworkLayerDevice.java 22 Oct 2008 21:33:00 -0000 1.29 *************** *** 54,57 **** --- 54,58 ---- private AccessListEngine acls = new AccessListEngine(this); private NATEngine nat = new NATEngine(this); + Hashtable<Integer, String> Vlans; *************** *** 66,75 **** public NetworkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { super(inName, inProtocolStackLayers, inOn); ! //set default startup-config ! config.working_config = DeviceConfig.STARTUP_CONFIG; ! //config.add("ip telnet 21"); ! //end set default startup-config ! config.working_config = DeviceConfig.RUNNING_CONFIG; ! config.load(); } --- 67,78 ---- public NetworkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { super(inName, inProtocolStackLayers, inOn); ! //set default startup-config ! config.working_config = DeviceConfig.STARTUP_CONFIG; ! //config.add("ip telnet 21"); ! //end set default startup-config ! config.working_config = DeviceConfig.RUNNING_CONFIG; ! config.load(); ! ! Vlans = new Hashtable<Integer, String>(); } *************** *** 521,523 **** --- 524,599 ---- } + + public Enumeration<Integer> getVlans(){ + return Vlans.keys(); + } + + public void addVlan(int v, String name){ + Vlans.put(v, name); + } + + public void removeVlan(int v){ + Vlans.remove(v); + } + + public void clearVlan(){ + Vlans.clear(); + } + + public String getVlanName(int v){ + if(Vlans.containsKey(v)){ + return Vlans.get(v); + } + else if(v == 1){ + return "default"; + } + return null; + } + + public void setVlanName(int v, String name){ + Vlans.remove(v); + Vlans.put(v, name); + } + + public String getAllData(){ + String file = ""; + file += "vlan.dat\n"; + file += "1\n"; + + Enumeration<Integer> it; + Integer v; + + it = Vlans.keys(); + + while (it.hasMoreElements()) { + v = it.nextElement(); + + file = file + v + "," + Vlans.get(v) + "|"; + } + + file += "\n"; + + return file; + } + + public void loadDataFile(String name, int lines, String Data){ + + if(name.equals("vlan.dat")){ + Vlans.clear(); + + String[] vlans = Data.split("\\|"); + + for(int i = 0; i<vlans.length; i++){ + if(vlans[i].length() > 1){ + String[] vlan = vlans[i].split(","); + if(vlan.length>1) + Vlans.put(Integer.valueOf(vlan[0]), vlan[1]); + else + Vlans.put(Integer.valueOf(vlan[0]), ""); + } + } + } + + return; + } }//EOF Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** CommandProcessor.java 22 Oct 2008 16:15:30 -0000 1.30 --- CommandProcessor.java 22 Oct 2008 21:32:59 -0000 1.31 *************** *** 173,177 **** commands.add("interface * description", interface__description_Command, "Interface specific description"); commands.addDescription("interface * encryption","Configure encryption"); ! commands.add("interface * encryption key", interface__encryption_key_Command, "Specify clock-rate"); commands.addDescription("interface * ip","Configure Internet Protocol"); commands.add("interface * ip address", interface__ip_address_Command, "Set the IP address of an interface"); --- 173,177 ---- commands.add("interface * description", interface__description_Command, "Interface specific description"); commands.addDescription("interface * encryption","Configure encryption"); ! commands.add("interface * encryption key", interface__encryption_key_Command, "Configure encryption key"); commands.addDescription("interface * ip","Configure Internet Protocol"); commands.add("interface * ip address", interface__ip_address_Command, "Set the IP address of an interface"); *************** *** 445,452 **** public String call(Vector<String> params){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if(params.size()==0){ ! msdev.clearVlan(); } else{ --- 445,452 ---- public String call(Vector<String> params){ String out = ""; ! if(device instanceof NetworkLayerDevice){ ! NetworkLayerDevice ndev = (NetworkLayerDevice) device; if(params.size()==0){ ! ndev.clearVlan(); } else{ *************** *** 1539,1544 **** private String parse(Vector<String> params, boolean add){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if((params.size()==2 && add) || (params.size()==1 && !add)){ try{ --- 1539,1543 ---- private String parse(Vector<String> params, boolean add){ String out = ""; ! if(device instanceof NetworkLayerDevice){ if((params.size()==2 && add) || (params.size()==1 && !add)){ try{ *************** *** 1584,1589 **** public String call(Vector<String> params){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if(params.size()==1){ try{ --- 1583,1587 ---- public String call(Vector<String> params){ String out = ""; ! if(device instanceof NetworkLayerDevice){ if(params.size()==1){ try{ *************** *** 1617,1622 **** public String call(Vector<String> params){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if(params.size()==1){ try{ --- 1615,1619 ---- public String call(Vector<String> params){ String out = ""; ! if(device instanceof NetworkLayerDevice){ if(params.size()==1){ try{ *************** *** 2211,2215 **** public ip_dns_primary_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "<DNS domain name> soa <DNS primary name server> <DNS mailbox of responsible person> <Refresh time> <Refresh retry time> <Authority expire time> <Minimum TTL for zone info>"; no_call_params = "<cr>"; } --- 2208,2214 ---- public ip_dns_primary_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "<DNS domain name> soa <DNS primary name server>\n"+ ! " <DNS mailbox of responsible person> <Refresh time>\n"+ ! " <Refresh retry time> <Authority expire time> <Minimum TTL for zone info>"; no_call_params = "<cr>"; } *************** *** 3873,3883 **** public String call(Vector<String> params){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if(params.size()==0){ Hashtable<Integer, Vector<String>> vlanport = new Hashtable<Integer, Vector<String>>(); TreeSet<Integer> vlans = new TreeSet<Integer>(); vlans.add(1); ! Enumeration<Integer> keys = msdev.getVlans(); while(keys.hasMoreElements()){ vlans.add(keys.nextElement()); --- 3872,3882 ---- public String call(Vector<String> params){ String out = ""; ! if(device instanceof NetworkLayerDevice){ ! NetworkLayerDevice ndev = (NetworkLayerDevice) device; if(params.size()==0){ Hashtable<Integer, Vector<String>> vlanport = new Hashtable<Integer, Vector<String>>(); TreeSet<Integer> vlans = new TreeSet<Integer>(); vlans.add(1); ! Enumeration<Integer> keys = ndev.getVlans(); while(keys.hasMoreElements()){ vlans.add(keys.nextElement()); *************** *** 3907,3911 **** while(vlansi.hasNext()){ int vlanid = vlansi.next(); ! String vlanname = msdev.getVlanName(vlanid); if(vlanname==null) vlanname = "(vlan not exists)"; String ports = ""; --- 3906,3910 ---- while(vlansi.hasNext()){ int vlanid = vlansi.next(); ! String vlanname = ndev.getVlanName(vlanid); if(vlanname==null) vlanname = "(vlan not exists)"; String ports = ""; *************** *** 3913,3917 **** Vector<String> ps = vlanport.get(vlanid); for(int i=0; i<ps.size(); i++){ ! ports += (i==0?"":",")+ps.get(i); } } --- 3912,3916 ---- Vector<String> ps = vlanport.get(vlanid); for(int i=0; i<ps.size(); i++){ ! ports += (i==0?"":",")+(i!=0 && i%5==0?"\n ":"")+ps.get(i); } } *************** *** 3919,3923 **** ports = "no ports found"; } ! out += vlanid+" "+String.format("%20s", vlanname)+" "+ports+"\n"; } } --- 3918,3922 ---- ports = "no ports found"; } ! out += String.format("%5d %20s", vlanid, vlanname)+" "+ports+"\n"; } } *************** *** 4195,4199 **** class vlan_CommandClass extends CommandInterface{ public vlan_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<vlanid> [<name>]"; no_call_params = "<vlanid> [<name>]"; --- 4194,4198 ---- class vlan_CommandClass extends CommandInterface{ public vlan_CommandClass(){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); call_params = "<vlanid> [<name>]"; no_call_params = "<vlanid> [<name>]"; *************** *** 4207,4212 **** private String parse(Vector<String> params, boolean add){ String out = ""; ! if(device instanceof MultilayerSwitch){ ! MultilayerSwitch msdev = (MultilayerSwitch) device; if(params.size()==1 || params.size()==2){ try{ --- 4206,4211 ---- private String parse(Vector<String> params, boolean add){ String out = ""; ! if(device instanceof NetworkLayerDevice){ ! NetworkLayerDevice ndev = (NetworkLayerDevice) device; if(params.size()==1 || params.size()==2){ try{ *************** *** 4220,4231 **** if(params.size()==2) name = params.get(1); if(add){ ! msdev.addVlan(vlanid, name); } else{ if(name.equals("")){ ! msdev.removeVlan(vlanid); } ! else if(msdev.getVlanName(vlanid).equals(name)){ ! msdev.removeVlan(vlanid); } } --- 4219,4230 ---- if(params.size()==2) name = params.get(1); if(add){ ! ndev.addVlan(vlanid, name); } else{ if(name.equals("")){ ! ndev.removeVlan(vlanid); } ! else if(ndev.getVlanName(vlanid).equals(name)){ ! ndev.removeVlan(vlanid); } } Index: MultilayerSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/MultilayerSwitch.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MultilayerSwitch.java 22 Oct 2008 21:22:55 -0000 1.7 --- MultilayerSwitch.java 22 Oct 2008 21:32:59 -0000 1.8 *************** *** 12,16 **** Hashtable<String, Hashtable<String, Long>> IntCaches; - Hashtable<Integer, String> Vlans; public MultilayerSwitch(String inName, boolean inOn) { --- 12,15 ---- *************** *** 19,97 **** IntCaches = new Hashtable<String, Hashtable<String, Long>>(); - Vlans = new Hashtable<Integer, String>(); - } - - public Enumeration<Integer> getVlans(){ - return Vlans.keys(); - } - - public void addVlan(int v, String name){ - Vlans.put(v, name); - } - - public void removeVlan(int v){ - Vlans.remove(v); - } - - public void clearVlan(){ - Vlans.clear(); - } - - public String getVlanName(int v){ - if(Vlans.containsKey(v)){ - return Vlans.get(v); - } - else if(v == 1){ - return "default"; - } - return null; } - - public void setVlanName(int v, String name){ - Vlans.remove(v); - Vlans.put(v, name); - } - - public String getAllData(){ - String file = ""; - file += "vlan.dat\n"; - file += "1\n"; - - Enumeration<Integer> it; - Integer v; - - it = Vlans.keys(); - - while (it.hasMoreElements()) { - v = it.nextElement(); - - file = file + v + "," + Vlans.get(v) + "|"; - } - - file += "\n"; - - return file; - } - - public void loadDataFile(String name, int lines, String Data){ - - if(name.equals("vlan.dat")){ - Vlans.clear(); - - String[] vlans = Data.split("\\|"); - - for(int i = 0; i<vlans.length; i++){ - if(vlans[i].length() > 1){ - String[] vlan = vlans[i].split(","); - if(vlan.length>1) - Vlans.put(Integer.valueOf(vlan[0]), vlan[1]); - else - Vlans.put(Integer.valueOf(vlan[0]), ""); - } - } - } - - return; - } --- 18,22 ---- Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** NetworkInterface.java 10 Oct 2008 22:18:05 -0000 1.19 --- NetworkInterface.java 22 Oct 2008 21:33:00 -0000 1.20 *************** *** 421,425 **** */ ! protected Link getConnectedLink() { return connectedLink; --- 421,425 ---- */ ! public Link getConnectedLink() { return connectedLink; |