diff options
author | Anton Kling <anton@kling.gg> | 2023-10-26 22:35:58 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-30 21:49:48 +0100 |
commit | f8e15da04472f5ed6a26e588de4a23cb3e1ba20b (patch) | |
tree | 9e646d6ba72dcc8f2eb95d04bac2a8b4a91ad946 /network/bytes.c | |
parent | cf60045bdb969f6fe44fe7dc9bf7cec593a0b05c (diff) |
Kernel: Fixup rtl8139, add basic ARP and ethernet support
Currently the ARP appears to be able to respond to requests.
Diffstat (limited to 'network/bytes.c')
-rw-r--r-- | network/bytes.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/network/bytes.c b/network/bytes.c new file mode 100644 index 0000000..94afa73 --- /dev/null +++ b/network/bytes.c @@ -0,0 +1,10 @@ +#include <network/bytes.h> + +uint16_t ntohs(uint16_t net) { return (net >> 8) | (net << 8); } + +uint16_t htons(uint16_t net) { return (net >> 8) | (net << 8); } + +uint32_t htonl(uint32_t net) { + return (((net & 0x000000FF) << 24) | ((net & 0x0000FF00) << 8) | + ((net & 0x00FF0000) >> 8) | ((net & 0xFF000000) >> 24)); +} |