[Javanetsim-cvs] javaNetSim/core SerialLink.java, NONE, 1.1 SerialNetworkInterface.java, NONE, 1.1
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-10-13 12:57:07
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30660/core Modified Files: DataLinkLayerDevice.java EthernetNetworkInterface.java ExternalProxy.java Hub.java NetworkInterface.java NetworkInterfacePort.java NetworkLayerDevice.java Node.java PC.java ProtocolStack.java Router.java Simulation.java Switch.java Added Files: SerialLink.java SerialNetworkInterface.java Log Message: Multiple changes in Link Layer, added DHCP D/C prototype, broadcast packets (+ forwarding), changed menu structure, added MAC address editing, Serial link type and more... Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PC.java 8 Nov 2006 14:27:29 -0000 1.11 --- PC.java 13 Oct 2007 12:57:00 -0000 1.12 *************** *** 139,143 **** addApp(snmpManager, 30161); ! addNetworkInterface("eth0"); } --- 139,145 ---- addApp(snmpManager, 30161); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); } Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DataLinkLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataLinkLayerDevice.java 20 Nov 2005 20:30:53 -0000 1.2 --- DataLinkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 55,60 **** protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); ! } public Object[] getAllInterfaces(){ --- 55,60 ---- protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); ! } public Object[] getAllInterfaces(){ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Node.java 14 Sep 2007 11:14:49 -0000 1.8 --- Node.java 13 Oct 2007 12:57:00 -0000 1.9 *************** *** 235,240 **** */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! return; --- 235,240 ---- */ ! protected void receivePacket(Packet inPacket) throws LowLinkException ! { return; *************** *** 277,284 **** * */ ! protected void addNetworkInterface(String interfaceName) { ! ! NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); } --- 277,294 ---- * */ ! protected void addNetworkInterface(String interfaceName, int type, boolean active) { + switch(type){ + case NetworkInterface.Ethernet10T: + if(active){ + NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); + }else{ + NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); + } + break; + case NetworkInterface.Serial: + NetworkInterfacetable.put(interfaceName,new SerialNetworkInterface(interfaceName,this)); + break; + } } *************** *** 445,451 **** if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! ! return temp.getMACAddress(); } --- 455,465 ---- if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! //"Not Applicable" ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterfaceName))).getType() == NetworkInterface.Ethernet10T){ ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! return temp.getMACAddress(); ! }else{ ! return "Not Applicable"; ! } } *************** *** 454,458 **** --- 468,541 ---- } + + public int getIntType(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + return temp.getType(); + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + public boolean isActiveInterface(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + return temp.isActive(); + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + + + public String getIntSType(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + switch(temp.getType()){ + case NetworkInterface.Ethernet10T: + return "Ethernet"; + case NetworkInterface.Serial: + return "Serial"; + case NetworkInterface.Wireless: + return "Wireless"; + default: + return "Unknown"; + } + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + /* public void setMACAddress(String inInterfaceName, String MAC)throws InvalidNetworkInterfaceNameException, SimulationException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + if(MAC.matches("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]")){ + temp.setMacAddress(MAC); + }else{ + throw new SimulationException("Invalid MAC address!"); + } + + }else{ + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + } + } */ --- NEW FILE: SerialNetworkInterface.java --- /* 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 core; //import java.util.*; /** * A NetworkInterface represents the physical interface between * a Node and a physical Link (network cable). Think of it as the NIC * (Network Interface Card) of a Node. This particular Network Interface * is modelled on an Ethernet Interface Card. * * <P>Different Nodes can contain different numbers of NetworkInterfaces. * A client PC usually only has one NetworkInterface, whereas a Router contains * at least two. A Hub or a Switch often has 8 or 16.</P> * * <P>In order for a Node to be able to send or receive network information (packets), * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> * * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and * the Link object they are connected to.</P> * * @author Tristan Veness * @author Bevan Calliess * @since 19 September 2004 * @version v0.20 */ class SerialNetworkInterface extends NetworkInterface{ /** * Constructs a NetworkInterface object with the name inName and a * reference to it's parent Node. * @author bevan_calliess * @param inName - The name to give the NetworkInterface eg: eth0 * @param parent - The Node that the NetworkInterface is to be added to, it's parent. * @version v0.20 */ protected SerialNetworkInterface(String inName, Node parent) { super(inName,parent); } protected void receivePacket(Packet inPacket) throws LowLinkException { } public int getType(){ return NetworkInterface.Serial; } protected void sendPacket(Packet inPacket) throws LowLinkException { } public boolean isActive(){ return false; } /** * This method displays details about the current interface card * @author bevan_calliess * @return String * @version v0.20 */ protected String getDetails(){ return "Interface: "+name + "\t\t" + "\t\t"+ getConnectLinkDetails(); } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Simulation.java 22 Nov 2006 21:18:38 -0000 1.13 --- Simulation.java 13 Oct 2007 12:57:00 -0000 1.14 *************** *** 595,598 **** --- 595,621 ---- } + public void addSerialLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) + throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { + + if (!linkTable.containsKey(inLinkName)) { + + //test if node's exist within hashtable + if(nodeTable.containsKey(inFirstNodeName) && nodeTable.containsKey(inSecondNodeName)){ + Node tempNode1 = (Node) nodeTable.get(inFirstNodeName); + Node tempNode2 = (Node) nodeTable.get(inSecondNodeName); + + //Return NetworkInterface from Node objects + NetworkInterface interface1 = tempNode1.getNetworkInterface(inFirstNodeInterface); + NetworkInterface interface2 = tempNode2.getNetworkInterface(inSecondNodeInterface); + + //Create link and add it to hashtable + linkTable.put(inLinkName,new SerialLink(inLinkName, interface1, interface2)); + }else{ + throw new InvalidNodeNameException("Invalid node name"); + } + } else + throw new InvalidLinkNameException("Link already exists with same name."); + } + /** * This method checks to see if inLinkName is contained within the has table(linkTable).If so, *************** *** 609,613 **** * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface, String sieveCoeff) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { --- 632,636 ---- * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface, String sieveCoeff ) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { *************** *** 1130,1139 **** { Vector vecInterfaceInfo = new Vector(); ! vecInterfaceInfo.add(inNodeName); vecInterfaceInfo.add(strDefaultGateway); String strInterfaceName = (String)it.next(); vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add((String)tempNetwork.getMACAddress(strInterfaceName)); String tempIP = tempNetwork.getIPAddress(strInterfaceName); if(tempIP != null) --- 1153,1163 ---- { Vector vecInterfaceInfo = new Vector(); ! vecInterfaceInfo.add(inNodeName); vecInterfaceInfo.add(strDefaultGateway); String strInterfaceName = (String)it.next(); vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add((String)tempNetwork.getIntSType(strInterfaceName)); ! vecInterfaceInfo.add((String)tempNetwork.getMACAddress(strInterfaceName)); String tempIP = tempNetwork.getIPAddress(strInterfaceName); if(tempIP != null) *************** *** 1169,1184 **** while(it.hasNext()) ! { Vector vecInterfaceInfo = new Vector(); vecInterfaceInfo.add(inNodeName); ! vecInterfaceInfo.add("Not Applicable"); ! String strInterfaceName = (String)it.next(); ! vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! NetworkInterface tempNetworkCard = tempData.getNetworkInterface(strInterfaceName); ! vecInterfaceInfo.add((String)tempNetworkCard.getConnectLinkName()); } --- 1193,1209 ---- while(it.hasNext()) ! { Vector vecInterfaceInfo = new Vector(); vecInterfaceInfo.add(inNodeName); ! String strInterfaceName = (String)it.next(); ! try{ ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add(strInterfaceName); ! vecInterfaceInfo.add((String)tempData.getIntSType(strInterfaceName)); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! NetworkInterface tempNetworkCard = tempData.getNetworkInterface(strInterfaceName); ! vecInterfaceInfo.add((String)tempNetworkCard.getConnectLinkName()); } Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Hub.java 24 Feb 2006 10:20:10 -0000 1.5 --- Hub.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 57,65 **** public Hub(String inName) { super(inName, 1); //pass name and protocolstack layer ! addNetworkInterface("eth0"); ! addNetworkInterface("eth1"); ! addNetworkInterface("eth2"); ! addNetworkInterface("eth3"); ! addNetworkInterface("eth4"); } --- 57,65 ---- public Hub(String inName) { super(inName, 1); //pass name and protocolstack layer ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "2", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "3", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "4", NetworkInterface.Ethernet10T, false); } *************** *** 115,119 **** --- 115,121 ---- }else{ sz=1; + System.out.println("Hub buffer overflow?"); System.out.println(th.toString()); + System.out.println(th.getStackTrace().length); throw new LowLinkException("Hub buffer overflow (packet loop flood?)."); } Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ProtocolStack.java 1 Dec 2005 15:03:28 -0000 1.6 --- ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.7 *************** *** 147,151 **** */ ! public abstract void receivePacket(Packet inPacket) throws LowLinkException,TransportLayerPortException; --- 147,151 ---- */ ! public abstract void receivePacket(Packet inPacket, String inInterface) throws LowLinkException,TransportLayerPortException; Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NetworkInterfacePort.java 14 Sep 2007 11:14:49 -0000 1.5 --- NetworkInterfacePort.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 186,189 **** --- 186,192 ---- } + public int getType(){ + return NetworkInterface.Ethernet10T; + } --- NEW FILE: SerialLink.java --- /* 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 core; import java.util.*; import core.FalseRandom; /** * SerialLink extends Link. It sets two Interface links to a pc. * @author luke_hamilton * @author bevan_calliess * @since Sep 17, 2004 * @version v0.20 */ public class SerialLink extends Link { /** * Constructor to be used by the Simulation when connecting 2 PC's * We have made a design decision to restrict a Ethernet link to only has 2 ends. * @author bevan_calliess * @author luke_hamilton * @param String Name - Node name eg: PC1 * @param inInterface1 The first Interface to connect this link to eg: eth0 * @param inInterface2 The Seceond Interface to connect this link to eg: eth1 * @throws InvalidLinkConnectionException */ public SerialLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); } } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NetworkInterface.java 9 Nov 2006 15:31:55 -0000 1.4 --- NetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.5 *************** *** 101,105 **** ! abstract class NetworkInterface implements Serializable{ /** The NetworkInterface's name, eg "eth0" */ --- 101,105 ---- ! public abstract class NetworkInterface implements Serializable{ /** The NetworkInterface's name, eg "eth0" */ *************** *** 113,118 **** protected Node parentNode; ! ! /** --- 113,143 ---- protected Node parentNode; ! public final static int Unknown = 0; ! public final static int Ethernet10T = 0; ! public final static int Serial = 1; ! public final static int Wireless = 2; ! ! public static String getIntName(int type){ ! switch(type){ ! case 0: ! return "eth"; ! case 1: ! return "cua"; ! case 2: ! return "wifi"; ! default: ! return "unk"; ! } ! } ! ! ! public boolean isActive(){ ! return false; ! } ! ! public int getType(){ ! return -1; ! } ! /** *************** *** 131,135 **** protected NetworkInterface(String inName, Node inParent) { ! name = inName; parentNode = inParent; --- 156,160 ---- protected NetworkInterface(String inName, Node inParent) { ! name = inName; parentNode = inParent; Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NetworkLayerDevice.java 12 Oct 2007 21:06:39 -0000 1.8 --- NetworkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.9 *************** *** 73,77 **** --- 73,81 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getSubnetMask(String inInterface) { + if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getSubnetMask(inInterface); + }else{ + return "Not Applicable"; + } } *************** *** 87,91 **** --- 91,99 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getIPAddress(String inInterface){ + if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getIPAddress(inInterface); + }else{ + return "Not Applicable"; + } } *************** *** 98,103 **** * @version v0.20 */ ! public void receivePacket(Packet inPacket) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket); } --- 106,111 ---- * @version v0.20 */ ! public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket, inInterface); } *************** *** 229,233 **** */ ! protected void setMACAddress(String inInterface, String inMACAddress) throws InvalidNetworkInterfaceNameException { if (NetworkInterfacetable.containsKey(inInterface)) { EthernetNetworkInterface tempNic = --- 237,241 ---- */ ! public void setMACAddress(String inInterface, String inMACAddress) throws InvalidNetworkInterfaceNameException { if (NetworkInterfacetable.containsKey(inInterface)) { EthernetNetworkInterface tempNic = Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Router.java 20 Nov 2005 20:30:53 -0000 1.2 --- Router.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 47,53 **** protected Router(String inName) { super(inName,3); ! addNetworkInterface("eth0"); ! addNetworkInterface("eth1"); ! } --- 47,53 ---- protected Router(String inName) { super(inName,3); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); } Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Switch.java 12 Oct 2006 17:55:11 -0000 1.5 --- Switch.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 61,84 **** IntCaches = new Hashtable(); ! addNetworkInterface("eth0"); ! Hashtable iceth0 = new Hashtable(); ! IntCaches.put("eth0", iceth0); ! addNetworkInterface("eth1"); ! Hashtable iceth1 = new Hashtable(); ! IntCaches.put("eth1", iceth1); ! addNetworkInterface("eth2"); ! Hashtable iceth2 = new Hashtable(); ! IntCaches.put("eth2", iceth2); ! addNetworkInterface("eth3"); ! Hashtable iceth3 = new Hashtable(); ! IntCaches.put("eth3", iceth3); - addNetworkInterface("eth4"); - Hashtable iceth4 = new Hashtable(); - IntCaches.put("eth4", iceth4); } --- 61,98 ---- IntCaches = new Hashtable(); + String name = NetworkInterface.getIntName(NetworkInterface.Ethernet10T); ! addNetworkInterface(name + "0", NetworkInterface.Ethernet10T, false); ! Hashtable iceth0 = new Hashtable(); ! IntCaches.put(name, iceth0); ! addNetworkInterface(name + "1", NetworkInterface.Ethernet10T, false); ! Hashtable iceth1 = new Hashtable(); ! IntCaches.put(name + "1", iceth1); ! addNetworkInterface(name + "2", NetworkInterface.Ethernet10T, false); ! Hashtable iceth2 = new Hashtable(); ! IntCaches.put(name + "2", iceth2); ! addNetworkInterface(name + "3", NetworkInterface.Ethernet10T, false); ! Hashtable iceth3 = new Hashtable(); ! IntCaches.put(name + "3", iceth3); ! ! addNetworkInterface(name + "4", NetworkInterface.Ethernet10T, false); ! Hashtable iceth4 = new Hashtable(); ! IntCaches.put(name + "4", iceth4); ! ! addNetworkInterface(name + "5", NetworkInterface.Ethernet10T, false); ! Hashtable iceth5 = new Hashtable(); ! IntCaches.put(name + "5", iceth5); ! ! addNetworkInterface(name + "6", NetworkInterface.Ethernet10T, false); ! Hashtable iceth6 = new Hashtable(); ! IntCaches.put(name + "6", iceth6); ! ! addNetworkInterface(name + "7", NetworkInterface.Ethernet10T, false); ! Hashtable iceth7 = new Hashtable(); ! IntCaches.put(name + "7", iceth7); } Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EthernetNetworkInterface.java 12 Oct 2006 16:14:14 -0000 1.7 --- EthernetNetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.8 *************** *** 106,110 **** Packet temp = tempPacket.getData(); ! parentNode.receivePacket(temp); }else{ //Packet is not for the Interface Drop Packet and record something in --- 106,110 ---- Packet temp = tempPacket.getData(); ! parentNode.receivePacket(temp, name); }else{ //Packet is not for the Interface Drop Packet and record something in *************** *** 119,122 **** --- 119,126 ---- } + public int getType(){ + return NetworkInterface.Ethernet10T; + } + /** * Typecasts the variables being passed in into a EthernetPacket packet and *************** *** 168,171 **** --- 172,179 ---- return MACAddress; } + + public boolean isActive(){ + return true; + } /** Index: ExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ExternalProxy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExternalProxy.java 22 Nov 2006 21:18:38 -0000 1.1 --- ExternalProxy.java 13 Oct 2007 12:57:00 -0000 1.2 *************** *** 69,73 **** super(inName,3); NodeProtocolStack.initNAT(); ! addNetworkInterface("eth0"); externalIP = null; Apps = new Hashtable(); --- 69,73 ---- super(inName,3); NodeProtocolStack.initNAT(); ! addNetworkInterface("eth0", NetworkInterface.Ethernet10T, true ); externalIP = null; Apps = new Hashtable(); *************** *** 122,129 **** }else{ ! NodeProtocolStack.receivePacket(inPacket); } }else{ ! NodeProtocolStack.receivePacket(inPacket); } } --- 122,129 ---- }else{ ! NodeProtocolStack.receivePacket(inPacket, "unk"); } }else{ ! NodeProtocolStack.receivePacket(inPacket, "unk"); } } |