Commit 937468b3 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

change folder name of message to ofp_manager

parent f34edd49
...@@ -5,11 +5,11 @@ use std::{ ...@@ -5,11 +5,11 @@ use std::{
use super::{ use super::{
events::PacketInEvent, events::PacketInEvent,
messages::{ ofp_manager::{
traiter::{MessageMarshal, OfpMsgEvent}, traiter::{MessageMarshal, OfpMsgEvent},
OfpMsg, OfpMsg,
}, },
tcp_listener_handler, OfpHeader, tcp_listener_handler,
}; };
pub trait ControllerFrame<OME: OfpMsgEvent> { pub trait ControllerFrame<OME: OfpMsgEvent> {
...@@ -23,7 +23,7 @@ pub trait ControllerFrame<OME: OfpMsgEvent> { ...@@ -23,7 +23,7 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
fn request_handler(&mut self, buf: &mut Vec<u8>, stream: &mut TcpStream) { fn request_handler(&mut self, buf: &mut Vec<u8>, stream: &mut TcpStream) {
let ofp = self.get_ofp(); let ofp = self.get_ofp();
let ofp_header = OfpHeader::parse(&buf); let ofp_header = ofp.header_parse(&buf);
let mut payload = vec![0u8; ofp_header.pkt_size()]; let mut payload = vec![0u8; ofp_header.pkt_size()];
let _ = stream.read(&mut payload); let _ = stream.read(&mut payload);
let message = ofp.msg_parse(ofp_header.message as u16); let message = ofp.msg_parse(ofp_header.message as u16);
...@@ -50,4 +50,3 @@ pub trait ControllerFrame<OME: OfpMsgEvent> { ...@@ -50,4 +50,3 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
let _ = stream.write_all(&header_bytes); let _ = stream.write_all(&header_bytes);
} }
} }
use crate::openflow::messages::{MessageMarshal, OfpMsg, OfpMsgEvent}; use crate::openflow::ofp_manager::{MessageMarshal, OfpMsg, OfpMsgEvent};
pub struct FeaturesReq {} pub struct FeaturesReq {}
......
...@@ -3,7 +3,7 @@ use std::io::Cursor; ...@@ -3,7 +3,7 @@ use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use crate::openflow::{ use crate::openflow::{
messages::{MessageMarshal, OfpMsg, OfpMsgEvent}, ofp_manager::{MessageMarshal, OfpMsg, OfpMsgEvent},
OfpPort, PseudoPort, OfpPort, PseudoPort,
}; };
......
use crate::openflow::messages::{MessageMarshal, OfpMsg}; use crate::openflow::ofp_manager::{MessageMarshal, OfpMsg};
use crate::openflow::traiter::OfpMsgEvent; use crate::openflow::traiter::OfpMsgEvent;
pub struct HelloEvent {} pub struct HelloEvent {}
......
...@@ -8,8 +8,8 @@ pub mod events; ...@@ -8,8 +8,8 @@ pub mod events;
pub mod ofp_port; pub mod ofp_port;
pub use ofp_port::{OfpPort, PseudoPort}; pub use ofp_port::{OfpPort, PseudoPort};
pub mod messages; pub mod ofp_manager;
pub use messages::{ofp_v1_0, traiter}; pub use ofp_manager::{ofp_v1_0, traiter};
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
...@@ -15,6 +15,9 @@ impl Openflow10 { ...@@ -15,6 +15,9 @@ impl Openflow10 {
} }
impl OfpMsgEvent for Openflow10 { impl OfpMsgEvent for Openflow10 {
fn header_parse(&self, bytes:&Vec<u8>) -> OfpHeader {
OfpHeader::parse(bytes)
}
fn header_size(&self) -> usize { fn header_size(&self) -> usize {
8 8
} }
......
...@@ -24,6 +24,7 @@ pub trait OfpMsgEvent { ...@@ -24,6 +24,7 @@ pub trait OfpMsgEvent {
fn version(&self) -> usize; fn version(&self) -> usize;
fn ofp_version() -> usize; fn ofp_version() -> usize;
fn header_size(&self) -> usize; fn header_size(&self) -> usize;
fn header_parse(&self, bytes:&Vec<u8>) -> OfpHeader;
fn msg_usize(&self, msg: OfpMsg) -> usize; fn msg_usize(&self, msg: OfpMsg) -> usize;
fn msg_parse(&self, msg: u16) -> OfpMsg; fn msg_parse(&self, msg: u16) -> OfpMsg;
......
use crate::openflow::{messages::Openflow10, traiter::OfpMsgEvent}; use crate::openflow::{ofp_manager::Openflow10, traiter::OfpMsgEvent};
use crate::{ofp_from_version, Controller}; use crate::{ofp_from_version, Controller};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{io::Read, net::TcpListener, thread}; use std::{io::Read, net::TcpListener, thread};
......
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