Generate and add remote hosts for the interface. :param int count: Number of generated remote hosts.
(
self,
count=1,
remote_host_ip4_generator=remote_host_ip4_172_16_generator,
remote_host_ip6_generator=remote_host_ip6_fd01_generator,
)
| 181 | return self._hosts_by_ip6[ip] |
| 182 | |
| 183 | def generate_remote_hosts( |
| 184 | self, |
| 185 | count=1, |
| 186 | remote_host_ip4_generator=remote_host_ip4_172_16_generator, |
| 187 | remote_host_ip6_generator=remote_host_ip6_fd01_generator, |
| 188 | ): |
| 189 | """Generate and add remote hosts for the interface. |
| 190 | |
| 191 | :param int count: Number of generated remote hosts. |
| 192 | """ |
| 193 | self._remote_hosts = [] |
| 194 | self._hosts_by_mac = {} |
| 195 | self._hosts_by_ip4 = {} |
| 196 | self._hosts_by_ip6 = {} |
| 197 | for i in range(2, count + 2): # 0: network address, 1: local vpp address |
| 198 | mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i) |
| 199 | ip4 = remote_host_ip4_generator(self.sw_if_index, i) |
| 200 | ip6 = remote_host_ip6_generator(self.sw_if_index, i) |
| 201 | ip6_ll = mk_ll_addr(mac) |
| 202 | host = Host(mac, ip4, ip6, ip6_ll) |
| 203 | self._remote_hosts.append(host) |
| 204 | self._hosts_by_mac[mac] = host |
| 205 | self._hosts_by_ip4[ip4] = host |
| 206 | self._hosts_by_ip6[ip6] = host |
| 207 | |
| 208 | @abc.abstractmethod |
| 209 | def __init__(self, test): |