Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Jonathan Hart
2014-09-23 16:58:04 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
09585c6272a7a3795453aa91f57f63b5e12d5771
09585c62
1 parent
1380eee1
Changed PortAddress API to allow multiple IP addresses per port
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
72 deletions
core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
View file @
09585c6
...
...
@@ -4,8 +4,6 @@ import java.util.Set;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
/**
* Service for administering the inventory of end-station hosts.
...
...
@@ -20,26 +18,34 @@ public interface HostAdminService {
void
removeHost
(
HostId
hostId
);
/**
* Binds an IP address and optional MAC address to the given connection
* point.
* Binds IP and MAC addresses to the given connection point.
* <p/>
* This method will overwrite any previously held address information for
* the connection point.
* The addresses are added to the set of addresses already bound to the
* connection point. If any of the fields in addresses is null, no change
* is made to the corresponding addresses in the store.
* {@link #unbindAddressesFromPort(PortAddresses)} must be use to unbind
* addresses that have previously been bound.
*
* @param addresses address object containing addresses to add and the port
* to add them to
*/
void
bindAddressesToPort
(
PortAddresses
addresses
);
/**
* Removes the addresses contained in the given PortAddresses object from
* the set of addresses bound to the port.
*
* @param ip the IP address to bind to the connection point. This parameter
* is mandatory and cannot be null.
* @param mac the optional MAC address to bind to the connection point. Can
* be set to null if no MAC address needs to be bound.
* @param connectPoint the connection point to bind the addresses to
* @param portAddresses set of addresses to remove and port to remove them
* from
*/
void
bindAddressesToPort
(
IpAddress
ip
,
MacAddress
mac
,
ConnectPoint
connectPoint
);
void
unbindAddressesFromPort
(
PortAddresses
portAddresses
);
/**
* Removes all address information for the given connection point.
*
* @param connectPoint the connection point to remove address information
*/
void
unbindAddressesFromPort
(
ConnectPoint
connectPoint
);
void
clearAddresses
(
ConnectPoint
connectPoint
);
/**
* Returns the addresses information for all connection points.
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
View file @
09585c6
...
...
@@ -99,19 +99,28 @@ public interface HostStore {
Set
<
Host
>
getConnectedHosts
(
DeviceId
deviceId
);
/**
* Updates the address information for a given port.
* Updates the address information for a given port. The given address
* information is added to any previously held information for the port.
*
* @param addresses the port and address information
*/
void
updateAddressBindings
(
PortAddresses
addresses
);
/**
* Removes the given addresses from the set of address information held for
* a port.
*
* @param addresses the port and address information
*/
void
removeAddressBindings
(
PortAddresses
addresses
);
/**
* Removes any previously stored address information for a given connection
* point.
*
* @param connectPoint the connection point
*/
void
remove
AddressBindings
(
ConnectPoint
connectPoint
);
void
clear
AddressBindings
(
ConnectPoint
connectPoint
);
/**
* Returns the address bindings stored for all connection points.
...
...
core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
View file @
09585c6
package
org
.
onlab
.
onos
.
net
.
host
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.MacAddress
;
/**
* Represents address information bound to a port.
*/
public
interface
PortAddresses
{
public
class
PortAddresses
{
private
final
ConnectPoint
connectPoint
;
private
final
Set
<
IpPrefix
>
ipAddresses
;
private
final
MacAddress
macAddress
;
/**
* Constructs a PortAddress object for the given connection point, with a
* set of IP addresses and a MAC address.
* <p/>
* Both address parameters are optional and can be set to null.
*
* @param connectPoint the connection point these addresses are for
* @param ips a set of IP addresses
* @param mac a MAC address
*/
public
PortAddresses
(
ConnectPoint
connectPoint
,
Set
<
IpPrefix
>
ips
,
MacAddress
mac
)
{
this
.
connectPoint
=
connectPoint
;
this
.
ipAddresses
=
(
ips
==
null
)
?
null
:
new
HashSet
<>(
ips
);
this
.
macAddress
=
mac
;
}
/**
* Returns the connection point this address information is bound to.
*
* @return the connection point
*/
ConnectPoint
connectPoint
();
public
ConnectPoint
connectPoint
()
{
return
connectPoint
;
}
/**
* Returns the
IP address bound to the port
.
* Returns the
set of IP addresses
.
*
* @return the IP address
* @return the IP address
es
*/
IpAddress
ip
();
public
Set
<
IpPrefix
>
ips
()
{
return
ipAddresses
;
}
/**
* Returns the MAC address
bound to the port
.
* Returns the MAC address.
*
* @return the MAC address
if one is bound, otherwise null
* @return the MAC address
*/
MacAddress
mac
();
public
MacAddress
mac
()
{
return
macAddress
;
}
}
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
deleted
100644 → 0
View file @
1380eee
package
org
.
onlab
.
onos
.
net
.
host
.
impl
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
public
class
DefaultPortAddresses
implements
PortAddresses
{
private
final
ConnectPoint
connectPoint
;
private
final
IpAddress
ipAddress
;
private
final
MacAddress
macAddress
;
public
DefaultPortAddresses
(
ConnectPoint
connectPoint
,
IpAddress
ip
,
MacAddress
mac
)
{
this
.
connectPoint
=
connectPoint
;
this
.
ipAddress
=
ip
;
this
.
macAddress
=
mac
;
}
@Override
public
ConnectPoint
connectPoint
()
{
return
connectPoint
;
}
@Override
public
IpAddress
ip
()
{
return
ipAddress
;
}
@Override
public
MacAddress
mac
()
{
return
macAddress
;
}
}
core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
View file @
09585c6
...
...
@@ -155,14 +155,18 @@ public class HostManager
}
@Override
public
void
bindAddressesToPort
(
IpAddress
ip
,
MacAddress
mac
,
ConnectPoint
connectPoint
)
{
store
.
updateAddressBindings
(
new
DefaultPortAddresses
(
connectPoint
,
ip
,
mac
));
public
void
bindAddressesToPort
(
PortAddresses
addresses
)
{
store
.
updateAddressBindings
(
addresses
);
}
@Override
public
void
unbindAddressesFromPort
(
ConnectPoint
connectPoint
)
{
store
.
removeAddressBindings
(
connectPoint
);
public
void
unbindAddressesFromPort
(
PortAddresses
portAddresses
)
{
store
.
removeAddressBindings
(
portAddresses
);
}
@Override
public
void
clearAddresses
(
ConnectPoint
connectPoint
)
{
store
.
clearAddressBindings
(
connectPoint
);
}
@Override
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
View file @
09585c6
...
...
@@ -128,9 +128,11 @@ public class HostMonitor implements TimerTask {
ConnectPoint
cp
=
new
ConnectPoint
(
device
.
id
(),
port
.
number
());
PortAddresses
addresses
=
hostStore
.
getAddressBindingsForPort
(
cp
);
if
(
addresses
.
ip
().
contains
(
targetIp
))
{
sendProbe
(
device
.
id
(),
port
,
addresses
,
targetIp
);
}
/*for (IpPrefix prefix : addresses.ips()) {
if (prefix.contains(targetIp)) {
sendProbe(device.id(), port, addresses, targetIp);
}
}*/
}
}
...
...
@@ -173,7 +175,7 @@ public class HostMonitor implements TimerTask {
}
arp
.
setSenderHardwareAddress
(
sourceMacAddress
)
.
setSenderProtocolAddress
(
portAddresses
.
ip
().
toOctets
())
//TODO .setSenderProtocolAddress(portAddresses.ips
().toOctets())
.
setTargetHardwareAddress
(
ZERO_MAC_ADDRESS
)
.
setTargetProtocolAddress
(
targetIp
.
toOctets
());
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
View file @
09585c6
...
...
@@ -198,12 +198,19 @@ public class SimpleHostStore implements HostStore {
@Override
public
void
updateAddressBindings
(
PortAddresses
addresses
)
{
portAddresses
.
put
(
addresses
.
connectPoint
(),
addresses
);
// TODO
portAddresses.put(addresses.connectPoint(), addresses);
}
@Override
public
void
removeAddressBindings
(
ConnectPoint
connectPoint
)
{
portAddresses
.
remove
(
connectPoint
);
public
void
removeAddressBindings
(
PortAddresses
addresses
)
{
// TODO Auto-generated method stub
}
@Override
public
void
clearAddressBindings
(
ConnectPoint
connectPoint
)
{
// TODO Auto-generated method stub
}
@Override
...
...
Please
register
or
login
to post a comment