diff options
author | dzwdz | 2023-08-14 18:51:07 +0200 |
---|---|---|
committer | dzwdz | 2023-08-14 18:51:07 +0200 |
commit | 642b5fb0007b64c77d186fcb018d571152ee1d47 (patch) | |
tree | 1c466461f3602d306be309a053edae558ef2568e /src/user/app/netstack/util.h | |
parent | 8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff) |
reorganization: first steps
Diffstat (limited to 'src/user/app/netstack/util.h')
-rw-r--r-- | src/user/app/netstack/util.h | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/user/app/netstack/util.h b/src/user/app/netstack/util.h deleted file mode 100644 index 0b29560..0000000 --- a/src/user/app/netstack/util.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#define eprintf(fmt, ...) fprintf(stderr, "netstack: "fmt"\n" __VA_OPT__(,) __VA_ARGS__) - -uint32_t crc32(const uint8_t *buf, size_t len); -uint16_t ip_checksum(const uint8_t *buf, size_t len); -uint16_t ip_checksumphdr( - const uint8_t *buf, size_t len, - uint32_t ip1, uint32_t ip2, - uint16_t proto); -/* 0 on success, negative failure */ -int ip_parse(const char *s, uint32_t *ip); - -static inline void nput16(void *vbuf, uint16_t n) { - uint8_t *b = vbuf; - b[0] = n >> 8; - b[1] = n >> 0; -} - -static inline void nput32(void *vbuf, uint32_t n) { - uint8_t *b = vbuf; - b[0] = n >> 24; - b[1] = n >> 16; - b[2] = n >> 8; - b[3] = n >> 0; -} - -static inline uint16_t nget16(const void *vbuf) { - const uint8_t *b = vbuf; - return (b[0] << 8) - | (b[1] << 0); -} - -static inline uint32_t nget32(const void *vbuf) { - const uint8_t *b = vbuf; - return (b[0] << 24) - | (b[1] << 16) - | (b[2] << 8) - | (b[3] << 0); -} |