Thread: [Javanetsim-cvs] javaNetSim/core CommandProcessor.java, 1.20, 1.21 WiFiPort.java, 1.9, 1.10
Status: Beta
Brought to you by:
darkkey
|
From: QweR <qw...@us...> - 2008-10-05 20:57:04
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32740/core Modified Files: CommandProcessor.java WiFiPort.java Log Message: 'sh dot11 assoc' added Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CommandProcessor.java 5 Oct 2008 18:08:55 -0000 1.20 --- CommandProcessor.java 5 Oct 2008 20:57:00 -0000 1.21 *************** *** 32,35 **** --- 32,36 ---- import core.CommandInterface.Modes; + import core.WiFiPort.APClient; import core.AccessListEngine.access_list; *************** *** 94,97 **** --- 95,99 ---- private show_dhcp_lease_CommandClass show_dhcp_lease_Command = new show_dhcp_lease_CommandClass(); private show_dhcp_server_CommandClass show_dhcp_server_Command = new show_dhcp_server_CommandClass(); + private show_dot11_associations_CommandClass show_dot11_associations_Command = new show_dot11_associations_CommandClass(); private show_hostname_CommandClass show_hostname_Command = new show_hostname_CommandClass(); private show_interfaces_CommandClass show_interfaces_Command = new show_interfaces_CommandClass(); *************** *** 206,209 **** --- 208,213 ---- commands.add("show dhcp lease", show_dhcp_lease_Command, "Show DHCP Addresses leased from a server"); commands.add("show dhcp server", show_dhcp_server_Command, "Show DHCP Servers we know about"); + commands.addDescription("show dot11","Show 802.11 information"); + commands.add("show dot11 associations", show_dot11_associations_Command, "Show associated clients"); commands.add("show hostname", show_hostname_Command, "Display name of host"); commands.add("show interfaces", show_interfaces_Command, "Interface status and configuration"); *************** *** 2669,2672 **** --- 2673,2726 ---- } }; + class show_dot11_associations_CommandClass extends CommandInterface{ + public show_dot11_associations_CommandClass(){ + modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(device instanceof WirelessAP){ + ArrayList inames = device.getAllInterfacesNames(); + for(int i=0; i<inames.size(); i++){ + try { + NetworkInterface ni = device.getNetworkInterface((String)inames.get(i)); + if(ni instanceof WiFiPort){ + out += "Associations on "+(String)inames.get(i)+" interface\n"; + boolean client_present = false; + String out_cl = " BSSID \tState\n"; + client_present = true; + WiFiPort wfi = (WiFiPort) ni; + Enumeration<APClient> apc = wfi.getAPClients().elements(); + while(apc.hasMoreElements()){ + APClient client = apc.nextElement(); + out_cl += " "+client.BSSID+"\t"; + switch(client.state){ + case WiFiPort.OFFLINE: out_cl += "offline\n"; break; + case WiFiPort.PROBE: out_cl +="probe\n"; break; + case WiFiPort.AUTH: out_cl += "auth\n"; break; + case WiFiPort.ASSOC: out_cl += "assoc\n"; break; + case WiFiPort.DATA: out_cl += "data\n"; break; + case WiFiPort.DATA_ACK: out_cl += "data ack\n"; break; + default: out_cl += "unknown\n"; + } + } + if(client_present){ + out += out_cl; + } + else{ + out += " no associated clients found\n"; + } + } + } catch (InvalidNetworkInterfaceNameException e) { + } + } + } + else{ + out += "This instruction not supported by device\n"; + } + + return out; + } + }; class show_hostname_CommandClass extends CommandInterface{ public show_hostname_CommandClass(){ *************** *** 2701,2708 **** out += " Description: \"" + ni.getDescription() + "\"\n"; out += " Hardware address " + device.getMACAddress((String)ins[i]) + "\n"; ! out += " Internet address " + device.getIPAddress((String)ins[i]) + "/" + device.getSubnetMask((String)ins[i]) + "\n"; if(ni instanceof WiFiPort){ WiFiPort wfi = (WiFiPort) ni; ! out += " BSSID: " + wfi.getBSSID() + "\n"; out += " SSID: " + wfi.getSSID() + "\n"; out += " Channel: " + wfi.getChannel() + "\n"; --- 2755,2769 ---- out += " Description: \"" + ni.getDescription() + "\"\n"; out += " Hardware address " + device.getMACAddress((String)ins[i]) + "\n"; ! String ip = device.getIPAddress((String)ins[i]); ! String mask = device.getSubnetMask((String)ins[i]); ! out += " Internet address " + (ip==null || ip.equals("")?"Not set":ip) + "/" + (mask==null || mask.equals("")?"Not set":mask) + "\n"; if(ni instanceof WiFiPort){ WiFiPort wfi = (WiFiPort) ni; ! if(device instanceof WirelessAP || device instanceof Router){ ! out += " BSSID: " + wfi.getBSSID() + "\n"; ! } ! else{ ! out += " Access point BSSID: " + wfi.getAPBSSID() + "\n"; ! } out += " SSID: " + wfi.getSSID() + "\n"; out += " Channel: " + wfi.getChannel() + "\n"; Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WiFiPort.java 5 Oct 2008 20:20:32 -0000 1.9 --- WiFiPort.java 5 Oct 2008 20:57:00 -0000 1.10 *************** *** 60,64 **** // AP block ! class APClient{ public String BSSID; --- 60,64 ---- // AP block ! class APClient{ public String BSSID; *************** *** 75,79 **** // Contructor ! public WiFiPort(long UID, String inName, Node inParent) { --- 75,79 ---- // Contructor ! public WiFiPort(long UID, String inName, Node inParent) { *************** *** 316,319 **** --- 316,323 ---- BSSID = bssid; } + + public String getAPBSSID() { + return apBSSID; + } public String getSSID() { *************** *** 352,355 **** --- 356,363 ---- } + public Hashtable<String, APClient> getAPClients() { + return APClients; + } + protected void setMacAddress(String macAddress){ if(macAddress==null){ |