Thread: [Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ARP.java, 1.11, 1.12 IPV4Address.java, 1.5, 1
Status: Beta
Brought to you by:
darkkey
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()); |