Merge pull request #236 from ssiloti/master

simulator: support IPv6 in enum_routes()
This commit is contained in:
Arvid Norberg 2015-10-30 02:14:00 -04:00
commit c6997fec24
1 changed files with 16 additions and 5 deletions

View File

@ -718,11 +718,22 @@ namespace libtorrent
for (int i = 0; i < int(ips.size()); ++i) for (int i = 0; i < int(ips.size()); ++i)
{ {
ip_route r; ip_route r;
if (ips[i].is_v4())
{
r.destination = address_v4(); r.destination = address_v4();
r.netmask = address_v4::from_string("255.255.255.0"); r.netmask = address_v4::from_string("255.255.255.0");
address_v4::bytes_type b = ips[i].to_v4().to_bytes(); address_v4::bytes_type b = ips[i].to_v4().to_bytes();
b[3] = 1; b[3] = 1;
r.gateway = address_v4(b); r.gateway = address_v4(b);
}
else
{
r.destination = address_v6();
r.netmask = address_v6::from_string("FFFF:FFFF:FFFF:FFFF::0");
address_v6::bytes_type b = ips[i].to_v6().to_bytes();
b[14] = 1;
r.gateway = address_v6(b);
}
strcpy(r.name, "eth0"); strcpy(r.name, "eth0");
r.mtu = ios.sim().config().path_mtu(ips[i], ips[i]); r.mtu = ios.sim().config().path_mtu(ips[i], ips[i]);
ret.push_back(r); ret.push_back(r);