I have been trying to calculate the LSA checksum for an OSPF packet without success.
I read the ospf's RFC and says there that you need to use the Fletcher algorithm. I tried to it but it still doesnt give the right answer. My code:
Void calccksum(lsaHeader* lsa)
{
  lsa->checksum = 0;
  unsigned short answer = 0;
  unsigned char* ptr = (unsigned char*) lsa;
  int len = ntohs(lsa->len);
  // skip the age field
  ptr += 2;
  len -= 2;
  unsigned short sum1 = 0;
  unsigned short sum2 = 0;
  for (int i=0; i<len; i++)
  {
     sum1 += *ptr;
     if (sum1 >= 255)
        sum1 -= 255;
     sum2 += sum1;
     if (sum2 >= 255)
        sum2 -= 255;
     ptr++;
    }
   answer = (sum2 << 8) | sum1;
   lsa->checksum = ntohs(answer);
}
Would love for some help.