I found an issue with the checksum routine. 
It was seen when sending group specific query with a high group number. 
e.g. 239.254.85.22.

It appears the checksum routine was folding the sum on every addition. The 
correct behavior is to fold after finishing the sum.

Here is a patch that fixes it.



-- 
You received this message because you are subscribed to the Google Groups 
"Multicast Proxy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--- a/mcproxy/src/utils/mroute_socket.cpp
+++ b/mcproxy/src/utils/mroute_socket.cpp
@@ -157,17 +157,23 @@ u_int16_t mroute_socket::calc_checksum(c
 
     u_int16_t* b = (u_int16_t*)buf;
     int sum = 0;
+    int csum;
 
     for (int i = 0; i < buf_size / 2; i++) {
-        ADD_SIGNED_NUM_U16(sum, b[i]);
-        //sum +=b[i];
+        sum +=b[i];
     }
 
     if (buf_size % 2 == 1) {
-        //sum += buf[buf_size-1];
-        ADD_SIGNED_NUM_U16(sum, buf[buf_size - 1]);
+        sum += buf[buf_size-1];
     }
 
+    // fold checksum 
+    csum = sum & 0xFFFF;
+    sum = sum >> 16;
+    sum += csum;
+    // fold again in case of overflow.
+    sum += sum >> 16;
+
     return ~sum;
 }
 

Reply via email to