Commit 04ef7b62 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

change msg_usize: remove unneeded code

parent f2d84128
...@@ -55,7 +55,7 @@ pub trait ControllerFrame10 { ...@@ -55,7 +55,7 @@ pub trait ControllerFrame10 {
let mut body_bytes: Vec<u8> = Vec::new(); let mut body_bytes: Vec<u8> = Vec::new();
msg.marshal(&mut body_bytes); msg.marshal(&mut body_bytes);
let ofp_header = ofp.header(msg.msg_usize(&ofp) as u8, body_bytes.len() as u16, xid); let ofp_header = ofp.header(msg.msg_usize() as u8, body_bytes.len() as u16, xid);
ofp_header.marshal(&mut header_bytes); ofp_header.marshal(&mut header_bytes);
header_bytes.append(&mut body_bytes); header_bytes.append(&mut body_bytes);
let _ = stream.write_all(&header_bytes); let _ = stream.write_all(&header_bytes);
......
...@@ -21,7 +21,7 @@ impl MessageMarshal for EchoReplyEvent { ...@@ -21,7 +21,7 @@ impl MessageMarshal for EchoReplyEvent {
ofp10::Msg::EchoReply ofp10::Msg::EchoReply
} }
fn msg_usize<OFP: ofp10::OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp10::Msg::EchoReply as usize ofp10::Msg::EchoReply as usize
} }
......
...@@ -21,7 +21,7 @@ impl MessageMarshal for EchoRequestEvent { ...@@ -21,7 +21,7 @@ impl MessageMarshal for EchoRequestEvent {
Msg::EchoRequest Msg::EchoRequest
} }
fn msg_usize<OFP: ofp10::OfpMsgEvent>(&self, _: &OFP) -> usize { fn msg_usize(&self) -> usize {
Msg::EchoRequest as usize Msg::EchoRequest as usize
} }
......
...@@ -4,7 +4,7 @@ use std::{ ...@@ -4,7 +4,7 @@ use std::{
}; };
use super::error_type::ErrorType; use super::error_type::ErrorType;
use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent}; use crate::openflow::ofp10::{MessageMarshal, Msg};
use byteorder::{BigEndian, ReadBytesExt}; use byteorder::{BigEndian, ReadBytesExt};
pub struct ErrorEvent { pub struct ErrorEvent {
...@@ -36,8 +36,8 @@ impl MessageMarshal for ErrorEvent { ...@@ -36,8 +36,8 @@ impl MessageMarshal for ErrorEvent {
Msg::Error Msg::Error
} }
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp.msg_usize(Msg::Error) Msg::Error as usize
} }
fn size_of(&self) -> usize { fn size_of(&self) -> usize {
......
use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent}; use crate::openflow::ofp10::{MessageMarshal, Msg};
pub struct FeaturesReqEvent {} pub struct FeaturesReqEvent {}
...@@ -19,7 +19,7 @@ impl MessageMarshal for FeaturesReqEvent { ...@@ -19,7 +19,7 @@ impl MessageMarshal for FeaturesReqEvent {
0 0
} }
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp.msg_usize(Msg::FeaturesRequest) Msg::FeaturesRequest as usize
} }
} }
...@@ -5,7 +5,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; ...@@ -5,7 +5,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use crate::openflow::ofp10::{ use crate::openflow::ofp10::{
events::{actions::SizeCheck, Action}, events::{actions::SizeCheck, Action},
ofp_port::OfpPort, ofp_port::OfpPort,
MessageMarshal, Msg, OfpMsgEvent, PseudoPort, MessageMarshal, Msg, PseudoPort,
}; };
use super::{FlowModCommand, FlowModFlags, MatchFields}; use super::{FlowModCommand, FlowModFlags, MatchFields};
...@@ -96,8 +96,8 @@ impl FlowModEvent { ...@@ -96,8 +96,8 @@ impl FlowModEvent {
} }
impl MessageMarshal for FlowModEvent { impl MessageMarshal for FlowModEvent {
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp.msg_usize(Msg::FlowMod) Msg::FlowMod as usize
} }
fn size_of(&self) -> usize { fn size_of(&self) -> usize {
24 24
......
use crate::openflow::ofp10::{MessageMarshal, Msg, OfpMsgEvent}; use crate::openflow::ofp10::{MessageMarshal, Msg};
pub struct HelloEvent {} pub struct HelloEvent {}
...@@ -19,7 +19,7 @@ impl MessageMarshal for HelloEvent { ...@@ -19,7 +19,7 @@ impl MessageMarshal for HelloEvent {
0 0
} }
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp.msg_usize(Msg::Hello) Msg::Hello as usize
} }
} }
...@@ -4,7 +4,7 @@ use std::{ ...@@ -4,7 +4,7 @@ use std::{
}; };
use crate::openflow::ofp10::PseudoPort; use crate::openflow::ofp10::PseudoPort;
use crate::openflow::ofp10::{ofp_port::OfpPort, MessageMarshal, Msg, OfpMsgEvent}; use crate::openflow::ofp10::{ofp_port::OfpPort, MessageMarshal, Msg};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use super::{actions::SizeCheck, Action, Payload}; use super::{actions::SizeCheck, Action, Payload};
...@@ -40,8 +40,8 @@ impl MessageMarshal for PacketOutEvent { ...@@ -40,8 +40,8 @@ impl MessageMarshal for PacketOutEvent {
Msg::PacketOut Msg::PacketOut
} }
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize { fn msg_usize(&self) -> usize {
ofp.msg_usize(Msg::PacketOut) Msg::PacketOut as usize
} }
fn size_of(&self) -> usize { fn size_of(&self) -> usize {
......
...@@ -11,7 +11,7 @@ use crate::openflow::ofp10::{ ...@@ -11,7 +11,7 @@ use crate::openflow::ofp10::{
pub trait MessageMarshal { pub trait MessageMarshal {
fn marshal(&self, bytes: &mut Vec<u8>); fn marshal(&self, bytes: &mut Vec<u8>);
fn msg_code(&self) -> Msg; fn msg_code(&self) -> Msg;
fn msg_usize<OFP: OfpMsgEvent>(&self, ofp: &OFP) -> usize; fn msg_usize(&self) -> usize;
fn size_of(&self) -> usize; fn size_of(&self) -> usize;
} }
......
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