Really not forwarding broadcast packets to the node we received it from

This commit is contained in:
senft-desktop 2012-11-30 10:47:27 +01:00
parent 42793ebe90
commit e4c66fbb35
2 changed files with 5 additions and 4 deletions

View File

@ -188,7 +188,7 @@ public class Node {
}
protected void forwardBroadcast(int packet_id, byte command, byte[] data,
SocketAddress originalSender) {
SocketAddress receivedFrom) {
ByteBuffer buffer = ByteBuffer.allocate(BUF_SIZE);
buffer.put(MessageType.BROADCAST);
@ -205,7 +205,7 @@ public class Node {
buffer.flip();
for (SocketAddress n : neighbors) {
if (!n.equals(originalSender)) {
if (!n.equals(receivedFrom)) {
try {
channel.send(buffer, n);
buffer.clear();

View File

@ -84,7 +84,7 @@ public class UDPHandler implements Runnable {
// "originalSender" and "data" are the same, because the only
// data of a STATUS broadcast is the original sender
node.forwardBroadcast(packet_id, command,
BufferUtil.addrToBytes(originalSender), originalSender);
BufferUtil.addrToBytes(originalSender), from);
LOGGER.log(
Level.INFO,
@ -111,7 +111,8 @@ public class UDPHandler implements Runnable {
}
private void receiveStatus(SocketAddress receivedFrom) {
LOGGER.info("Received status from " + receivedFrom.toString());
LOGGER.log(Level.INFO, "{0}: Received status from {1}",
new Object[] { node.getName(), receivedFrom.toString() });
List<String> neighbors = new ArrayList<String>();
while (buf.hasRemaining()) {