1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/net_help/net_help.c
Oliver bb580d1c4f [sys net destiny]
- fixed a bug where the tcp retransmit timer triggered even before
beeing ready to receive an ACK
- fixed a bug where MSS option was added by mistake because checking for
the appropriate flag was broken
2012-02-12 04:26:55 +01:00

60 lines
1.0 KiB
C

/*
* common.c
*
* Created on: 05.10.2011
* Author: Oliver
*/
#include <stdio.h>
#include <thread.h>
#include <string.h>
#include "net_help.h"
void printArrayRange(uint8_t *array, uint16_t len, char *str)
{
int i = 0;
printf("-------------%s-------------\n", str);
for (i = 0; i < len; i++)
{
printf("%#x ", *(array+i));
}
printf("\n-----------%u-------------\n", len);
}
uint16_t csum(uint16_t sum, uint8_t *buf, uint16_t len)
{
int count;
uint16_t carry;
count = len >> 1;
if(count)
{
if(count)
{
carry = 0;
do
{
uint16_t t = (*buf << 8) + *(buf+1);
count--;
buf += 2;
sum += carry;
sum += t;
carry = (t > sum);
} while(count);
sum += carry;
}
}
if(len & 1)
{
uint16_t u = (*buf << 8);
sum += (*buf << 8);
if(sum < u)
{
sum++;
}
}
return sum;
}