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
42ffef9b
Commit
42ffef9b
authored
Jun 21, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change port
parent
303d46be
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
39 deletions
+36
-39
actions.rs
src/openflow/ofp13/events/actions.rs
+2
-2
flow_mod_handler.rs
src/openflow/ofp13/events/flow_mod/flow_mod_handler.rs
+2
-2
packet_out.rs
src/openflow/ofp13/events/packet_out.rs
+2
-2
ofp_port.rs
src/openflow/ofp13/ofp_port.rs
+30
-33
No files found.
src/openflow/ofp13/events/actions.rs
View file @
42ffef9b
...
@@ -149,7 +149,7 @@ impl Action {
...
@@ -149,7 +149,7 @@ impl Action {
let
_
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
_
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
match
action_code
{
match
action_code
{
t
if
t
==
(
ActionType
::
Output
as
u16
)
=>
{
t
if
t
==
(
ActionType
::
Output
as
u16
)
=>
{
let
port_code
=
bytes
.read_u
16
::
<
BigEndian
>
()
?
;
let
port_code
=
bytes
.read_u
32
::
<
BigEndian
>
()
?
;
let
len
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
len
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
Ok
(
Action
::
Oputput
(
PseudoPort
::
new
(
Ok
(
Action
::
Oputput
(
PseudoPort
::
new
(
port_code
,
port_code
,
...
@@ -212,7 +212,7 @@ impl Action {
...
@@ -212,7 +212,7 @@ impl Action {
Ok
(
Action
::
SetTpDest
(
pt
))
Ok
(
Action
::
SetTpDest
(
pt
))
}
}
t
if
t
==
(
ActionType
::
Enqueue
as
u16
)
=>
{
t
if
t
==
(
ActionType
::
Enqueue
as
u16
)
=>
{
let
pt
=
bytes
.read_u
16
::
<
BigEndian
>
()
?
;
let
pt
=
bytes
.read_u
32
::
<
BigEndian
>
()
?
;
bytes
.consume
(
6
);
bytes
.consume
(
6
);
let
qid
=
bytes
.read_u32
::
<
BigEndian
>
()
?
;
let
qid
=
bytes
.read_u32
::
<
BigEndian
>
()
?
;
Ok
(
Action
::
Enqueue
(
PseudoPort
::
new
(
pt
,
Some
(
0
)),
qid
))
Ok
(
Action
::
Enqueue
(
PseudoPort
::
new
(
pt
,
Some
(
0
)),
qid
))
...
...
src/openflow/ofp13/events/flow_mod/flow_mod_handler.rs
View file @
42ffef9b
...
@@ -72,7 +72,7 @@ impl FlowModEvent {
...
@@ -72,7 +72,7 @@ impl FlowModEvent {
let
hard_timeout
=
Timeout
::
parse
(
bytes
.read_u16
::
<
BigEndian
>
()
?
);
let
hard_timeout
=
Timeout
::
parse
(
bytes
.read_u16
::
<
BigEndian
>
()
?
);
let
priority
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
priority
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
buffer_id
=
bytes
.read_i32
::
<
BigEndian
>
()
?
;
let
buffer_id
=
bytes
.read_i32
::
<
BigEndian
>
()
?
;
let
out_port
=
PseudoPort
::
parse
(
bytes
.read_u
16
::
<
BigEndian
>
()
?
);
let
out_port
=
PseudoPort
::
parse
(
bytes
.read_u
32
::
<
BigEndian
>
()
?
);
let
flags
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
flags
=
bytes
.read_u16
::
<
BigEndian
>
()
?
;
let
actions
=
Action
::
parse_sequence
(
&
mut
bytes
);
let
actions
=
Action
::
parse_sequence
(
&
mut
bytes
);
Ok
(
FlowModEvent
{
Ok
(
FlowModEvent
{
...
@@ -119,7 +119,7 @@ impl MessageMarshal for FlowModEvent {
...
@@ -119,7 +119,7 @@ impl MessageMarshal for FlowModEvent {
match
self
.out_port
.as_ref
()
{
match
self
.out_port
.as_ref
()
{
Some
(
p
)
=>
p
.marshal
(
bytes
),
Some
(
p
)
=>
p
.marshal
(
bytes
),
None
=>
{
None
=>
{
let
_
=
bytes
.write_u
16
::
<
BigEndian
>
(
OfpPort
::
None
as
u16
);
let
_
=
bytes
.write_u
32
::
<
BigEndian
>
(
OfpPort
::
Any
as
u32
);
}
}
}
}
self
.flags
.marshal
(
bytes
);
self
.flags
.marshal
(
bytes
);
...
...
src/openflow/ofp13/events/packet_out.rs
View file @
42ffef9b
...
@@ -3,8 +3,8 @@ use std::{
...
@@ -3,8 +3,8 @@ use std::{
mem
::
size_of
,
mem
::
size_of
,
};
};
use
crate
::
openflow
::
ofp1
3
::
PseudoPort
;
use
crate
::
openflow
::
ofp1
0
::
PseudoPort
;
use
crate
::
openflow
::
ofp1
3
::{
ofp_port
::
OfpPort
,
MessageMarshal
,
Msg
};
use
crate
::
openflow
::
ofp1
0
::{
ofp_port
::
OfpPort
,
MessageMarshal
,
Msg
};
use
byteorder
::{
BigEndian
,
ReadBytesExt
,
WriteBytesExt
};
use
byteorder
::{
BigEndian
,
ReadBytesExt
,
WriteBytesExt
};
use
super
::{
actions
::
SizeCheck
,
Action
,
Payload
};
use
super
::{
actions
::
SizeCheck
,
Action
,
Payload
};
...
...
src/openflow/ofp13/ofp_port.rs
View file @
42ffef9b
use
byteorder
::{
BigEndian
,
WriteBytesExt
};
use
byteorder
::{
BigEndian
,
WriteBytesExt
};
#[repr(u32)]
pub
enum
OfpPort
{
pub
enum
OfpPort
{
Max
=
0xff00
,
Max
=
0xff
ffff
00
,
InPort
=
0xfff8
,
InPort
=
0xfff
ffff
8
,
Table
=
0xfff9
,
Table
=
0xfff
ffff
9
,
Normal
=
0xfffa
,
Normal
=
0xfff
ffff
a
,
Flood
=
0xfffb
,
Flood
=
0xfff
ffff
b
,
All
=
0xfffc
,
All
=
0xfff
ffff
c
,
Controller
=
0xfffd
,
Controller
=
0xfff
ffff
d
,
Local
=
0xfffe
,
Local
=
0xfff
ffff
e
,
None
=
0x
ffff
,
Any
=
0xffff
ffff
,
}
}
#[derive(Clone)]
#[derive(Clone)]
pub
enum
PseudoPort
{
pub
enum
PseudoPort
{
PhysicalPort
(
u
16
),
PhysicalPort
(
u
32
),
InPort
,
InPort
,
Table
,
Table
,
Normal
,
Normal
,
...
@@ -26,27 +27,23 @@ pub enum PseudoPort {
...
@@ -26,27 +27,23 @@ pub enum PseudoPort {
}
}
impl
PseudoPort
{
impl
PseudoPort
{
pub
fn
parse
(
byte
:
u16
)
->
Option
<
PseudoPort
>
{
pub
fn
parse
(
byte
:
u32
)
->
Option
<
PseudoPort
>
{
if
(
OfpPort
::
None
as
u16
)
==
byte
{
None
}
else
{
Some
(
PseudoPort
::
new
(
byte
,
Some
(
0
)))
Some
(
PseudoPort
::
new
(
byte
,
Some
(
0
)))
}
}
}
pub
fn
new
(
port
:
u32
,
len
:
Option
<
u64
>
)
->
PseudoPort
{
pub
fn
new
(
port
:
u16
,
len
:
Option
<
u64
>
)
->
PseudoPort
{
match
port
{
match
port
{
p
if
p
==
(
OfpPort
::
InPort
as
u
16
)
=>
PseudoPort
::
InPort
,
p
if
p
==
(
OfpPort
::
InPort
as
u
32
)
=>
PseudoPort
::
InPort
,
p
if
p
==
(
OfpPort
::
Table
as
u
16
)
=>
PseudoPort
::
Table
,
p
if
p
==
(
OfpPort
::
Table
as
u
32
)
=>
PseudoPort
::
Table
,
p
if
p
==
(
OfpPort
::
Normal
as
u
16
)
=>
PseudoPort
::
Normal
,
p
if
p
==
(
OfpPort
::
Normal
as
u
32
)
=>
PseudoPort
::
Normal
,
p
if
p
==
(
OfpPort
::
Flood
as
u
16
)
=>
PseudoPort
::
Flood
,
p
if
p
==
(
OfpPort
::
Flood
as
u
32
)
=>
PseudoPort
::
Flood
,
p
if
p
==
(
OfpPort
::
All
as
u
16
)
=>
PseudoPort
::
AllPorts
,
p
if
p
==
(
OfpPort
::
All
as
u
32
)
=>
PseudoPort
::
AllPorts
,
p
if
p
==
(
OfpPort
::
Controller
as
u
16
)
=>
match
len
{
p
if
p
==
(
OfpPort
::
Controller
as
u
32
)
=>
match
len
{
Some
(
len
)
=>
PseudoPort
::
Controller
(
len
),
Some
(
len
)
=>
PseudoPort
::
Controller
(
len
),
None
=>
PseudoPort
::
Unsupport
,
None
=>
PseudoPort
::
Unsupport
,
},
},
p
if
p
==
(
OfpPort
::
Local
as
u
16
)
=>
PseudoPort
::
InPort
,
p
if
p
==
(
OfpPort
::
Local
as
u
32
)
=>
PseudoPort
::
InPort
,
_
=>
{
_
=>
{
if
port
<=
(
OfpPort
::
Max
as
u
16
)
{
if
port
<=
(
OfpPort
::
Max
as
u
32
)
{
PseudoPort
::
PhysicalPort
(
port
)
PseudoPort
::
PhysicalPort
(
port
)
}
else
{
}
else
{
PseudoPort
::
Unsupport
PseudoPort
::
Unsupport
...
@@ -57,16 +54,16 @@ impl PseudoPort {
...
@@ -57,16 +54,16 @@ impl PseudoPort {
pub
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
pub
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
let
port
=
match
*
self
{
let
port
=
match
*
self
{
PseudoPort
::
PhysicalPort
(
p
)
=>
p
,
PseudoPort
::
PhysicalPort
(
p
)
=>
p
,
PseudoPort
::
InPort
=>
OfpPort
::
InPort
as
u
16
,
PseudoPort
::
InPort
=>
OfpPort
::
InPort
as
u
32
,
PseudoPort
::
Table
=>
OfpPort
::
Table
as
u
16
,
PseudoPort
::
Table
=>
OfpPort
::
Table
as
u
32
,
PseudoPort
::
Normal
=>
OfpPort
::
Normal
as
u
16
,
PseudoPort
::
Normal
=>
OfpPort
::
Normal
as
u
32
,
PseudoPort
::
Flood
=>
OfpPort
::
Flood
as
u
16
,
PseudoPort
::
Flood
=>
OfpPort
::
Flood
as
u
32
,
PseudoPort
::
AllPorts
=>
OfpPort
::
All
as
u
16
,
PseudoPort
::
AllPorts
=>
OfpPort
::
All
as
u
32
,
PseudoPort
::
Controller
(
_
)
=>
OfpPort
::
Controller
as
u
16
,
PseudoPort
::
Controller
(
_
)
=>
OfpPort
::
Controller
as
u
32
,
PseudoPort
::
Local
=>
OfpPort
::
Local
as
u
16
,
PseudoPort
::
Local
=>
OfpPort
::
Local
as
u
32
,
// not sure how to handle unsupport
// not sure how to handle unsupport
PseudoPort
::
Unsupport
=>
OfpPort
::
Flood
as
u
16
,
PseudoPort
::
Unsupport
=>
OfpPort
::
Flood
as
u
32
,
};
};
let
_
=
bytes
.write_u
16
::
<
BigEndian
>
(
port
);
let
_
=
bytes
.write_u
32
::
<
BigEndian
>
(
port
);
}
}
}
}
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