1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

Kernel+LibC+Userland: Start working on an IPv4 socket backend.

The first userland networking program will be "ping" :^)
This commit is contained in:
Andreas Kling 2019-03-12 15:51:42 +01:00
parent 8e667747f0
commit a017a77442
23 changed files with 374 additions and 3 deletions

19
LibC/arpa/inet.cpp Normal file
View file

@ -0,0 +1,19 @@
#include <arpa/inet.h>
#include <stdio.h>
#include <errno.h>
extern "C" {
const char* inet_ntop(int af, const void* src, char* dst, socklen_t len)
{
if (af != AF_INET) {
errno = EAFNOSUPPORT;
return nullptr;
}
auto* bytes = (const unsigned char*)src;
snprintf(dst, len, "%u.%u.%u.%u", bytes[3], bytes[2], bytes[1], bytes[0]);
return (const char*)dst;
}
}