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
ee7e37e4
Commit
ee7e37e4
authored
12 years ago
by
Wilson Ng
Browse files
Options
Downloads
Patches
Plain Diff
Initial check-in of VRS traceroute support [BVS-356]
parent
8936db01
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/ICMP.java
+31
-1
31 additions, 1 deletion
src/main/java/net/floodlightcontroller/packet/ICMP.java
with
31 additions
and
1 deletion
src/main/java/net/floodlightcontroller/packet/ICMP.java
+
31
−
1
View file @
ee7e37e4
...
...
@@ -18,6 +18,8 @@
package
net.floodlightcontroller.packet
;
import
java.nio.ByteBuffer
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Implements ICMP packet format
...
...
@@ -28,8 +30,23 @@ public class ICMP extends BasePacket {
protected
byte
icmpCode
;
protected
short
checksum
;
// The value is the number of bytes of padding
public
static
final
Map
<
Byte
,
Short
>
paddingMap
;
public
static
final
byte
ECHO_REPLY
=
0x0
;
public
static
final
byte
ECHO_REQUEST
=
0x8
;
public
static
final
byte
TIME_EXCEEDED
=
0xB
;
public
static
final
byte
DESTINATION_UNREACHABLE
=
0x3
;
public
static
final
byte
CODE_PORT_UNREACHABLE
=
0x3
;
static
{
paddingMap
=
new
HashMap
<
Byte
,
Short
>();
ICMP
.
paddingMap
.
put
(
ICMP
.
ECHO_REPLY
,
(
short
)
0
);
ICMP
.
paddingMap
.
put
(
ICMP
.
ECHO_REQUEST
,
(
short
)
0
);
ICMP
.
paddingMap
.
put
(
ICMP
.
TIME_EXCEEDED
,
(
short
)
4
);
ICMP
.
paddingMap
.
put
(
ICMP
.
DESTINATION_UNREACHABLE
,
(
short
)
4
);
}
/**
* @return the icmpType
...
...
@@ -84,7 +101,11 @@ public class ICMP extends BasePacket {
*/
@Override
public
byte
[]
serialize
()
{
int
length
=
4
;
short
padding
=
0
;
if
(
paddingMap
.
containsKey
(
this
.
icmpType
))
padding
=
paddingMap
.
get
(
this
.
icmpType
);
int
length
=
4
+
padding
;
byte
[]
payloadData
=
null
;
if
(
payload
!=
null
)
{
payload
.
setParent
(
this
);
...
...
@@ -98,6 +119,9 @@ public class ICMP extends BasePacket {
bb
.
put
(
this
.
icmpType
);
bb
.
put
(
this
.
icmpCode
);
bb
.
putShort
(
this
.
checksum
);
for
(
int
i
=
0
;
i
<
padding
;
i
++)
bb
.
put
((
byte
)
0
);
if
(
payloadData
!=
null
)
bb
.
put
(
payloadData
);
...
...
@@ -166,6 +190,12 @@ public class ICMP extends BasePacket {
this
.
icmpCode
=
bb
.
get
();
this
.
checksum
=
bb
.
getShort
();
short
padding
=
0
;
if
(
paddingMap
.
containsKey
(
this
.
icmpType
))
padding
=
paddingMap
.
get
(
this
.
icmpType
);
bb
.
position
(
bb
.
position
()
+
padding
);
this
.
payload
=
new
Data
();
this
.
payload
=
payload
.
deserialize
(
data
,
bb
.
position
(),
bb
.
limit
()-
bb
.
position
());
this
.
payload
.
setParent
(
this
);
...
...
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