Commit 78cf45a2 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

add packet_out to ofp trait and ofp v1.0

parent 5e3ca5f4
...@@ -13,6 +13,13 @@ pub struct PacketOutEvent { ...@@ -13,6 +13,13 @@ pub struct PacketOutEvent {
} }
impl PacketOutEvent { impl PacketOutEvent {
pub fn new(port_id: Option<u16>, payload: Payload, actions: Vec<FlowAction>) -> Self {
Self {
port_id,
payload,
actions,
}
}
pub fn parse(buf: &Vec<u8>) -> Self { pub fn parse(buf: &Vec<u8>) -> Self {
let mut bytes = Cursor::new(buf); let mut bytes = Cursor::new(buf);
let buf_id = match bytes let buf_id = match bytes
......
use crate::openflow::{ use crate::openflow::{
events::{FeaturesReq, HelloEvent}, events::{FeaturesReq, FlowAction, HelloEvent, PacketOutEvent, Payload},
ofp_header::{OfpHeader10, OpenflowHeader}, ofp_header::{OfpHeader10, OpenflowHeader},
OfpHeader, OfpHeader,
}; };
...@@ -29,6 +29,14 @@ impl OfpMsgEvent for Openflow10 { ...@@ -29,6 +29,14 @@ impl OfpMsgEvent for Openflow10 {
fn fetures_req(&self) -> FeaturesReq { fn fetures_req(&self) -> FeaturesReq {
FeaturesReq::new() FeaturesReq::new()
} }
fn packet_out(
&self,
port_id: Option<u16>,
payload: Payload,
actions: Vec<FlowAction>,
) -> PacketOutEvent {
PacketOutEvent::new(port_id, payload, actions)
}
fn ofp_version() -> usize { fn ofp_version() -> usize {
1 1
} }
......
use crate::openflow::{ use crate::openflow::{
events::{FeaturesReq, HelloEvent}, events::{FeaturesReq, FlowAction, HelloEvent, PacketOutEvent, Payload},
ofp_header::OpenflowHeader, ofp_header::OpenflowHeader,
OfpHeader, OfpHeader,
}; };
...@@ -31,4 +31,5 @@ pub trait OfpMsgEvent { ...@@ -31,4 +31,5 @@ pub trait OfpMsgEvent {
fn msg_parse(&self, msg: u16) -> OfpMsg; fn msg_parse(&self, msg: u16) -> OfpMsg;
fn hello_event(&self) -> HelloEvent; fn hello_event(&self) -> HelloEvent;
fn fetures_req(&self) -> FeaturesReq; fn fetures_req(&self) -> FeaturesReq;
fn packet_out(&self, port_id: Option<u16>, payload: Payload, actions: Vec<FlowAction>) -> PacketOutEvent;
} }
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