[Javanetsim-cvs] javaNetSim/core CommandProcessor.java, 1.37, 1.38 DeviceConfig.java, 1.28, 1.29 Ne
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-27 21:22:17
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17633/core Modified Files: CommandProcessor.java DeviceConfig.java NetworkInterfacePort.java Log Message: quit() was extended Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** CommandProcessor.java 26 Oct 2008 22:06:51 -0000 1.37 --- CommandProcessor.java 27 Oct 2008 21:22:11 -0000 1.38 *************** *** 86,89 **** --- 86,90 ---- private interface__stopbits_CommandClass interface__stopbits_Command = new interface__stopbits_CommandClass(); private interface__switchport_access_vlan_CommandClass interface__switchport_access_vlan_Command = new interface__switchport_access_vlan_CommandClass(); + private interface__switchport_description_CommandClass interface__switchport_description_Command = new interface__switchport_description_CommandClass(); private interface__switchport_mode_access_CommandClass interface__switchport_mode_access_Command = new interface__switchport_mode_access_CommandClass(); private interface__switchport_mode_trunk_CommandClass interface__switchport_mode_trunk_Command = new interface__switchport_mode_trunk_CommandClass(); *************** *** 200,203 **** --- 201,205 ---- commands.addDescription("interface * switchport access","Configure a port access"); commands.add("interface * switchport access vlan", interface__switchport_access_vlan_Command, "Configure a port as a static-access port"); + commands.add("interface * switchport description", interface__switchport_description_Command, "Port specific description"); commands.addDescription("interface * switchport mode","Configure the VLAN membership mode of a port"); commands.add("interface * switchport mode access", interface__switchport_mode_access_Command, "Set the port to access mode"); *************** *** 1841,1844 **** --- 1843,1889 ---- } }; + class interface__switchport_description_CommandClass extends CommandInterface{ + public interface__switchport_description_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); + call_params = "<description>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + return parse(params, true); + } + public String no_call(Vector<String> params){ + return parse(params, false); + } + private String parse(Vector<String> params, boolean add){ + String out = ""; + if((params.size()>1 && add) || (params.size()==1 && !add)){ + try{ + NetworkInterface ni = device.getNetworkInterface(params.get(0)); + if(ni instanceof NetworkInterfacePort){ + NetworkInterfacePort eni = (NetworkInterfacePort) ni; + if(add){ + String desc = params.get(1); + for(int i=2; i<params.size(); i++){ + desc += " "+params.get(i); + } + eni.description = desc; + } + else{ + eni.description = ""; + } + } + else{ + out += "error: only ethernet interfaces is allowed\n"; + } + } catch (InvalidNetworkInterfaceNameException ex) { + out += "error: invalid inferface\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + return out; + } + }; class interface__switchport_mode_access_CommandClass extends CommandInterface{ public interface__switchport_mode_access_CommandClass(){ *************** *** 3768,3772 **** if(ni instanceof NetworkInterfacePort){ NetworkInterfacePort eni = (NetworkInterfacePort)ni; - //if(eni.vlan > 1){ out += " VLAN ID: "+eni.vlan+"\n"; String vmode = "unknown"; --- 3813,3816 ---- *************** *** 3776,3780 **** } out += " VLAN mode: "+vmode+"\n"; ! //} } if(ni instanceof WiFiPort){ --- 3820,3825 ---- } out += " VLAN mode: "+vmode+"\n"; ! if(eni.description!="") ! out += " VLAN description: "+eni.description+"\n"; } if(ni instanceof WiFiPort){ Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NetworkInterfacePort.java 24 Oct 2008 16:18:48 -0000 1.13 --- NetworkInterfacePort.java 27 Oct 2008 21:22:11 -0000 1.14 *************** *** 121,124 **** --- 121,125 ---- final static int MODE_TRUNK = 1; public int mode = NetworkInterfacePort.MODE_ACCESS; + public String description = ""; protected NetworkInterfacePort(long UID, String inName, Node inParent) { Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** DeviceConfig.java 26 Oct 2008 22:06:51 -0000 1.28 --- DeviceConfig.java 27 Oct 2008 21:22:11 -0000 1.29 *************** *** 446,449 **** --- 446,452 ---- break; } + if(pni.description!=""){ + conf.add("interface "+intName+" switchport description "+pni.description); + } } |