Added APIs for binding address information to ports and for monitoring hosts/ips
Showing
7 changed files
with
190 additions
and
11 deletions
1 | package org.onlab.onos.net.host; | 1 | package org.onlab.onos.net.host; |
2 | 2 | ||
3 | +import java.util.Set; | ||
4 | + | ||
5 | +import org.onlab.onos.net.ConnectPoint; | ||
3 | import org.onlab.onos.net.HostId; | 6 | import org.onlab.onos.net.HostId; |
7 | +import org.onlab.packet.IpAddress; | ||
8 | +import org.onlab.packet.MacAddress; | ||
4 | 9 | ||
5 | /** | 10 | /** |
6 | * Service for administering the inventory of end-station hosts. | 11 | * Service for administering the inventory of end-station hosts. |
... | @@ -14,4 +19,42 @@ public interface HostAdminService { | ... | @@ -14,4 +19,42 @@ public interface HostAdminService { |
14 | */ | 19 | */ |
15 | void removeHost(HostId hostId); | 20 | void removeHost(HostId hostId); |
16 | 21 | ||
22 | + /** | ||
23 | + * Binds an IP address and optional MAC address to the given connection | ||
24 | + * point. | ||
25 | + * <p/> | ||
26 | + * This method will overwrite any previously held address information for | ||
27 | + * the connection point. | ||
28 | + * | ||
29 | + * @param ip the IP address to bind to the connection point. This parameter | ||
30 | + * is mandatory and cannot be null. | ||
31 | + * @param mac the optional MAC address to bind to the connection point. Can | ||
32 | + * be set to null if no MAC address needs to be bound. | ||
33 | + * @param connectPoint the connection point to bind the addresses to | ||
34 | + */ | ||
35 | + void bindAddressesToPort(IpAddress ip, MacAddress mac, ConnectPoint connectPoint); | ||
36 | + | ||
37 | + /** | ||
38 | + * Removes all address information for the given connection point. | ||
39 | + * | ||
40 | + * @param connectPoint the connection point to remove address information | ||
41 | + */ | ||
42 | + void unbindAddressesFromPort(ConnectPoint connectPoint); | ||
43 | + | ||
44 | + /** | ||
45 | + * Returns the addresses information for all connection points. | ||
46 | + * | ||
47 | + * @return the set of address bindings for all connection points | ||
48 | + */ | ||
49 | + Set<PortAddresses> getAddressBindings(); | ||
50 | + | ||
51 | + /** | ||
52 | + * Retrieves the addresses that have been bound to the given connection | ||
53 | + * point. | ||
54 | + * | ||
55 | + * @param connectPoint the connection point to retrieve address bindings | ||
56 | + * for | ||
57 | + * @return addresses bound to the port | ||
58 | + */ | ||
59 | + PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint); | ||
17 | } | 60 | } | ... | ... |
... | @@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint; | ... | @@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint; |
6 | import org.onlab.onos.net.DeviceId; | 6 | import org.onlab.onos.net.DeviceId; |
7 | import org.onlab.onos.net.Host; | 7 | import org.onlab.onos.net.Host; |
8 | import org.onlab.onos.net.HostId; | 8 | import org.onlab.onos.net.HostId; |
9 | +import org.onlab.packet.IpAddress; | ||
9 | import org.onlab.packet.IpPrefix; | 10 | import org.onlab.packet.IpPrefix; |
10 | import org.onlab.packet.MacAddress; | 11 | import org.onlab.packet.MacAddress; |
11 | import org.onlab.packet.VlanId; | 12 | import org.onlab.packet.VlanId; |
... | @@ -87,7 +88,7 @@ public interface HostService { | ... | @@ -87,7 +88,7 @@ public interface HostService { |
87 | * | 88 | * |
88 | * @param ip IP address of the host to monitor | 89 | * @param ip IP address of the host to monitor |
89 | */ | 90 | */ |
90 | - void monitorIp(IpPrefix ip); | 91 | + void startMonitoringIp(IpAddress ip); |
91 | 92 | ||
92 | /** | 93 | /** |
93 | * Stops the host service from monitoring an IP address. | 94 | * Stops the host service from monitoring an IP address. |
... | @@ -95,7 +96,18 @@ public interface HostService { | ... | @@ -95,7 +96,18 @@ public interface HostService { |
95 | * @param ip IP address to stop monitoring | 96 | * @param ip IP address to stop monitoring |
96 | */ | 97 | */ |
97 | // TODO clients can cancel other client's requests | 98 | // TODO clients can cancel other client's requests |
98 | - void stopMonitoringIp(IpPrefix ip); | 99 | + void stopMonitoringIp(IpAddress ip); |
100 | + | ||
101 | + /** | ||
102 | + * Requests the host service to resolve the MAC address for the given IP | ||
103 | + * address. | ||
104 | + * <p/> | ||
105 | + * This will trigger a notification to the host listeners if the MAC | ||
106 | + * address is found. | ||
107 | + * | ||
108 | + * @param ip IP address to find the MAC address for | ||
109 | + */ | ||
110 | + void requestMac(IpAddress ip); | ||
99 | 111 | ||
100 | /** | 112 | /** |
101 | * Adds the specified host listener. | 113 | * Adds the specified host listener. | ... | ... |
1 | package org.onlab.onos.net.host; | 1 | package org.onlab.onos.net.host; |
2 | 2 | ||
3 | +import java.util.Set; | ||
4 | + | ||
3 | import org.onlab.onos.net.ConnectPoint; | 5 | import org.onlab.onos.net.ConnectPoint; |
4 | import org.onlab.onos.net.DeviceId; | 6 | import org.onlab.onos.net.DeviceId; |
5 | import org.onlab.onos.net.Host; | 7 | import org.onlab.onos.net.Host; |
... | @@ -9,8 +11,6 @@ import org.onlab.packet.IpPrefix; | ... | @@ -9,8 +11,6 @@ import org.onlab.packet.IpPrefix; |
9 | import org.onlab.packet.MacAddress; | 11 | import org.onlab.packet.MacAddress; |
10 | import org.onlab.packet.VlanId; | 12 | import org.onlab.packet.VlanId; |
11 | 13 | ||
12 | -import java.util.Set; | ||
13 | - | ||
14 | /** | 14 | /** |
15 | * Manages inventory of end-station hosts; not intended for direct use. | 15 | * Manages inventory of end-station hosts; not intended for direct use. |
16 | */ | 16 | */ |
... | @@ -98,4 +98,34 @@ public interface HostStore { | ... | @@ -98,4 +98,34 @@ public interface HostStore { |
98 | */ | 98 | */ |
99 | Set<Host> getConnectedHosts(DeviceId deviceId); | 99 | Set<Host> getConnectedHosts(DeviceId deviceId); |
100 | 100 | ||
101 | + /** | ||
102 | + * Updates the address information for a given port. | ||
103 | + * | ||
104 | + * @param addresses the port and address information | ||
105 | + */ | ||
106 | + void updateAddressBindings(PortAddresses addresses); | ||
107 | + | ||
108 | + /** | ||
109 | + * Removes any previously stored address information for a given connection | ||
110 | + * point. | ||
111 | + * | ||
112 | + * @param connectPoint the connection point | ||
113 | + */ | ||
114 | + void removeAddressBindings(ConnectPoint connectPoint); | ||
115 | + | ||
116 | + /** | ||
117 | + * Returns the address bindings stored for all connection points. | ||
118 | + * | ||
119 | + * @return the set of address bindings | ||
120 | + */ | ||
121 | + Set<PortAddresses> getAddressBindings(); | ||
122 | + | ||
123 | + /** | ||
124 | + * Returns the address bindings for a particular connection point. | ||
125 | + * | ||
126 | + * @param connectPoint the connection point to return address information | ||
127 | + * for | ||
128 | + * @return address information for the connection point | ||
129 | + */ | ||
130 | + PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint); | ||
101 | } | 131 | } | ... | ... |
1 | +package org.onlab.onos.net.host; | ||
2 | + | ||
3 | +import org.onlab.onos.net.ConnectPoint; | ||
4 | +import org.onlab.packet.IpAddress; | ||
5 | +import org.onlab.packet.MacAddress; | ||
6 | + | ||
7 | +/** | ||
8 | + * Represents address information bound to a port. | ||
9 | + */ | ||
10 | +public interface PortAddresses { | ||
11 | + | ||
12 | + /** | ||
13 | + * Returns the connection point this address information is bound to. | ||
14 | + * | ||
15 | + * @return the connection point | ||
16 | + */ | ||
17 | + ConnectPoint connectPoint(); | ||
18 | + | ||
19 | + /** | ||
20 | + * Returns the IP address bound to the port. | ||
21 | + * | ||
22 | + * @return the IP address | ||
23 | + */ | ||
24 | + IpAddress ip(); | ||
25 | + | ||
26 | + /** | ||
27 | + * Returns the MAC address bound to the port. | ||
28 | + * | ||
29 | + * @return the MAC address if one is bound, otherwise null | ||
30 | + */ | ||
31 | + MacAddress mac(); | ||
32 | +} |
... | @@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint; | ... | @@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint; |
6 | import org.onlab.onos.net.DeviceId; | 6 | import org.onlab.onos.net.DeviceId; |
7 | import org.onlab.onos.net.Host; | 7 | import org.onlab.onos.net.Host; |
8 | import org.onlab.onos.net.HostId; | 8 | import org.onlab.onos.net.HostId; |
9 | +import org.onlab.packet.IpAddress; | ||
9 | import org.onlab.packet.IpPrefix; | 10 | import org.onlab.packet.IpPrefix; |
10 | import org.onlab.packet.MacAddress; | 11 | import org.onlab.packet.MacAddress; |
11 | import org.onlab.packet.VlanId; | 12 | import org.onlab.packet.VlanId; |
... | @@ -55,11 +56,15 @@ public class HostServiceAdapter implements HostService { | ... | @@ -55,11 +56,15 @@ public class HostServiceAdapter implements HostService { |
55 | } | 56 | } |
56 | 57 | ||
57 | @Override | 58 | @Override |
58 | - public void monitorIp(IpPrefix ip) { | 59 | + public void startMonitoringIp(IpAddress ip) { |
59 | } | 60 | } |
60 | 61 | ||
61 | @Override | 62 | @Override |
62 | - public void stopMonitoringIp(IpPrefix ip) { | 63 | + public void stopMonitoringIp(IpAddress ip) { |
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public void requestMac(IpAddress ip) { | ||
63 | } | 68 | } |
64 | 69 | ||
65 | @Override | 70 | @Override | ... | ... |
... | @@ -26,8 +26,10 @@ import org.onlab.onos.net.host.HostProviderRegistry; | ... | @@ -26,8 +26,10 @@ import org.onlab.onos.net.host.HostProviderRegistry; |
26 | import org.onlab.onos.net.host.HostProviderService; | 26 | import org.onlab.onos.net.host.HostProviderService; |
27 | import org.onlab.onos.net.host.HostService; | 27 | import org.onlab.onos.net.host.HostService; |
28 | import org.onlab.onos.net.host.HostStore; | 28 | import org.onlab.onos.net.host.HostStore; |
29 | +import org.onlab.onos.net.host.PortAddresses; | ||
29 | import org.onlab.onos.net.provider.AbstractProviderRegistry; | 30 | import org.onlab.onos.net.provider.AbstractProviderRegistry; |
30 | import org.onlab.onos.net.provider.AbstractProviderService; | 31 | import org.onlab.onos.net.provider.AbstractProviderService; |
32 | +import org.onlab.packet.IpAddress; | ||
31 | import org.onlab.packet.IpPrefix; | 33 | import org.onlab.packet.IpPrefix; |
32 | import org.onlab.packet.MacAddress; | 34 | import org.onlab.packet.MacAddress; |
33 | import org.onlab.packet.VlanId; | 35 | import org.onlab.packet.VlanId; |
... | @@ -118,13 +120,18 @@ public class HostManager | ... | @@ -118,13 +120,18 @@ public class HostManager |
118 | } | 120 | } |
119 | 121 | ||
120 | @Override | 122 | @Override |
121 | - public void monitorIp(IpPrefix ip) { | 123 | + public void startMonitoringIp(IpAddress ip) { |
122 | - // TODO pass through to SimpleHostMonitor | 124 | + // TODO pass through to HostMonitor |
123 | } | 125 | } |
124 | 126 | ||
125 | @Override | 127 | @Override |
126 | - public void stopMonitoringIp(IpPrefix ip) { | 128 | + public void stopMonitoringIp(IpAddress ip) { |
127 | - // TODO pass through to SimpleHostMonitor | 129 | + // TODO pass through to HostMonitor |
130 | + } | ||
131 | + | ||
132 | + @Override | ||
133 | + public void requestMac(IpAddress ip) { | ||
134 | + // TODO Auto-generated method stub | ||
128 | } | 135 | } |
129 | 136 | ||
130 | @Override | 137 | @Override |
... | @@ -147,6 +154,31 @@ public class HostManager | ... | @@ -147,6 +154,31 @@ public class HostManager |
147 | } | 154 | } |
148 | } | 155 | } |
149 | 156 | ||
157 | + @Override | ||
158 | + public void bindAddressesToPort(IpAddress ip, MacAddress mac, | ||
159 | + ConnectPoint connectPoint) { | ||
160 | + // TODO Auto-generated method stub | ||
161 | + | ||
162 | + } | ||
163 | + | ||
164 | + @Override | ||
165 | + public void unbindAddressesFromPort(ConnectPoint connectPoint) { | ||
166 | + // TODO Auto-generated method stub | ||
167 | + | ||
168 | + } | ||
169 | + | ||
170 | + @Override | ||
171 | + public Set<PortAddresses> getAddressBindings() { | ||
172 | + // TODO Auto-generated method stub | ||
173 | + return null; | ||
174 | + } | ||
175 | + | ||
176 | + @Override | ||
177 | + public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
178 | + // TODO Auto-generated method stub | ||
179 | + return null; | ||
180 | + } | ||
181 | + | ||
150 | // Personalized host provider service issued to the supplied provider. | 182 | // Personalized host provider service issued to the supplied provider. |
151 | private class InternalHostProviderService | 183 | private class InternalHostProviderService |
152 | extends AbstractProviderService<HostProvider> | 184 | extends AbstractProviderService<HostProvider> | ... | ... |
... | @@ -24,15 +24,16 @@ import org.onlab.onos.net.HostId; | ... | @@ -24,15 +24,16 @@ import org.onlab.onos.net.HostId; |
24 | import org.onlab.onos.net.host.HostDescription; | 24 | import org.onlab.onos.net.host.HostDescription; |
25 | import org.onlab.onos.net.host.HostEvent; | 25 | import org.onlab.onos.net.host.HostEvent; |
26 | import org.onlab.onos.net.host.HostStore; | 26 | import org.onlab.onos.net.host.HostStore; |
27 | +import org.onlab.onos.net.host.PortAddresses; | ||
27 | import org.onlab.onos.net.provider.ProviderId; | 28 | import org.onlab.onos.net.provider.ProviderId; |
28 | import org.onlab.packet.IpPrefix; | 29 | import org.onlab.packet.IpPrefix; |
29 | import org.onlab.packet.MacAddress; | 30 | import org.onlab.packet.MacAddress; |
30 | import org.onlab.packet.VlanId; | 31 | import org.onlab.packet.VlanId; |
32 | +import org.slf4j.Logger; | ||
31 | 33 | ||
32 | import com.google.common.collect.HashMultimap; | 34 | import com.google.common.collect.HashMultimap; |
33 | import com.google.common.collect.ImmutableSet; | 35 | import com.google.common.collect.ImmutableSet; |
34 | import com.google.common.collect.Multimap; | 36 | import com.google.common.collect.Multimap; |
35 | -import org.slf4j.Logger; | ||
36 | 37 | ||
37 | /** | 38 | /** |
38 | * Manages inventory of end-station hosts using trivial in-memory | 39 | * Manages inventory of end-station hosts using trivial in-memory |
... | @@ -192,4 +193,28 @@ public class SimpleHostStore implements HostStore { | ... | @@ -192,4 +193,28 @@ public class SimpleHostStore implements HostStore { |
192 | return hostset; | 193 | return hostset; |
193 | } | 194 | } |
194 | 195 | ||
196 | + @Override | ||
197 | + public void updateAddressBindings(PortAddresses addresses) { | ||
198 | + // TODO Auto-generated method stub | ||
199 | + | ||
200 | + } | ||
201 | + | ||
202 | + @Override | ||
203 | + public void removeAddressBindings(ConnectPoint connectPoint) { | ||
204 | + // TODO Auto-generated method stub | ||
205 | + | ||
206 | + } | ||
207 | + | ||
208 | + @Override | ||
209 | + public Set<PortAddresses> getAddressBindings() { | ||
210 | + // TODO Auto-generated method stub | ||
211 | + return null; | ||
212 | + } | ||
213 | + | ||
214 | + @Override | ||
215 | + public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
216 | + // TODO Auto-generated method stub | ||
217 | + return null; | ||
218 | + } | ||
219 | + | ||
195 | } | 220 | } | ... | ... |
-
Please register or login to post a comment