[Javanetsim-cvs] javaNetSim/core EthernetNetworkInterface.java,1.4,1.5 NetworkLayerDevice.java,1.5,1
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-12-08 16:45:24
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24020/core Modified Files: EthernetNetworkInterface.java NetworkLayerDevice.java Simulation.java Log Message: MAC Addr. S/L Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NetworkLayerDevice.java 20 Nov 2005 20:30:53 -0000 1.5 --- NetworkLayerDevice.java 8 Dec 2005 16:45:08 -0000 1.6 *************** *** 220,223 **** --- 220,242 ---- } + /** + * This method will set the mac address for a network interface. + * @param inInterface - The Interface name eg: eth0 + * @param macAddress - The MAC address on the Interface card was set. + * @throws InvalidNetworkInterfaceNameException + */ + + protected void setMACAddress(String inInterface, String inMACAddress) throws InvalidNetworkInterfaceNameException { + if (NetworkInterfacetable.containsKey(inInterface)) { + EthernetNetworkInterface tempNic = + (EthernetNetworkInterface) NetworkInterfacetable.get( + inInterface); + tempNic.setMacAddress(inMACAddress); + + } else { + throw new InvalidNetworkInterfaceNameException("Interface does not exist"); + } + } + /** * This method will call the protocol stacks' add to ARP method Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EthernetNetworkInterface.java 20 Nov 2005 20:30:53 -0000 1.4 --- EthernetNetworkInterface.java 8 Dec 2005 16:45:08 -0000 1.5 *************** *** 197,200 **** --- 197,206 ---- } + protected final void setMacAddress(String macAddress){ + this.MACAddress = macAddress; + } + + + /** * This method displays details about the current interface card Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Simulation.java 3 Dec 2005 12:20:52 -0000 1.6 --- Simulation.java 8 Dec 2005 16:45:08 -0000 1.7 *************** *** 202,205 **** --- 202,228 ---- } + /** + * This method is called from the GUI. Checks to see if inNodeName is an instance of networkLayerDevice, + * if so, move up to the NetworkLayerDevice and then returns the mac address of the interface passed in. Else it will throw exceptions. + * @author key + * @param inNodeName - The Name of the Node eg: pc1 + * @param inInterface - The Interface Name eg: eth0 + * @return MAC ADDRESS + * @throws InvalidNetworkLayerDeviceException + * @throws InvalidNodeNameException + * @version v0.20 + **/ + public String getMacAddressForInterface(String inNodeName, String inInterface) throws InvalidNetworkInterfaceNameException, InvalidNodeNameException, InvalidNetworkLayerDeviceException { + if(nodeTable.containsKey(inNodeName)){ + Node temp = (Node)nodeTable.get(inNodeName); + if (temp instanceof NetworkLayerDevice){ + NetworkLayerDevice tempNode = (NetworkLayerDevice)nodeTable.get(inNodeName); + return tempNode.getMACAddress(inInterface); + } + throw new InvalidNetworkLayerDeviceException("This node is not a network layered device."); + } + throw new InvalidNodeNameException("Node does not exist."); + } + /** * This method is called from TEXTUI or GUI. If inNodeName is an instance of node pass it up to the *************** *** 417,420 **** --- 440,475 ---- } } + + /** + * This method will set the MAC Address of a Node interface. + * This method needs to test if the inNodeName is valid. + * Please note that static can still be implemented but we are currently using + * Dynamic ARP. + * @author luke_hamilton + * @author bevan_calliess + * @param inNodeName - The Name of the Node eg: pc1 + * @param inNodeInterface - The Interface name eg: eth0 + * @param inMACAddress - The MAC address + * @throws InvalidNetworkLayerDeviceException + * @throws InvalidNodeNameException + * @version v0.20 + **/ + public void setMACAddress(String inNodeName, String inNodeInterface, String inMACAddress) throws InvalidNodeNameException, InvalidNetworkInterfaceNameException, InvalidNetworkLayerDeviceException{ + + if(nodeTable.containsKey(inNodeName)){ + Node temp = (Node)nodeTable.get(inNodeName); + if (temp instanceof NetworkLayerDevice){ //test if device is a network layer device + NetworkLayerDevice t = (NetworkLayerDevice)temp; + t.setMACAddress(inNodeInterface,inMACAddress); + //updateARP(inIPAddress, macAddress, inNodeName); + //t.addToARP(inIPAddress, macAddress); + }else{ + throw new InvalidNetworkLayerDeviceException("This device is not a network layered device"); + } + }else{ + throw new InvalidNodeNameException("Node does not exist"); + } + } + /** * This method will loop through the node hash table, checking whether its |