diff --git a/Internetworking.zip b/Internetworking.zip new file mode 100644 index 0000000000000000000000000000000000000000..65c5ff488dc246cf0597bc8de544bcfd470f7375 Binary files /dev/null and b/Internetworking.zip differ diff --git a/src/main/java/cp/CPCookie.java b/src/main/java/cp/CPCookie.java index 161efa8b9fd284f1d194142d2629dd2519a60124..cd8ed74a6bb59d907fab4ab00146f52d96d028a1 100644 --- a/src/main/java/cp/CPCookie.java +++ b/src/main/java/cp/CPCookie.java @@ -1,4 +1,19 @@ package cp; public class CPCookie { + + private int cookie; + private long createdAt; + CPCookie(long createdAt, int cookie){ + this.createdAt = createdAt; + this.cookie = cookie; + } + + public int getCookie() { + return cookie; + } + + public long getCreatedAt() { + return createdAt; + } } diff --git a/src/main/java/cp/CPProtocol.java b/src/main/java/cp/CPProtocol.java index b44babeb6ff99c606df7625387a90ecfdbbb2542..44cfc8c02c240201b4daa8e373011ffbc93b7d59 100644 --- a/src/main/java/cp/CPProtocol.java +++ b/src/main/java/cp/CPProtocol.java @@ -112,6 +112,7 @@ public class CPProtocol extends Protocol { public void cookieProcesing(PhyConfiguration config, String cookie){ if(cookieMap.size() >= CP_HASHMAP_SIZE){ + System.out.println("Too many cookies."); return; } @@ -125,7 +126,7 @@ public class CPProtocol extends Protocol { CPCookieRequestMsg reqMsg = new CPCookieRequestMsg(); reqMsg.create(null); - this.PhyProto.send(new String (reqMsg.getDataBytes()), this.PhyConfig); + this.PhyProto .send(new String (reqMsg.getDataBytes()), this.PhyConfig); Msg resMsg = new CPMsg(); try { diff --git a/src/main/java/phy/PhyConfiguration.java b/src/main/java/phy/PhyConfiguration.java index b91e2bae334ecc7037e32c55a062eeb63642ac86..e434d09123e693f05f51590acf6eebf1e0027a7f 100644 --- a/src/main/java/phy/PhyConfiguration.java +++ b/src/main/java/phy/PhyConfiguration.java @@ -37,4 +37,19 @@ public class PhyConfiguration extends Configuration{ public int hashCode(String cookie){ return System.identityHashCode(cookie); } + + + //generated using Alt+Insert + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof PhyConfiguration that)) return false; + return remotePort == that.remotePort && isClient == that.isClient && Objects.equals(remoteIPAddress, that.remoteIPAddress) && pid == that.pid; + } + + //generated using Alt+Insert + @Override + public int hashCode() { + return Objects.hash(remotePort, remoteIPAddress, pid, isClient); + } }