diff --git a/include/utils.h b/include/utils.h index bb651a1..08c983f 100644 --- a/include/utils.h +++ b/include/utils.h @@ -168,13 +168,20 @@ namespace Tins { /** - * \brief Retrieves entries int the routing table. + * \brief Retrieves entries in the routing table. * * \brief output ForwardIterator in which entries will be stored. */ template void route_entries(ForwardIterator output); + /** + * \brief Retrieves entries in the routing table. + * + * \return a vector which contains all of the route entries. + */ + std::vector route_entries(); + /** \brief Returns the 32 bit crc of the given buffer. * * \param data The input buffer. diff --git a/src/utils.cpp b/src/utils.cpp index d63996f..b7820fa 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -62,12 +62,12 @@ struct InterfaceCollector { #ifdef WIN32 bool operator() (PIP_ADAPTER_ADDRESSES addr) { ifaces.insert(addr->AdapterName); - return true; + return false; } #else bool operator() (struct ifaddrs *addr) { ifaces.insert(addr->ifa_name); - return true; + return false; } #endif }; @@ -121,6 +121,12 @@ HWAddress<6> resolve_hwaddr(IPv4Address ip, PacketSender &sender) { return resolve_hwaddr(sender.default_interface(), ip, sender); } +std::vector route_entries() { + std::vector entries; + route_entries(std::back_inserter(entries)); + return entries; +} + bool gateway_from_ip(IPv4Address ip, IPv4Address &gw_addr) { typedef std::vector entries_type; entries_type entries;