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
tom
2014-09-12 14:48:04 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
0b11b746cdb52c5cd28acb4682d89f6811d1b9e6
0b11b746
2 parents
8bb16061
c3bd6950
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
core/api/src/main/java/org/onlab/onos/net/HostId.java
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
utils/misc/src/main/java/org/onlab/packet/VLANID.java
core/api/src/main/java/org/onlab/onos/net/HostId.java
View file @
0b11b74
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
java.net.URI
;
...
...
@@ -42,7 +43,7 @@ public final class HostId extends ElementId {
* @return host identifier
*/
// FIXME: replace vlanId long with a rich data-type, e.g. VLanId or something like that
public
static
HostId
hostId
(
MACAddress
mac
,
long
vlanId
)
{
public
static
HostId
hostId
(
MACAddress
mac
,
VLANID
vlanId
)
{
// FIXME: use more efficient means of encoding
return
hostId
(
"nic"
+
":"
+
mac
+
"/"
+
vlanId
);
}
...
...
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
View file @
0b11b74
...
...
@@ -12,7 +12,7 @@ public class IPAddress {
//lengths of address, in bytes
public
static
final
int
INET_LEN
=
4
;
public
static
final
int
INET6_LEN
=
6
;
public
static
final
int
INET6_LEN
=
1
6
;
protected
Version
version
;
//does it make more sense to have a integral address?
...
...
utils/misc/src/main/java/org/onlab/packet/VLANID.java
View file @
0b11b74
...
...
@@ -4,13 +4,28 @@ package org.onlab.packet;
* Representation of a VLAN ID.
*/
public
class
VLANID
{
// A VLAN ID is 12 bits, short is close
private
final
short
value
;
private
static
final
short
NONE
=
0
;
// A VLAN ID is actually 12 bits of a VLAN tag.
private
static
final
short
MAX_VLAN
=
4095
;
p
ublic
VLANID
(
short
value
)
{
p
rotected
VLANID
(
short
value
)
{
this
.
value
=
value
;
}
public
static
VLANID
vlanId
()
{
return
new
VLANID
(
NONE
);
}
public
static
VLANID
vlanId
(
short
value
)
{
if
(
value
>=
MAX_VLAN
)
{
throw
new
IllegalArgumentException
(
"value exceeds allowed maximum VLAN ID value (4095)"
);
}
return
new
VLANID
(
value
);
}
public
short
toShort
()
{
return
this
.
value
;
}
...
...
@@ -37,5 +52,10 @@ public class VLANID {
public
int
hashCode
()
{
return
this
.
value
;
}
@Override
public
String
toString
()
{
return
String
.
valueOf
(
this
.
value
);
}
}
...
...
Please
register
or
login
to post a comment