Commit 3d7a789e authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

move controller_frame and tcp_listener to ofp10 and remove unused code

parent 32a24045
......@@ -5,12 +5,11 @@ use std::{collections::HashMap, net::TcpStream};
use crate::{
etherparser::ether_type::EtherType,
openflow::{
controller_frame::ControllerFrame,
ofp10::{
self,
events::{flow_mod::MatchFields, Action},
ofp_v1_0::Openflow10,
FlowModEvent, PacketInEvent,
ControllerFrame10, FlowModEvent, PacketInEvent,
},
traiter::OfpMsgEvent,
},
......@@ -25,7 +24,7 @@ pub struct Controller {
mac_to_port: HashMap<u64, u16>,
}
impl ControllerFrame<Openflow10> for Controller {
impl ControllerFrame10 for Controller {
fn get_ofp(&self) -> &impl OfpMsgEvent {
&self.ofp
}
......
use tenjin::{openflow::controller_frame::ControllerFrame, Controller};
use tenjin::{openflow::ofp10::ControllerFrame10, Controller};
extern crate byteorder;
......
pub mod controller_frame;
pub mod ofp10;
pub mod tcp_listener;
pub mod traiter;
\ No newline at end of file
use crate::openflow::ofp10::{ErrorEvent, Msg, PacketInEvent};
use crate::openflow::{
ofp10::{ErrorEvent, Msg, PacketInEvent},
traiter::{MessageMarshal, OfpMsgEvent},
};
use std::{
io::{Read, Write},
net::TcpStream,
};
use super::{
tcp_listener::tcp_listener_handler,
traiter::{MessageMarshal, OfpMsgEvent},
};
use super::tcp_listener_handler;
pub trait ControllerFrame<OME: OfpMsgEvent> {
pub trait ControllerFrame10 {
fn get_ofp(&self) -> &impl OfpMsgEvent;
fn packet_in_handler(&mut self, xid: u32, packetin: PacketInEvent, stream: &mut TcpStream);
fn new() -> Self;
fn listener(address: &str) {
tcp_listener_handler::<OME>(address);
tcp_listener_handler(address);
}
fn handle_header(&mut self, buf: &mut Vec<u8>) -> (u8, usize, u32) {
......
......@@ -9,3 +9,9 @@ pub use events::{ErrorEvent, FlowModEvent, HelloEvent, PacketInEvent, PacketOutE
pub mod ofp_header;
pub mod ofp_v1_0;
pub mod controller_frame;
pub use controller_frame::ControllerFrame10;
pub mod tcp_listener;
pub use tcp_listener::tcp_listener_handler;
\ No newline at end of file
use crate::Controller;
use crate::{openflow::traiter::OfpMsgEvent, Controller};
use std::{io::Read, net::TcpListener, thread};
use super::{controller_frame::ControllerFrame, traiter::OfpMsgEvent};
use crate::openflow::ofp10::HelloEvent;
pub fn tcp_listener_handler<OME: OfpMsgEvent>(address: &str) {
use super::ControllerFrame10;
pub fn tcp_listener_handler(address: &str) {
let listener = TcpListener::bind(address).unwrap();
for stream in listener.incoming() {
match stream {
......
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