mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibC: Add definitions/stubs for IPv6 functionality
This lets us build some of the ports without patching out any of their IPv6 stuff.
This commit is contained in:
parent
1bd6705636
commit
e4339be13b
4 changed files with 67 additions and 0 deletions
|
@ -18,6 +18,7 @@ set(LIBC_SOURCES
|
|||
malloc.cpp
|
||||
mman.cpp
|
||||
mntent.cpp
|
||||
net.cpp
|
||||
netdb.cpp
|
||||
poll.cpp
|
||||
pthread_forward.cpp
|
||||
|
|
23
Userland/Libraries/LibC/net.cpp
Normal file
23
Userland/Libraries/LibC/net.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibC/errno.h>
|
||||
#include <LibC/net/if.h>
|
||||
#include <LibC/netinet/in.h>
|
||||
|
||||
in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
||||
|
||||
unsigned int if_nametoindex([[maybe_unused]] const char* ifname)
|
||||
{
|
||||
errno = ENODEV;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char* if_indextoname([[maybe_unused]] unsigned int ifindex, [[maybe_unused]] char* ifname)
|
||||
{
|
||||
errno = ENXIO;
|
||||
return nullptr;
|
||||
}
|
|
@ -46,4 +46,7 @@ struct ifreq {
|
|||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr // MAC address
|
||||
};
|
||||
|
||||
unsigned int if_nametoindex(const char* ifname);
|
||||
char* if_indextoname(unsigned int ifindex, char* ifname);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -25,6 +25,12 @@ in_addr_t inet_addr(const char*);
|
|||
#define IP_MULTICAST_LOOP 3
|
||||
#define IP_ADD_MEMBERSHIP 4
|
||||
#define IP_DROP_MEMBERSHIP 5
|
||||
#define IP_MULTICAST_IF 6
|
||||
#define IP_MULTICAST_TTL 7
|
||||
|
||||
/* Make sure these don't overlap with any other IPv4 and IPv6 options */
|
||||
#define MCAST_JOIN_SOURCE_GROUP 100
|
||||
#define MCAST_LEAVE_SOURCE_GROUP 101
|
||||
|
||||
#define IPPORT_RESERVED 1024
|
||||
#define IPPORT_USERRESERVED 5000
|
||||
|
@ -47,10 +53,39 @@ struct ip_mreq {
|
|||
struct in_addr imr_interface;
|
||||
};
|
||||
|
||||
struct group_source_req {
|
||||
uint32_t gsr_interface;
|
||||
struct sockaddr_storage gsr_group;
|
||||
struct sockaddr_storage gsr_source;
|
||||
};
|
||||
|
||||
struct ip_mreq_source {
|
||||
struct in_addr imr_multiaddr;
|
||||
struct in_addr imr_sourceaddr;
|
||||
struct in_addr imr_interface;
|
||||
};
|
||||
|
||||
#define IPV6_UNICAST_HOPS 1
|
||||
#define IPV6_MULTICAST_HOPS 2
|
||||
#define IPV6_MULTICAST_LOOP 3
|
||||
#define IPV6_MULTICAST_IF 4
|
||||
#define IPV6_ADD_MEMBERSHIP 5
|
||||
#define IPV6_DROP_MEMBERSHIP 6
|
||||
#define IP_ADD_SOURCE_MEMBERSHIP 7
|
||||
#define IP_DROP_SOURCE_MEMBERSHIP 8
|
||||
#define IPV6_V6ONLY 9
|
||||
|
||||
struct in6_addr {
|
||||
uint8_t s6_addr[16];
|
||||
};
|
||||
|
||||
#define IN6ADDR_ANY_INIT \
|
||||
{ \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
|
||||
}
|
||||
|
||||
extern struct in6_addr in6addr_any;
|
||||
|
||||
struct sockaddr_in6 {
|
||||
sa_family_t sin6_family; // AF_INET6.
|
||||
in_port_t sin6_port; // Port number.
|
||||
|
@ -59,4 +94,9 @@ struct sockaddr_in6 {
|
|||
uint32_t sin6_scope_id; // Set of interfaces for a scop
|
||||
};
|
||||
|
||||
struct ipv6_mreq {
|
||||
struct in6_addr ipv6mr_multiaddr;
|
||||
uint32_t ipv6mr_interface;
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue