} while (0)
#endif
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
+static inline size_t max(size_t a, size_t b) {
+ return a > b ? a : b;
+}
#ifdef UTCP_DEBUG
#include <stdarg.h>
if(len > sizeof hdr) {
uint32_t datalen = len - sizeof hdr;
uint8_t *str = malloc((datalen << 1) + 7);
+ if(!str) {
+ debug("out of memory");
+ return;
+ }
memcpy(str, " data=", 6);
uint8_t *strptr = str + 6;
const uint8_t *data = pkt;
* that are shifted to before the start of the receive buffer.
*
* There are three cases:
- * - the SACK entry is ahead of ^, in that case just change the offset.
+ * - the SACK entry is after ^, in that case just change the offset.
* - the SACK entry starts before and ends after ^, so we have to
* change both its offset and size.
* - the SACK entry is completely before ^, in that case delete it.
memmove(&c->sacks[i + 1], &c->sacks[i], (NSACKS - i - 1) * sizeof c->sacks[i]);
c->sacks[i].offset = offset;
c->sacks[i].len = rxd;
+ } else {
+ debug("SACK entries full, dropping packet\n");
}
break;
} else { // merge