Commit 98928545 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

change flow_mod apply_to_packet to buffer_id

parent caa61fc7
#![allow(unused)] #![allow(unused)]
#![allow(unused_variables)] #![allow(unused_variables)]
use crate::etherparser::ether_type::EtherType;
use crate::openflow::events::flow_mod::{FlowModCommand, MatchFields}; use crate::openflow::events::flow_mod::{FlowModCommand, MatchFields};
/** /**
* Here is Controller you can modify and write the process or more you need. * Here is Controller you can modify and write the process or more you need.
...@@ -35,7 +36,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> { ...@@ -35,7 +36,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
let mac_dst = pkt.mac_des; let mac_dst = pkt.mac_des;
let mac_src = pkt.mac_src; let mac_src = pkt.mac_src;
// if pkt. if let EtherType::LLDP = pkt.ether_type {
return;
}
let out_port = self.mac_to_port.get(&mac_dst); let out_port = self.mac_to_port.get(&mac_dst);
match out_port { match out_port {
...@@ -82,6 +85,6 @@ impl<OME: OfpMsgEvent> Controller<OME> { ...@@ -82,6 +85,6 @@ impl<OME: OfpMsgEvent> Controller<OME> {
actions: Vec<FlowAction>, actions: Vec<FlowAction>,
stream: &mut TcpStream, stream: &mut TcpStream,
) { ) {
self.send_msg(FlowModEvent::add_flow(10, flow, actions), xid, stream) self.send_msg(FlowModEvent::add_flow(10, flow, actions, None), xid, stream)
} }
} }
...@@ -37,13 +37,18 @@ pub struct FlowModEvent { ...@@ -37,13 +37,18 @@ pub struct FlowModEvent {
idle_timeout: Timeout, idle_timeout: Timeout,
hard_timeout: Timeout, hard_timeout: Timeout,
notify_when_removed: bool, notify_when_removed: bool,
apply_to_packet: Option<u32>, buffer_id: Option<u32>,
out_port: Option<PseudoPort>, out_port: Option<PseudoPort>,
check_overlap: bool, check_overlap: bool,
} }
impl FlowModEvent { impl FlowModEvent {
pub fn add_flow(priority: u16, match_fileds: MatchFields, actions: Vec<FlowAction>) -> Self { pub fn add_flow(
priority: u16,
match_fileds: MatchFields,
actions: Vec<FlowAction>,
buffer_id: Option<u32>,
) -> Self {
Self { Self {
command: FlowModCommand::Add, command: FlowModCommand::Add,
match_fields: match_fileds, match_fields: match_fileds,
...@@ -53,7 +58,7 @@ impl FlowModEvent { ...@@ -53,7 +58,7 @@ impl FlowModEvent {
idle_timeout: Timeout::Permanent, idle_timeout: Timeout::Permanent,
hard_timeout: Timeout::Permanent, hard_timeout: Timeout::Permanent,
notify_when_removed: false, notify_when_removed: false,
apply_to_packet: None, buffer_id,
out_port: None, out_port: None,
check_overlap: false, check_overlap: false,
} }
...@@ -80,7 +85,7 @@ impl FlowModEvent { ...@@ -80,7 +85,7 @@ impl FlowModEvent {
idle_timeout, idle_timeout,
hard_timeout, hard_timeout,
notify_when_removed: flags & 1 != 0, notify_when_removed: flags & 1 != 0,
apply_to_packet: { buffer_id: {
match buffer_id { match buffer_id {
-1 => None, -1 => None,
n => Some(n as u32), n => Some(n as u32),
...@@ -109,7 +114,7 @@ impl MessageMarshal for FlowModEvent { ...@@ -109,7 +114,7 @@ impl MessageMarshal for FlowModEvent {
let _ = bytes.write_u16::<BigEndian>(self.idle_timeout.to_int()); let _ = bytes.write_u16::<BigEndian>(self.idle_timeout.to_int());
let _ = bytes.write_u16::<BigEndian>(self.hard_timeout.to_int()); let _ = bytes.write_u16::<BigEndian>(self.hard_timeout.to_int());
let _ = bytes.write_u16::<BigEndian>(self.priority); let _ = bytes.write_u16::<BigEndian>(self.priority);
let _ = bytes.write_i32::<BigEndian>(match self.apply_to_packet { let _ = bytes.write_i32::<BigEndian>(match self.buffer_id {
None => -1, None => -1,
Some(buf_id) => buf_id as i32, Some(buf_id) => buf_id as i32,
}); });
......
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