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>
@@ -46,6 +47,8 @@ namespace net {
4647 template <typename IPv>
4748 using resolve_func = delegate<void (typename IPv::addr)>;
4849
50+ using Vip_list = std::unordered_set<typename IPV::addr>;
51+
4952
5053 // /
5154 // / NETWORK CONFIGURATION
@@ -80,19 +83,37 @@ namespace net {
8083 /* * Use DHCP to configure this interface */
8184 virtual void negotiate_dhcp (double timeout = 10.0 , dhcp_timeout_func = nullptr ) = 0;
8285
86+ /* * Get a list of virtual IP4 addresses assigned to this interface */
87+ virtual const Vip_list virtual_ips () const = 0;
88+
89+ /* * Check if an IP is a (possibly virtual) loopback address */
90+ virtual bool is_loopback (typename IPV::addr a) const = 0;
91+
92+ /* * Add an IP address as a virtual loopback IP */
93+ virtual void add_vip (typename IPV::addr a) = 0;
94+
95+ /* * Remove an IP address from the virtual loopback IP list */
96+ virtual void remove_vip (typename IPV::addr a) = 0;
97+
98+ /* * Determine the appropriate source address for a destination. */
99+ virtual typename IPV::addr get_source_addr (typename IPV::addr dest) = 0;
100+
101+ /* * Determine if an IP address is a valid source address for this stack */
102+ virtual bool is_valid_source (typename IPV::addr) = 0;
103+
83104
84105 // /
85106 // / PROTOCOL OBJECTS
86107 // /
87108
88109 /* * Get the IP protocol object for this interface */
89- virtual IPV& ip_obj () = 0;
110+ virtual IPV& ip_obj () = 0;
90111
91112 /* * Get the TCP protocol object for this interface */
92- virtual TCP& tcp () = 0;
113+ virtual TCP& tcp () = 0;
93114
94115 /* * Get the UDP protocol object for this interface */
95- virtual UDP& udp () = 0;
116+ virtual UDP& udp () = 0;
96117
97118
98119 // /
@@ -108,13 +129,13 @@ namespace net {
108129 // /
109130
110131 /* * Get the network interface device */
111- virtual hw::Nic& nic () = 0;
132+ virtual hw::Nic& nic () = 0;
112133
113134 /* * Get interface name for this interface **/
114- virtual std::string ifname () const = 0;
135+ virtual std::string ifname () const = 0;
115136
116137 /* * Get linklayer address for this interface **/
117- virtual MAC::Addr link_addr () = 0;
138+ virtual MAC::Addr link_addr () = 0;
118139
119140 /* * Add cache entry to the link / IP address cache */
120141 virtual void cache_link_addr (typename IPV::addr, MAC::Addr) = 0;
@@ -123,7 +144,7 @@ namespace net {
123144 virtual void flush_link_cache () = 0;
124145
125146 /* * Set the regular interval for link address cache flushing */
126- virtual void set_link_cache_flush_interval (std::chrono::minutes);
147+ virtual void set_link_cache_flush_interval (std::chrono::minutes) = 0 ;
127148
128149
129150 // /
0 commit comments