* Features:
+ Optional features can be configured with "auto" to autodetect if
they are usable. This is the default value for JSON and XML support.
+ * Change:
+ + Modify checksum function. While this should be strictly
+ equivalent, if you notice CDP packets not accepted anymore, this
+ change is the first culprit.
lldpd (0.7.14)
* Features:
#include "lldpd.h"
+/**
+ * Compute the checksum as 16-bit word.
+ */
u_int16_t
frame_checksum(const u_char *cp, int len, int cisco)
{
unsigned int sum = 0, v = 0;
int oddbyte = 0;
- /* We compute in network byte order */
while ((len -= 2) >= 0) {
sum += *cp++ << 8;
sum += *cp++;
sum = (sum >> 16) + (sum & 0xffff);
sum += sum >> 16;
- sum = ntohs(sum);
return (0xffff & ~sum);
}
if (!(POKE_UINT16(end - pos_llc))) goto toobig;
checksum = frame_checksum(pos_cdp, end - pos_cdp, (version != 0) ? 1 : 0);
POKE_RESTORE(pos_checksum);
- if (!(POKE_UINT16(ntohs(checksum)))) goto toobig;
+ if (!(POKE_UINT16(checksum))) goto toobig;
if (interfaces_send_helper(global, hardware,
(char *)packet, end - packet) == -1) {
POKE_RESTORE(pos_len_edp);
if (!(POKE_UINT16(v))) goto toobig;
checksum = frame_checksum(pos_edp, v, 0);
- if (!(POKE_UINT16(ntohs(checksum)))) goto toobig;
+ if (!(POKE_UINT16(checksum))) goto toobig;
if (interfaces_send_helper(global, hardware,
(char *)packet, end - packet) == -1) {