Several years ago I wrte the following macro
to update a checksum when changing a word
in an IP packet.

here's the code...


  #define FIXSUM16(c, op, np)                                 \
    do {                                                      \
      (c) -= (u_int16_t) ~*((u_int16_t *) (op));              \
      if ((c) < 0) {                                          \
        (c) += 0xffff;                                        \
      }                                                       \
      (c) -= (u_int16_t)  *((u_int16_t *) (np));              \
      if ((c) < 0) {                                          \
        (c) += 0xffff;                                        \
      }                                                       \
    } while (0)



The question is:
apparently there are several "tricks" with this checksum
and + and - 0. Does anyone know how to test if this macro gets it
right?




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to