// Look up an older packet for responses // Return true if the packet is unique; false if we have seen it before private boolean rememberPacket(GnutellaPacket pkt) { GnutellaConnection gc = (GnutellaConnection) packetTable.get(pkt.getGUID()); if (gc != null) return false; if (DEBUG) System.err.println("**** REMEMBERING: " + pkt + " from " + pkt.getConnection()); packetTable.put(pkt.getGUID(), pkt.getConnection()); return true; }
// Forward an incoming packet to the corresponding source private void forwardPacket(GnutellaPacket pkt) { GnutellaConnection gc; gc = (GnutellaConnection) packetTable.get(pkt.getGUID()); if (gc == null) { if (VERBOSE) System.err.println("-- Received reply with no request: " + pkt); return; } if (DEBUG) System.err.println("**** REPLYING: " + pkt + " to " + gc); if ((pkt.ttl == 0) || (--pkt.ttl == 0)) { if (VERBOSE) System.err.println("-- Dropping packet, TTL expired: " + pkt); } pkt.hops++; gc.enqueue_lossy(pkt); }