Commit 490eb6e7 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

move traiter into ofp10

parent 3c3c717f
...@@ -4,14 +4,11 @@ use std::{collections::HashMap, net::TcpStream}; ...@@ -4,14 +4,11 @@ use std::{collections::HashMap, net::TcpStream};
use crate::{ use crate::{
etherparser::ether_type::EtherType, etherparser::ether_type::EtherType,
openflow::{ openflow::ofp10::{
ofp10::{ self,
self, events::{flow_mod::MatchFields, Action},
events::{flow_mod::MatchFields, Action}, ofp_manager::Openflow10,
ofp_manager::Openflow10, ControllerFrame10, FlowModEvent, OfpMsgEvent, PacketInEvent,
ControllerFrame10, FlowModEvent, PacketInEvent,
},
traiter::OfpMsgEvent,
}, },
}; };
/** /**
......
pub mod ofp10; pub mod ofp10;
pub mod traiter; \ No newline at end of file
\ No newline at end of file
use crate::openflow::{ use crate::openflow::ofp10::{ErrorEvent, Msg, PacketInEvent};
ofp10::{ErrorEvent, Msg, PacketInEvent},
traiter::{MessageMarshal, OfpMsgEvent},
};
use std::{ use std::{
io::{Read, Write}, io::{Read, Write},
net::TcpStream, net::TcpStream,
}; };
use super::tcp_listener_handler; use super::{tcp_listener_handler, MessageMarshal, OfpMsgEvent};
pub trait ControllerFrame10 { pub trait ControllerFrame10 {
fn get_ofp(&self) -> &impl OfpMsgEvent; fn get_ofp(&self) -> &impl OfpMsgEvent;
......
...@@ -4,10 +4,7 @@ use std::{ ...@@ -4,10 +4,7 @@ use std::{
}; };
use super::error_type::ErrorType; use super::error_type::ErrorType;
use crate::openflow::{ use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent};
ofp10::Msg,
traiter::{MessageMarshal, OfpMsgEvent},
};
use byteorder::{BigEndian, ReadBytesExt}; use byteorder::{BigEndian, ReadBytesExt};
pub struct ErrorEvent { pub struct ErrorEvent {
......
use crate::openflow::{ use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent};
ofp10::Msg,
traiter::{MessageMarshal, OfpMsgEvent},
};
pub struct FeaturesReqEvent {} pub struct FeaturesReqEvent {}
......
...@@ -2,13 +2,10 @@ use std::io::Cursor; ...@@ -2,13 +2,10 @@ use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use crate::openflow::{ use crate::openflow::ofp10::{
ofp10::{ events::{actions::SizeCheck, Action},
events::{actions::SizeCheck, Action}, ofp_port::OfpPort,
ofp_port::OfpPort, MessageMarshal, Msg, OfpMsgEvent, PseudoPort,
Msg, PseudoPort,
},
traiter::{MessageMarshal, OfpMsgEvent},
}; };
use super::{FlowModCommand, MatchFields}; use super::{FlowModCommand, MatchFields};
......
use crate::openflow::{ use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent};
ofp10::Msg,
traiter::{MessageMarshal, OfpMsgEvent},
};
pub struct HelloEvent {} pub struct HelloEvent {}
......
...@@ -3,11 +3,8 @@ use std::{ ...@@ -3,11 +3,8 @@ use std::{
mem::size_of, mem::size_of,
}; };
use crate::openflow::ofp10::{ofp_port::OfpPort, Msg}; use crate::openflow::ofp10::PseudoPort;
use crate::openflow::{ use crate::openflow::ofp10::{ofp_port::OfpPort, MessageMarshal, Msg, OfpMsgEvent};
ofp10::PseudoPort,
traiter::{MessageMarshal, OfpMsgEvent},
};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use super::{actions::SizeCheck, Action, Payload}; use super::{actions::SizeCheck, Action, Payload};
......
...@@ -14,4 +14,7 @@ pub mod controller_frame; ...@@ -14,4 +14,7 @@ pub mod controller_frame;
pub use controller_frame::ControllerFrame10; pub use controller_frame::ControllerFrame10;
pub mod tcp_listener; pub mod tcp_listener;
pub use tcp_listener::tcp_listener_handler; pub use tcp_listener::tcp_listener_handler;
\ No newline at end of file
pub mod traiter;
pub use traiter::{MessageMarshal, OfpMsgEvent, OpenflowHeader};
use crate::openflow::traiter::header_trait::OpenflowHeader; use crate::openflow::ofp10::OpenflowHeader;
pub struct OfpHeader<OFH: OpenflowHeader> { pub struct OfpHeader<OFH: OpenflowHeader> {
ofp_header: OFH, ofp_header: OFH,
......
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use std::{io::Cursor, mem::size_of}; use std::{io::Cursor, mem::size_of};
use crate::openflow::traiter::header_trait::OpenflowHeader; use crate::openflow::ofp10::OpenflowHeader;
pub struct OfpHeader10 { pub struct OfpHeader10 {
pub version: u8, pub version: u8,
......
use super::{ use super::{
events::{Action, FeaturesReqEvent, Payload}, events::{Action, FeaturesReqEvent, Payload},
ofp_header::{OfpHeader, OfpHeader10}, ofp_header::{OfpHeader, OfpHeader10},
HelloEvent, Msg, PacketOutEvent, HelloEvent, Msg, OfpMsgEvent, OpenflowHeader, PacketOutEvent,
}; };
use crate::openflow::traiter::{event_trait::OfpMsgEvent, header_trait::OpenflowHeader};
pub struct Openflow10 {} pub struct Openflow10 {}
......
use crate::{openflow::traiter::OfpMsgEvent, Controller}; use crate::Controller;
use std::{io::Read, net::TcpListener, thread}; use std::{io::Read, net::TcpListener, thread};
use crate::openflow::ofp10::HelloEvent; use crate::openflow::ofp10::HelloEvent;
use super::ControllerFrame10; use super::{ControllerFrame10, OfpMsgEvent};
pub fn tcp_listener_handler(address: &str) { pub fn tcp_listener_handler(address: &str) {
let listener = TcpListener::bind(address).unwrap(); let listener = TcpListener::bind(address).unwrap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment