[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip DHCPC.java, NONE, 1.1 DHCPD.java, NONE, 1.1 D
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-10-13 12:57:06
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30660/core/protocolsuite/tcp_ip Modified Files: ARP.java Application.java IPV4Address.java IpV4.java ProtocolStack.java Added Files: DHCPC.java DHCPD.java DHCPPacket.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: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Application.java 1 Oct 2007 04:58:12 -0000 1.23 --- Application.java 13 Oct 2007 12:57:00 -0000 1.24 *************** *** 87,92 **** */ ! public abstract void SendData(int sock, String Data) throws LowLinkException, TransportLayerException, CommunicationException; public void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException --- 87,99 ---- */ ! public abstract void SendData(int sock, String Data) throws LowLinkException, TransportLayerException, CommunicationException; + public void SendData(int sock, String host, int port, String Data) throws LowLinkException, TransportLayerException, CommunicationException { + try{ + if(Connect(host, port)){ + SendData(sock, Data); + } + }catch(InvalidNetworkLayerDeviceException e){ throw new CommunicationException(e.toString()); } + } public void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException --- NEW FILE: DHCPPacket.java --- (This appears to be a binary file; contents omitted.) Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** ProtocolStack.java 23 Sep 2007 01:49:58 -0000 1.57 --- ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.58 *************** *** 77,80 **** --- 77,82 ---- import java.util.TimerTask; + import java.util.ArrayList; + import core.Error; *************** *** 740,745 **** */ ! public void receivePacket(Packet inPacket) throws LowLinkException{ if(inPacket instanceof ARP_packet){ packetARPCounter++; --- 742,748 ---- */ ! public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException{ + try{ if(inPacket instanceof ARP_packet){ packetARPCounter++; *************** *** 779,783 **** //if it is then pass it to the appropriate protocol ! if(mIPprotocol.isInternalIP(destIPAddress)){ --- 782,788 ---- //if it is then pass it to the appropriate protocol ! IPV4Address ip = new IPV4Address(destIPAddress); ! ! if(mIPprotocol.isInternalIP(destIPAddress) || ip.isBroadcast()){ *************** *** 953,956 **** --- 958,999 ---- } + + if(ip.isBroadcast()){ + + NetworkLayerDevice temp = (NetworkLayerDevice)mParentNode; + + ArrayList nics = mParentNode.getAllInterfacesNames(); + + for(int i=0; i<nics.size(); i++){ + if(!inInterface.equals((String)nics.get(i)) && temp.isActiveInterface((String)nics.get(i))){ + LayerInfo routeInfo = new LayerInfo(getClass().getName()); + routeInfo.setObjectName(getParentNodeName()); + routeInfo.setDataType(trimClassName(inPacket.getClass().getName())); + routeInfo.setLayer("Network"); + routeInfo.setDescription("Packet Received: Network Layer Device is Routable forwarding packet to interface " + (String)nics.get(i) + "."); + Simulation.addLayerInfo(routeInfo); + temp.sendPacket("FF:FF:FF:FF:FF:FF", inPacket, (String)nics.get(i) ); + } + } + + + + } + + }catch(InvalidIPAddressException e){ + }catch(InvalidNetworkInterfaceNameException e){ + }catch(CommunicationException ex){ + + String myName = mParentNode.getName(); + + System.out.println(myName + " unable to forward packet due to the following error: " + ex.toString()); + + }catch(LowLinkException ex){ + + String myName = mParentNode.getName(); + + // System.out.println(myName + " unable to forward packet due to the following error: " + ex.toString()); + + } } *************** *** 1224,1227 **** --- 1267,1275 ---- } + public Node getParentNode(){ + + return mParentNode; + + } Index: IPV4Address.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IPV4Address.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IPV4Address.java 1 Dec 2005 15:04:55 -0000 1.4 --- IPV4Address.java 13 Oct 2007 12:57:00 -0000 1.5 *************** *** 63,66 **** --- 63,78 ---- setIp(inDecimal); } + + public boolean isBroadcast(){ + //binaryIpAddress + String[] ip = getDecimalIp().split("\\."); + Integer firstoctet = new Integer(ip[0].trim()); + + if(firstoctet.intValue() == 255){ + return true; + }else{ + return false; + } + } /** *************** *** 234,240 **** try { Integer octet = new Integer(ip[i].trim()); ! if (octet.intValue() == 255){ //test all octet's for 255 ! throw new InvalidIPAddressException("Invalid IP Address, cant use Subnet Mask as IP address"); ! } if (i == 0){ //test first octect for 0 eg 0.1.2.3 is an invalid address --- 246,253 ---- try { Integer octet = new Integer(ip[i].trim()); ! //if (octet.intValue() == 255){ //test all octet's for 255 ! // throw new InvalidIPAddressException("Invalid IP Address, cant use Subnet Mask as IP address"); ! //} ! // FIXME if (i == 0){ //test first octect for 0 eg 0.1.2.3 is an invalid address *************** *** 448,451 **** --- 461,468 ---- } + if(inDecIPAddress.contains("255.255.255.255")){ + return true; + } + for (int i = 0; i < ip.length; i++){ try { --- NEW FILE: DHCPC.java --- (This appears to be a binary file; contents omitted.) Index: IpV4.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IpV4.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IpV4.java 26 Oct 2006 18:47:38 -0000 1.10 --- IpV4.java 13 Oct 2007 12:57:00 -0000 1.11 *************** *** 1,452 **** ! /* ! 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. [...1332 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 ! Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ARP.java 24 Feb 2006 15:41:43 -0000 1.7 --- ARP.java 13 Oct 2007 12:57:00 -0000 1.8 *************** *** 322,334 **** { String output= null; int tryings = 5; ! ! //this cleans out any entries older than 2 minutes ! ! cleanARPTable(); ! Iterator it = ARPTable.iterator(); --- 322,343 ---- { + + String output= null; int tryings = 5; ! ! IPV4Address ip; ! ! try{ ! ip = new IPV4Address(IPAddress); ! //this cleans out any entries older than 2 minutes + if(ip.isBroadcast()){ + return "FF:FF:FF:FF:FF:FF"; + } + }catch(Exception e){} + + cleanARPTable(); Iterator it = ARPTable.iterator(); --- NEW FILE: DHCPD.java --- (This appears to be a binary file; contents omitted.) |