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
44d9a1e3
Commit
44d9a1e3
authored
Jun 02, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add error event
parent
349affa4
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
223 additions
and
5 deletions
+223
-5
controller_frame.rs
src/openflow/controller_frame.rs
+8
-1
error_handler.rs
src/openflow/ofp10/events/error/error_handler.rs
+44
-0
error_type.rs
src/openflow/ofp10/events/error/error_type.rs
+152
-0
mod.rs
src/openflow/ofp10/events/error/mod.rs
+5
-0
mod.rs
src/openflow/ofp10/events/mod.rs
+3
-0
message.rs
src/openflow/ofp10/message.rs
+1
-0
mod.rs
src/openflow/ofp10/mod.rs
+2
-2
ofp_v1_0.rs
src/openflow/ofp10/ofp_v1_0.rs
+8
-2
No files found.
src/openflow/controller_frame.rs
View file @
44d9a1e3
use
crate
::
openflow
::
ofp10
::{
traiter
::{
MessageMarshal
,
OfpMsgEvent
},
ErrorEvent
,
Msg
,
PacketInEvent
};
use
std
::{
use
std
::{
io
::{
Read
,
Write
},
io
::{
Read
,
Write
},
net
::
TcpStream
,
net
::
TcpStream
,
};
};
use
crate
::
openflow
::
ofp10
::{
Msg
,
PacketInEvent
,
traiter
::{
MessageMarshal
,
OfpMsgEvent
}};
use
super
::
tcp_listener
::
tcp_listener_handler
;
use
super
::
tcp_listener
::
tcp_listener_handler
;
...
@@ -31,6 +33,11 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
...
@@ -31,6 +33,11 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
let
message
=
self
.get_ofp
()
.msg_parse
(
message
as
u16
);
let
message
=
self
.get_ofp
()
.msg_parse
(
message
as
u16
);
match
message
{
match
message
{
Msg
::
Hello
=>
self
.send_msg
(
self
.get_ofp
()
.fetures_req
(),
xid
,
stream
),
Msg
::
Hello
=>
self
.send_msg
(
self
.get_ofp
()
.fetures_req
(),
xid
,
stream
),
Msg
::
Error
=>
{
let
error
=
ErrorEvent
::
parse
(
&
payload
);
println!
(
"Error {:?}"
,
error
.error_type
);
()
},
Msg
::
FeaturesReq
=>
(),
Msg
::
FeaturesReq
=>
(),
Msg
::
PacketIn
=>
{
Msg
::
PacketIn
=>
{
self
.packet_in_handler
(
xid
,
PacketInEvent
::
parse
(
&
payload
),
stream
);
self
.packet_in_handler
(
xid
,
PacketInEvent
::
parse
(
&
payload
),
stream
);
...
...
src/openflow/ofp10/events/error/error_handler.rs
0 → 100644
View file @
44d9a1e3
use
std
::{
io
::{
BufRead
,
Cursor
},
mem
::
size_of
};
use
crate
::
openflow
::
ofp10
::{
traiter
::
MessageMarshal
,
Msg
};
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
super
::
error_type
::
ErrorType
;
pub
struct
ErrorEvent
{
pub
error_type
:
ErrorType
,
pub
payload
:
Vec
<
u8
>
,
}
impl
ErrorEvent
{
pub
fn
new
(
error_type
:
ErrorType
,
payload
:
Vec
<
u8
>
)
->
Self
{
ErrorEvent
{
error_type
,
payload
,
}
}
pub
fn
parse
(
buf
:
&
Vec
<
u8
>
)
->
ErrorEvent
{
let
mut
bytes
=
Cursor
::
new
(
buf
);
let
error_type
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
error_code
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
code
=
ErrorType
::
new
(
error_type
,
error_code
);
let
payload
=
bytes
.fill_buf
()
.unwrap
()
.to_vec
();
ErrorEvent
::
new
(
code
,
payload
)
}
}
impl
MessageMarshal
for
ErrorEvent
{
fn
marshal
(
&
self
,
_
:
&
mut
Vec
<
u8
>
)
{}
fn
msg_code
(
&
self
)
->
crate
::
openflow
::
ofp10
::
Msg
{
Msg
::
Error
}
fn
msg_usize
<
OFP
:
crate
::
openflow
::
ofp10
::
traiter
::
OfpMsgEvent
>
(
&
self
,
ofp
:
&
OFP
)
->
usize
{
ofp
.msg_usize
(
Msg
::
Error
)
}
fn
size_of
(
&
self
)
->
usize
{
size_of
::
<
(
u16
,
u16
)
>
()
+
self
.payload
.len
()
}
}
src/openflow/ofp10/events/error/error_type.rs
0 → 100644
View file @
44d9a1e3
#
[
derive
(
Debug
)]
pub
enum
ErrorType
{
HelloFailed
(
HelloFailed
),
BadRequest
(
BadRequest
),
BadAction
(
BadAction
),
FlowModFailed
(
FlowModFailed
),
PortModFailed
(
PortModFailed
),
QueueOpFailed
(
QueueOpFailed
),
}
impl
ErrorType
{
pub
fn
new
(
error_type
:
u16
,
error_code
:
u16
)
->
ErrorType
{
match
error_type
{
0
=>
ErrorType
::
HelloFailed
(
HelloFailed
::
new
(
error_code
)),
1
=>
ErrorType
::
BadRequest
(
BadRequest
::
new
(
error_code
)),
2
=>
ErrorType
::
BadAction
(
BadAction
::
new
(
error_code
)),
3
=>
ErrorType
::
FlowModFailed
(
FlowModFailed
::
new
(
error_code
)),
4
=>
ErrorType
::
PortModFailed
(
PortModFailed
::
new
(
error_code
)),
5
=>
ErrorType
::
QueueOpFailed
(
QueueOpFailed
::
new
(
error_code
)),
_
=>
panic!
(
"bad error_type in error {}"
,
error_type
),
}
}
}
#[derive(Debug)]
pub
enum
HelloFailed
{
Incompatible
,
EPerm
,
}
impl
HelloFailed
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
Incompatible
,
_
=>
Self
::
EPerm
,
}
}
}
#[derive(Debug)]
pub
enum
BadRequest
{
BadVersion
,
BadType
,
BadStat
,
BadVendor
,
BadSubType
,
EPerm
,
BadLen
,
BufferEmpty
,
BufferUnkown
,
}
impl
BadRequest
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
BadVersion
,
1
=>
Self
::
BadType
,
2
=>
Self
::
BadStat
,
3
=>
Self
::
BadVendor
,
4
=>
Self
::
BadSubType
,
5
=>
Self
::
EPerm
,
6
=>
Self
::
BadLen
,
7
=>
Self
::
BufferEmpty
,
8
=>
Self
::
BufferUnkown
,
_
=>
Self
::
BadVersion
,
}
}
}
#[derive(Debug)]
pub
enum
BadAction
{
BadType
,
BadLen
,
BadVendor
,
BadVendotType
,
BadOutPort
,
BadArgument
,
EPerm
,
TooMany
,
BadQueue
,
}
impl
BadAction
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
BadType
,
1
=>
Self
::
BadLen
,
2
=>
Self
::
BadVendor
,
3
=>
Self
::
BadVendotType
,
4
=>
Self
::
BadOutPort
,
5
=>
Self
::
BadArgument
,
6
=>
Self
::
EPerm
,
7
=>
Self
::
TooMany
,
_
=>
Self
::
BadQueue
,
}
}
}
#[derive(Debug)]
pub
enum
FlowModFailed
{
AllTablesFull
,
Overlap
,
EPerm
,
BadEmergTimeout
,
BadCommand
,
Unsupported
,
}
impl
FlowModFailed
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
AllTablesFull
,
1
=>
Self
::
Overlap
,
2
=>
Self
::
EPerm
,
3
=>
Self
::
BadEmergTimeout
,
4
=>
Self
::
BadCommand
,
_
=>
Self
::
Unsupported
,
}
}
}
#[derive(Debug)]
pub
enum
PortModFailed
{
BadPort
,
BadHwAddr
,
}
impl
PortModFailed
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
BadPort
,
_
=>
Self
::
BadHwAddr
,
}
}
}
#[derive(Debug)]
pub
enum
QueueOpFailed
{
BadPort
,
BadQueue
,
EPerm
,
}
impl
QueueOpFailed
{
pub
fn
new
(
error_code
:
u16
)
->
Self
{
match
error_code
{
0
=>
Self
::
BadPort
,
1
=>
Self
::
BadQueue
,
_
=>
Self
::
EPerm
,
}
}
}
src/openflow/ofp10/events/error/mod.rs
0 → 100644
View file @
44d9a1e3
pub
mod
error_handler
;
pub
use
error_handler
::
ErrorEvent
;
pub
mod
error_type
;
\ No newline at end of file
src/openflow/ofp10/events/mod.rs
View file @
44d9a1e3
pub
mod
error
;
pub
use
error
::
ErrorEvent
;
pub
mod
packet_in
;
pub
mod
packet_in
;
pub
use
packet_in
::{
PacketInEvent
,
PacketInReason
};
pub
use
packet_in
::{
PacketInEvent
,
PacketInReason
};
...
...
src/openflow/ofp10/message.rs
View file @
44d9a1e3
pub
enum
Msg
{
pub
enum
Msg
{
Hello
,
Hello
,
Error
,
FeaturesReq
,
FeaturesReq
,
PacketIn
,
PacketIn
,
PacketOut
,
PacketOut
,
...
...
src/openflow/ofp10/mod.rs
View file @
44d9a1e3
...
@@ -5,8 +5,8 @@ pub mod ofp_port;
...
@@ -5,8 +5,8 @@ pub mod ofp_port;
pub
use
ofp_port
::
PseudoPort
;
pub
use
ofp_port
::
PseudoPort
;
pub
mod
events
;
pub
mod
events
;
pub
use
events
::{
FlowModEvent
,
HelloEvent
,
PacketInEvent
,
PacketOutEvent
};
pub
use
events
::{
ErrorEvent
,
FlowModEvent
,
HelloEvent
,
PacketInEvent
,
PacketOutEvent
};
pub
mod
traiter
;
pub
mod
ofp_header
;
pub
mod
ofp_header
;
pub
mod
ofp_v1_0
;
pub
mod
ofp_v1_0
;
pub
mod
traiter
;
src/openflow/ofp10/ofp_v1_0.rs
View file @
44d9a1e3
use
super
::{
events
::{
Action
,
FeaturesReqEvent
,
Payload
},
ofp_header
::{
OfpHeader
,
OfpHeader10
,
OpenflowHeader
},
traiter
::
OfpMsgEvent
,
HelloEvent
,
Msg
,
PacketOutEvent
};
use
super
::{
events
::{
Action
,
FeaturesReqEvent
,
Payload
},
ofp_header
::{
OfpHeader
,
OfpHeader10
,
OpenflowHeader
},
traiter
::
OfpMsgEvent
,
HelloEvent
,
Msg
,
PacketOutEvent
,
};
pub
struct
Openflow10
{}
pub
struct
Openflow10
{}
...
@@ -45,6 +49,7 @@ impl OfpMsgEvent for Openflow10 {
...
@@ -45,6 +49,7 @@ impl OfpMsgEvent for Openflow10 {
fn
msg_parse
(
&
self
,
msg
:
u16
)
->
Msg
{
fn
msg_parse
(
&
self
,
msg
:
u16
)
->
Msg
{
match
msg
{
match
msg
{
0
=>
Msg
::
Hello
,
0
=>
Msg
::
Hello
,
1
=>
Msg
::
Error
,
5
=>
Msg
::
FeaturesReq
,
5
=>
Msg
::
FeaturesReq
,
10
=>
Msg
::
PacketIn
,
10
=>
Msg
::
PacketIn
,
13
=>
Msg
::
PacketOut
,
13
=>
Msg
::
PacketOut
,
...
@@ -56,6 +61,7 @@ impl OfpMsgEvent for Openflow10 {
...
@@ -56,6 +61,7 @@ impl OfpMsgEvent for Openflow10 {
fn
msg_usize
(
&
self
,
msg
:
Msg
)
->
usize
{
fn
msg_usize
(
&
self
,
msg
:
Msg
)
->
usize
{
match
msg
{
match
msg
{
Msg
::
Hello
=>
0
,
Msg
::
Hello
=>
0
,
Msg
::
Error
=>
1
,
Msg
::
FeaturesReq
=>
5
,
Msg
::
FeaturesReq
=>
5
,
Msg
::
PacketIn
=>
10
,
Msg
::
PacketIn
=>
10
,
Msg
::
PacketOut
=>
13
,
Msg
::
PacketOut
=>
13
,
...
...
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