javanetsim-cvs Mailing List for javaNetSim (Page 5)
Status: Beta
Brought to you by:
darkkey
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(120) |
Dec
(62) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(1) |
Feb
(69) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(76) |
Oct
(28) |
Nov
(77) |
Dec
(186) |
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(36) |
Oct
(61) |
Nov
(23) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(17) |
Oct
(105) |
Nov
(5) |
Dec
(1) |
| 2009 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(9) |
Nov
|
Dec
|
|
From: QweR <qw...@us...> - 2008-10-13 20:40:52
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4553/guiUI Modified Files: Terminal.java Log Message: 'interface' command in exec mode was off Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Terminal.java 13 Oct 2008 20:04:25 -0000 1.16 --- Terminal.java 13 Oct 2008 20:40:32 -0000 1.17 *************** *** 72,75 **** --- 72,76 ---- private end_CommandClass end_Command = new end_CommandClass(); private exit_CommandClass exit_Command = new exit_CommandClass(); + private interface__exit_CommandClass interface__exit_Command = new interface__exit_CommandClass(); private interface_CommandClass interface_Command = new interface_CommandClass();private logout_CommandClass logout_Command = new logout_CommandClass(); private ping_CommandClass ping_Command = new ping_CommandClass(); *************** *** 100,104 **** cmdproc.add("interface *", interface_Command, ""); cmdproc.add("interface * end", end_Command, "Exit from configuration mode"); ! cmdproc.add("interface * exit", exit_Command, "Exit from current mode"); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); --- 101,105 ---- cmdproc.add("interface *", interface_Command, ""); cmdproc.add("interface * end", end_Command, "Exit from configuration mode"); ! cmdproc.add("interface * exit", interface__exit_Command, "Exit from current mode"); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); *************** *** 417,420 **** --- 418,438 ---- } }; + class interface__exit_CommandClass extends CommandInterface{ + public interface__exit_CommandClass (){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + } + public String call(Vector<String> params){ + if(interface_mode!=DEF_MODE){ + interface_mode = DEF_MODE; + command_prefix = ""; + } + else{ + current_mode.conf_mode = CommandInterface.STD_MODE; + device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; + } + return ""; + } + }; class interface_CommandClass extends CommandInterface{ public interface_CommandClass (){ |
|
From: QweR <qw...@us...> - 2008-10-13 20:04:31
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1563/guiUI Modified Files: Terminal.java Log Message: NAT.clear() ip nat * oveload Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Terminal.java 5 Oct 2008 18:08:55 -0000 1.15 --- Terminal.java 13 Oct 2008 20:04:25 -0000 1.16 *************** *** 517,521 **** class ping_CommandClass extends CommandInterface{ public ping_CommandClass(){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<ip address>"; } --- 517,521 ---- class ping_CommandClass extends CommandInterface{ public ping_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<ip address>"; } |
|
From: QweR <qw...@us...> - 2008-10-13 20:04:29
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1563/core Modified Files: DeviceConfig.java NATEngine.java NetworkLayerDevice.java Log Message: NAT.clear() ip nat * oveload Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** NetworkLayerDevice.java 13 Oct 2008 12:36:15 -0000 1.22 --- NetworkLayerDevice.java 13 Oct 2008 20:04:25 -0000 1.23 *************** *** 81,84 **** --- 81,85 ---- public void turnOff(){ acls.clear(); + nat.clear(); super.turnOff(); } Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NATEngine.java 13 Oct 2008 19:36:35 -0000 1.6 --- NATEngine.java 13 Oct 2008 20:04:25 -0000 1.7 *************** *** 288,290 **** --- 288,297 ---- return sessions.size(); } + + public void clear(){ + static_rules.clear(); + dynamic_rules.clear(); + sessions.clear(); + pools.clear(); + } } Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** DeviceConfig.java 13 Oct 2008 19:36:35 -0000 1.20 --- DeviceConfig.java 13 Oct 2008 20:04:25 -0000 1.21 *************** *** 578,582 **** if(rule.dynamic){ params = " list "+rule.acl; ! params += (rule.pool?" pool ":" interface ")+rule.out_int; } else{ --- 578,582 ---- if(rule.dynamic){ params = " list "+rule.acl; ! params += (rule.pool?" pool ":" interface ")+rule.out_int+" overload"; } else{ |
|
From: Alexander B. <da...@us...> - 2008-10-13 19:49:22
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32623/guiUI Modified Files: GuiNode.java MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** MainScreen.java 6 Oct 2008 13:20:39 -0000 1.91 --- MainScreen.java 13 Oct 2008 19:49:15 -0000 1.92 *************** *** 778,781 **** --- 778,783 ---- tempNode.addInterfaces(this, Sim.getNode(result)); + + tempNode.updateInterfacesMenu(); tempNode.setNodeLocation(inPoint); *************** *** 2219,2222 **** --- 2221,2225 ---- tempNode.setNodeLocation(pnt); tempNode.setEnabled(false); + tempNode.updateInterfacesMenu(); Sandbox.add(tempNode); Sandbox.setLayer((Component) tempNode, 3, 0); *************** *** 2484,2487 **** --- 2487,2492 ---- tempSwitch.setEnabled(true); + + tempSwitch.updateInterfacesMenu(); Sandbox.add(tempSwitch); *************** *** 2517,2520 **** --- 2522,2527 ---- tempPC.setNodeLocation(pnt); + + tempPC.updateInterfacesMenu(); Sandbox.add(tempPC); *************** *** 2566,2569 **** --- 2573,2578 ---- tempRouter.setEnabled(true); + + tempRouter.updateInterfacesMenu(); Sandbox.add(tempRouter); Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GuiNode.java 6 Oct 2008 13:20:39 -0000 1.8 --- GuiNode.java 13 Oct 2008 19:49:15 -0000 1.9 *************** *** 271,308 **** }); - try { - Object ints[] = controller.getInterfaces(lblNodeName.getText()); - - for (int i = 0; i < ints.length; i++) { - JMenuItem mnuI = new JMenuItem((String) ints[i]); - mnuI.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - - controller.showIntProps(lblNodeName.getText(), - ((JMenuItem) e.getSource()).getText()); - - } - - }); - mnuInt.add(mnuI); - JMenuItem mnuDI = new JMenuItem((String) ints[i]); - mnuDI.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - - controller.breakLink(lblNodeName.getText(), - ((JMenuItem) e.getSource()).getText()); - - } - - }); - mnuBreakLink.add(mnuDI); - } - - } catch (Exception e) { - e.printStackTrace(); - } mnuLink.addActionListener(new ActionListener() { --- 271,275 ---- *************** *** 339,342 **** --- 306,353 ---- } + public void updateInterfacesMenu(){ + try { + Object ints[] = controller.getInterfaces(lblNodeName.getText()); + + for (int i = 0; i < ints.length; i++) { + int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); + + if(int_type != core.NetworkInterface.Console && int_type != core.NetworkInterface.Wireless){ + JMenuItem mnuI = new JMenuItem((String) ints[i]); + mnuI.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + controller.showIntProps(lblNodeName.getText(), + ((JMenuItem) e.getSource()).getText()); + + } + + }); + mnuInt.add(mnuI); + } + + if(int_type != core.NetworkInterface.Wireless){ + + JMenuItem mnuDI = new JMenuItem((String) ints[i]); + mnuDI.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + controller.breakLink(lblNodeName.getText(), + ((JMenuItem) e.getSource()).getText()); + + } + + }); + mnuBreakLink.add(mnuDI); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + public abstract void addInterfaces(MainScreen parent, Node node); |
|
From: QweR <qw...@us...> - 2008-10-13 19:37:05
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31542/core Modified Files: CommandProcessor.java DeviceConfig.java NATEngine.java Log Message: NAT refashioned Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** CommandProcessor.java 12 Oct 2008 21:45:47 -0000 1.23 --- CommandProcessor.java 13 Oct 2008 19:36:35 -0000 1.24 *************** *** 33,36 **** --- 33,37 ---- import core.CommandInterface.Modes; import core.NATEngine.NAT_rule; + import core.NATEngine.NAT_session; import core.WiFiPort.APClient; import core.AccessListEngine.access_list; *************** *** 101,105 **** private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); ! private show_ip_nat_translation_CommandClass show_ip_nat_translation_Command = new show_ip_nat_translation_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); --- 102,106 ---- private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); ! private show_ip_nat_translations_CommandClass show_ip_nat_translations_Command = new show_ip_nat_translations_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); *************** *** 217,221 **** commands.add("show ip route", show_ip_route_Command, "Print route table"); commands.addDescription("show ip nat","IP NAT information"); ! commands.add("show ip nat translation", show_ip_nat_translation_Command, "Translation entries"); commands.add("show kron", show_kron_Command, "Kron Subsystem"); commands.add("show location", show_location_Command, "Display the system location"); --- 218,222 ---- commands.add("show ip route", show_ip_route_Command, "Print route table"); commands.addDescription("show ip nat","IP NAT information"); ! commands.add("show ip nat translations", show_ip_nat_translations_Command, "Translation entries"); commands.add("show kron", show_kron_Command, "Kron Subsystem"); commands.add("show location", show_location_Command, "Display the system location"); *************** *** 2089,2093 **** if(overload){ NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = false; rule.pool = true; rule.acl = iacl; --- 2090,2094 ---- if(overload){ NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = true; rule.pool = true; rule.acl = iacl; *************** *** 2100,2106 **** } else{ ! Vector<Integer> finds = device.getNAT().findRules(false, true, iacl, "", 0, "", 0, poolname); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); } else{ --- 2101,2107 ---- } else{ ! Vector<Integer> finds = device.getNAT().findRules(true, true, iacl, "", 0, "", 0, poolname); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue(), true); } else{ *************** *** 2120,2124 **** if(overload){ NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = false; rule.pool = false; rule.acl = iacl; --- 2121,2125 ---- if(overload){ NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = true; rule.pool = false; rule.acl = iacl; *************** *** 2131,2137 **** } else{ ! Vector<Integer> finds = device.getNAT().findRules(false, false, iacl, "", 0, "", 0, intname); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); } else{ --- 2132,2138 ---- } else{ ! Vector<Integer> finds = device.getNAT().findRules(true, false, iacl, "", 0, "", 0, intname); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue(), true); } else{ *************** *** 2232,2236 **** finds = device.getNAT().findRules(false, false, 0, local_ip, local_port, global_ip, global_port, ""); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); } else{ --- 2233,2237 ---- finds = device.getNAT().findRules(false, false, 0, local_ip, local_port, global_ip, global_port, ""); if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue(), false); } else{ *************** *** 2922,2927 **** } }; ! class show_ip_nat_translation_CommandClass extends CommandInterface{ ! public show_ip_nat_translation_CommandClass(){ modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; --- 2923,2928 ---- } }; ! class show_ip_nat_translations_CommandClass extends CommandInterface{ ! public show_ip_nat_translations_CommandClass(){ modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; *************** *** 2930,2949 **** String out = ""; if(params.size()==0){ - out += "Protocol Inside Outside\n"; NATEngine nat = device.getNAT(); ! for(int i=0; i<nat.countRules(); i++){ ! NAT_rule rule = nat.getRule(i); ! String inside = rule.in_ip; ! if(rule.in_port>0) inside += ":"+rule.in_port; ! String outside = rule.out_ip; ! if(rule.out_port>0) outside += ":"+rule.out_port; ! String protocol = ""; ! switch(rule.protocol){ ! case NAT_rule.IP: protocol="ip"; break; ! case NAT_rule.ICMP: protocol="icmp"; break; ! case NAT_rule.UDP: protocol="udp"; break; ! case NAT_rule.TCP: protocol="tcp"; break; } - out += String.format("%-12s%-23s%s\n", protocol, inside, outside); } } --- 2931,2955 ---- String out = ""; if(params.size()==0){ NATEngine nat = device.getNAT(); ! if(nat.countSessions()<1){ ! out += "found no sessions\n"; ! } ! else{ ! out += "Protocol Inside Outside\n"; ! for(int i=0; i<nat.countSessions(); i++){ ! NAT_session rule = nat.getSession(i); ! String inside = rule.in_ip; ! if(rule.in_port>0) inside += ":"+rule.in_port; ! String outside = rule.out_ip; ! if(rule.out_port>0) outside += ":"+rule.out_port; ! String protocol = ""; ! switch(rule.protocol){ ! case NAT_session.UNKNOWN: protocol="---"; break; ! case NAT_session.ICMP: protocol="icmp"; break; ! case NAT_session.UDP: protocol="udp"; break; ! case NAT_session.TCP: protocol="tcp"; break; ! } ! out += String.format("%-12s%-23s%s\n", protocol, inside, outside); } } } Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NATEngine.java 13 Oct 2008 12:41:31 -0000 1.5 --- NATEngine.java 13 Oct 2008 19:36:35 -0000 1.6 *************** *** 11,15 **** public class NAT_session{ ! public final static int UNKNOWN = 1; public final static int ICMP = 1; public final static int UDP = 2; --- 11,15 ---- public class NAT_session{ ! public final static int UNKNOWN = 0; public final static int ICMP = 1; public final static int UDP = 2; *************** *** 55,59 **** } ! Vector<NAT_rule> rules; Hashtable<String, Pair> pools; --- 55,60 ---- } ! Vector<NAT_rule> static_rules; ! Vector<NAT_rule> dynamic_rules; Hashtable<String, Pair> pools; *************** *** 61,65 **** parentNode = node; ! rules = new Vector<NAT_rule>(); pools = new Hashtable<String, Pair>(); } --- 62,68 ---- parentNode = node; ! static_rules = new Vector<NAT_rule>(); ! dynamic_rules = new Vector<NAT_rule>(); ! sessions = new Vector<NAT_session>(); pools = new Hashtable<String, Pair>(); } *************** *** 70,73 **** --- 73,78 ---- public int addRule(NAT_rule rule, int pos){ + Vector<NAT_rule> rules = static_rules; + if(rule.dynamic) rules = dynamic_rules; if(pos<0 || pos>=rules.size()){ rules.add(rule); *************** *** 78,82 **** } ! public boolean removeRule(int rnum){ if(rnum>=0 && rnum<rules.size()){ rules.remove(rnum); --- 83,89 ---- } ! public boolean removeRule(int rnum, boolean dynamic){ ! Vector<NAT_rule> rules = static_rules; ! if(dynamic) rules = dynamic_rules; if(rnum>=0 && rnum<rules.size()){ rules.remove(rnum); *************** *** 87,102 **** public boolean isOverloadIP(String ip){ ! for(int i=0; i<rules.size(); i++) ! if(rules.get(i).out_ip.equals(ip)) return true; return false; } ! public Vector<Integer> findRules(Boolean dynamic, Boolean pool, Integer acl, String in_ip, Integer in_port, String out_ip, Integer out_port, String out_int){ Vector<Integer> result = new Vector<Integer>(); for(int i=0; i<rules.size(); i++){ NAT_rule rule = rules.get(i); ! if((dynamic==null || rule.dynamic==dynamic.booleanValue()) ! && (pool==null || rule.pool==pool.booleanValue()) && (acl==null || rule.acl==acl.intValue()) && (in_ip==null || rule.in_ip.equalsIgnoreCase(in_ip)) --- 94,110 ---- public boolean isOverloadIP(String ip){ ! for(int i=0; i<static_rules.size(); i++) ! if(static_rules.get(i).out_ip.equals(ip)) return true; return false; } ! public Vector<Integer> findRules(boolean dynamic, Boolean pool, Integer acl, String in_ip, Integer in_port, String out_ip, Integer out_port, String out_int){ ! Vector<NAT_rule> rules = static_rules; ! if(dynamic) rules = dynamic_rules; Vector<Integer> result = new Vector<Integer>(); for(int i=0; i<rules.size(); i++){ NAT_rule rule = rules.get(i); ! if((pool==null || rule.pool==pool.booleanValue()) && (acl==null || rule.acl==acl.intValue()) && (in_ip==null || rule.in_ip.equalsIgnoreCase(in_ip)) *************** *** 114,119 **** IP_packet rp = p; ! for(int i=0; i<rules.size(); i++){ ! NAT_rule rule = rules.get(i); String NewIP = ""; int NewPort = 0; --- 122,127 ---- IP_packet rp = p; ! for(int i=0; i<static_rules.size(); i++){ ! NAT_rule rule = static_rules.get(i); String NewIP = ""; int NewPort = 0; *************** *** 176,181 **** IP_packet rp = p; ! for(int i=0; i<rules.size(); i++){ ! NAT_rule rule = rules.get(i); String NewIP = ""; int NewPort = 0; --- 184,189 ---- IP_packet rp = p; ! for(int i=0; i<static_rules.size(); i++){ ! NAT_rule rule = static_rules.get(i); String NewIP = ""; int NewPort = 0; *************** *** 223,227 **** } ! public NAT_rule getRule(int i){ if(i>=0 && i<rules.size()){ return rules.get(i); --- 231,237 ---- } ! public NAT_rule getRule(int i, boolean dynamic){ ! Vector<NAT_rule> rules = static_rules; ! if(dynamic) rules = dynamic_rules; if(i>=0 && i<rules.size()){ return rules.get(i); *************** *** 230,234 **** } ! public int countRules(){ return rules.size(); } --- 240,246 ---- } ! public int countRules(boolean dynamic){ ! Vector<NAT_rule> rules = static_rules; ! if(dynamic) rules = dynamic_rules; return rules.size(); } *************** *** 265,267 **** --- 277,290 ---- return pools.keys(); } + + public NAT_session getSession(int i){ + if(i>=0 && i<sessions.size()){ + return sessions.get(i); + } + return null; + } + + public int countSessions(){ + return sessions.size(); + } } Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** DeviceConfig.java 12 Oct 2008 21:45:47 -0000 1.19 --- DeviceConfig.java 13 Oct 2008 19:36:35 -0000 1.20 *************** *** 572,580 **** NetworkLayerDevice ndev = (NetworkLayerDevice)device; NATEngine nat = ndev.getNAT(); ! for(int i=0; i<nat.countRules(); i++){ ! String params; ! NAT_rule rule = nat.getRule(i); ! if(!rule.dynamic){ ! if(rule.acl>0){ params = " list "+rule.acl; params += (rule.pool?" pool ":" interface ")+rule.out_int; --- 572,580 ---- NetworkLayerDevice ndev = (NetworkLayerDevice)device; NATEngine nat = ndev.getNAT(); ! for(int dyn=0; dyn<2; dyn++){ ! for(int i=0; i<nat.countRules(dyn==1); i++){ ! String params; ! NAT_rule rule = nat.getRule(i,dyn==1); // dyn==0 -- static_rules, dyn==1 -- dynamic_rules ! if(rule.dynamic){ params = " list "+rule.acl; params += (rule.pool?" pool ":" interface ")+rule.out_int; |
|
From: Alexander B. <da...@us...> - 2008-10-13 12:41:41
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10532/core Modified Files: NATEngine.java Log Message: Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NATEngine.java 13 Oct 2008 12:36:15 -0000 1.4 --- NATEngine.java 13 Oct 2008 12:41:31 -0000 1.5 *************** *** 10,13 **** --- 10,37 ---- NetworkLayerDevice parentNode; + public class NAT_session{ + public final static int UNKNOWN = 1; + public final static int ICMP = 1; + public final static int UDP = 2; + public final static int TCP = 3; + + public int protocol = 0; + + public String in_ip = ""; + public int in_port = 0; + + public String out_ip = ""; + public int out_port = 0; + + public long last_time = 0; + + public NAT_session(){ + last_time = System.currentTimeMillis(); + } + + } + + Vector<NAT_session> sessions; + public class NAT_rule{ public boolean dynamic = false; // false -- static, true -- dymanic *************** *** 89,93 **** public IP_packet NAT_inside(IP_packet p){ IP_packet rp = p; ! for(int i=0; i<rules.size(); i++){ NAT_rule rule = rules.get(i); --- 113,117 ---- public IP_packet NAT_inside(IP_packet p){ IP_packet rp = p; ! for(int i=0; i<rules.size(); i++){ NAT_rule rule = rules.get(i); |
|
From: Alexander B. <da...@us...> - 2008-10-13 12:36:32
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8468/core Modified Files: AccessListEngine.java ExternalProxy.java NATEngine.java NetworkLayerDevice.java Log Message: Static NAT/PAT seems to be working now. Heading for dynamic NAT... Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** NetworkLayerDevice.java 10 Oct 2008 22:18:05 -0000 1.21 --- NetworkLayerDevice.java 13 Oct 2008 12:36:15 -0000 1.22 *************** *** 34,37 **** --- 34,39 ---- import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; import core.protocolsuite.tcp_ip.Route_entry; + import core.protocolsuite.tcp_ip.IP_packet; + import core.protocolsuite.tcp_ip.ARP_packet; import java.util.*; *************** *** 53,56 **** --- 55,59 ---- private NATEngine nat = new NATEngine(this); + /** * calls the super class (Node) and passes it inName and inProtocolStack *************** *** 127,141 **** public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! try{ ! if(this.getNetworkInterface(inInterface).getNAT() == 1){ ! ! }else if(this.getNetworkInterface(inInterface).getNAT() == 2){ ! } ! }catch(InvalidNetworkInterfaceNameException e){ } if(NodeProtocolStack != null) NodeProtocolStack.receivePacket(inPacket, inInterface); } /** --- 130,162 ---- public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! if(inPacket instanceof IP_packet && !(inPacket instanceof ARP_packet)){ ! try{ ! if(this.getNetworkInterface(inInterface).getNAT() == NetworkInterface.INSIDE_NAT){ ! // mark packet ! ((IP_packet) inPacket).NatMark = true; ! Simulation.addLayerInfo(getClass().getName(), getName(), "IP Packet", "Network", ! "Marked packet as possible inside NAT candidate."); ! }else if(this.getNetworkInterface(inInterface).getNAT() == NetworkInterface.OUTSIDE_NAT){ ! inPacket = nat.NAT_outside((IP_packet) inPacket); ! } ! }catch(InvalidNetworkInterfaceNameException e){ } ! } if(NodeProtocolStack != null) NodeProtocolStack.receivePacket(inPacket, inInterface); } + + public Packet preparePacket(Packet inPacket){ + if(inPacket instanceof IP_packet && !(inPacket instanceof ARP_packet)){ + if(((IP_packet) inPacket).NatMark){ + inPacket = nat.NAT_inside((IP_packet) inPacket); + } + + ((IP_packet) inPacket).NatMark = false; + } + + return inPacket; + } /** *************** *** 193,197 **** if (NetworkInterfacetable.containsKey(inInterfaceKey)) { ! if(NetworkInterfacetable.get(inInterfaceKey) instanceof EthernetNetworkInterface){ EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); temp.sendPacket(inPacket,inDestMACAddress); --- 214,221 ---- if (NetworkInterfacetable.containsKey(inInterfaceKey)) { ! inPacket = preparePacket(inPacket); ! ! if(NetworkInterfacetable.get(inInterfaceKey) instanceof EthernetNetworkInterface){ ! EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); temp.sendPacket(inPacket,inDestMACAddress); *************** *** 209,212 **** --- 233,238 ---- if (NetworkInterfacetable.containsKey(inInterfaceKey)) { + inPacket = preparePacket(inPacket); + NetworkInterface temp = (NetworkInterface)NetworkInterfacetable.get(inInterfaceKey); temp.sendPacket(inPacket); Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NATEngine.java 12 Oct 2008 21:45:47 -0000 1.3 --- NATEngine.java 13 Oct 2008 12:36:15 -0000 1.4 *************** *** 4,7 **** --- 4,8 ---- import java.util.Hashtable; import java.util.Vector; + import core.protocolsuite.tcp_ip.*; public class NATEngine { *************** *** 61,64 **** --- 62,72 ---- } + public boolean isOverloadIP(String ip){ + for(int i=0; i<rules.size(); i++) + if(rules.get(i).out_ip.equals(ip)) + return true; + return false; + } + public Vector<Integer> findRules(Boolean dynamic, Boolean pool, Integer acl, String in_ip, Integer in_port, String out_ip, Integer out_port, String out_int){ Vector<Integer> result = new Vector<Integer>(); *************** *** 79,82 **** --- 87,202 ---- } + public IP_packet NAT_inside(IP_packet p){ + IP_packet rp = p; + + for(int i=0; i<rules.size(); i++){ + NAT_rule rule = rules.get(i); + String NewIP = ""; + int NewPort = 0; + + if(rule.in_ip.equals(p.getSourceIPAddress()) && parentNode.getACL().passACL(rule.acl, p)){ + // rule found, let's see its type + + if(rule.protocol == NAT_rule.IP || rule.protocol == NAT_rule.ICMP){ + + NewIP = rule.out_ip; + + if(rule.out_ip.length() < 5){ + NewIP = parentNode.getIPAddress(rule.out_int); + } + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Inside NAT for packet applied: changed src IP from " + p.getSourceIPAddress() + " to " + NewIP + "."); + + rp.setSourceIPAddress(NewIP); + + break; + }else if(rule.protocol == NAT_rule.TCP && p instanceof TCP_packet){ + if(((TCP_packet)p).get_srcPort() == rule.in_port){ + NewIP = rule.out_ip; + NewPort = rule.out_port; + + if(rule.out_ip.length() < 5){ + NewIP = parentNode.getIPAddress(rule.out_int); + } + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Inside PAT(tcp) for ip packet applied: changed src from " + p.getSourceIPAddress() + ":" + ((TCP_packet)p).get_srcPort() + " to " + NewIP + ":" + NewPort + "."); + + ((TCP_packet)rp).setSrcPort(NewPort); + rp.setSourceIPAddress(NewIP); + } + }else if(rule.protocol == NAT_rule.UDP && p instanceof UDP_packet){ + if(((UDP_packet)p).get_srcPort() == rule.in_port){ + NewIP = rule.out_ip; + NewPort = rule.out_port; + + if(rule.out_ip.length() < 5){ + NewIP = parentNode.getIPAddress(rule.out_int); + } + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Inside PAT(udp) for ip packet applied: changed src from " + p.getSourceIPAddress() + ":" + ((UDP_packet)p).get_srcPort() + " to " + NewIP + ":" + NewPort + "."); + + ((UDP_packet)rp).setSrcPort(NewPort); + rp.setSourceIPAddress(NewIP); + } + } + } + } + + return p; + } + + public IP_packet NAT_outside(IP_packet p){ + IP_packet rp = p; + + for(int i=0; i<rules.size(); i++){ + NAT_rule rule = rules.get(i); + String NewIP = ""; + int NewPort = 0; + + if(rule.out_ip.equals(p.getDestIPAddress()) && parentNode.getACL().passACL(rule.acl, p)){ + // rule found, let's see its type + + if(rule.protocol == NAT_rule.IP || rule.protocol == NAT_rule.ICMP){ + + NewIP = rule.in_ip; + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Outside NAT for packet applied: changed dst IP from " + p.getDestIPAddress() + " to " + NewIP + "."); + + rp.setDestIPAddress(NewIP); + + break; + }else if(rule.protocol == NAT_rule.TCP && p instanceof TCP_packet){ + if(((TCP_packet)p).get_destPort() == rule.out_port){ + NewIP = rule.in_ip; + NewPort = rule.in_port; + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Inside PAT(tcp) for packet applied: changed dst from " + p.getDestIPAddress() + ":" + ((TCP_packet)p).get_destPort() + " to " + NewIP + ":" + NewPort + "."); + + ((TCP_packet)rp).setDestPort(NewPort); + rp.setDestIPAddress(NewIP); + } + }else if(rule.protocol == NAT_rule.UDP && p instanceof UDP_packet){ + if(((UDP_packet)p).get_destPort() == rule.out_port){ + NewIP = rule.in_ip; + NewPort = rule.in_port; + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "IP Packet", "Network", + "Inside PAT(udp) for packet applied: changed dst from " + p.getDestIPAddress() + ":" + ((UDP_packet)p).get_destPort() + " to " + NewIP + ":" + NewPort + "."); + + ((UDP_packet)rp).setDestPort(NewPort); + rp.setDestIPAddress(NewIP); + } + } + } + } + + return p; + } + public NAT_rule getRule(int i){ if(i>=0 && i<rules.size()){ *************** *** 108,111 **** --- 228,241 ---- } + public boolean inPool(String name, String IP){ + if(pools.containsKey(name)){ + Pair ips = pools.get(name); + + return IPV4Address.IPEqLower(IP, (String)ips.getFirst()) + && IPV4Address.IPEqLower((String)ips.getSecond(), IP); + } + return false; + } + public Enumeration<String> getPools(){ return pools.keys(); Index: ExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ExternalProxy.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExternalProxy.java 6 Oct 2008 13:20:39 -0000 1.5 --- ExternalProxy.java 13 Oct 2008 12:36:15 -0000 1.6 *************** *** 136,140 **** if(inPacket instanceof IP_packet){ IP_packet IPP = (IP_packet) inPacket; ! System.out.println("Activating NAT when sending..."); //if(!NodeProtocolStack.isInternalIP(IPP.getSourceIPAddress())){ //System.out.println("Activating NAT when sending..."); --- 136,140 ---- if(inPacket instanceof IP_packet){ IP_packet IPP = (IP_packet) inPacket; ! System.out.println("Activating Proxy when sending..."); //if(!NodeProtocolStack.isInternalIP(IPP.getSourceIPAddress())){ //System.out.println("Activating NAT when sending..."); Index: AccessListEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/AccessListEngine.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AccessListEngine.java 14 Sep 2008 20:51:29 -0000 1.4 --- AccessListEngine.java 13 Oct 2008 12:36:15 -0000 1.5 *************** *** 173,177 **** Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); ! if(ACLl == null) return false; try{ --- 173,177 ---- Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); ! if(ACLl == null) return true; try{ |
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8468/core/protocolsuite/tcp_ip Modified Files: ARP.java IPV4Address.java IP_packet.java IpV4.java ProtocolStack.java TCP_packet.java UDP_packet.java Log Message: Static NAT/PAT seems to be working now. Heading for dynamic NAT... Index: TCP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_packet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TCP_packet.java 20 Oct 2007 13:27:21 -0000 1.6 --- TCP_packet.java 13 Oct 2008 12:36:15 -0000 1.7 *************** *** 70,73 **** --- 70,82 ---- + public void setDestPort(int dp){ + TCP_destPort = dp; + } + + public void setSrcPort(int sp){ + TCP_srcPort = sp; + } + + /** * This method passes the destination and source addresses into the super class Index: UDP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/UDP_packet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UDP_packet.java 15 Oct 2007 18:25:54 -0000 1.5 --- UDP_packet.java 13 Oct 2008 12:36:15 -0000 1.6 *************** *** 100,103 **** --- 100,111 ---- + public void setDestPort(int dp){ + UDP_destPort = dp; + } + + public void setSrcPort(int sp){ + UDP_srcPort = sp; + } + /** Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** ProtocolStack.java 5 Oct 2008 19:12:31 -0000 1.70 --- ProtocolStack.java 13 Oct 2008 12:36:15 -0000 1.71 *************** *** 282,286 **** String sourceIP = mIPprotocol .getIPAddress(outInterface[0]); ! inPacket.setSourceIPAddress(sourceIP); // test if on local of remote network if (mParentNode.getIntType(outInterface[0]) != NetworkInterface.Serial) { --- 282,288 ---- String sourceIP = mIPprotocol .getIPAddress(outInterface[0]); ! ! if(!(inPacket instanceof ARP_packet)) // ! inPacket.setSourceIPAddress(sourceIP); // test if on local of remote network if (mParentNode.getIntType(outInterface[0]) != NetworkInterface.Serial) { Index: IP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IP_packet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IP_packet.java 15 Oct 2007 18:25:54 -0000 1.5 --- IP_packet.java 13 Oct 2008 12:36:15 -0000 1.6 *************** *** 88,91 **** --- 88,93 ---- String mDestIPAddress; + + public boolean NatMark = false; *************** *** 110,113 **** --- 112,116 ---- mDestIPAddress = inDestIPAddress; + NatMark = false; } Index: IPV4Address.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IPV4Address.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IPV4Address.java 13 Oct 2007 12:57:00 -0000 1.5 --- IPV4Address.java 13 Oct 2008 12:36:15 -0000 1.6 *************** *** 108,111 **** --- 108,125 ---- } + + public static boolean IPEqLower(String IP1, String IP2){ + + String IPOct1[] = IP1.split("\\."); + String IPOct2[] = IP2.split("\\."); + + for(int i = 0; i < 4; i++){ + if(Integer.valueOf(IPOct1[i]) - Integer.valueOf(IPOct2[i]) < 0) + return false; + } + + return true; + } + /** * This method will return the binary version of an IPV4 address or subnet mask Index: IpV4.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IpV4.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** IpV4.java 5 Oct 2008 19:12:31 -0000 1.14 --- IpV4.java 13 Oct 2008 12:36:15 -0000 1.15 *************** *** 61,64 **** --- 61,66 ---- import java.util.Hashtable; + import java.util.ArrayList; + import core.InvalidDefaultGatewayException; *************** *** 67,70 **** --- 69,74 ---- import core.NetworkLayerDevice; + import core.NetworkInterface; + import core.InvalidNetworkInterfaceNameException; *************** *** 819,822 **** --- 823,837 ---- } + + ArrayList ifaces = parentNode.getAllInterfacesNames(); + + for(int i = 0; i < ifaces.size(); i++){ + try{ + if(parentNode.getNetworkInterface((String)ifaces.get(i)).getNAT() == NetworkInterface.OUTSIDE_NAT) + if(parentNode.getNAT().isOverloadIP(inIPAddress)) + return true; + }catch(core.InvalidNetworkInterfaceNameException e){ } + } + return false; Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ARP.java 5 Oct 2008 13:03:47 -0000 1.11 --- ARP.java 13 Oct 2008 12:36:15 -0000 1.12 *************** *** 352,355 **** --- 352,357 ---- ArpDisc.setSourceMAC(srcMAC); + + ArpDisc.setSourceIPAddress(mParentStack.getIPAddress(inInterfaceKey)); //Create layer info object *************** *** 444,447 **** --- 446,451 ---- ArpResponse.setMessageCode(ARP_packet.ARP_REPLY); + + ArpResponse.setSourceIPAddress(inARPpacket.getDestIPAddress()); String outInterface = mParentStack.getRouteInfo(inARPpacket.getSourceIPAddress()); |
|
From: QweR <qw...@us...> - 2008-10-12 21:46:41
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7391/core Modified Files: CommandProcessor.java DeviceConfig.java NATEngine.java Log Message: 'ip nat poll' was added Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** CommandProcessor.java 10 Oct 2008 22:18:05 -0000 1.22 --- CommandProcessor.java 12 Oct 2008 21:45:47 -0000 1.23 *************** *** 2257,2261 **** modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); call_params = "<pool> <low ip> <high ip>"; ! no_call_params = "<pool> <low ip> <high ip>"; } public String call(Vector<String> params){ --- 2257,2261 ---- modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); call_params = "<pool> <low ip> <high ip>"; ! no_call_params = "<pool>"; } public String call(Vector<String> params){ *************** *** 2266,2283 **** } private String parse(Vector<String> params, boolean add){ ! String out = "Command not supported yet\n"; ! if(params.size()==3){ String poolname = params.get(0); String low_ip = params.get(1); String high_ip = params.get(2); if(IPV4Address.validateDecIP(low_ip) && IPV4Address.validateDecIP(high_ip)){ ! if(add){ ! //nat.pool.add(poolname, low_ip, high_ip); ! } ! else{ ! //nat.pool.remove(poolname, low_ip, high_ip); ! } } } else{ out += "error: invalid parameters\n"; --- 2266,2285 ---- } private String parse(Vector<String> params, boolean add){ ! String out = ""; ! if(params.size()==3 && add){ String poolname = params.get(0); String low_ip = params.get(1); String high_ip = params.get(2); if(IPV4Address.validateDecIP(low_ip) && IPV4Address.validateDecIP(high_ip)){ ! device.getNAT().addPool(poolname, new Pair(low_ip,high_ip)); ! } ! else{ ! out += "error: invalid IP address\n"; } } + else if(params.size()==1 && !add){ + String poolname = params.get(0); + device.getNAT().removePool(poolname); + } else{ out += "error: invalid parameters\n"; Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NATEngine.java 10 Oct 2008 22:18:05 -0000 1.2 --- NATEngine.java 12 Oct 2008 21:45:47 -0000 1.3 *************** *** 1,4 **** --- 1,6 ---- package core; + import java.util.Enumeration; + import java.util.Hashtable; import java.util.Vector; *************** *** 29,32 **** --- 31,35 ---- Vector<NAT_rule> rules; + Hashtable<String, Pair> pools; public NATEngine(NetworkLayerDevice node){ *************** *** 34,37 **** --- 37,41 ---- rules = new Vector<NAT_rule>(); + pools = new Hashtable<String, Pair>(); } *************** *** 85,87 **** --- 89,113 ---- return rules.size(); } + + public Pair getPool(String name){ + if(pools.containsKey(name)){ + return pools.get(name); + } + return null; + } + + public void addPool(String name, Pair pool){ + pools.put(name, pool); + } + + public Pair removePool(String name){ + if(pools.containsKey(name)){ + return pools.remove(name); + } + return null; + } + + public Enumeration<String> getPools(){ + return pools.keys(); + } } Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DeviceConfig.java 10 Oct 2008 22:18:05 -0000 1.18 --- DeviceConfig.java 12 Oct 2008 21:45:47 -0000 1.19 *************** *** 596,599 **** --- 596,605 ---- } } + Enumeration<String> pools = nat.getPools(); + while(pools.hasMoreElements()){ + String name = pools.nextElement(); + Pair pool = nat.getPool(name); + conf.add("ip nat pool "+name+" "+(String)pool.getFirst()+" "+(String)pool.getSecond()); + } } if(device instanceof ApplicationLayerDevice){ |
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31762/core Modified Files: CommandProcessor.java DeviceConfig.java NATEngine.java NetworkInterface.java NetworkLayerDevice.java Log Message: NAT command was added Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** NetworkLayerDevice.java 7 Oct 2008 08:25:02 -0000 1.20 --- NetworkLayerDevice.java 10 Oct 2008 22:18:05 -0000 1.21 *************** *** 51,54 **** --- 51,55 ---- private DeviceConfig config = new DeviceConfig(this); private AccessListEngine acls = new AccessListEngine(this); + private NATEngine nat = new NATEngine(this); /** *************** *** 435,437 **** --- 436,442 ---- return acls; } + + public NATEngine getNAT(){ + return nat; + } }//EOF Index: NATEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NATEngine.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NATEngine.java 7 Oct 2008 08:25:02 -0000 1.1 --- NATEngine.java 10 Oct 2008 22:18:05 -0000 1.2 *************** *** 13,16 **** --- 13,22 ---- public int acl = 0; // acl number for dynamic + public final static int IP = 0; + public final static int ICMP = 1; + public final static int UDP = 2; + public final static int TCP = 3; + public int protocol = IP; + public String in_ip = ""; public int in_port = 0; *************** *** 29,31 **** --- 35,87 ---- rules = new Vector<NAT_rule>(); } + + public int addRule(NAT_rule rule){ + return addRule(rule,-1); + } + + public int addRule(NAT_rule rule, int pos){ + if(pos<0 || pos>=rules.size()){ + rules.add(rule); + return rules.size()-1; + } + rules.add(pos, rule); + return pos; + } + + public boolean removeRule(int rnum){ + if(rnum>=0 && rnum<rules.size()){ + rules.remove(rnum); + return true; + } + return false; + } + + public Vector<Integer> findRules(Boolean dynamic, Boolean pool, Integer acl, String in_ip, Integer in_port, String out_ip, Integer out_port, String out_int){ + Vector<Integer> result = new Vector<Integer>(); + for(int i=0; i<rules.size(); i++){ + NAT_rule rule = rules.get(i); + if((dynamic==null || rule.dynamic==dynamic.booleanValue()) + && (pool==null || rule.pool==pool.booleanValue()) + && (acl==null || rule.acl==acl.intValue()) + && (in_ip==null || rule.in_ip.equalsIgnoreCase(in_ip)) + && (in_port==null || rule.in_port==in_port.intValue()) + && (out_ip==null || rule.out_ip.equalsIgnoreCase(out_ip)) + && (out_port==null || rule.out_port==out_port.intValue()) + && (out_int==null || rule.out_int.equalsIgnoreCase(out_int))){ + result.add(new Integer(i)); + } + } + return result; + } + + public NAT_rule getRule(int i){ + if(i>=0 && i<rules.size()){ + return rules.get(i); + } + return null; + } + + public int countRules(){ + return rules.size(); + } } Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CommandProcessor.java 5 Oct 2008 20:57:00 -0000 1.21 --- CommandProcessor.java 10 Oct 2008 22:18:05 -0000 1.22 *************** *** 32,35 **** --- 32,36 ---- import core.CommandInterface.Modes; + import core.NATEngine.NAT_rule; import core.WiFiPort.APClient; import core.AccessListEngine.access_list; *************** *** 100,103 **** --- 101,105 ---- private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); + private show_ip_nat_translation_CommandClass show_ip_nat_translation_Command = new show_ip_nat_translation_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); *************** *** 185,191 **** commands.addDescription("ip nat","NAT configuration commands"); commands.addDescription("ip nat inside","Inside address translation"); ! commands.addDescription("ip nat inside destination","Destination address translation"); commands.addDescription("ip nat inside source","Source address translation"); ! commands.add("ip nat inside destination list", ip_nat_inside_destination_list_Command, "Specify access list describing global addresses"); commands.add("ip nat inside source list", ip_nat_inside_source_list_Command, "Specify access list describing local addresses"); commands.add("ip nat inside source static", ip_nat_inside_source_static_Command, "Specify static local->global mapping"); --- 187,193 ---- commands.addDescription("ip nat","NAT configuration commands"); commands.addDescription("ip nat inside","Inside address translation"); ! //commands.addDescription("ip nat inside destination","Destination address translation"); commands.addDescription("ip nat inside source","Source address translation"); ! //commands.add("ip nat inside destination list", ip_nat_inside_destination_list_Command, "Specify access list describing global addresses"); commands.add("ip nat inside source list", ip_nat_inside_source_list_Command, "Specify access list describing local addresses"); commands.add("ip nat inside source static", ip_nat_inside_source_static_Command, "Specify static local->global mapping"); *************** *** 214,217 **** --- 216,221 ---- commands.add("show ip", show_ip_Command, "IP information"); commands.add("show ip route", show_ip_route_Command, "Print route table"); + commands.addDescription("show ip nat","IP NAT information"); + commands.add("show ip nat translation", show_ip_nat_translation_Command, "Translation entries"); commands.add("show kron", show_kron_Command, "Kron Subsystem"); commands.add("show location", show_location_Command, "Display the system location"); *************** *** 987,995 **** } public String call(Vector<String> params){ ! String out = "Command not supported yet.\n"; if(device instanceof ApplicationLayerDevice){ if(params.size()==2){ try { ! device.getNetworkInterface(params.get(0)); } catch (InvalidNetworkInterfaceNameException ex) { out += "error: invalid inferface\n"; --- 991,1009 ---- } public String call(Vector<String> params){ ! String out = ""; if(device instanceof ApplicationLayerDevice){ if(params.size()==2){ try { ! NetworkInterface ni = device.getNetworkInterface(params.get(0)); ! String natt = params.get(1); ! if(natt.equalsIgnoreCase("inside")){ ! ni.setNAT(NetworkInterface.INSIDE_NAT); ! } ! else if(natt.equalsIgnoreCase("outside")){ ! ni.setNAT(NetworkInterface.OUTSIDE_NAT); ! } ! else{ ! out += "error: invalid parameter '"+natt+"'\n"; ! } } catch (InvalidNetworkInterfaceNameException ex) { out += "error: invalid inferface\n"; *************** *** 1006,1018 **** } public String no_call(Vector<String> params){ ! String out = "Command not supported yet.\n"; if(device instanceof ApplicationLayerDevice){ ! if(params.size()==2){ try { ! device.getNetworkInterface(params.get(0)); } catch (InvalidNetworkInterfaceNameException ex) { out += "error: invalid inferface\n"; } - // device.getConfig().remove("^interface "+params.get(0)+" ip nat "+params.get(1)); } else{ --- 1020,1046 ---- } public String no_call(Vector<String> params){ ! String out = ""; if(device instanceof ApplicationLayerDevice){ ! if(params.size()==2 || params.size()==1){ try { ! NetworkInterface ni = device.getNetworkInterface(params.get(0)); ! if(params.size()==1){ ! ni.setNAT(NetworkInterface.NO_NAT); ! } ! else{ ! String natt = params.get(1); ! if(natt.equalsIgnoreCase("inside") && ni.getNAT()==NetworkInterface.INSIDE_NAT){ ! ni.setNAT(NetworkInterface.NO_NAT); ! } ! else if(natt.equalsIgnoreCase("outside") && ni.getNAT()==NetworkInterface.OUTSIDE_NAT){ ! ni.setNAT(NetworkInterface.NO_NAT); ! } ! else{ ! out += "error: invalid parameter '"+natt+"'\n"; ! } ! } } catch (InvalidNetworkInterfaceNameException ex) { out += "error: invalid inferface\n"; } } else{ *************** *** 2059,2066 **** } if(add){ ! //nat.inside.src.list.add(iacl,poolname,overload); } else{ ! //nat.inside.src.list.remove(iacl,poolname); } } --- 2087,2144 ---- } if(add){ ! if(overload){ ! NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = false; ! rule.pool = true; ! rule.acl = iacl; ! rule.out_int = poolname; ! device.getNAT().addRule(rule); ! } ! else{ ! out += "error: parameter 'overload' expected\n"; ! } } else{ ! Vector<Integer> finds = device.getNAT().findRules(false, true, iacl, "", 0, "", 0, poolname); ! if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); ! } ! else{ ! out += "error: record not found\n"; ! } ! } ! } ! else if(params.get(1).equalsIgnoreCase("interface")){ ! String intname = params.get(2); ! try { ! device.getNetworkInterface(intname); ! boolean overload = false; ! if(params.size()==4){ ! overload = params.get(3).equalsIgnoreCase("overload"); ! } ! if(add){ ! if(overload){ ! NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.dynamic = false; ! rule.pool = false; ! rule.acl = iacl; ! rule.out_int = intname; ! device.getNAT().addRule(rule); ! } ! else{ ! out += "error: parameter 'overload' expected\n"; ! } ! } ! else{ ! Vector<Integer> finds = device.getNAT().findRules(false, false, iacl, "", 0, "", 0, intname); ! if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); ! } ! else{ ! out += "error: record not found\n"; ! } ! } ! } catch (InvalidNetworkInterfaceNameException e) { ! out += "error: invalid interface name\n"; } } *************** *** 2086,2091 **** public ip_nat_inside_source_static_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "(ip|tcp|udp) <local ip> [<local port>] <global ip> [<global ip>]"; ! no_call_params = "(ip|tcp|udp) <local ip> [<local port>] <global ip> [<global ip>]"; } public String call(Vector<String> params){ --- 2164,2169 ---- public ip_nat_inside_source_static_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "(ip|tcp|udp) <local ip> [<local port>] <global ip> [<global port>]"; ! no_call_params = "(ip|tcp|udp) <local ip> [<local port>] <global ip> [<global port>]"; } public String call(Vector<String> params){ *************** *** 2096,2106 **** } private String parse(Vector<String> params, boolean add){ ! int IP_protocol = 0; ! int TCP_protocol = 1; ! int UDP_protocol = 2; String out = ""; if(params.size()==3 || params.size()==5){ try{ String sprotocol = params.get(0); int protocol = -1; --- 2174,2185 ---- } private String parse(Vector<String> params, boolean add){ ! int IP_protocol = NAT_rule.IP; ! int TCP_protocol = NAT_rule.TCP; ! int UDP_protocol = NAT_rule.UDP; String out = ""; if(params.size()==3 || params.size()==5){ try{ + boolean valid = true; String sprotocol = params.get(0); int protocol = -1; *************** *** 2131,2142 **** } } ! if(IPV4Address.validateDecIP(local_ip) && IPV4Address.validateDecIP(global_ip)){ if(add){ ! //nat.inside.src.static.add(protocol, local_ip, local_port, global_ip, global_port); } else{ ! //nat.inside.src.static.remove(protocol, local_ip, local_port, global_ip, global_port); } } } catch(NumberFormatException e){ --- 2210,2245 ---- } } ! else{ ! valid = false; ! } ! if(valid && IPV4Address.validateDecIP(local_ip) && IPV4Address.validateDecIP(global_ip)){ if(add){ ! NAT_rule rule = device.getNAT().new NAT_rule(); ! rule.in_ip = local_ip; ! rule.out_ip = global_ip; ! rule.in_port = local_port; ! rule.out_port = local_port; ! rule.protocol = protocol; ! rule.dynamic = false; ! rule.pool = false; ! device.getNAT().addRule(rule); } else{ ! Vector<Integer> finds; ! if(params.size()==3) ! finds = device.getNAT().findRules(false, false, 0, local_ip, 0, global_ip, 0, ""); ! else ! finds = device.getNAT().findRules(false, false, 0, local_ip, local_port, global_ip, global_port, ""); ! if(finds.size()>0){ ! device.getNAT().removeRule(finds.get(0).intValue()); ! } ! else{ ! out += "error: nat rule not found\n"; ! } } } + else{ + out += "error: invalid parameters\n"; + } } catch(NumberFormatException e){ *************** *** 2163,2167 **** } private String parse(Vector<String> params, boolean add){ ! String out = ""; if(params.size()==3){ String poolname = params.get(0); --- 2266,2270 ---- } private String parse(Vector<String> params, boolean add){ ! String out = "Command not supported yet\n"; if(params.size()==3){ String poolname = params.get(0); *************** *** 2817,2820 **** --- 2920,2955 ---- } }; + class show_ip_nat_translation_CommandClass extends CommandInterface{ + public show_ip_nat_translation_CommandClass(){ + modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(params.size()==0){ + out += "Protocol Inside Outside\n"; + NATEngine nat = device.getNAT(); + for(int i=0; i<nat.countRules(); i++){ + NAT_rule rule = nat.getRule(i); + String inside = rule.in_ip; + if(rule.in_port>0) inside += ":"+rule.in_port; + String outside = rule.out_ip; + if(rule.out_port>0) outside += ":"+rule.out_port; + String protocol = ""; + switch(rule.protocol){ + case NAT_rule.IP: protocol="ip"; break; + case NAT_rule.ICMP: protocol="icmp"; break; + case NAT_rule.UDP: protocol="udp"; break; + case NAT_rule.TCP: protocol="tcp"; break; + } + out += String.format("%-12s%-23s%s\n", protocol, inside, outside); + } + } + else{ + out += "error: invalid parameters\n"; + } + return out; + } + }; class show_kron_CommandClass extends CommandInterface{ public show_kron_CommandClass(){ Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** DeviceConfig.java 5 Oct 2008 18:08:55 -0000 1.17 --- DeviceConfig.java 10 Oct 2008 22:18:05 -0000 1.18 *************** *** 16,19 **** --- 16,21 ---- import java.util.regex.PatternSyntaxException; import core.CommandInterface.Modes; + import core.NATEngine.NAT_rule; + import java.util.Enumeration; import java.util.Hashtable; *************** *** 457,460 **** --- 459,467 ---- if(ni.getACLout()!=0) conf.add("interface "+intName+" ip access-group "+ni.getACLout()+" out"); + switch(ni.getNAT()){ + case NetworkInterface.NO_NAT: break; + case NetworkInterface.INSIDE_NAT: conf.add("interface "+intName+" ip nat inside"); break; + case NetworkInterface.OUTSIDE_NAT: conf.add("interface "+intName+" ip nat outside"); break; + } if(!ni.unreachables) conf.add("no interface "+intName+" ip unreachables"); *************** *** 560,564 **** --- 567,600 ---- } + protected void fillIP(LinkedList conf){ + if(device instanceof NetworkLayerDevice){ + NetworkLayerDevice ndev = (NetworkLayerDevice)device; + NATEngine nat = ndev.getNAT(); + for(int i=0; i<nat.countRules(); i++){ + String params; + NAT_rule rule = nat.getRule(i); + if(!rule.dynamic){ + if(rule.acl>0){ + params = " list "+rule.acl; + params += (rule.pool?" pool ":" interface ")+rule.out_int; + } + else{ + params = " static"; + switch(rule.protocol){ + case NAT_rule.IP: params+=" ip"; break; + case NAT_rule.ICMP: params+=" icmp"; break; + case NAT_rule.UDP: params+=" udp"; break; + case NAT_rule.TCP: params+=" tcp"; break; + } + params += " "+rule.in_ip; + if(rule.in_port>0) params += " "+rule.in_port; + params += " "+rule.out_ip; + if(rule.out_port>0) params += " "+rule.out_port; + } + conf.add("ip nat inside source"+params); + } + } + } if(device instanceof ApplicationLayerDevice){ DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** NetworkInterface.java 7 Oct 2008 08:25:02 -0000 1.18 --- NetworkInterface.java 10 Oct 2008 22:18:05 -0000 1.19 *************** *** 197,202 **** public final static int NO_NAT = 0; ! public final static int INSIDE_NAT = 0; ! public final static int OUTSIDE_NAT = 1; private int NAT_STATUS = 0; --- 197,202 ---- public final static int NO_NAT = 0; ! public final static int INSIDE_NAT = 1; ! public final static int OUTSIDE_NAT = 2; private int NAT_STATUS = 0; |
|
From: Alexander B. <da...@us...> - 2008-10-07 08:29:25
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17763/core Modified Files: NetworkInterface.java NetworkLayerDevice.java Added Files: NATEngine.java Log Message: Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** NetworkLayerDevice.java 3 Oct 2008 22:29:10 -0000 1.19 --- NetworkLayerDevice.java 7 Oct 2008 08:25:02 -0000 1.20 *************** *** 48,52 **** */ public abstract class NetworkLayerDevice extends Node { ! private DeviceConfig config = new DeviceConfig(this); private AccessListEngine acls = new AccessListEngine(this); --- 48,52 ---- */ public abstract class NetworkLayerDevice extends Node { ! private DeviceConfig config = new DeviceConfig(this); private AccessListEngine acls = new AccessListEngine(this); *************** *** 125,129 **** */ public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! if(NodeProtocolStack != null) NodeProtocolStack.receivePacket(inPacket, inInterface); } --- 125,139 ---- */ public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! ! try{ ! if(this.getNetworkInterface(inInterface).getNAT() == 1){ ! ! }else if(this.getNetworkInterface(inInterface).getNAT() == 2){ ! ! } ! }catch(InvalidNetworkInterfaceNameException e){ } ! ! if(NodeProtocolStack != null) ! NodeProtocolStack.receivePacket(inPacket, inInterface); } --- NEW FILE: NATEngine.java --- package core; import java.util.Vector; public class NATEngine { NetworkLayerDevice parentNode; public class NAT_rule{ public boolean dynamic = false; // false -- static, true -- dymanic public boolean pool = false; // false -- int, true -- pool public int acl = 0; // acl number for dynamic public String in_ip = ""; public int in_port = 0; public String out_ip = ""; public String out_int = ""; //or pool public int out_port = 0; } Vector<NAT_rule> rules; public NATEngine(NetworkLayerDevice node){ parentNode = node; rules = new Vector<NAT_rule>(); } } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** NetworkInterface.java 5 Oct 2008 19:12:30 -0000 1.17 --- NetworkInterface.java 7 Oct 2008 08:25:02 -0000 1.18 *************** *** 196,199 **** --- 196,212 ---- } + public final static int NO_NAT = 0; + public final static int INSIDE_NAT = 0; + public final static int OUTSIDE_NAT = 1; + + private int NAT_STATUS = 0; + + public void setNAT(int nat){ + NAT_STATUS = nat; + } + + public int getNAT(){ + return NAT_STATUS; + } public boolean isActive(){ |
|
From: Alexander B. <da...@us...> - 2008-10-06 13:25:03
|
Update of /cvsroot/javanetsim/javaNetSim In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18909 Modified Files: README.txt Log Message: Index: README.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/README.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** README.txt 9 Sep 2008 09:16:09 -0000 1.16 --- README.txt 6 Oct 2008 13:20:39 -0000 1.17 *************** *** 3,7 **** ################################### ! Version: Public Release Version 0.34 Website: http://sf.net/projects/javanetsim Authors: See 'About' menu. --- 3,7 ---- ################################### ! Version: Public Release Version 0.40 Website: http://sf.net/projects/javanetsim Authors: See 'About' menu. *************** *** 24,28 **** to start the Graphical User Interface. ! Note: The Java Network Simulator has only been fully tested under WinXP/WinVista and Linux (Gentoo/Fedora). While there should be no problem running on other platforms, unexpected results may possibly occur. --- 24,28 ---- to start the Graphical User Interface. ! Note: The Java Network Simulator has only been fully tested under WinXP/WinVista, OpenBSD and Linux (Gentoo/Fedora). While there should be no problem running on other platforms, unexpected results may possibly occur. *************** *** 32,35 **** --- 32,53 ---- ********************* + ***** Release Version 0.40 1st November 2008 ***** + + Fixed + ----- + + GUI Issues - + + 1. Fixed some bugs with interface and console. + + New Features + ------------ + + 1. Added wireless interfaces and wireless APs. + 2. New ICMP packets: TIME_EXCEEDED, DEST_UNREACH. + 3. New application protocols: RIP, DNS (with server and client). + 4. New link type: fiber. + + ***** Release Version 0.39 20rd November 2007 ***** |
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18909/core Modified Files: ExternalProxy.java PC.java Printer.java Router.java Simulation.java Version.java W80211_packet.java WiFiPort.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PC.java 27 Sep 2008 08:38:22 -0000 1.23 --- PC.java 6 Oct 2008 13:20:39 -0000 1.24 *************** *** 97,101 **** * @version v0.10 */ ! protected PC(String inName, boolean inOn) { super(inName,7, inOn); } --- 97,101 ---- * @version v0.10 */ ! public PC(String inName, boolean inOn) { super(inName,7, inOn); } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Simulation.java 27 Sep 2008 08:38:22 -0000 1.31 --- Simulation.java 6 Oct 2008 13:20:39 -0000 1.32 *************** *** 30,33 **** --- 30,34 ---- import java.io.Serializable; import java.util.*; + import java.lang.reflect.*; import core.protocolsuite.tcp_ip.IPV4Address; *************** *** 1071,1074 **** --- 1072,1094 ---- } + public void addNode(String ClassName, String inName, boolean inOn)throws InvalidNodeNameException { + try{ + Class cNode = Class.forName( "core." + ClassName ); + + //Class.forName( ClassName ). + + Constructor con = cNode.getConstructor(String.class, Boolean.TYPE); + + if (!nodeTable.containsKey(inName)) { + nodeTable.put(inName, con.newInstance(new Object[]{inName, inOn})); + } else { + throw new InvalidNodeNameException("Node already exists with same name"); + } + }catch(Exception e){ + e.printStackTrace(); + } + return; + } + /** * This method is for creating a PC within the simulation. Index: Printer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Printer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Printer.java 26 Sep 2008 17:53:49 -0000 1.3 --- Printer.java 6 Oct 2008 13:20:39 -0000 1.4 *************** *** 20,24 **** * @version v0.10 */ ! protected Printer(String inName, boolean inOn) { super(inName,7, inOn); } --- 20,24 ---- * @version v0.10 */ ! public Printer(String inName, boolean inOn) { super(inName,7, inOn); } Index: W80211_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/W80211_packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** W80211_packet.java 5 Oct 2008 13:03:47 -0000 1.3 --- W80211_packet.java 6 Oct 2008 13:20:39 -0000 1.4 *************** *** 9,12 **** --- 9,15 ---- public String SSID; + public boolean shared = false; + public int auth_seq = 0; + public String WEP; public int keyNum; *************** *** 29,32 **** --- 32,40 ---- } + public void setAuth(boolean inShared, int seq){ + shared = inShared; + auth_seq = seq; + } + public W80211_packet(Packet inPacket, String inSrc, String inDst, int inType, int inSubType, String inSSID) { Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** WiFiPort.java 5 Oct 2008 20:57:00 -0000 1.10 --- WiFiPort.java 6 Oct 2008 13:20:39 -0000 1.11 *************** *** 26,29 **** --- 26,33 ---- protected String WEP_keys[] = {"", "", "", ""}; + protected boolean isSecureEnabled(){ + return ((new String(WEP_keys[0] + WEP_keys[1] + WEP_keys[2] + WEP_keys[3])).length() > 5); + } + protected static final int OFFLINE = 0; protected static final int PROBE = 1; *************** *** 148,160 **** } ! void sendAuthReq(String inBSSID) throws LowLinkException{ W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Sending auth req packet from interface "+ name); sendWirelessConfirmPacket(tempWiFi); } void sendAssocReq(String inBSSID) throws LowLinkException{ W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); --- 152,189 ---- } ! void sendAuthReq(String inBSSID, int seq) throws LowLinkException{ W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); ! tempWiFi.setAuth(shared_auth, seq); ! ! tempWiFi.Cypher(WEP_keys[0], 0); ! ! if(seq == 0) ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Sending auth req packet from interface "+ name); ! else ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Sending auth challenge reply packet from interface "+ name); sendWirelessConfirmPacket(tempWiFi); } + void sendAuthReply(String inBSSID, int seq) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); + + tempWiFi.setAuth(shared_auth, seq); + + tempWiFi.Cypher(WEP_keys[0], 0); + + if(seq == 1 || !shared_auth) + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Sending auth reply packet from interface "+ name); + else + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Sending auth challenge req packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + void sendAssocReq(String inBSSID) throws LowLinkException{ W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); *************** *** 413,417 **** //&& ! if(tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong WEP params."); --- 442,446 ---- //&& ! if(isSecureEnabled() && !tempWiFi.WEP.trim().equals(WEP_keys[tempWiFi.keyNum].trim()) ){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong WEP params."); *************** *** 496,502 **** Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); - state = ASSOC; ResendPackets.clear(); ! sendAssocReq(apBSSID); }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ ResendPackets.remove(tempWiFi.getID()); --- 525,566 ---- Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); ResendPackets.clear(); ! if(!isSecureEnabled()){ ! state = ASSOC; ! sendAssocReq(apBSSID); ! }else{ ! state = AUTH; ! sendAuthReq(apBSSID, 0); ! } ! }else if(state == AUTH && tempWiFi.Type == 0 && tempWiFi.subType == 11){ ! ! if(!shared_auth && !tempWiFi.shared){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Recieved successful auth reply from " + apBSSID + " on interface "+ name); ! ResendPackets.clear(); ! state = ASSOC; ! sendAssocReq(apBSSID); ! }else if(shared_auth && tempWiFi.shared){ ! if(tempWiFi.auth_seq == 1){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Recieved auth challenge from " + apBSSID + " on interface "+ name); ! ResendPackets.clear(); ! state = AUTH; ! sendAuthReq(apBSSID, 2); ! }else{ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Recieved successful auth reply from " + apBSSID + " on interface "+ name); ! ResendPackets.clear(); ! state = ASSOC; ! sendAssocReq(apBSSID); ! } ! }else{ ! ResendPackets.clear(); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Wrong 802.11 protocol action!"); ! failed=true; ! associated=false; ! DOWN(); ! } ! }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ ResendPackets.remove(tempWiFi.getID()); *************** *** 528,531 **** --- 592,626 ---- sendProbeReply(tempWiFi.getSrcBSSID(), tempWiFi.getID()); + }else if(tempWiFi.Type == 0 && tempWiFi.subType == 11){ + if(APClients.get(tempWiFi.getSrcBSSID()) != null){ + APClients.put(tempWiFi.getSrcBSSID() , new APClient(tempWiFi.getSrcBSSID())); + } + + if(!shared_auth && !tempWiFi.shared){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Recieved auth req from " + apBSSID + " on interface "+ name); + ResendPackets.clear(); + state = AUTH; + sendAuthReply(tempWiFi.getSrcBSSID(), 1); + }else if(shared_auth && tempWiFi.shared){ + if(tempWiFi.auth_seq == 0){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Recieved auth req from " + apBSSID + " on interface "+ name); + ResendPackets.clear(); + state = AUTH; + sendAuthReply(tempWiFi.getSrcBSSID(), 1); + }else{ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Recieved auth challenge reply from " + apBSSID + " on interface "+ name); + ResendPackets.clear(); + state = AUTH; + sendAuthReply(tempWiFi.getSrcBSSID(), 3); + } + }else{ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Wrong 802.11 protocol action!"); + if(APClients.get(tempWiFi.getSrcBSSID()) != null){ + APClients.remove(tempWiFi.getSrcBSSID()); + } + } }else if(tempWiFi.Type == 0 && tempWiFi.subType == 0){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", *************** *** 572,575 **** --- 667,673 ---- W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, tempPacket.getDestinationMACAddress(), 2, 0, SSID); + + if(isSecureEnabled()) + tempWiFi.Cypher(WEP_keys[0], 0); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", *************** *** 604,607 **** --- 702,708 ---- W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, apBSSID, 2, 0, SSID); + if(isSecureEnabled()) + tempWiFi.Cypher(WEP_keys[0], 0); + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", "Link", "Sending packet from interface " + name + " to " + tempWiFi.getDstBSSID()); Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Router.java 26 Sep 2008 17:53:49 -0000 1.10 --- Router.java 6 Oct 2008 13:20:39 -0000 1.11 *************** *** 52,56 **** * @version v0.10 **/ ! protected Router(String inName, boolean inOn) { super(inName,7, inOn); } --- 52,56 ---- * @version v0.10 **/ ! public Router(String inName, boolean inOn) { super(inName,7, inOn); } Index: Version.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Version.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Version.java 20 Nov 2007 19:17:09 -0000 1.15 --- Version.java 6 Oct 2008 13:20:39 -0000 1.16 *************** *** 40,45 **** */ public class Version { ! public final static String CORE_VERSION = "v0.39"; //version of the simulation core ! public final static String YEARS = "2005 - 2007"; public static final String TEAM_MEMBERS[] = { --- 40,45 ---- */ public class Version { ! public final static String CORE_VERSION = "v0.40"; //version of the simulation core ! public final static String YEARS = "2005 - 2008"; public static final String TEAM_MEMBERS[] = { *************** *** 48,55 **** "from 03 Nov 2005","", "Alexander Bolshev [Key]", "Project Leader / Developer / Maintainer", - "Ilgar Alekperov [Gift]", "Developer / Tester", "Konstantin Karpov [QweR]", "Developer / Tester", ! "", "If you found a bug, please post it to: http://sf.net/tracker/?atid=784685&group_id=152576", ! "", "Get information about latest releases at rss:", "http://sf.net/export/rss2_projfiles.php?group_id=152576", "and about latest news at rss:", "http://sf.net/export/rss2_projnews.php?group_id=152576&rss_fulltext=1" /*, "Semester 2, 2004", "", "Angela Brown " , "Project Manager / Documentation Manager / Developer ", --- 48,58 ---- "from 03 Nov 2005","", "Alexander Bolshev [Key]", "Project Leader / Developer / Maintainer", "Konstantin Karpov [QweR]", "Developer / Tester", ! "","Contributors & Old Developers:", ! "Ilgar Alekperov [Gift]", "\t First version of TCP, Echo TCP, Export to HTML, Testing & Bugfixinig", ! "Igor Goroshkov", "\t RIP protocol core & GUI", ! "", "If you found a bug, please post it to: http://sf.net/tracker/?atid=784685&group_id=152576", ! ! //"", "Get information about latest releases at rss:", "http://sf.net/export/rss2_projfiles.php?group_id=152576", "and about latest news at rss:", "http://sf.net/export/rss2_projnews.php?group_id=152576&rss_fulltext=1" /*, "Semester 2, 2004", "", "Angela Brown " , "Project Manager / Documentation Manager / Developer ", *************** *** 60,64 **** "Semester 1, 2004", "", "Tristan Veness " , "Project Manager / Developer ", ! "James Nikolaidis" , "Developer ", ! */}; }//EOF --- 63,67 ---- "Semester 1, 2004", "", "Tristan Veness " , "Project Manager / Developer ", ! "James Nikolaidis" , "Developer ",*/ ! }; }//EOF Index: ExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ExternalProxy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExternalProxy.java 26 Sep 2008 17:53:48 -0000 1.4 --- ExternalProxy.java 6 Oct 2008 13:20:39 -0000 1.5 *************** *** 66,73 **** * @version v0.10 **/ ! protected ExternalProxy(String inName, boolean inOn) { super(inName,3, inOn); NodeProtocolStack.initNAT(); - addNetworkInterface("eth0", NetworkInterface.Ethernet10T, true, 0 ); externalIP = null; Apps = new Hashtable(); --- 66,72 ---- * @version v0.10 **/ ! public ExternalProxy(String inName, boolean inOn) { super(inName,3, inOn); NodeProtocolStack.initNAT(); externalIP = null; Apps = new Hashtable(); |
|
From: Alexander B. <da...@us...> - 2008-10-06 13:21:43
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18909/guiUI Modified Files: ApplicationLayerDevice.java GuiCSUDSU.java GuiExternalProxy.java GuiHub.java GuiNode.java GuiPC.java GuiPrinter.java GuiRouter.java GuiSwitch.java GuiWirelessAP.java MainScreen.java MenuBar.java SandBox.java SimulationToolBar.java Log Message: Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MenuBar.java 26 Sep 2008 17:53:49 -0000 1.19 --- MenuBar.java 6 Oct 2008 13:20:39 -0000 1.20 *************** *** 1,3 **** --- 1,4 ---- package guiUI; + import core.Version; *************** *** 8,12 **** /** ! * <P>The MenuBar class is the menubar that is used for the MainScreen class</P> * * @author VC2 Team --- 9,15 ---- /** ! * <P> ! * The MenuBar class is the menubar that is used for the MainScreen class ! * </P> * * @author VC2 Team *************** *** 15,165 **** */ ! public class MenuBar extends JMenuBar ! { private MainScreen controller; ! ! //File menu private JMenu mnuFile = new JMenu("File"); ! private JMenuItem mnuNew = new JMenuItem("New"); //Create new simulation ! ! ! private JMenuItem mnuOpen = new JMenuItem("Open ..."); //Open a old simulation ! ! private JMenuItem mnuSave = new JMenuItem("Save ..."); //Save a simulation ! private JMenuItem mnuSaveAs = new JMenuItem("Save As..."); //Save a simulation ! //HTML report generator menu ! ! private JMenuItem mnuImport = new JMenuItem("Import ..."); //Open a old simulation ! private JMenuItem mnuGenRep = new JMenuItem("Export to HTML ..."); ! private JMenuItem mnuExit = new JMenuItem("Exit"); //Exit appliction ! //private JMenuItem mnuClose = new JMenuItem("Close"); //Close ! ! //Simulation menu ! private JMenu mnuSimulation = new JMenu("Simulation"); //Simulation menu private JMenu mnuEnvironment = new JMenu("Enviroment"); private JMenuItem mnuClearConsole = new JMenuItem("Clear Console"); ! private JMenuItem mnuClearNodeInformation = new JMenuItem("Clear Node Information"); ! private JMenu mnuFilters = new JMenu("Show simulation messages for:"); ! private JMenu mnuFilters2 = new JMenu("Show headers:"); ! //Filters menu ! ! private JCheckBoxMenuItem mnuLayers = new JCheckBoxMenuItem("for Layers",true); ! private JCheckBoxMenuItem mnuPackets = new JCheckBoxMenuItem("for Packet Names",true); ! ! private JCheckBoxMenuItem mnuMsgLinkLayer = new JCheckBoxMenuItem("Link and DataLink Layers",true); ! private JCheckBoxMenuItem mnuMsgARP = new JCheckBoxMenuItem("ARP",true); ! private JCheckBoxMenuItem mnuMsgNetwork = new JCheckBoxMenuItem("Network Layer",true); ! private JCheckBoxMenuItem mnuMsgTransport = new JCheckBoxMenuItem("Transport Layer",true); ! private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! ! //Add submenu ! private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation ! private JMenuItem mnuPC = new JMenuItem("PC ..."); ! private JMenuItem mnuRouter = new JMenuItem("Router ..."); ! private JMenuItem mnuHub = new JMenuItem("Hub ..."); ! private JMenuItem mnuSwitch = new JMenuItem("Switch ..."); ! private JMenuItem mnuCSUDSU = new JMenuItem("CSU/DSU device..."); ! private JMenuItem mnuPrinter = new JMenuItem("Printer..."); ! private JMenuItem mnuExternalNAT = new JMenuItem("Socks Proxy..."); ! private JMenuItem mnuAP = new JMenuItem("Access Point..."); ! ! ! //help menu private JMenu mnuHelp = new JMenu("Help"); ! private JMenuItem mnuAbout = new JMenuItem("About..."); private JMenuItem mnuHelpPane = new JMenuItem("ReadMe/ChangeLog"); ! ! /** * Constucts the Menubar ! * @param inController The JFrame that the Menu will be attached to. */ ! public MenuBar(MainScreen inController){ controller = inController; ! buildMenu(); } ! /** ! * Intilizes all the menu buttons to their respective menu structure, associates action listeners ! * and sets mnemonics for all menu buttons. ! * */ - - private void buildMenu(){ ! mnuNew.setAccelerator(KeyStroke.getKeyStroke("ctrl N")); ! mnuOpen.setAccelerator(KeyStroke.getKeyStroke("ctrl O")); ! mnuSave.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); ! mnuPC.setAccelerator(KeyStroke.getKeyStroke("ctrl P")); ! mnuRouter.setAccelerator(KeyStroke.getKeyStroke("ctrl R")); ! mnuHub.setAccelerator(KeyStroke.getKeyStroke("ctrl H")); ! mnuSwitch.setAccelerator(KeyStroke.getKeyStroke("ctrl W")); ! mnuGenRep.setAccelerator(KeyStroke.getKeyStroke("ctrl G")); ! ! mnuClearConsole.setAccelerator(KeyStroke.getKeyStroke("F3")); ! mnuClearNodeInformation.setAccelerator(KeyStroke.getKeyStroke("F4")); ! ! mnuMsgLinkLayer.setAccelerator(KeyStroke.getKeyStroke("F9")); ! mnuMsgNetwork.setAccelerator(KeyStroke.getKeyStroke("F10")); ! mnuMsgTransport.setAccelerator(KeyStroke.getKeyStroke("F11")); ! mnuMsgApplication.setAccelerator(KeyStroke.getKeyStroke("F12")); ! ! mnuHelpPane.setAccelerator(KeyStroke.getKeyStroke("F1")); ! mnuExit.setAccelerator(KeyStroke.getKeyStroke("ctrl + Q")); ! ! mnuLayers.setAccelerator(KeyStroke.getKeyStroke("F7")); ! mnuPackets.setAccelerator(KeyStroke.getKeyStroke("F8")); ! ! //Add items to file menu mnuFile.add(mnuNew); mnuFile.add(mnuOpen); ! mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); ! mnuFile.addSeparator(); ! mnuFile.add(mnuImport); ! mnuFile.add(mnuGenRep); ! mnuFile.addSeparator(); mnuFile.add(mnuExit); ! //Add items to simulation menu ! mnuSimulation.add(mnuAdd); ! mnuAdd.add(mnuPC); ! mnuAdd.add(mnuRouter); ! mnuAdd.add(mnuHub); ! mnuAdd.add(mnuSwitch); ! mnuAdd.add(mnuCSUDSU); ! mnuAdd.add(mnuExternalNAT); ! mnuAdd.add(mnuPrinter); ! mnuAdd.add(mnuAP); ! ! ! //mnuSimulation.add(mnuScenario); ! //mnuScenario.add(mnuTest1); ! //mnuScenario.add(mnuTest2); ! //mnuScenario.add(mnuTest3); ! //mnuScenario.add(mnuTest4); ! mnuEnvironment.add(mnuClearConsole); mnuEnvironment.add(mnuClearNodeInformation); ! mnuEnvironment.add(mnuFilters); ! mnuEnvironment.add(mnuFilters2); ! ! mnuFilters2.add(mnuLayers); ! mnuFilters2.add(mnuPackets); ! ! mnuFilters.add(mnuMsgLinkLayer); ! //mnuFilters.add(mnuMsgARP); ! mnuFilters.add(mnuMsgNetwork); ! mnuFilters.add(mnuMsgTransport); ! mnuFilters.add(mnuMsgApplication); ! ! //Add items to help mnuHelp.add(mnuHelpPane); ! mnuHelp.add(mnuAbout); ! // Set up Mnemonics for menu bar. ! mnuFile.setMnemonic('F'); mnuNew.setMnemonic('N'); --- 18,170 ---- */ ! public class MenuBar extends JMenuBar { private MainScreen controller; ! ! // File menu private JMenu mnuFile = new JMenu("File"); ! ! private JMenuItem mnuNew = new JMenuItem("New"); // Create new simulation ! ! private JMenuItem mnuOpen = new JMenuItem("Open ..."); // Open a old ! // simulation ! ! private JMenuItem mnuSave = new JMenuItem("Save ..."); // Save a simulation ! ! private JMenuItem mnuSaveAs = new JMenuItem("Save As..."); // Save a ! // simulation ! ! // HTML report generator menu ! ! private JMenuItem mnuImport = new JMenuItem("Import ..."); // Open a old ! // simulation ! ! private JMenuItem mnuGenRep = new JMenuItem("Export to HTML ..."); ! ! private JMenuItem mnuExit = new JMenuItem("Exit"); // Exit appliction ! ! // private JMenuItem mnuClose = new JMenuItem("Close"); //Close ! ! // Simulation menu ! private JMenu mnuSimulation = new JMenu("Simulation"); // Simulation menu ! private JMenu mnuEnvironment = new JMenu("Enviroment"); + private JMenuItem mnuClearConsole = new JMenuItem("Clear Console"); ! ! private JMenuItem mnuClearNodeInformation = new JMenuItem( ! "Clear Node Information"); ! ! private JMenu mnuFilters = new JMenu("Show simulation messages for:"); ! ! private JMenu mnuFilters2 = new JMenu("Show headers:"); ! ! // Filters menu ! ! private JCheckBoxMenuItem mnuLayers = new JCheckBoxMenuItem("for Layers", ! true); ! ! private JCheckBoxMenuItem mnuPackets = new JCheckBoxMenuItem( ! "for Packet Names", true); ! ! private JCheckBoxMenuItem mnuMsgLinkLayer = new JCheckBoxMenuItem( ! "Link and DataLink Layers", true); ! ! private JCheckBoxMenuItem mnuMsgARP = new JCheckBoxMenuItem("ARP", true); ! ! private JCheckBoxMenuItem mnuMsgNetwork = new JCheckBoxMenuItem( ! "Network Layer", true); ! ! private JCheckBoxMenuItem mnuMsgTransport = new JCheckBoxMenuItem( ! "Transport Layer", true); ! ! private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem( ! "Application Layer", true); ! ! // Add submenu ! public JMenu mnuAdd = new JMenu("Add Device"); // For Adding objects to ! // simulation ! ! // help menu private JMenu mnuHelp = new JMenu("Help"); ! ! private JMenuItem mnuAbout = new JMenuItem("About..."); ! private JMenuItem mnuHelpPane = new JMenuItem("ReadMe/ChangeLog"); ! /** * Constucts the Menubar ! * ! * @param inController ! * The JFrame that the Menu will be attached to. */ ! public MenuBar(MainScreen inController) { controller = inController; ! buildMenu(); } ! /** ! * Intilizes all the menu buttons to their respective menu structure, ! * associates action listeners and sets mnemonics for all menu buttons. ! * */ ! private void buildMenu() { ! ! mnuNew.setAccelerator(KeyStroke.getKeyStroke("ctrl N")); ! mnuOpen.setAccelerator(KeyStroke.getKeyStroke("ctrl O")); ! mnuSave.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); ! ! mnuGenRep.setAccelerator(KeyStroke.getKeyStroke("ctrl G")); ! ! mnuClearConsole.setAccelerator(KeyStroke.getKeyStroke("F3")); ! mnuClearNodeInformation.setAccelerator(KeyStroke.getKeyStroke("F4")); ! ! mnuMsgLinkLayer.setAccelerator(KeyStroke.getKeyStroke("F9")); ! mnuMsgNetwork.setAccelerator(KeyStroke.getKeyStroke("F10")); ! mnuMsgTransport.setAccelerator(KeyStroke.getKeyStroke("F11")); ! mnuMsgApplication.setAccelerator(KeyStroke.getKeyStroke("F12")); ! ! mnuHelpPane.setAccelerator(KeyStroke.getKeyStroke("F1")); ! mnuExit.setAccelerator(KeyStroke.getKeyStroke("ctrl + Q")); ! ! mnuLayers.setAccelerator(KeyStroke.getKeyStroke("F7")); ! mnuPackets.setAccelerator(KeyStroke.getKeyStroke("F8")); ! ! // Add items to file menu mnuFile.add(mnuNew); mnuFile.add(mnuOpen); ! mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); ! mnuFile.addSeparator(); ! mnuFile.add(mnuImport); ! mnuFile.add(mnuGenRep); ! mnuFile.addSeparator(); mnuFile.add(mnuExit); ! // Add items to simulation menu ! mnuSimulation.add(mnuAdd); ! mnuEnvironment.add(mnuClearConsole); mnuEnvironment.add(mnuClearNodeInformation); ! mnuEnvironment.add(mnuFilters); ! mnuEnvironment.add(mnuFilters2); ! ! mnuFilters2.add(mnuLayers); ! mnuFilters2.add(mnuPackets); ! ! mnuFilters.add(mnuMsgLinkLayer); ! // mnuFilters.add(mnuMsgARP); ! mnuFilters.add(mnuMsgNetwork); ! mnuFilters.add(mnuMsgTransport); ! mnuFilters.add(mnuMsgApplication); ! ! // Add items to help mnuHelp.add(mnuHelpPane); ! mnuHelp.add(mnuAbout); ! // Set up Mnemonics for menu bar. ! mnuFile.setMnemonic('F'); mnuNew.setMnemonic('N'); *************** *** 168,181 **** mnuSaveAs.setMnemonic('a'); mnuExit.setMnemonic('x'); ! mnuSimulation.setMnemonic('S'); mnuAdd.setMnemonic('A'); ! ! mnuPC.setMnemonic('P'); ! mnuRouter.setMnemonic('R'); ! mnuHub.setMnemonic('H'); ! mnuGenRep.setMnemonic('G'); ! //mnuSwitch.setMnemonic('S'); ! mnuEnvironment.setMnemonic('E'); mnuClearConsole.setMnemonic('C'); --- 173,182 ---- mnuSaveAs.setMnemonic('a'); mnuExit.setMnemonic('x'); ! mnuSimulation.setMnemonic('S'); mnuAdd.setMnemonic('A'); ! ! mnuGenRep.setMnemonic('G'); ! mnuEnvironment.setMnemonic('E'); mnuClearConsole.setMnemonic('C'); *************** *** 183,426 **** mnuHelp.setMnemonic('H'); mnuAbout.setMnemonic('A'); ! //mnuHelpPane.setMnemonic('H'); ! ! ! ! //Add action listener to generate html report menuitem ! mnuGenRep.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.save_html_rep(null); ! } ! }); ! ! //Add action listener to new Pc menuitem ! mnuPC.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.PC_CURSOR); ! } ! }); ! ! //Add action listener to new CSU/DSU menuitem ! mnuCSUDSU.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.CSUDSU_CURSOR); ! } ! }); ! ! //Add action listener to new router menuitem ! mnuRouter.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.ROUTER_CURSOR); ! } ! }); ! ! ! //Add action listener to new hub ! mnuHub.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.HUB_CURSOR); ! } ! }); ! ! //Add action listener to new hub ! mnuExternalNAT.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.EXTERNALNAT_CURSOR); ! } ! }); ! ! ! //Add action listener to new hub ! mnuPrinter.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.PRINTER_CURSOR); ! } ! }); ! ! mnuAP.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.AP_CURSOR); ! } ! }); ! ! ! mnuMsgLinkLayer.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter(0,!controller.getFilter(0)); } }); ! ! mnuLayers.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter2(1,!controller.getFilter2(1)); } }); ! ! mnuPackets.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter2(0,!controller.getFilter2(0)); } }); ! ! mnuMsgARP.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter(1,!controller.getFilter(1)); } }); ! ! mnuMsgNetwork.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter(2,!controller.getFilter(2)); } }); ! ! mnuMsgTransport.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter(3,!controller.getFilter(3)); } }); ! ! mnuMsgApplication.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setFilter(4,!controller.getFilter(4)); } }); ! ! //Add action listener to new switch ! ! mnuSwitch.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.setAllHighlightsOff(); ! controller.addingNode(SandBox.SWITCH_CURSOR); } }); ! ! ! //Add action listener to exit ! mnuExit.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! int result = JOptionPane.showConfirmDialog(null, "Are you sure you wish to quit?", ! "Really Quit?", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); ! ! if(result == JOptionPane.YES_OPTION) ! { ! // Quit the program if Yes is selected. ! controller.quit(); } } }); ! ! //Add action listener to Save menu item ! mnuSave.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! //JOptionPane.showMessageDialog(null,"Sorry this is not yet implemented.","Save Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.Save(); } }); ! ! //Add action listener to Save As menu item ! mnuSaveAs.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! //JOptionPane.showMessageDialog(null,"Sorry this is not yet implemented.","SaveAs Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.SaveAs(null); } }); ! ! //Add action listener to Save menu item ! mnuOpen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! //JOptionPane.showMessageDialog(null,"Sorry this is not yet implemented.","Open Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.Open(); } }); ! ! //Add action listener to Save menu item ! mnuImport.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.Import(); } }); ! //Add action listener to New menu item ! mnuNew.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.clearSaveAs(); controller.refreshMainScreen(); } }); ! ! mnuAbout.addActionListener(new ActionListener() ! { ! public void actionPerformed(ActionEvent e) ! { // Display message box with info about the project. String strAboutProject; ! strAboutProject = "javaNetSim " + Version.CORE_VERSION + ! "\n\n"; ! ! for(int i=0;i<Version.TEAM_MEMBERS.length;i++) ! { ! strAboutProject = strAboutProject + Version.TEAM_MEMBERS[i] + "\n"; ! } ! JOptionPane.showMessageDialog(null, strAboutProject,"About javaNetSim", ! JOptionPane.INFORMATION_MESSAGE); } }); ! ! mnuClearConsole.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ controller.clearConsole(); } }); ! ! mnuClearNodeInformation.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ controller.clearNodeInformation(); } }); ! /* ! mnuTest1.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.createTest1(); ! } ! }); ! ! mnuTest2.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.createTest2(); ! } ! }); ! ! mnuTest3.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.createTest3(); ! } ! }); ! ! mnuTest4.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.createTest4(); ! } ! }); ! */ ! mnuHelpPane.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ controller.showHelpPane(); } }); ! ! ! ! //Add menu's to menubar this.add(mnuFile); this.add(mnuSimulation); --- 184,332 ---- mnuHelp.setMnemonic('H'); mnuAbout.setMnemonic('A'); ! ! // Add action listener to generate html report menuitem ! mnuGenRep.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.save_html_rep(null); } }); ! ! mnuMsgLinkLayer.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter(0, !controller.getFilter(0)); } }); ! ! mnuLayers.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter2(1, !controller.getFilter2(1)); } }); ! ! mnuPackets.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter2(0, !controller.getFilter2(0)); } }); ! ! mnuMsgARP.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter(1, !controller.getFilter(1)); } }); ! ! mnuMsgNetwork.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter(2, !controller.getFilter(2)); } }); ! ! mnuMsgTransport.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter(3, !controller.getFilter(3)); } }); ! ! mnuMsgApplication.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.setFilter(4, !controller.getFilter(4)); } }); ! ! // Add action listener to exit ! mnuExit.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! int result = JOptionPane ! .showConfirmDialog(null, ! "Are you sure you wish to quit?", ! "Really Quit?", JOptionPane.YES_NO_OPTION, ! JOptionPane.QUESTION_MESSAGE); ! ! if (result == JOptionPane.YES_OPTION) { ! // Quit the program if Yes is selected. ! controller.quit(); } } }); ! ! // Add action listener to Save menu item ! mnuSave.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! // JOptionPane.showMessageDialog(null,"Sorry this is not yet ! // implemented.","Save Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.Save(); } }); ! ! // Add action listener to Save As menu item ! mnuSaveAs.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! // JOptionPane.showMessageDialog(null,"Sorry this is not yet ! // implemented.","SaveAs Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.SaveAs(null); } }); ! ! // Add action listener to Save menu item ! mnuOpen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! // JOptionPane.showMessageDialog(null,"Sorry this is not yet ! // implemented.","Open Dialog Message", ! // JOptionPane.INFORMATION_MESSAGE); ! controller.Open(); } }); ! ! // Add action listener to Save menu item ! mnuImport.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.Import(); } }); ! // Add action listener to New menu item ! mnuNew.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.clearSaveAs(); controller.refreshMainScreen(); } }); ! ! mnuAbout.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { // Display message box with info about the project. String strAboutProject; ! strAboutProject = "javaNetSim " + Version.CORE_VERSION + "\n\n"; ! ! for (int i = 0; i < Version.TEAM_MEMBERS.length; i++) { ! strAboutProject = strAboutProject + Version.TEAM_MEMBERS[i] ! + "\n"; ! } ! JOptionPane.showMessageDialog(null, strAboutProject, ! "About javaNetSim", JOptionPane.INFORMATION_MESSAGE); } }); ! ! mnuClearConsole.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { controller.clearConsole(); } }); ! ! mnuClearNodeInformation.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { controller.clearNodeInformation(); } }); ! ! mnuHelpPane.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { controller.showHelpPane(); } }); ! ! // Add menu's to menubar this.add(mnuFile); this.add(mnuSimulation); *************** *** 429,431 **** --- 335,338 ---- } + } Index: GuiSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiSwitch.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiSwitch.java 15 Oct 2007 18:25:54 -0000 1.3 --- GuiSwitch.java 6 Oct 2008 13:20:39 -0000 1.4 *************** *** 55,58 **** --- 55,60 ---- package guiUI; + import core.Node; + *************** *** 90,93 **** --- 92,139 ---- } + + public void addInterfaces(MainScreen parent, Node node){ + + String[] choices = {"5 Ethernet-TX ports simple switch.", + "8 Ethernet-TX ports switch.", + "12 Ethernet-TX ports switch.", + "24 Ethernet-TX ports switch.", + "12 Ethernet-TX ports with 2 Ethernet-FX switch.", + "24 Ethernet-TX ports with 2 Ethernet-FX switch.", + "12 Ethernet-FX ports with 2 Ethernet-TX switch.", + "24 Ethernet-FX ports with 2 Ethernet-TX switch." + }; + + String choice = parent.getDeviceTypeDialog("Create new switch", "Please choose switch type", choices); + + int tx=0, fx=0; + + if(choice.contains(choices[0])){ + tx = 5; fx = 0; + }else if(choice.contains(choices[1])){ + tx = 8; fx = 0; + }else if(choice.contains(choices[2])){ + tx = 12; fx = 0; + }else if(choice.contains(choices[3])){ + tx = 24; fx = 0; + }else if(choice.contains(choices[4])){ + tx = 12; fx = 2; + }else if(choice.contains(choices[5])){ + tx = 24; fx = 2; + }else if(choice.contains(choices[6])){ + tx = 2; fx = 12; + }else if(choice.contains(choices[7])){ + tx = 2; fx = 24; + } + + for(int i = 0; i < tx; i++){ + node.addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i), core.NetworkInterface.Ethernet10T, false); + } + + for(int i = 0; i < fx; i++){ + node.addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet100FX) + String.valueOf(i), core.NetworkInterface.Ethernet100FX, false); + } + + } } Index: SimulationToolBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SimulationToolBar.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimulationToolBar.java 20 Oct 2007 20:19:46 -0000 1.4 --- SimulationToolBar.java 6 Oct 2008 13:20:39 -0000 1.5 *************** *** 173,179 **** btnNewHub.setToolTipText("Creates a new Hub"); ! btnNewCSUDSU.setToolTipText("Creates a new CSU/DSU device"); ! btnNewPrinter.setToolTipText("Creates a new CSU/DSU device"); --- 173,179 ---- btnNewHub.setToolTipText("Creates a new Hub"); ! btnNewCSUDSU.setToolTipText("Creates a new CSU/DSU device"); ! btnNewPrinter.setToolTipText("Creates a new Printer"); *************** *** 207,211 **** highlightButton(btnNewPC, true); ! controller.addingNode(SandBox.PC_CURSOR); } --- 207,211 ---- highlightButton(btnNewPC, true); ! controller.addingNode("PC"); } *************** *** 222,226 **** highlightButton(btnNewPrinter, true); ! controller.addingNode(SandBox.PRINTER_CURSOR); } --- 222,226 ---- highlightButton(btnNewPrinter, true); ! controller.addingNode("Printer"); } *************** *** 239,243 **** highlightButton(btnNewHub, true); ! controller.addingNode(SandBox.HUB_CURSOR); } --- 239,243 ---- highlightButton(btnNewHub, true); ! controller.addingNode("Hub"); } *************** *** 256,260 **** highlightButton(btnNewCSUDSU, true); ! controller.addingNode(SandBox.CSUDSU_CURSOR); } --- 256,260 ---- highlightButton(btnNewCSUDSU, true); ! controller.addingNode("CSUDSU"); } *************** *** 272,276 **** highlightButton(btnNewRouter, true); ! controller.addingNode(SandBox.ROUTER_CURSOR); } --- 272,276 ---- highlightButton(btnNewRouter, true); ! controller.addingNode("Router"); } *************** *** 292,296 **** highlightButton(btnNewSwitch, true); ! controller.addingNode(SandBox.SWITCH_CURSOR); } --- 292,296 ---- highlightButton(btnNewSwitch, true); ! controller.addingNode("Switch"); } Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GuiPC.java 22 Sep 2008 16:13:22 -0000 1.8 --- GuiPC.java 6 Oct 2008 13:20:39 -0000 1.9 *************** *** 1,59 **** /* ! Java Firewall Simulator (jFirewallSim) ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ package guiUI; import core.InvalidNodeNameException; import java.awt.Dimension; import java.awt.event.ActionEvent; --- 1,61 ---- /* ! Java Firewall Simulator (jFirewallSim) ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ package guiUI; import core.InvalidNodeNameException; + import core.Node; + import java.awt.Dimension; import java.awt.event.ActionEvent; *************** *** 64,223 **** /** ! * <P>The GuiPC class is used to instantiate new PC on the GUI</P> ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! public class GuiPC extends ApplicationLayerDevice { ! ! /** ! * @param inName The name of the PC ! * @param inMainscreen The JFrame that the router will be created on ! */ ! ! private JMenuItem mnuEchoListen = new JMenuItem("Start udp echo server to listen."); ! private JMenuItem mnuEchoSend = new JMenuItem("Send data via udp echo client."); ! private JMenuItem mnuEchotcpListen = new JMenuItem("Start tcp echo server to listen."); ! private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); ! private JMenuItem mnuTelnetListen = new JMenuItem("Start telnet server to listen."); ! private JMenuItem mnuTelnetNoListen = new JMenuItem("Stop telnet server."); ! private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); ! private JMenuItem mnuPosixTelnet = new JMenuItem("RFC(line) telnet client."); ! private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); ! private JMenuItem mnuDHCPD = new JMenuItem("Start DHCP Server"); ! private JMenuItem mnuDNSListen = new JMenuItem("Start DNS server"); ! private JMenuItem mnuDNSSend = new JMenuItem("Send request to DNS server"); ! private JMenuItem mnuDNSEdit = new JMenuItem("Edit DNS-table"); ! ! public GuiPC(String inName, MainScreen inMainScreen){ ! ! super(inName, inMainScreen, "images/simulation/mymac.png"); ! ! mnuEchoListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ controller.EchoServerListen(lblNodeName.getText()); ! ! } }); ! mnuEchoSend.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.EchoSend(lblNodeName.getText()); } }); ! ! mnuEchotcpListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ controller.EchotcpServerListen(lblNodeName.getText()); ! ! } }); ! mnuEchotcpSend.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.EchotcpSend(lblNodeName.getText()); } ! }); ! ! mnuSNMPManager.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.SNMPSendMessage(lblNodeName.getText()); } }); ! ! mnuTelnetListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetListen(lblNodeName.getText()); } }); ! mnuTelnetNoListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetNoListen(lblNodeName.getText()); } }); ! mnuTelnetConnect.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetConnect(lblNodeName.getText()); } }); ! ! mnuPosixTelnet.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.PosixTelnet(lblNodeName.getText()); } }); ! ! mnuDHCPD.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.DHCPD(lblNodeName.getText()); } }); - - mnuDNSListen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - controller.DNSStartServer(lblNodeName.getText()); - } - }); - - mnuDNSSend.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - controller.DNSSendMessage(lblNodeName.getText()); - } - }); - - mnuDNSEdit.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - controller.DNSEditTable(lblNodeName.getText()); - } - }); - ! ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuEchoListen); ! mnuAppLayer.add(mnuEchoSend); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuEchotcpListen); ! mnuAppLayer.add(mnuEchotcpSend); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuSNMPManager); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuTelnetListen); ! mnuAppLayer.add(mnuTelnetNoListen); ! mnuAppLayer.add(mnuTelnetConnect); ! mnuAppLayer.add(mnuPosixTelnet); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDHCPD); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDNSListen); ! mnuAppLayer.add(mnuDNSSend); ! mnuAppLayer.add(mnuDNSEdit); ! } ! } --- 66,244 ---- /** + * + * <P> + * The GuiPC class is used to instantiate new PC on the GUI + * </P> + * + * + * + * @author VC2 Team. + * + * @since 15th November 2004 + * + * @version v0.20 + * + */ ! public class GuiPC extends ApplicationLayerDevice { ! /** ! * ! * @param inName ! * The name of the PC ! * ! * @param inMainscreen ! * The JFrame that the router will be created on ! * ! */ ! private JMenuItem mnuEchoListen = new JMenuItem( ! "Start udp echo server to listen."); ! private JMenuItem mnuEchoSend = new JMenuItem( ! "Send data via udp echo client."); ! private JMenuItem mnuEchotcpListen = new JMenuItem( ! "Start tcp echo server to listen."); ! private JMenuItem mnuEchotcpSend = new JMenuItem( ! "Send data via tcp echo client."); + private JMenuItem mnuTelnetListen = new JMenuItem( + "Start telnet server to listen."); + private JMenuItem mnuTelnetNoListen = new JMenuItem("Stop telnet server."); ! private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); ! private JMenuItem mnuPosixTelnet = new JMenuItem("RFC(line) telnet client."); ! private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); ! private JMenuItem mnuDHCPD = new JMenuItem("Start DHCP Server"); ! private JMenuItem mnuDNSListen = new JMenuItem("Start DNS server"); ! private JMenuItem mnuDNSSend = new JMenuItem("Send request to DNS server"); ! private JMenuItem mnuDNSEdit = new JMenuItem("Edit DNS-table"); ! public GuiPC(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen, "images/simulation/mymac.png"); ! ! mnuEchoListen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { controller.EchoServerListen(lblNodeName.getText()); ! } }); ! mnuEchoSend.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.EchoSend(lblNodeName.getText()); } }); ! ! mnuEchotcpListen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { controller.EchotcpServerListen(lblNodeName.getText()); ! } }); ! mnuEchotcpSend.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.EchotcpSend(lblNodeName.getText()); } ! }); ! ! mnuSNMPManager.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.SNMPSendMessage(lblNodeName.getText()); } }); ! ! mnuTelnetListen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.TelnetListen(lblNodeName.getText()); } }); ! mnuTelnetNoListen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.TelnetNoListen(lblNodeName.getText()); } }); ! mnuTelnetConnect.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.TelnetConnect(lblNodeName.getText()); } }); ! ! mnuPosixTelnet.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.PosixTelnet(lblNodeName.getText()); } }); ! ! mnuDHCPD.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.DHCPD(lblNodeName.getText()); } }); ! mnuDNSListen.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.DNSStartServer(lblNodeName.getText()); ! } ! }); ! ! mnuDNSSend.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! controller.DNSSendMessage(lblNodeName.getText()); ! } ! }); + mnuDNSEdit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + controller.DNSEditTable(lblNodeName.getText()); + } + }); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuEchoListen); ! mnuAppLayer.add(mnuEchoSend); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuEchotcpListen); ! mnuAppLayer.add(mnuEchotcpSend); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuSNMPManager); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuTelnetListen); ! mnuAppLayer.add(mnuTelnetNoListen); ! mnuAppLayer.add(mnuTelnetConnect); ! mnuAppLayer.add(mnuPosixTelnet); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDHCPD); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDNSListen); ! mnuAppLayer.add(mnuDNSSend); ! mnuAppLayer.add(mnuDNSEdit); + } + + public void addInterfaces(MainScreen parent, Node node) { + + node.addNetworkInterface(core.NetworkInterface + .getIntName(core.NetworkInterface.Ethernet10T) + + "0", core.NetworkInterface.Ethernet10T, true, 0); + + node.addNetworkInterface(core.NetworkInterface + .getIntName(core.NetworkInterface.Console) + + "0", core.NetworkInterface.Console, false, 0); + + node.addNetworkInterface(core.NetworkInterface + .getIntName(core.NetworkInterface.Wireless) + + "0", core.NetworkInterface.Wireless, true, 0); + + } + + } Index: GuiExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiExternalProxy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuiExternalProxy.java 22 Nov 2006 21:18:38 -0000 1.1 --- GuiExternalProxy.java 6 Oct 2008 13:20:39 -0000 1.2 *************** *** 28,31 **** --- 28,33 ---- package guiUI; + import core.Node; + /** * <P>The GuiRouter class is used to instantiate new Routers on the GUI</P> *************** *** 46,48 **** --- 48,58 ---- super(inName, inMainScreen,"images/simulation/network_local.png"); } + + public void addInterfaces(MainScreen parent, Node node){ + + node.addNetworkInterface(core.NetworkInterface + .getIntName(core.NetworkInterface.Ethernet10T) + + "0", core.NetworkInterface.Ethernet10T, true, 0); + + } } Index: GuiPrinter.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPrinter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuiPrinter.java 20 Oct 2007 20:19:46 -0000 1.1 --- GuiPrinter.java 6 Oct 2008 13:20:39 -0000 1.2 *************** *** 1,12 **** package guiUI; public class GuiPrinter extends ApplicationLayerDevice { ! public GuiPrinter(String inName, MainScreen inMainScreen){ ! ! super(inName, inMainScreen, "images/simulation/printer.png"); ! } ! } --- 1,20 ---- package guiUI; + import core.Node; public class GuiPrinter extends ApplicationLayerDevice { ! public GuiPrinter(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen, "images/simulation/printer.png"); ! ! } ! ! public void addInterfaces(MainScreen parent, Node node) { + node.addNetworkInterface(core.NetworkInterface + .getIntName(core.NetworkInterface.Ethernet10T) + + "0", core.NetworkInterface.Ethernet10T, true); + + } + } Index: SandBox.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SandBox.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SandBox.java 26 Sep 2008 17:53:49 -0000 1.10 --- SandBox.java 6 Oct 2008 13:20:39 -0000 1.11 *************** *** 53,60 **** public static final int SWITCH_CURSOR = 2; public static final int HUB_CURSOR = 3; ! public static final int EXTERNALNAT_CURSOR = 4; ! public static final int CSUDSU_CURSOR = 5; ! public static final int PRINTER_CURSOR = 6; ! public static final int AP_CURSOR = 7; private Cursor csrDefault = new Cursor(Cursor.DEFAULT_CURSOR); --- 53,60 ---- public static final int SWITCH_CURSOR = 2; public static final int HUB_CURSOR = 3; ! public static final int EXTERNALNAT_CURSOR = 4; ! public static final int CSUDSU_CURSOR = 5; ! public static final int PRINTER_CURSOR = 6; ! public static final int AP_CURSOR = 7; private Cursor csrDefault = new Cursor(Cursor.DEFAULT_CURSOR); *************** *** 65,72 **** private boolean blnPlaceableLocation = false; private int controlX; ! private int controlY; // Create the various cursors for this panel ! private ClassLoader cl = this.getClass().getClassLoader(); Image pcImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/mymac.png")); Cursor customPCCursor = Toolkit.getDefaultToolkit().createCustomCursor(pcImage, cursorLocation, "pcCursor"); --- 65,74 ---- private boolean blnPlaceableLocation = false; private int controlX; ! private int controlY; ! private String cursorClass = ""; // Create the various cursors for this panel ! private ClassLoader cl = this.getClass().getClassLoader(); ! Image pcImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/mymac.png")); Cursor customPCCursor = Toolkit.getDefaultToolkit().createCustomCursor(pcImage, cursorLocation, "pcCursor"); *************** *** 81,91 **** Cursor customHubCursor = Toolkit.getDefaultToolkit().createCustomCursor(hubImage, cursorLocation, "hubCursor"); ! Image externalnatImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/network_local.png")); Cursor customExternalNATCursor = Toolkit.getDefaultToolkit().createCustomCursor(externalnatImage, cursorLocation, "externalnatCursor"); ! Image csudsuImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/csudsu2.png")); Cursor customCSUDSUCursor = Toolkit.getDefaultToolkit().createCustomCursor(csudsuImage, cursorLocation, "csudsuCursor"); ! Image printerImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/printer.png")); Cursor customPrinterCursor = Toolkit.getDefaultToolkit().createCustomCursor(printerImage, cursorLocation, "printerCursor"); --- 83,93 ---- Cursor customHubCursor = Toolkit.getDefaultToolkit().createCustomCursor(hubImage, cursorLocation, "hubCursor"); ! Image externalnatImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/network_local.png")); Cursor customExternalNATCursor = Toolkit.getDefaultToolkit().createCustomCursor(externalnatImage, cursorLocation, "externalnatCursor"); ! Image csudsuImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/csudsu2.png")); Cursor customCSUDSUCursor = Toolkit.getDefaultToolkit().createCustomCursor(csudsuImage, cursorLocation, "csudsuCursor"); ! Image printerImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/printer.png")); Cursor customPrinterCursor = Toolkit.getDefaultToolkit().createCustomCursor(printerImage, cursorLocation, "printerCursor"); *************** *** 101,116 **** pnlLinkLayer = new LinkLayerPanel(); ! this.setLayer(pnlLinkLayer,1,0); this.add(pnlLinkLayer); controller = inMainScreen; ! this.setPreferredSize(new Dimension(7000,7000)); } - - // public void setLayer(Object o, int y, int x) { - // ((GuiNode) o).setVisible(true); - // } - /** * Adds a new line to the LinkLayerPanel --- 103,113 ---- pnlLinkLayer = new LinkLayerPanel(); ! this.setLayer(pnlLinkLayer,1,0); this.add(pnlLinkLayer); controller = inMainScreen; ! this.setPreferredSize(new Dimension(7000,7000)); } /** * Adds a new line to the LinkLayerPanel *************** *** 198,236 **** { ! if(blnPlaceableLocation) { ! if(this.getCursor() == customPCCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addPC(NodeLocation); ! }else if(this.getCursor() == customRouterCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addRouter(NodeLocation); ! }else if(this.getCursor() == customSwitchCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addSwitch(NodeLocation); ! }else if(this.getCursor() == customHubCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addHub(NodeLocation); ! }else if(this.getCursor() == customExternalNATCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addExternalNAT(NodeLocation); ! }else if(this.getCursor() == customCSUDSUCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addCSUDSU(NodeLocation); ! }else if(this.getCursor() == customPrinterCursor){ ! this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addPrinter(NodeLocation); ! }else if(this.getCursor() == customAPCursor){ this.setCursor(csrDefault); ! Point NodeLocation = new Point(e.getX(), e.getY()); ! controller.addAP(NodeLocation); ! } } --- 195,204 ---- { ! if(blnPlaceableLocation && cursorClass.length()>1) { ! this.setCursor(csrDefault); ! controller.addNode(cursorClass, new Point(e.getX(), e.getY())); ! cursorClass = ""; } *************** *** 243,265 **** */ ! public void setCursorType(int cursorType){ ! if(cursorType == PC_CURSOR){ ! this.setCursor(customPCCursor); ! }else if(cursorType == ROUTER_CURSOR){ ! this.setCursor(customRouterCursor); ! }else if(cursorType == SWITCH_CURSOR){ ! this.setCursor(customSwitchCursor); ! }else if(cursorType == HUB_CURSOR){ ! this.setCursor(customHubCursor); ! }else if(cursorType == EXTERNALNAT_CURSOR){ ! this.setCursor(customExternalNATCursor); ! }else if(cursorType == CSUDSU_CURSOR){ ! this.setCursor(customCSUDSUCursor); ! }else if(cursorType == PRINTER_CURSOR){ ! this.setCursor(customPrinterCursor); ! }else if(cursorType == AP_CURSOR){ ! this.setCursor(customAPCursor); ! } } --- 211,219 ---- */ ! public void setCursorType(String nodeType){ ! cursorClass = nodeType; ! ! this.setCursor(controller.nodeTemplates.get(nodeType).getCursor()); } Index: GuiCSUDSU.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiCSUDSU.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuiCSUDSU.java 15 Oct 2007 18:25:54 -0000 1.1 --- GuiCSUDSU.java 6 Oct 2008 13:20:39 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- package guiUI; + import core.Node; + public class GuiCSUDSU extends DataLinkLayerDevice { *************** *** 18,21 **** --- 20,28 ---- } + + public void addInterfaces(MainScreen parent, Node node){ + ((core.CSUDSU)node).addSerialInterface(); + ((core.CSUDSU)node).addWANInterface(); + } } Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** MainScreen.java 5 Oct 2008 18:41:06 -0000 1.90 --- MainScreen.java 6 Oct 2008 13:20:39 -0000 1.91 *************** *** 1,59 **** /* ! Java Firewall Simulator (jFirewallSim) ! Copyright (c) 2004, jFirewallSim development team All rights reserved. [...9114 lines suppressed...] ! } ! } ! ! public void breakLink(String NodeName, String IntName) { ! if (JOptionPane.showConfirmDialog(this, "Disconnect link from port " ! + IntName + " on " + NodeName + "?", "Confirm disconnect!", ! JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { ! try { ! String str = Sim.disconnectLink(NodeName, IntName); ! Sandbox.removeLine(str); ! this.refreshNodeInformationTab(); ! // controller.addToConsole(NodeName +"'s link on interface ! // "+Interface+" has been disconnected!\n"); ! // ^^^FIXME! ! } catch (Exception e) { ! } ! } ! } public Cursor getCurrentSandboxCursor() Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GuiNode.java 9 Sep 2008 09:16:10 -0000 1.7 --- GuiNode.java 6 Oct 2008 13:20:39 -0000 1.8 *************** *** 1,57 **** /* ! Java Firewall Simulator (jFirewallSim) ! ! - Copyright (c) 2004, jFirewallSim development team All rights reserved. [...1853 lines suppressed...] ! SandBoxWidth = (int)inDimension.getWidth(); ! } ! ! ! } - --- 941,949 ---- { ! SandBoxHeight = (int) inDimension.getHeight(); ! SandBoxWidth = (int) inDimension.getWidth(); ! } } Index: GuiWirelessAP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiWirelessAP.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuiWirelessAP.java 28 Sep 2008 17:11:47 -0000 1.2 --- GuiWirelessAP.java 6 Oct 2008 13:20:39 -0000 1.3 *************** *** 1,94 **** /* ! Java Firewall Simulator (jFirewallSim) ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ package guiUI; ! /** - - * <P>The GuiSwitch class is used to instantiate new Switches on the GUI</P> - * ! * @author luke_hamilton ! * @since 15th November 2004 ! * @version v0.20 ! */ - - public class G... [truncated message content] |
|
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){ |
|
From: Alexander B. <da...@us...> - 2008-10-05 20:20:38
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29460/core Modified Files: WiFiPort.java WirelessAP.java Log Message: Index: WirelessAP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WirelessAP.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WirelessAP.java 5 Oct 2008 13:03:47 -0000 1.4 --- WirelessAP.java 5 Oct 2008 20:20:32 -0000 1.5 *************** *** 93,105 **** super.turnOn(); ! ifacesUP(); } public void turnOff() { super.turnOff(); - ifacesDOWN(); - } public String getCache(){ --- 93,106 ---- super.turnOn(); ! //ifacesUP(); } public void turnOff() { + + ifacesDOWN(); + super.turnOff(); } public String getCache(){ Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WiFiPort.java 5 Oct 2008 18:41:06 -0000 1.8 --- WiFiPort.java 5 Oct 2008 20:20:32 -0000 1.9 *************** *** 57,60 **** --- 57,61 ---- protected int state; protected String apBSSID; + protected boolean lineFree; // AP block *************** *** 87,90 **** --- 88,93 ---- failed = false; //channel = 0; + + lineFree=false; } *************** *** 96,99 **** --- 99,104 ---- state = PROBE; + lineFree=false; + sendProbeReq(); } *************** *** 104,112 **** void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! sendWirelessPacket(inWP); } --- 109,127 ---- void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ + boolean canSend = true; + ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! if(Mode == MODE_STATION && inWP.Type == 2){ ! canSend = checkLineFree(); ! if(!canSend) ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Can't resend packet: no CTS -> medium is busy?Resending packet from interface " + name + " due to timeout."); ! } ! ! if(canSend) ! sendWirelessPacket(inWP); } *************** *** 118,122 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, "FF:FF:FF:FF:FF:FF", 0, 4, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending probe req packet from interface "+ name); --- 133,137 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, "FF:FF:FF:FF:FF:FF", 0, 4, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending probe req packet from interface "+ name); *************** *** 127,131 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 5, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending probe reply packet to " + inBSSID + " from interface "+ name); --- 142,146 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 5, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending probe reply packet to " + inBSSID + " from interface "+ name); *************** *** 136,140 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending auth req packet from interface "+ name); --- 151,155 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending auth req packet from interface "+ name); *************** *** 145,149 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending assoc req packet from interface "+ name); --- 160,164 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending assoc req packet from interface "+ name); *************** *** 156,160 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 1, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending assoc reply packet from interface "+ name); --- 171,175 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 1, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending assoc reply packet from interface "+ name); *************** *** 167,175 **** tempWiFi.setID(seq); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending ack packet from interface "+ name); sendWirelessPacket(tempWiFi); } public void Timer(int temp){ --- 182,223 ---- tempWiFi.setID(seq); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", "Link", "Sending ack packet from interface "+ name); sendWirelessPacket(tempWiFi); } + + void sendCTS(String inBSSID) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 1, 12, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Sending CTS packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + void sendRTS() throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, apBSSID, 1, 11, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Sending RTS packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + boolean checkLineFree() throws LowLinkException{ + boolean actlineFree = false; + + sendRTS(); + + try{ + Thread.sleep(100); + }catch(Exception e){ } + + actlineFree = lineFree; + lineFree = false; + + return actlineFree; + } public void Timer(int temp){ *************** *** 188,197 **** p.nextTime = System.currentTimeMillis() + p.period; ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Resending packet from interface " + name + " due to timeout."); ! try{ ! sendWirelessPacket(p.packet); }catch(LowLinkException ex){ } --- 236,257 ---- p.nextTime = System.currentTimeMillis() + p.period; ! boolean canSend = true; ! try{ ! if(Mode == MODE_STATION && p.packet.Type == 2){ ! canSend = checkLineFree(); ! ! if(!canSend) ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Can't resend packet: no CTS -> medium is busy?Resending packet from interface " + name + " due to timeout."); ! } ! ! if(canSend){ ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Resending packet from interface " + name + " due to timeout."); + sendWirelessPacket(p.packet); + } }catch(LowLinkException ex){ } *************** *** 325,329 **** if(Mode == MODE_STATION){ try{ ! associate(); }catch(Exception e){} } --- 385,389 ---- if(Mode == MODE_STATION){ try{ ! associate(); }catch(Exception e){} } *************** *** 440,445 **** "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; } - }else if(Mode == MODE_AP){ --- 500,508 ---- "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; + }else if(state == DATA && tempWiFi.Type == 1 && tempWiFi.subType == 12){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved CTS packet from " + tempWiFi.getSrcBSSID() + " on interface "+ name + "."); + lineFree=true; } }else if(Mode == MODE_AP){ *************** *** 471,474 **** --- 534,546 ---- } + }else if(tempWiFi.Type == 1 && tempWiFi.subType == 11){ + if(APClients.get(tempWiFi.getSrcBSSID()) != null){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved RTS packet from " + tempWiFi.getSrcBSSID() + " on interface "+ name + "."); + sendCTS(tempWiFi.getSrcBSSID()); + }else{ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control packet", "Link", "Wrong 802.11 protocol action!"); + } + } |
|
From: Alexander B. <da...@us...> - 2008-10-05 20:16:41
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27263/core/protocolsuite/tcp_ip Modified Files: IpV4.java ProtocolStack.java Log Message: Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ProtocolStack.java 3 Oct 2008 22:29:10 -0000 1.69 --- ProtocolStack.java 5 Oct 2008 19:12:31 -0000 1.70 *************** *** 137,141 **** mARPprotocol = new ARP(this); ! mIPprotocol = new IpV4(); mICMPprotocol = new ICMP(this); --- 137,141 ---- mARPprotocol = new ARP(this); ! mIPprotocol = new IpV4((NetworkLayerDevice)node); mICMPprotocol = new ICMP(this); *************** *** 148,152 **** mARPprotocol = new ARP(this); ! mIPprotocol = new IpV4(); // Currnetly only using IPv4 protocol mICMPprotocol = new ICMP(this); --- 148,152 ---- mARPprotocol = new ARP(this); ! mIPprotocol = new IpV4((NetworkLayerDevice)node); // Currnetly only using IPv4 protocol mICMPprotocol = new ICMP(this); Index: IpV4.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IpV4.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** IpV4.java 23 Sep 2008 15:22:14 -0000 1.13 --- IpV4.java 5 Oct 2008 19:12:31 -0000 1.14 *************** *** 1,64 **** /* ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! [...1690 lines suppressed...] ! * @version v0.20 ! * ! */ ! public String getIPAddress(String inInterfaceKey) { ! if (ipAddress.containsKey(inInterfaceKey)) { ! IPV4Address temp = (IPV4Address) ipAddress.get(inInterfaceKey); ! return temp.getDecimalIp(); ! } ! return null; ! } ! }// EOF |
|
From: Alexander B. <da...@us...> - 2008-10-05 19:15:14
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27263/core Modified Files: DataLinkLayerDevice.java EthernetLink.java EthernetNetworkInterface.java NetworkInterface.java NetworkInterfacePort.java Node.java SerialLink.java Log Message: Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EthernetLink.java 23 Sep 2008 15:22:09 -0000 1.15 --- EthernetLink.java 5 Oct 2008 19:12:30 -0000 1.16 *************** *** 53,57 **** * @throws InvalidLinkConnectionException */ ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); --- 53,57 ---- * @throws InvalidLinkConnectionException */ ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); *************** *** 62,66 **** } ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface, double sieveCoeff)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); --- 62,66 ---- } ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface, double sieveCoeff)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); *************** *** 83,98 **** public void transportPacket(Ethernet_packet inPacket,String inSourceName) throws LowLinkException { ! Iterator it = NetworkInterfaces.iterator(); ! while (it.hasNext()) ! { ! NetworkInterface temp = (NetworkInterface) it.next(); ! if(!temp.isOn()) return; ! if (!temp.getSourceName().equals(inSourceName)) ! { //if( ((sievingCoefficient)/100)>Math.random()) if((sievingCoefficient)>rng.nextInt(100)) ! temp.receivePacket(inPacket); else{ LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); --- 83,98 ---- public void transportPacket(Ethernet_packet inPacket,String inSourceName) throws LowLinkException { ! Iterator it = NetworkInterfaces.iterator(); ! while (it.hasNext()){ ! NetworkInterface temp = (NetworkInterface) it.next(); ! if(!temp.isOn() || (!temp.isUP())) return; ! ! if (!temp.getSourceName().equals(inSourceName)) ! { //if( ((sievingCoefficient)/100)>Math.random()) if((sievingCoefficient)>rng.nextInt(100)) ! temp.receivePacket(inPacket); else{ LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); *************** *** 109,116 **** if(cat==1) ! temp.receivePacket(inPacket); else throw new LowLinkException("(***) Packet lost due to physical link problems!");*/ ! } ! } ! } } --- 109,116 ---- if(cat==1) ! temp.receivePacket(inPacket); else throw new LowLinkException("(***) Packet lost due to physical link problems!");*/ ! } ! } ! } } Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Node.java 5 Oct 2008 18:41:06 -0000 1.26 --- Node.java 5 Oct 2008 19:12:31 -0000 1.27 *************** *** 461,464 **** --- 461,480 ---- } + public void ifacesLinkUP(){ + + Enumeration keys = NetworkInterfacetable.keys(); + + while(keys.hasMoreElements()){ + + String str = (String)keys.nextElement(); + + NetworkInterface temp = (NetworkInterface)NetworkInterfacetable.get(str); + + if(!temp.isActive()) + temp.setUP(); + + } + } + protected void ifacesDOWN(){ Enumeration keys = NetworkInterfacetable.keys(); Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NetworkInterfacePort.java 5 Oct 2008 18:41:06 -0000 1.8 --- NetworkInterfacePort.java 5 Oct 2008 19:12:31 -0000 1.9 *************** *** 118,121 **** --- 118,130 ---- } + + protected NetworkInterfacePort(long UID, String inName, Node inParent, boolean inUP) { + + super(UID, inName,inParent); + + if(inUP) + setUP(); + + } Index: SerialLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/SerialLink.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SerialLink.java 23 Sep 2008 15:22:11 -0000 1.4 --- SerialLink.java 5 Oct 2008 19:12:31 -0000 1.5 *************** *** 61,75 **** public void transportPacket(Serial_packet inPacket,String inSourceName) throws LowLinkException { ! Iterator it = NetworkInterfaces.iterator(); ! while (it.hasNext()) ! { ! NetworkInterface temp = (NetworkInterface) it.next(); ! if(!temp.isOn()) return; ! if (!temp.getSourceName().equals(inSourceName)) ! { temp.receivePacket(inPacket); ! } ! } } } --- 61,76 ---- public void transportPacket(Serial_packet inPacket,String inSourceName) throws LowLinkException { ! Iterator it = NetworkInterfaces.iterator(); ! while (it.hasNext()){ ! NetworkInterface temp = (NetworkInterface) it.next(); ! ! if(!temp.isOn() || !temp.isUP()) return; ! ! if (!temp.getSourceName().equals(inSourceName)) ! { temp.receivePacket(inPacket); ! } } + } } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NetworkInterface.java 26 Sep 2008 17:53:48 -0000 1.16 --- NetworkInterface.java 5 Oct 2008 19:12:30 -0000 1.17 *************** *** 134,137 **** --- 134,141 ---- protected String description = ""; + public void setUP(){ + up = true; + } + public void UP(){ up = true; Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DataLinkLayerDevice.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DataLinkLayerDevice.java 26 Sep 2008 17:53:48 -0000 1.6 --- DataLinkLayerDevice.java 5 Oct 2008 19:12:30 -0000 1.7 *************** *** 44,48 **** */ public DataLinkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { ! super(inName, inProtocolStackLayers, inOn); } --- 44,48 ---- */ public DataLinkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { ! super(inName, inProtocolStackLayers, inOn); } *************** *** 55,60 **** protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(core.Simulation.UIDGen++,interfaceName,this)); } public Object[] getAllInterfaces(){ --- 55,66 ---- protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(core.Simulation.UIDGen++,interfaceName,this,true)); } + + public void turnOn() { + super.turnOn(); + + ifacesLinkUP(); + } public Object[] getAllInterfaces(){ Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** EthernetNetworkInterface.java 5 Oct 2008 18:41:06 -0000 1.16 --- EthernetNetworkInterface.java 5 Oct 2008 19:12:30 -0000 1.17 *************** *** 155,158 **** --- 155,160 ---- protected void sendPacket(Packet inPacket, String inMacAddress) throws LowLinkException { + if(!parentNode.On || !up) return; + Ethernet_packet Packet = new Ethernet_packet(inPacket,inMacAddress, MACAddress); //if(Packet.getHopCount()>255) throw new CommunicationException("Hub buffer overflow (packet loop flood?)."); |
|
From: Alexander B. <da...@us...> - 2008-10-05 18:42:11
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26108/guiUI Modified Files: MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** MainScreen.java 5 Oct 2008 13:03:48 -0000 1.89 --- MainScreen.java 5 Oct 2008 18:41:06 -0000 1.90 *************** *** 761,764 **** --- 761,765 ---- try { + APcnt++; Sim.addAP(result, true); *************** *** 766,769 **** --- 767,773 ---- Sim.getNode(result).addNetworkInterface("eth0", NetworkInterface.Ethernet10T, false, 0); Sim.getNode(result).addNetworkInterface("wrl0", NetworkInterface.Wireless, false, 0); + + Sim.getNode(result).ifacesUP(); + ((core.NetworkLayerDevice)Sim.getNode(result)).getConfig().executeCommand("write mem"); GuiWirelessAP tempPC = new GuiWirelessAP(result,this); |
|
From: Alexander B. <da...@us...> - 2008-10-05 18:42:08
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26108/core Modified Files: EthernetNetworkInterface.java NetworkInterfacePort.java Node.java SerialNetworkInterface.java WiFiPort.java Log Message: Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NetworkInterfacePort.java 26 Sep 2008 17:53:48 -0000 1.7 --- NetworkInterfacePort.java 5 Oct 2008 18:41:06 -0000 1.8 *************** *** 140,148 **** protected void receivePacket(Packet inPacket) throws LowLinkException { ! if(!parentNode.On) return; parentNode.receivePacket(inPacket, name); ! return; } --- 140,148 ---- protected void receivePacket(Packet inPacket) throws LowLinkException { ! if(!parentNode.On) return; parentNode.receivePacket(inPacket, name); ! return; } *************** *** 170,174 **** protected void sendPacket(Packet outPacket) throws LowLinkException{ ! if(!parentNode.On) return; Ethernet_packet tempPacket = (Ethernet_packet)outPacket; --- 170,174 ---- protected void sendPacket(Packet outPacket) throws LowLinkException{ ! if(!parentNode.On) return; Ethernet_packet tempPacket = (Ethernet_packet)outPacket; Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Node.java 5 Oct 2008 16:53:12 -0000 1.25 --- Node.java 5 Oct 2008 18:41:06 -0000 1.26 *************** *** 476,480 **** public void turnOff() { ifacesDOWN(); ! On = false; NodeProtocolStack = null; } --- 476,481 ---- public void turnOff() { ifacesDOWN(); ! ! On = false; NodeProtocolStack = null; } Index: SerialNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/SerialNetworkInterface.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SerialNetworkInterface.java 26 Sep 2008 17:53:49 -0000 1.6 --- SerialNetworkInterface.java 5 Oct 2008 18:41:06 -0000 1.7 *************** *** 73,76 **** --- 73,78 ---- protected void sendPacket(Packet inPacket) throws LowLinkException { + if(!parentNode.On || !up) return; + Serial_packet Packet = new Serial_packet(inPacket, ClockRate); Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WiFiPort.java 5 Oct 2008 13:03:47 -0000 1.7 --- WiFiPort.java 5 Oct 2008 18:41:06 -0000 1.8 *************** *** 4,7 **** --- 4,8 ---- import core.protocolsuite.tcp_ip.IP_packet; import java.util.Hashtable; + import java.util.Enumeration; public class WiFiPort extends EthernetNetworkInterface { *************** *** 111,115 **** void sendWirelessConfirmPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessConfirmPacket(inWP, 100); } --- 112,116 ---- void sendWirelessConfirmPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessConfirmPacket(inWP, 500); } *************** *** 172,176 **** } ! public void Timer(int temp){ } --- 173,233 ---- } ! public void Timer(int temp){ ! Long pID; ! ResendPacket p; ! ! for (Enumeration e=ResendPackets.keys(); e.hasMoreElements();) { ! ! pID = (Long)e.nextElement(); ! p = (ResendPacket)ResendPackets.get(pID); ! ! if(System.currentTimeMillis() > p.nextTime){ ! ! p.cnt --; ! ! p.nextTime = System.currentTimeMillis() + p.period; ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Resending packet from interface " + name + " due to timeout."); ! ! try{ ! sendWirelessPacket(p.packet); ! ! }catch(LowLinkException ex){ } ! ! if(p.cnt < 1){ ! ResendPackets.remove(pID); ! ! if(Mode == MODE_STATION){ ! if(state > ASSOC){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Deassociated at AP " + apBSSID + "/" + SSID + " due to network timeout."); ! }else if(state == PROBE){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Probing AP " + SSID + " failed: no such AP found."); ! }else{ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Associating at AP " + SSID + " failed: protocol mistmatch."); ! } ! ! associated = false; ! failed = true; ! DOWN(); ! return ; ! ! ! }else if(Mode == MODE_AP){ ! if(state >= ASSOC){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Deassociating client " + p.packet.getDstBSSID() + " due to network timeout."); ! } ! ! APClients.remove(p.packet.getSrcBSSID()); ! } ! } ! } ! ! } ! } *************** *** 319,323 **** } ! sendACK(tempWiFi.getDstBSSID(), tempWiFi.getID()); if(allowReceive) --- 376,380 ---- } ! sendACK(tempWiFi.getSrcBSSID(), tempWiFi.getID()); if(allowReceive) *************** *** 337,341 **** W80211_packet tempWiFi = (W80211_packet) inPacket; ! if((tempWiFi.getDstBSSID() != BSSID || tempWiFi.SSID != SSID) && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF"){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); --- 394,402 ---- W80211_packet tempWiFi = (W80211_packet) inPacket; ! boolean b1 = (tempWiFi.getDstBSSID() != BSSID); ! boolean b2 = !(tempWiFi.SSID.equals(SSID)); ! boolean b3 = (tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF"); ! ! if((tempWiFi.getDstBSSID() != BSSID || !tempWiFi.SSID.equals(SSID)) && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF"){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); *************** *** 368,372 **** "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; ! ResendPackets.remove(tempWiFi.getID()); sendAssocReq(apBSSID); }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ --- 429,433 ---- "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; ! ResendPackets.clear(); sendAssocReq(apBSSID); }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ *************** *** 375,379 **** "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; ! ResendPackets.remove(tempWiFi.getID()); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); --- 436,440 ---- "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; ! ResendPackets.clear(); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EthernetNetworkInterface.java 29 Sep 2008 19:14:16 -0000 1.15 --- EthernetNetworkInterface.java 5 Oct 2008 18:41:06 -0000 1.16 *************** *** 102,106 **** Ethernet_packet tempPacket = (Ethernet_packet)inPacket; ! if(!parentNode.On) return; //Test if this packet is for this interface or a broadcast --- 102,106 ---- Ethernet_packet tempPacket = (Ethernet_packet)inPacket; ! if(!parentNode.On || !up) return; //Test if this packet is for this interface or a broadcast |
|
From: QweR <qw...@us...> - 2008-10-05 18:13:18
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24648/guiUI Modified Files: Terminal.java Log Message: command 'end' was added 'sh int' was corrected Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Terminal.java 5 Oct 2008 16:53:12 -0000 1.14 --- Terminal.java 5 Oct 2008 18:08:55 -0000 1.15 *************** *** 99,103 **** cmdproc.add("interface", interface_Command, ""); cmdproc.add("interface *", interface_Command, ""); ! cmdproc.add("interface * exit", exit_Command, ""); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); --- 99,104 ---- cmdproc.add("interface", interface_Command, ""); cmdproc.add("interface *", interface_Command, ""); ! cmdproc.add("interface * end", end_Command, "Exit from configuration mode"); ! cmdproc.add("interface * exit", exit_Command, "Exit from current mode"); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); *************** *** 381,400 **** class end_CommandClass extends CommandInterface{ public end_CommandClass (){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! if(interface_mode!=DEF_MODE){ ! interface_mode = DEF_MODE; ! command_prefix = ""; ! } ! else{ ! current_mode.conf_mode = CommandInterface.STD_MODE; ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! } ! } ! else if(current_mode.conf_mode == CommandInterface.STD_MODE){ ! exitWindow(); } return ""; --- 382,394 ---- class end_CommandClass extends CommandInterface{ public end_CommandClass (){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); call_params = "<cr>"; } public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! interface_mode = DEF_MODE; ! command_prefix = ""; ! current_mode.conf_mode = CommandInterface.STD_MODE; ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } return ""; |
|
From: QweR <qw...@us...> - 2008-10-05 18:11:44
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24648/core Modified Files: CommandProcessor.java DeviceConfig.java Log Message: command 'end' was added 'sh int' was corrected Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CommandProcessor.java 5 Oct 2008 16:53:12 -0000 1.19 --- CommandProcessor.java 5 Oct 2008 18:08:55 -0000 1.20 *************** *** 2690,2694 **** try { NetworkInterface ni = device.getNetworkInterface((String)ins[i]); ! boolean isLineUp = ni.getConnectedLink() != null; boolean isUp = ni.isUP(); out += "Interface " + (String)ins[i] + " is " + (isUp?"up":"down") + ", line protocol is " + (isLineUp?"up":"down") + "\n"; --- 2690,2700 ---- try { NetworkInterface ni = device.getNetworkInterface((String)ins[i]); ! boolean isLineUp = false; ! if(ni instanceof WiFiPort){ ! isLineUp = ((WiFiPort) ni).associated; ! } ! else{ ! isLineUp = ni.getConnectedLink() != null; ! } boolean isUp = ni.isUP(); out += "Interface " + (String)ins[i] + " is " + (isUp?"up":"down") + ", line protocol is " + (isLineUp?"up":"down") + "\n"; *************** *** 2696,2699 **** --- 2702,2718 ---- 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"; + if(wfi.getMode()==WiFiPort.MODE_AP) + out += " Station-role is access point\n"; + else if(wfi.getMode()==WiFiPort.MODE_REPEATER) + out += " Station-role is repeater\n"; + else if(wfi.getMode()==WiFiPort.MODE_STATION) + out += " Station-role is client\n"; + out += " Authentication type: " + (wfi.isSharedAuth()?"shared":"open") + "\n"; + } if(ni instanceof SerialNetworkInterface){ out += " Clock-rate " + ((SerialNetworkInterface)ni).getClockRate() + "\n"; Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** DeviceConfig.java 5 Oct 2008 16:53:12 -0000 1.16 --- DeviceConfig.java 5 Oct 2008 18:08:55 -0000 1.17 *************** *** 441,449 **** else conf.add("interface "+intName+" channel "+wfi.getChannel()); ! if(wfi.getMode()==wfi.MODE_AP) conf.add("interface "+intName+" station-role root access-point"); ! else if(wfi.getMode()==wfi.MODE_REPEATER) conf.add("interface "+intName+" station-role repeater"); ! else if(wfi.getMode()==wfi.MODE_STATION) conf.add("interface "+intName+" station-role client"); conf.add("interface "+intName+" authentication "+(wfi.isSharedAuth()?"shared":"open")); --- 441,449 ---- else conf.add("interface "+intName+" channel "+wfi.getChannel()); ! if(wfi.getMode()==WiFiPort.MODE_AP) conf.add("interface "+intName+" station-role root access-point"); ! else if(wfi.getMode()==WiFiPort.MODE_REPEATER) conf.add("interface "+intName+" station-role repeater"); ! else if(wfi.getMode()==WiFiPort.MODE_STATION) conf.add("interface "+intName+" station-role client"); conf.add("interface "+intName+" authentication "+(wfi.isSharedAuth()?"shared":"open")); |
|
From: QweR <qw...@us...> - 2008-10-05 17:20:56
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21203/guiUI Modified Files: Terminal.java Log Message: no shutdown corrected Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Terminal.java 3 Oct 2008 22:29:10 -0000 1.13 --- Terminal.java 5 Oct 2008 16:53:12 -0000 1.14 *************** *** 70,73 **** --- 70,74 ---- // private configure_memory_CommandClass configure_memory_Command = new configure_memory_CommandClass(); private configure_terminal_CommandClass configure_terminal_Command = new configure_terminal_CommandClass(); + private end_CommandClass end_Command = new end_CommandClass(); private exit_CommandClass exit_Command = new exit_CommandClass(); private interface_CommandClass interface_Command = new interface_CommandClass();private logout_CommandClass logout_Command = new logout_CommandClass(); *************** *** 94,97 **** --- 95,99 ---- // cmdproc.add("configure memory", configure_memory_Command, "Configure from memory"); cmdproc.add("configure terminal", configure_terminal_Command, "Configure from the terminal"); + cmdproc.add("end", end_Command, "Exit from configuration mode"); cmdproc.add("exit", exit_Command, "Exit from current mode"); cmdproc.add("interface", interface_Command, ""); *************** *** 377,380 **** --- 379,404 ---- // } // }; + class end_CommandClass extends CommandInterface{ + public end_CommandClass (){ + modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + } + public String call(Vector<String> params){ + if(current_mode.conf_mode == CommandInterface.CONF_MODE){ + if(interface_mode!=DEF_MODE){ + interface_mode = DEF_MODE; + command_prefix = ""; + } + else{ + current_mode.conf_mode = CommandInterface.STD_MODE; + device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; + } + } + else if(current_mode.conf_mode == CommandInterface.STD_MODE){ + exitWindow(); + } + return ""; + } + }; class exit_CommandClass extends CommandInterface{ public exit_CommandClass (){ *************** *** 449,454 **** int success = 0; for(int pi=0; pi<count; pi++){ ! ICMP_packet icmpout = device.sendPing(ip); ! ICMP_packet icmpin = device.getReceivedICMPPacket(icmpout.getMessageID()); if(icmpin!=null){ if(icmpin.getMessageCode()==ICMP_packet.DESTINATION_UNREACHABLE){ --- 473,486 ---- int success = 0; for(int pi=0; pi<count; pi++){ ! ICMP_packet icmpout = null; ! ICMP_packet icmpin = null; ! try{ ! icmpout = device.sendPing(ip); ! icmpin = device.getReceivedICMPPacket(icmpout.getMessageID()); ! } catch (CommunicationException e) { ! // some error - skip :) ! } catch (LowLinkException e) { ! // some error - skip :) ! } if(icmpin!=null){ if(icmpin.getMessageCode()==ICMP_packet.DESTINATION_UNREACHABLE){ *************** *** 483,492 **** } addToTerminal("\nSuccess rate is " +(int)(success*100/count)+ " percent ("+success+"/"+count+")\n"); - } catch (CommunicationException e) { - //addToTerminal("Internal error: ping: CommunicationException\n"); - addToTerminal("CommunicationException: "+e.getMessage()); - } catch (LowLinkException e) { - //addToTerminal("Internal error: ping: LowLinkException\n"); - addToTerminal("LowLinkException: "+e.getMessage()); } catch (Exception e){ addToTerminal("Internal error: ping: Exception: "+e.getMessage()+"\n"); --- 515,518 ---- |
|
From: QweR <qw...@us...> - 2008-10-05 16:56:15
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21203/core Modified Files: CommandProcessor.java DeviceConfig.java Node.java Log Message: no shutdown corrected Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CommandProcessor.java 3 Oct 2008 22:29:09 -0000 1.18 --- CommandProcessor.java 5 Oct 2008 16:53:12 -0000 1.19 *************** *** 532,542 **** WiFiPort wi = (WiFiPort)ni; String bssid = params.get(1); ! if(EthernetNetworkInterface.isMacAddress(bssid)){ ! wi.setBSSID(bssid); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else{ ! out += "error: incorrect BSSID\n"; } } --- 532,549 ---- WiFiPort wi = (WiFiPort)ni; String bssid = params.get(1); ! if(device instanceof WirelessAP || device instanceof Router){ ! if(EthernetNetworkInterface.isMacAddress(bssid)){ ! wi.setBSSID(bssid); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } ! } ! else{ ! out += "error: incorrect BSSID\n"; ! } } else{ ! out += "error: command isn't support by this device\n"; } } *************** *** 562,567 **** String bssid = wi.getMACAddress(); wi.setBSSID(bssid); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else{ --- 569,576 ---- String bssid = wi.getMACAddress(); wi.setBSSID(bssid); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } } else{ *************** *** 595,604 **** if(channel==0){ wi.setChannel(0); ! if(wi.isActive()) wi.DOWN(); } else if(channel>=1 && channel<=14){ wi.setChannel(channel); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else{ --- 604,617 ---- if(channel==0){ wi.setChannel(0); ! if(wi.isUP()){ ! wi.DOWN(); ! } } else if(channel>=1 && channel<=14){ wi.setChannel(channel); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } } else{ *************** *** 630,634 **** WiFiPort wi = (WiFiPort)ni; wi.setChannel(0); ! if(wi.isActive()) wi.DOWN(); } else{ --- 643,649 ---- WiFiPort wi = (WiFiPort)ni; wi.setChannel(0); ! if(wi.isUP()){ ! wi.DOWN(); ! } } else{ *************** *** 657,661 **** SerialNetworkInterface sni = (SerialNetworkInterface)device.getNetworkInterface(params.get(0)); int cr = Integer.parseInt(params.get(1)); ! if(cr>sni.MIN_CLOCKRATE || cr<=sni.MAX_CLOCKRATE){ if(sni!=null){ sni.setClockRate(cr); --- 672,676 ---- SerialNetworkInterface sni = (SerialNetworkInterface)device.getNetworkInterface(params.get(0)); int cr = Integer.parseInt(params.get(1)); ! if(cr>SerialNetworkInterface.MIN_CLOCKRATE || cr<=SerialNetworkInterface.MAX_CLOCKRATE){ if(sni!=null){ sni.setClockRate(cr); *************** *** 685,689 **** SerialNetworkInterface sni = (SerialNetworkInterface)device.getNetworkInterface(params.get(0)); if(sni!=null){ ! sni.setClockRate(sni.DEFAULT_CLOCKRATE); } else{ --- 700,704 ---- SerialNetworkInterface sni = (SerialNetworkInterface)device.getNetworkInterface(params.get(0)); if(sni!=null){ ! sni.setClockRate(SerialNetworkInterface.DEFAULT_CLOCKRATE); } else{ *************** *** 1371,1383 **** String role = params.get(1); if(role.equalsIgnoreCase("client")){ ! wi.setMode(wi.MODE_STATION); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else if(role.equalsIgnoreCase("repeater")){ if(false && (device instanceof WirelessAP || device instanceof Router)){ ! wi.setMode(wi.MODE_REPEATER); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else{ --- 1386,1402 ---- String role = params.get(1); if(role.equalsIgnoreCase("client")){ ! wi.setMode(WiFiPort.MODE_STATION); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } } else if(role.equalsIgnoreCase("repeater")){ if(false && (device instanceof WirelessAP || device instanceof Router)){ ! wi.setMode(WiFiPort.MODE_REPEATER); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } } else{ *************** *** 1387,1393 **** else if(role.equalsIgnoreCase("root") && params.size()==3 && params.get(2).equalsIgnoreCase("access-point")){ if(device instanceof WirelessAP || device instanceof Router){ ! wi.setMode(wi.MODE_AP); ! if(wi.isActive()) wi.DOWN(); ! wi.UP(); } else{ --- 1406,1414 ---- else if(role.equalsIgnoreCase("root") && params.size()==3 && params.get(2).equalsIgnoreCase("access-point")){ if(device instanceof WirelessAP || device instanceof Router){ ! wi.setMode(WiFiPort.MODE_AP); ! if(wi.isActive() && wi.isUP()){ ! wi.DOWN(); ! wi.UP(); ! } } else{ Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DeviceConfig.java 3 Oct 2008 22:29:10 -0000 1.15 --- DeviceConfig.java 5 Oct 2008 16:53:12 -0000 1.16 *************** *** 426,433 **** if(ni.getDescription()!=null && !ni.getDescription().equals("")) conf.add("interface "+intName+" description "+ni.getDescription()); - if(ni.isUP()) - conf.add("no interface "+intName+" shutdown"); - else - conf.add("interface "+intName+" shutdown"); if(eni!=null && !eni.getMACAddress().equalsIgnoreCase(eni.defaultMACAddress)) conf.add("interface "+intName+" mac-address "+eni.getMACAddress()); --- 426,429 ---- *************** *** 469,472 **** --- 465,473 ---- if(!ni.informationReplay) conf.add("no interface "+intName+" ip information-replay"); + + if(ni.isUP()) + conf.add("no interface "+intName+" shutdown"); + else + conf.add("interface "+intName+" shutdown"); if(device instanceof ApplicationLayerDevice){ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Node.java 28 Sep 2008 17:11:47 -0000 1.24 --- Node.java 5 Oct 2008 16:53:12 -0000 1.25 *************** *** 475,480 **** public void turnOff() { ! ! On = false; NodeProtocolStack = null; --- 475,479 ---- public void turnOff() { ! ifacesDOWN(); On = false; NodeProtocolStack = null; |
|
From: Alexander B. <da...@us...> - 2008-10-05 13:08:16
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10499/core Modified Files: W80211_packet.java WiFiPort.java WirelessAP.java Log Message: Index: WirelessAP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WirelessAP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WirelessAP.java 28 Sep 2008 17:11:47 -0000 1.3 --- WirelessAP.java 5 Oct 2008 13:03:47 -0000 1.4 *************** *** 170,174 **** // if it is skip that interface NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! if(!tempInterface.getName().contains("eth")){ try{ --- 170,174 ---- // if it is skip that interface NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! if(!(tempInterface.getName().equals(inInterfaceName) && !inInterfaceName.contains("wrl"))){ try{ *************** *** 177,181 **** System.out.println("WirelessAP.java: " + e.toString()); } ! } } --- 177,181 ---- System.out.println("WirelessAP.java: " + e.toString()); } ! } } Index: W80211_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/W80211_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** W80211_packet.java 3 Oct 2008 14:49:54 -0000 1.2 --- W80211_packet.java 5 Oct 2008 13:03:47 -0000 1.3 *************** *** 20,23 **** --- 20,27 ---- } + public void setID(Long nID){ + pID = nID; + } + public void Cypher(String inWEP, int inkeyNum){ WEP = inWEP; *************** *** 25,29 **** } ! public W80211_packet(Packet inPacket, String inDst, String inSrc, int inType, int inSubType, String inSSID) { dstBSSID = inDst; --- 29,33 ---- } ! public W80211_packet(Packet inPacket, String inSrc, String inDst, int inType, int inSubType, String inSSID) { dstBSSID = inDst; Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WiFiPort.java 3 Oct 2008 14:49:54 -0000 1.6 --- WiFiPort.java 5 Oct 2008 13:03:47 -0000 1.7 *************** *** 93,111 **** associated = false; ! Mode = PROBE; sendProbeReq(); } ! void sendWirelessPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! Simulation.Sim.sendWirelessPacket(this, inWP, channel); } ! void sendWirelessPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessPacket(inWP, 100); } --- 93,115 ---- associated = false; ! state = PROBE; sendProbeReq(); } ! void sendWirelessPacket(W80211_packet inWP) throws LowLinkException{ ! Simulation.Sim.sendWirelessPacket(this, inWP, channel); ! } ! ! void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! sendWirelessPacket(inWP); } ! void sendWirelessConfirmPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessConfirmPacket(inWP, 100); } *************** *** 116,127 **** "Link", "Sending probe req packet from interface "+ name); ! sendWirelessPacket(tempWiFi, 5000); } ! void sendProbeReply(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 4, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply packet from interface "+ name); sendWirelessPacket(tempWiFi); --- 120,131 ---- "Link", "Sending probe req packet from interface "+ name); ! sendWirelessConfirmPacket(tempWiFi, 5000); } ! void sendProbeReply(String inBSSID, Long seq) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 5, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply packet to " + inBSSID + " from interface "+ name); sendWirelessPacket(tempWiFi); *************** *** 129,138 **** void sendAuthReq(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 4, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending auth req packet from interface "+ name); ! sendWirelessPacket(tempWiFi); } --- 133,142 ---- void sendAuthReq(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending auth req packet from interface "+ name); ! sendWirelessConfirmPacket(tempWiFi); } *************** *** 143,146 **** --- 147,172 ---- "Link", "Sending assoc req packet from interface "+ name); + sendWirelessConfirmPacket(tempWiFi); + } + + + + void sendAssocReply(String inBSSID, Long seq) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 1, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", + "Link", "Sending assoc reply packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + void sendACK(String inBSSID, Long seq) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 1, 13, SSID); + + tempWiFi.setID(seq); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", + "Link", "Sending ack packet from interface "+ name); + sendWirelessPacket(tempWiFi); } *************** *** 170,174 **** public void setBSSID(String bssid) { ! BSSID = bssid; } --- 196,201 ---- public void setBSSID(String bssid) { ! if(Mode != MODE_STATION) ! BSSID = bssid; } *************** *** 214,219 **** this.MACAddress = macAddress; } ! // if(BSSID==null || BSSID.equals("")) ! // this.BSSID = this.MACAddress; } --- 241,246 ---- this.MACAddress = macAddress; } ! if(Mode == MODE_STATION) ! this.BSSID = this.MACAddress; } *************** *** 259,270 **** protected void receiveDataPacket( W80211_packet tempWiFi) throws LowLinkException { ! if((tempWiFi.getDstBSSID() != BSSID && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF") || tempWiFi.SSID!=SSID || tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; ! } ! ! if(tempWiFi.SSID!=SSID || tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong 802.11 protocol params."); return; --- 286,293 ---- protected void receiveDataPacket( W80211_packet tempWiFi) throws LowLinkException { ! //&& ! ! if(tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong WEP params."); return; *************** *** 295,298 **** --- 318,323 ---- } } + + sendACK(tempWiFi.getDstBSSID(), tempWiFi.getID()); if(allowReceive) *************** *** 302,306 **** //Packet is not for the Interface Drop Packet and record something in //the Layerinfo object ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", "Link", "Recieved and dropped packet at interface " + MACAddress); } --- 327,331 ---- //Packet is not for the Interface Drop Packet and record something in //the Layerinfo object ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", "Link", "Recieved and dropped packet at interface " + MACAddress); } *************** *** 309,366 **** protected void receivePacket(Packet inPacket) throws LowLinkException { if(!parentNode.On) return; ! ! W80211_packet tempWiFi = (W80211_packet) inPacket; if(tempWiFi.Type == 2 && tempWiFi.subType == 0){ ! receiveDataPacket(tempWiFi); }else{ if(Mode == MODE_STATION){ ! if(tempWiFi.getDstBSSID() != BSSID || tempWiFi.SSID != SSID){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; } ! if(state == PROBE && tempWiFi.Type == 0 && tempWiFi.Type == 5){ ResendPackets.remove(tempWiFi.getID()); apBSSID = tempWiFi.getSrcBSSID(); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; sendAssocReq(apBSSID); ! }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.Type == 1){ ResendPackets.remove(tempWiFi.getID()); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; associated = true; } }else if(Mode == MODE_AP){ - if((tempWiFi.getDstBSSID() != BSSID && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF") || tempWiFi.SSID != SSID){ - Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); - - return; - } ! if(tempWiFi.Type == 0 && tempWiFi.Type == 4){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved probe req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Connection state with " + tempWiFi.getSrcBSSID() + " cleared."); APClients.remove(tempWiFi.getSrcBSSID()); } ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply to " + tempWiFi.getSrcBSSID() + " on interface "+ name); ! APClients.put(tempWiFi.getSrcBSSID() , new APClient(tempWiFi.getSrcBSSID())); ! sendProbeReply(tempWiFi.getSrcBSSID()); } --- 334,413 ---- protected void receivePacket(Packet inPacket) throws LowLinkException { if(!parentNode.On) return; ! W80211_packet tempWiFi = (W80211_packet) inPacket; + if((tempWiFi.getDstBSSID() != BSSID || tempWiFi.SSID != SSID) && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF"){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); + + return; + } + if(tempWiFi.Type == 2 && tempWiFi.subType == 0){ ! receiveDataPacket(tempWiFi); ! }else if(tempWiFi.Type == 1 && tempWiFi.subType == 13){ ! ! ResendPackets.remove(tempWiFi.getID()); + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved ack from " + tempWiFi.getSrcBSSID() + " on interface "+ name); + }else{ if(Mode == MODE_STATION){ ! ! if(tempWiFi.getDstBSSID() == "FF:FF:FF:FF:FF:FF"){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; } ! if(state == PROBE && tempWiFi.Type == 0 && tempWiFi.subType == 5){ ResendPackets.remove(tempWiFi.getID()); apBSSID = tempWiFi.getSrcBSSID(); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; + ResendPackets.remove(tempWiFi.getID()); sendAssocReq(apBSSID); ! }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ ResendPackets.remove(tempWiFi.getID()); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; + ResendPackets.remove(tempWiFi.getID()); + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; } }else if(Mode == MODE_AP){ ! if(tempWiFi.Type == 0 && tempWiFi.subType == 4){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11", "Link", "Connection state with " + tempWiFi.getSrcBSSID() + " cleared."); APClients.remove(tempWiFi.getSrcBSSID()); } ! APClients.put(tempWiFi.getSrcBSSID() , new APClient(tempWiFi.getSrcBSSID())); ! sendProbeReply(tempWiFi.getSrcBSSID(), tempWiFi.getID()); ! }else if(tempWiFi.Type == 0 && tempWiFi.subType == 0){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Recieved assoc req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); ! ! if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11", ! "Link", "Station " + tempWiFi.getSrcBSSID() + " associated."); ! ! APClients.get(tempWiFi.getSrcBSSID()).state = DATA; ! sendAssocReply(tempWiFi.getSrcBSSID(), tempWiFi.getID()); ! }else{ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Wrong 802.11 protocol action!"); ! } ! } *************** *** 378,381 **** --- 425,439 ---- if(Mode == MODE_AP){ + Ethernet_packet tempPacket = (Ethernet_packet)outPacket; + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", + "Link", "Sending packet from interface "+ MACAddress); + + W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, tempPacket.getDestinationMACAddress(), 2, 0, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", + "Link", "Sending packet from interface "+ name); + + sendWirelessConfirmPacket(tempWiFi, 200); }else if(Mode == MODE_STATION){ *************** *** 403,412 **** "Link", "Sending packet from interface "+ MACAddress); ! //W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, "FF:FF:FF:FF:FF:FF"); ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending packet from interface "+ name); ! //Simulation.Sim.sendWirelessPacket(this, tempWiFi, channel); } --- 461,470 ---- "Link", "Sending packet from interface "+ MACAddress); ! W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, apBSSID, 2, 0, SSID); ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Sending packet from interface " + name + " to " + tempWiFi.getDstBSSID()); ! sendWirelessConfirmPacket(tempWiFi, 200); } |