Commit fec3d6cb authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

create handle features reply

parent c5a87ff1
...@@ -6,7 +6,8 @@ use std::{ ...@@ -6,7 +6,8 @@ use std::{
use super::{ use super::{
events::{echo_reply::EchoReplyEvent, EchoRequestEvent}, events::{echo_reply::EchoReplyEvent, EchoRequestEvent},
tcp_listener_handler, MessageMarshal, OfpMsgEvent, Openflow13, OpenflowHeader, tcp_listener_handler, FeaturesReplyEvent, MessageMarshal, OfpMsgEvent, Openflow13,
OpenflowHeader,
}; };
pub trait ControllerFrame13 pub trait ControllerFrame13
...@@ -55,7 +56,10 @@ where ...@@ -55,7 +56,10 @@ where
Msg::EchoRequest => { Msg::EchoRequest => {
self.echo_request_handler(xid, EchoRequestEvent::new(payload), stream) self.echo_request_handler(xid, EchoRequestEvent::new(payload), stream)
} }
Msg::FeaturesReply => {} Msg::FeaturesReply => match FeaturesReplyEvent::parse(&payload) {
Ok(features) => self.switch_features_handler(xid, features, stream),
Err(_) => (),
},
Msg::PacketIn => match PacketInEvent::parse(&payload) { Msg::PacketIn => match PacketInEvent::parse(&payload) {
Ok(pkt_in) => self.packet_in_handler(xid, pkt_in, stream), Ok(pkt_in) => self.packet_in_handler(xid, pkt_in, stream),
Err(_) => (), Err(_) => (),
...@@ -88,5 +92,11 @@ where ...@@ -88,5 +92,11 @@ where
fn echo_request_handler(&self, xid: u32, echo: EchoRequestEvent, stream: &mut TcpStream) { fn echo_request_handler(&self, xid: u32, echo: EchoRequestEvent, stream: &mut TcpStream) {
self.send_msg(EchoReplyEvent::new(echo.payload), xid, stream); self.send_msg(EchoReplyEvent::new(echo.payload), xid, stream);
} }
fn switch_features_handler(&self) {} fn switch_features_handler(
&self,
xid: u32,
features_reply: FeaturesReplyEvent,
stream: &mut TcpStream,
) {
}
} }
...@@ -13,7 +13,7 @@ pub struct FeaturesReplyEvent { ...@@ -13,7 +13,7 @@ pub struct FeaturesReplyEvent {
} }
impl FeaturesReplyEvent { impl FeaturesReplyEvent {
pub fn parse(bytes: &mut Vec<u8>) -> Result<Self, Error> { pub fn parse(bytes: &Vec<u8>) -> Result<Self, Error> {
let mut bytes = Cursor::new(bytes); let mut bytes = Cursor::new(bytes);
let datapath_id = bytes.read_u64::<BigEndian>()?; let datapath_id = bytes.read_u64::<BigEndian>()?;
let n_buffers = bytes.read_u32::<BigEndian>()?; let n_buffers = bytes.read_u32::<BigEndian>()?;
......
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