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_variables)]
use crate::etherparser::ether_type::EtherType;
use crate::openflow::events::flow_mod::{FlowModCommand, MatchFields};
/**
* 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> {
let mac_dst = pkt.mac_des;
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);
match out_port {
......@@ -82,6 +85,6 @@ impl<OME: OfpMsgEvent> Controller<OME> {
actions: Vec<FlowAction>,
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 {
idle_timeout: Timeout,
hard_timeout: Timeout,
notify_when_removed: bool,
apply_to_packet: Option<u32>,
buffer_id: Option<u32>,
out_port: Option<PseudoPort>,
check_overlap: bool,
}
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 {
command: FlowModCommand::Add,
match_fields: match_fileds,
......@@ -53,7 +58,7 @@ impl FlowModEvent {
idle_timeout: Timeout::Permanent,
hard_timeout: Timeout::Permanent,
notify_when_removed: false,
apply_to_packet: None,
buffer_id,
out_port: None,
check_overlap: false,
}
......@@ -80,7 +85,7 @@ impl FlowModEvent {
idle_timeout,
hard_timeout,
notify_when_removed: flags & 1 != 0,
apply_to_packet: {
buffer_id: {
match buffer_id {
-1 => None,
n => Some(n as u32),
......@@ -109,7 +114,7 @@ impl MessageMarshal for FlowModEvent {
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.priority);
let _ = bytes.write_i32::<BigEndian>(match self.apply_to_packet {
let _ = bytes.write_i32::<BigEndian>(match self.buffer_id {
None => -1,
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