1919#define NET_INET_HPP
2020
2121#include < chrono>
22+ #include < unordered_set>
2223
2324#include < net/inet_common.hpp>
2425#include < hw/mac_addr.hpp>
@@ -48,6 +49,7 @@ namespace net {
4849
4950 template <typename IPv>
5051 using resolve_func = delegate<void (typename IPv::addr)>;
52+ using Vip_list = std::unordered_set<typename IPV::addr>;
5153
5254 // /
5355 // / NETWORK CONFIGURATION
@@ -85,19 +87,37 @@ namespace net {
8587 /* * Use DHCP to configure this interface */
8688 virtual void negotiate_dhcp (double timeout = 10.0 , dhcp_timeout_func = nullptr ) = 0;
8789
90+ /* * Get a list of virtual IP4 addresses assigned to this interface */
91+ virtual const Vip_list virtual_ips () const = 0;
92+
93+ /* * Check if an IP is a (possibly virtual) loopback address */
94+ virtual bool is_loopback (typename IPV::addr a) const = 0;
95+
96+ /* * Add an IP address as a virtual loopback IP */
97+ virtual void add_vip (typename IPV::addr a) = 0;
98+
99+ /* * Remove an IP address from the virtual loopback IP list */
100+ virtual void remove_vip (typename IPV::addr a) = 0;
101+
102+ /* * Determine the appropriate source address for a destination. */
103+ virtual typename IPV::addr get_source_addr (typename IPV::addr dest) = 0;
104+
105+ /* * Determine if an IP address is a valid source address for this stack */
106+ virtual bool is_valid_source (typename IPV::addr) = 0;
107+
88108
89109 // /
90110 // / PROTOCOL OBJECTS
91111 // /
92112
93113 /* * Get the IP protocol object for this interface */
94- virtual IPV& ip_obj () = 0;
114+ virtual IPV& ip_obj () = 0;
95115
96116 /* * Get the TCP protocol object for this interface */
97- virtual TCP& tcp () = 0;
117+ virtual TCP& tcp () = 0;
98118
99119 /* * Get the UDP protocol object for this interface */
100- virtual UDP& udp () = 0;
120+ virtual UDP& udp () = 0;
101121
102122 /* * Get the ICMP protocol object for this interface */
103123 virtual ICMPv4& icmp () = 0;
@@ -122,13 +142,13 @@ namespace net {
122142 // /
123143
124144 /* * Get the network interface device */
125- virtual hw::Nic& nic () = 0;
145+ virtual hw::Nic& nic () = 0;
126146
127147 /* * Get interface name for this interface **/
128- virtual std::string ifname () const = 0;
148+ virtual std::string ifname () const = 0;
129149
130150 /* * Get linklayer address for this interface **/
131- virtual MAC::Addr link_addr () = 0;
151+ virtual MAC::Addr link_addr () = 0;
132152
133153 /* * Add cache entry to the link / IP address cache */
134154 virtual void cache_link_addr (typename IPV::addr, MAC::Addr) = 0;
@@ -137,7 +157,7 @@ namespace net {
137157 virtual void flush_link_cache () = 0;
138158
139159 /* * Set the regular interval for link address cache flushing */
140- virtual void set_link_cache_flush_interval (std::chrono::minutes);
160+ virtual void set_link_cache_flush_interval (std::chrono::minutes) = 0 ;
141161
142162
143163 // /
0 commit comments