Commit 46111381 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

declare one point for ofp version

parent 6c4a5497
...@@ -6,6 +6,8 @@ use std::{ ...@@ -6,6 +6,8 @@ use std::{
use crate::openflow::ofp13::OpenflowHeader; use crate::openflow::ofp13::OpenflowHeader;
use super::{OfpMsgEvent, Openflow13};
pub struct OfpHeader { pub struct OfpHeader {
pub version: u8, pub version: u8,
pub message: u8, pub message: u8,
...@@ -16,14 +18,14 @@ pub struct OfpHeader { ...@@ -16,14 +18,14 @@ pub struct OfpHeader {
impl OpenflowHeader for OfpHeader { impl OpenflowHeader for OfpHeader {
fn new(message: u8, length: usize, xid: usize) -> Self { fn new(message: u8, length: usize, xid: usize) -> Self {
Self { Self {
version: 4, version: Openflow13::ofp_version() as u8,
message, message,
length: (size_of::<OfpHeader>() + length) as u16, length: (size_of::<OfpHeader>() + length) as u16,
xid: xid as u32, xid: xid as u32,
} }
} }
fn version(&self) -> usize { fn version(&self) -> usize {
4 Openflow13::ofp_version()
} }
fn message(&self) -> u8 { fn message(&self) -> u8 {
self.message self.message
......
...@@ -35,10 +35,10 @@ impl OfpMsgEvent for Openflow13 { ...@@ -35,10 +35,10 @@ impl OfpMsgEvent for Openflow13 {
PacketOutEvent::new(port_id, payload, actions) PacketOutEvent::new(port_id, payload, actions)
} }
fn ofp_version() -> usize { fn ofp_version() -> usize {
4 0x04
} }
fn version(&self) -> usize { fn version(&self) -> usize {
4 Self::ofp_version()
} }
fn header(&self, message: u8, length: u16, xid: u32) -> OfpHeader { fn header(&self, message: u8, length: u16, xid: u32) -> OfpHeader {
......
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