improve enum_routes and enum_net_interfaces for simulator

This commit is contained in:
arvidn 2020-01-07 18:14:36 +01:00 committed by Arvid Norberg
parent 2e15b3edfa
commit 37063afd5c
1 changed files with 6 additions and 3 deletions

View File

@ -511,7 +511,10 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
{
ip_interface wan;
wan.interface_address = ip;
wan.netmask = address_v4::from_string("255.255.255.255");
if (ip.is_v4())
wan.netmask = address_v4::from_string("255.0.0.0");
else
wan.netmask = address_v6::from_string("ffff::");
std::strcpy(wan.name, "eth0");
std::strcpy(wan.friendly_name, "Ethernet");
std::strcpy(wan.description, "Simulator Ethernet Adapter");
@ -803,7 +806,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
if (ip.is_v4())
{
r.destination = address_v4();
r.netmask = address_v4::from_string("255.255.255.0");
r.netmask = address_v4::from_string("255.0.0.0");
address_v4::bytes_type b = ip.to_v4().to_bytes();
b[3] = 1;
r.gateway = address_v4(b);
@ -811,7 +814,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
else
{
r.destination = address_v6();
r.netmask = address_v6::from_string("FFFF:FFFF:FFFF:FFFF::0");
r.netmask = address_v6::from_string("ffff:ffff:ffff:ffff::0");
address_v6::bytes_type b = ip.to_v6().to_bytes();
b[14] = 1;
r.gateway = address_v6(b);