Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
Tenjin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
Tenjin
Commits
591e2223
Commit
591e2223
authored
Jun 04, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix parse wrong packetInReason code
parent
c48821ad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
controller.rs
src/controller.rs
+3
-0
packet_in.rs
src/openflow/ofp10/events/packet_in.rs
+15
-6
No files found.
src/controller.rs
View file @
591e2223
...
...
@@ -39,6 +39,7 @@ impl ControllerFrame<Openflow10> for Controller {
* Start here for handle packetIn message.
*/
fn
packet_in_handler
(
&
mut
self
,
xid
:
u32
,
packetin
:
PacketInEvent
,
stream
:
&
mut
TcpStream
)
{
println!
(
"reason {:?}"
,
packetin
.reason
);
let
pkt
=
packetin
.ether_parse
();
self
.mac_to_port
.insert
(
pkt
.mac_src
,
packetin
.in_port
);
...
...
@@ -62,9 +63,11 @@ impl ControllerFrame<Openflow10> for Controller {
match_fields
.mac_dest
=
Some
(
mac_dst
);
match_fields
.mac_src
=
Some
(
mac_src
);
if
let
Some
(
buf_id
)
=
packetin
.buf_id
{
println!
(
"found buf id"
);
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
Some
(
buf_id
as
u32
),
stream
);
return
;
}
else
{
println!
(
"not found buf id"
);
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
None
,
stream
);
}
}
...
...
src/openflow/ofp10/events/packet_in.rs
View file @
591e2223
...
...
@@ -4,10 +4,23 @@ use super::Payload;
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
std
::
io
::{
BufRead
,
Cursor
};
#[derive(Debug)]
pub
enum
PacketInReason
{
NoMatch
,
Action
,
Unknown
,
InvalidTTL
,
Unknown
(
u8
),
}
impl
PacketInReason
{
fn
new
(
code
:
u8
)
->
Self
{
match
code
{
0
=>
PacketInReason
::
NoMatch
,
1
=>
PacketInReason
::
Action
,
2
=>
PacketInReason
::
InvalidTTL
,
t
=>
PacketInReason
::
Unknown
(
t
),
}
}
}
pub
struct
PacketInEvent
{
...
...
@@ -33,11 +46,7 @@ impl PacketInEvent {
};
let
total_len
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
in_port
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
reason
=
match
bytes
.read_u8
()
.unwrap
()
{
1
=>
PacketInReason
::
NoMatch
,
2
=>
PacketInReason
::
Action
,
_
=>
PacketInReason
::
Unknown
,
};
let
reason
=
PacketInReason
::
new
(
bytes
.read_u8
()
.unwrap
());
let
table_id
=
bytes
.read_u8
()
.unwrap
();
let
packet
=
bytes
.fill_buf
()
.unwrap
()
.to_vec
();
let
payload
=
match
buf_id
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment