浏览代码

Add explanation for CDP checksum algorithm

Wolfgang Denk 19 年之前
父节点
当前提交
3ada834e30
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      net/net.c

+ 4 - 1
net/net.c

@@ -829,7 +829,10 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
 		}
 		if (len) {
 			leftover = (signed short)(*(const signed char *)buff);
-			/* * XXX CISCO SUCKS big time! (and blows too) */
+			/* CISCO SUCKS big time! (and blows too):
+			 * CDP uses the IP checksum algorithm with a twist;
+			 * for the last byte it *sign* extends and sums.
+			 */
 			result = (result & 0xffff0000) | ((result + leftover) & 0x0000ffff);
 		}
 		while (result >> 16)