mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
userspace/libc: add <arpa/inet.h>
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
ade1c77361
commit
d9433256ab
33
Userspace/libc/include/arpa/inet.h
Normal file
33
Userspace/libc/include/arpa/inet.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix C Library.
|
||||||
|
|
||||||
|
Fennix C Library is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ARPA_INET_H
|
||||||
|
#define ARPA_INET_H
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
uint32_t htonl(uint32_t hostlong);
|
||||||
|
uint16_t htons(uint16_t hostshort);
|
||||||
|
uint32_t ntohl(uint32_t netlong);
|
||||||
|
uint16_t ntohs(uint16_t netshort);
|
||||||
|
|
||||||
|
in_addr_t inet_addr(const char *);
|
||||||
|
char *inet_ntoa(struct in_addr);
|
||||||
|
const char *inet_ntop(int, const void *restrict, char *restrict, socklen_t);
|
||||||
|
int inet_pton(int, const char *restrict, void *restrict);
|
||||||
|
|
||||||
|
#endif // ARPA_INET_H
|
49
Userspace/libc/src/std/arpa/inet.c
Normal file
49
Userspace/libc/src/std/arpa/inet.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix C Library.
|
||||||
|
|
||||||
|
Fennix C Library is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
export uint32_t htonl(uint32_t hostlong)
|
||||||
|
{
|
||||||
|
return ((hostlong & 0x000000FF) << 24) |
|
||||||
|
((hostlong & 0x0000FF00) << 8) |
|
||||||
|
((hostlong & 0x00FF0000) >> 8) |
|
||||||
|
((hostlong & 0xFF000000) >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
export uint16_t htons(uint16_t hostshort)
|
||||||
|
{
|
||||||
|
return ((hostshort & 0x00FF) << 8) |
|
||||||
|
((hostshort & 0xFF00) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
export uint32_t ntohl(uint32_t netlong)
|
||||||
|
{
|
||||||
|
return htonl(netlong);
|
||||||
|
}
|
||||||
|
|
||||||
|
export uint16_t ntohs(uint16_t netshort)
|
||||||
|
{
|
||||||
|
return htons(netshort);
|
||||||
|
}
|
||||||
|
|
||||||
|
export in_addr_t inet_addr(const char *);
|
||||||
|
export char *inet_ntoa(struct in_addr);
|
||||||
|
export const char *inet_ntop(int, const void *restrict, char *restrict, socklen_t);
|
||||||
|
export int inet_pton(int, const char *restrict, void *restrict);
|
Loading…
x
Reference in New Issue
Block a user