Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
3623e1e3
Commit
3623e1e3
authored
13 years ago
by
Alex Reimers
Browse files
Options
Downloads
Patches
Plain Diff
Re-added back in boolean Ethernet.isMACAddress(String macAddress).
parent
51aa40f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/packet/Ethernet.java
+21
-2
21 additions, 2 deletions
src/main/java/net/floodlightcontroller/packet/Ethernet.java
with
21 additions
and
2 deletions
src/main/java/net/floodlightcontroller/packet/Ethernet.java
+
21
−
2
View file @
3623e1e3
...
...
@@ -30,6 +30,7 @@ import org.openflow.util.HexString;
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
public
class
Ethernet
extends
BasePacket
{
private
static
String
HEXES
=
"0123456789ABCDEF"
;
public
static
final
short
TYPE_ARP
=
0x0806
;
public
static
final
short
TYPE_IPv4
=
0x0800
;
public
static
final
short
TYPE_LLDP
=
(
short
)
0x88cc
;
...
...
@@ -250,11 +251,29 @@ public class Ethernet extends BasePacket {
return
this
;
}
/**
* Checks to see if a string is a valid MAC address.
* @param macAddress
* @return True if macAddress is a valid MAC, False otherwise
*/
public
static
boolean
isMACAddress
(
String
macAddress
)
{
String
[]
macBytes
=
macAddress
.
split
(
":"
);
if
(
macBytes
.
length
!=
6
)
return
false
;
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
if
(
HEXES
.
indexOf
(
macBytes
[
i
].
toUpperCase
().
charAt
(
0
))
==
-
1
||
HEXES
.
indexOf
(
macBytes
[
i
].
toUpperCase
().
charAt
(
1
))
==
-
1
)
{
return
false
;
}
}
return
true
;
}
/**
* Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not
* matter, and returns a corresponding byte[].
* @param macAddress
* @return
* @param macAddress
The MAC address to convert into a bye array
* @return
The macAddress as a byte array
*/
public
static
byte
[]
toMACAddress
(
String
macAddress
)
{
return
MACAddress
.
valueOf
(
macAddress
).
toBytes
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment