summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-07-20 14:10:50 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-07-21 21:38:42 +0900
commit5099034d0c5f7aa1d4b10d52d46a6279489dc129 (patch)
treece3c8b5eae3678896ddaf42cf4266e61dc5e17f0
parentb964275b5360ba45c8e0ccba2a6fde5d50bd4ac6 (diff)
ofproto: Handle OFPErrorExperimenterMsg
Currently, OFPErrorExperimenterMsg is not registered into OpenFlow message events dict as "EventOFPErrorExperimenterMsg", and could not be converted to events by ofp_event module. This patch obsolete OFPErrorExperimenterMsg class and fixes to use EventOFPErrorMsg to handle the experimenter error messages. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/controller/ofp_handler.py25
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py88
-rw-r--r--ryu/ofproto/ofproto_v1_3_parser.py87
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py87
-rw-r--r--ryu/ofproto/ofproto_v1_5_parser.py87
5 files changed, 225 insertions, 149 deletions
diff --git a/ryu/controller/ofp_handler.py b/ryu/controller/ofp_handler.py
index 70ffc8cb..7b4bfd11 100644
--- a/ryu/controller/ofp_handler.py
+++ b/ryu/controller/ofp_handler.py
@@ -271,15 +271,24 @@ class OFPHandler(ryu.base.app_manager.RyuApp):
self.logger.debug(
"EventOFPErrorMsg received.\n"
"version=%s, msg_type=%s, msg_len=%s, xid=%s\n"
- " `-- msg_type: %s\n"
- "OFPErrorMsg(type=%s, code=%s, data=b'%s')\n"
- " |-- type: %s\n"
- " |-- code: %s",
+ " `-- msg_type: %s",
hex(msg.version), hex(msg.msg_type), hex(msg.msg_len),
- hex(msg.xid), ofp.ofp_msg_type_to_str(msg.msg_type),
- hex(msg.type), hex(msg.code), utils.binary_str(msg.data),
- ofp.ofp_error_type_to_str(msg.type),
- ofp.ofp_error_code_to_str(msg.type, msg.code))
+ hex(msg.xid),
+ ofp.ofp_msg_type_to_str(msg.msg_type))
+ if msg.type == ofp.OFPET_EXPERIMENTER:
+ self.logger.debug(
+ "OFPErrorExperimenterMsg(type=%s, exp_type=%s,"
+ " experimenter=%s, data=b'%s')",
+ hex(msg.type), hex(msg.exp_type),
+ hex(msg.experimenter), utils.binary_str(msg.data))
+ else:
+ self.logger.debug(
+ "OFPErrorMsg(type=%s, code=%s, data=b'%s')\n"
+ " |-- type: %s\n"
+ " |-- code: %s",
+ hex(msg.type), hex(msg.code), utils.binary_str(msg.data),
+ ofp.ofp_error_type_to_str(msg.type),
+ ofp.ofp_error_code_to_str(msg.type, msg.code))
if msg.type == ofp.OFPET_HELLO_FAILED:
self.logger.debug(
" `-- data: %s", msg.data.decode('ascii'))
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py
index ddb56f3f..9758c26d 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -114,6 +114,16 @@ class OFPErrorMsg(MsgBase):
OFPET_EXPERIMENTER N/A
============================= ===========
+ If ``type == OFPET_EXPERIMENTER``, this message has also the following
+ attributes.
+
+ ============= ======================================================
+ Attribute Description
+ ============= ======================================================
+ exp_type Experimenter defined type
+ experimenter Experimenter ID
+ ============= ======================================================
+
Example::
@set_ev_cls(ofp_event.EventOFPErrorMsg,
@@ -125,61 +135,67 @@ class OFPErrorMsg(MsgBase):
'message=%s',
msg.type, msg.code, utils.hex_array(msg.data))
"""
- def __init__(self, datapath, type_=None, code=None, data=None):
+ def __init__(self, datapath, type_=None, code=None, data=None, **kwargs):
super(OFPErrorMsg, self).__init__(datapath)
self.type = type_
self.code = code
self.data = data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ self.exp_type = kwargs.get('exp_type', None)
+ self.experimenter = kwargs.get('experimenter', None)
@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
type_, = struct.unpack_from('!H', six.binary_type(buf),
ofproto.OFP_HEADER_SIZE)
- if type_ == ofproto.OFPET_EXPERIMENTER:
- return OFPErrorExperimenterMsg.parser(datapath, version, msg_type,
- msg_len, xid, buf)
-
msg = super(OFPErrorMsg, cls).parser(datapath, version, msg_type,
msg_len, xid, buf)
- msg.type, msg.code = struct.unpack_from(
- ofproto.OFP_ERROR_MSG_PACK_STR, msg.buf,
- ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ if type_ == ofproto.OFPET_EXPERIMENTER:
+ (msg.type, msg.exp_type, msg.experimenter,
+ msg.data) = cls.parse_experimenter_body(buf)
+ else:
+ (msg.type, msg.code,
+ msg.data) = cls.parse_body(buf)
return msg
- def _serialize_body(self):
- assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR, self.buf,
- ofproto.OFP_HEADER_SIZE, self.type, self.code)
- self.buf += self.data
-
-
-class OFPErrorExperimenterMsg(MsgBase):
- def __init__(self, datapath, type_=None, exp_type=None, experimenter=None,
- data=None):
- super(OFPErrorExperimenterMsg, self).__init__(datapath)
- self.type = ofproto.OFPET_EXPERIMENTER
- self.exp_type = exp_type
- self.experimenter = experimenter
- self.data = data
+ @classmethod
+ def parse_body(cls, buf):
+ type_, code = struct.unpack_from(
+ ofproto.OFP_ERROR_MSG_PACK_STR, buf,
+ ofproto.OFP_HEADER_SIZE)
+ data = buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ return type_, code, data
@classmethod
- def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
- cls.cls_msg_type = msg_type
- msg = super(OFPErrorExperimenterMsg, cls).parser(
- datapath, version, msg_type, msg_len, xid, buf)
- msg.type, msg.exp_type, msg.experimenter = struct.unpack_from(
- ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, msg.buf,
+ def parse_experimenter_body(cls, buf):
+ type_, exp_type, experimenter = struct.unpack_from(
+ ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, buf,
ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
- return msg
+ data = buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
+ return type_, exp_type, experimenter, data
def _serialize_body(self):
assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
- self.buf, ofproto.OFP_HEADER_SIZE,
- self.type, self.exp_type, self.experimenter)
- self.buf += self.data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.exp_type, self.experimenter)
+ self.buf += self.data
+ else:
+ msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.code)
+ self.buf += self.data
+
+
+# For the backward compatibility
+def OFPErrorExperimenterMsg(datapath, type_=None, exp_type=None,
+ experimenter=None, data=None):
+ msg = OFPErrorMsg(datapath, data=data)
+ msg.type = ofproto.OFPET_EXPERIMENTER
+ msg.exp_type = exp_type
+ msg.experimenter = experimenter
+ return msg
@_register_parser
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index c298c998..c8f2a3d3 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -214,6 +214,16 @@ class OFPErrorMsg(MsgBase):
OFPET_EXPERIMENTER N/A
============================= ===========
+ If ``type == OFPET_EXPERIMENTER``, this message has also the following
+ attributes.
+
+ ============= ======================================================
+ Attribute Description
+ ============= ======================================================
+ exp_type Experimenter defined type
+ experimenter Experimenter ID
+ ============= ======================================================
+
Example::
@set_ev_cls(ofp_event.EventOFPErrorMsg,
@@ -225,60 +235,67 @@ class OFPErrorMsg(MsgBase):
'message=%s',
msg.type, msg.code, utils.hex_array(msg.data))
"""
- def __init__(self, datapath, type_=None, code=None, data=None):
+ def __init__(self, datapath, type_=None, code=None, data=None, **kwargs):
super(OFPErrorMsg, self).__init__(datapath)
self.type = type_
self.code = code
self.data = data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ self.exp_type = kwargs.get('exp_type', None)
+ self.experimenter = kwargs.get('experimenter', None)
@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
type_, = struct.unpack_from('!H', six.binary_type(buf),
ofproto.OFP_HEADER_SIZE)
- if type_ == ofproto.OFPET_EXPERIMENTER:
- return OFPErrorExperimenterMsg.parser(datapath, version, msg_type,
- msg_len, xid, buf)
msg = super(OFPErrorMsg, cls).parser(datapath, version, msg_type,
msg_len, xid, buf)
- msg.type, msg.code = struct.unpack_from(
- ofproto.OFP_ERROR_MSG_PACK_STR, msg.buf,
- ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ if type_ == ofproto.OFPET_EXPERIMENTER:
+ (msg.type, msg.exp_type, msg.experimenter,
+ msg.data) = cls.parse_experimenter_body(buf)
+ else:
+ (msg.type, msg.code,
+ msg.data) = cls.parse_body(buf)
return msg
- def _serialize_body(self):
- assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR, self.buf,
- ofproto.OFP_HEADER_SIZE, self.type, self.code)
- self.buf += self.data
-
-
-class OFPErrorExperimenterMsg(MsgBase):
- def __init__(self, datapath, type_=None, exp_type=None, experimenter=None,
- data=None):
- super(OFPErrorExperimenterMsg, self).__init__(datapath)
- self.type = ofproto.OFPET_EXPERIMENTER
- self.exp_type = exp_type
- self.experimenter = experimenter
- self.data = data
+ @classmethod
+ def parse_body(cls, buf):
+ type_, code = struct.unpack_from(
+ ofproto.OFP_ERROR_MSG_PACK_STR, buf,
+ ofproto.OFP_HEADER_SIZE)
+ data = buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ return type_, code, data
@classmethod
- def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
- cls.cls_msg_type = msg_type
- msg = super(OFPErrorExperimenterMsg, cls).parser(
- datapath, version, msg_type, msg_len, xid, buf)
- msg.type, msg.exp_type, msg.experimenter = struct.unpack_from(
- ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, msg.buf,
+ def parse_experimenter_body(cls, buf):
+ type_, exp_type, experimenter = struct.unpack_from(
+ ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, buf,
ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
- return msg
+ data = buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
+ return type_, exp_type, experimenter, data
def _serialize_body(self):
assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
- self.buf, ofproto.OFP_HEADER_SIZE,
- self.type, self.exp_type, self.experimenter)
- self.buf += self.data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.exp_type, self.experimenter)
+ self.buf += self.data
+ else:
+ msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.code)
+ self.buf += self.data
+
+
+# For the backward compatibility
+def OFPErrorExperimenterMsg(datapath, type_=None, exp_type=None,
+ experimenter=None, data=None):
+ msg = OFPErrorMsg(datapath, data=data)
+ msg.type = ofproto.OFPET_EXPERIMENTER
+ msg.exp_type = exp_type
+ msg.experimenter = experimenter
+ return msg
@_register_parser
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index 31379c85..f26075c0 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -233,6 +233,16 @@ class OFPErrorMsg(MsgBase):
OFPET_EXPERIMENTER N/A
============================= ===========
+ If ``type == OFPET_EXPERIMENTER``, this message has also the following
+ attributes.
+
+ ============= ======================================================
+ Attribute Description
+ ============= ======================================================
+ exp_type Experimenter defined type
+ experimenter Experimenter ID
+ ============= ======================================================
+
Example::
@set_ev_cls(ofp_event.EventOFPErrorMsg,
@@ -244,60 +254,67 @@ class OFPErrorMsg(MsgBase):
'message=%s',
msg.type, msg.code, utils.hex_array(msg.data))
"""
- def __init__(self, datapath, type_=None, code=None, data=None):
+ def __init__(self, datapath, type_=None, code=None, data=None, **kwargs):
super(OFPErrorMsg, self).__init__(datapath)
self.type = type_
self.code = code
self.data = data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ self.exp_type = kwargs.get('exp_type', None)
+ self.experimenter = kwargs.get('experimenter', None)
@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
type_, = struct.unpack_from('!H', six.binary_type(buf),
ofproto.OFP_HEADER_SIZE)
- if type_ == ofproto.OFPET_EXPERIMENTER:
- return OFPErrorExperimenterMsg.parser(datapath, version, msg_type,
- msg_len, xid, buf)
msg = super(OFPErrorMsg, cls).parser(datapath, version, msg_type,
msg_len, xid, buf)
- msg.type, msg.code = struct.unpack_from(
- ofproto.OFP_ERROR_MSG_PACK_STR, msg.buf,
- ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ if type_ == ofproto.OFPET_EXPERIMENTER:
+ (msg.type, msg.exp_type, msg.experimenter,
+ msg.data) = cls.parse_experimenter_body(buf)
+ else:
+ (msg.type, msg.code,
+ msg.data) = cls.parse_body(buf)
return msg
- def _serialize_body(self):
- assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR, self.buf,
- ofproto.OFP_HEADER_SIZE, self.type, self.code)
- self.buf += self.data
-
-
-class OFPErrorExperimenterMsg(MsgBase):
- def __init__(self, datapath, type_=None, exp_type=None, experimenter=None,
- data=None):
- super(OFPErrorExperimenterMsg, self).__init__(datapath)
- self.type = ofproto.OFPET_EXPERIMENTER
- self.exp_type = exp_type
- self.experimenter = experimenter
- self.data = data
+ @classmethod
+ def parse_body(cls, buf):
+ type_, code = struct.unpack_from(
+ ofproto.OFP_ERROR_MSG_PACK_STR, buf,
+ ofproto.OFP_HEADER_SIZE)
+ data = buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ return type_, code, data
@classmethod
- def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
- cls.cls_msg_type = msg_type
- msg = super(OFPErrorExperimenterMsg, cls).parser(
- datapath, version, msg_type, msg_len, xid, buf)
- msg.type, msg.exp_type, msg.experimenter = struct.unpack_from(
- ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, msg.buf,
+ def parse_experimenter_body(cls, buf):
+ type_, exp_type, experimenter = struct.unpack_from(
+ ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, buf,
ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
- return msg
+ data = buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
+ return type_, exp_type, experimenter, data
def _serialize_body(self):
assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
- self.buf, ofproto.OFP_HEADER_SIZE,
- self.type, self.exp_type, self.experimenter)
- self.buf += self.data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.exp_type, self.experimenter)
+ self.buf += self.data
+ else:
+ msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.code)
+ self.buf += self.data
+
+
+# For the backward compatibility
+def OFPErrorExperimenterMsg(datapath, type_=None, exp_type=None,
+ experimenter=None, data=None):
+ msg = OFPErrorMsg(datapath, data=data)
+ msg.type = ofproto.OFPET_EXPERIMENTER
+ msg.exp_type = exp_type
+ msg.experimenter = experimenter
+ return msg
@_register_parser
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py
index be2e8628..b61e6fef 100644
--- a/ryu/ofproto/ofproto_v1_5_parser.py
+++ b/ryu/ofproto/ofproto_v1_5_parser.py
@@ -233,6 +233,16 @@ class OFPErrorMsg(MsgBase):
OFPET_EXPERIMENTER N/A
============================= ===========
+ If ``type == OFPET_EXPERIMENTER``, this message has also the following
+ attributes.
+
+ ============= ======================================================
+ Attribute Description
+ ============= ======================================================
+ exp_type Experimenter defined type
+ experimenter Experimenter ID
+ ============= ======================================================
+
Example::
@set_ev_cls(ofp_event.EventOFPErrorMsg,
@@ -244,60 +254,67 @@ class OFPErrorMsg(MsgBase):
'message=%s',
msg.type, msg.code, utils.hex_array(msg.data))
"""
- def __init__(self, datapath, type_=None, code=None, data=None):
+ def __init__(self, datapath, type_=None, code=None, data=None, **kwargs):
super(OFPErrorMsg, self).__init__(datapath)
self.type = type_
self.code = code
self.data = data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ self.exp_type = kwargs.get('exp_type', None)
+ self.experimenter = kwargs.get('experimenter', None)
@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
type_, = struct.unpack_from('!H', six.binary_type(buf),
ofproto.OFP_HEADER_SIZE)
- if type_ == ofproto.OFPET_EXPERIMENTER:
- return OFPErrorExperimenterMsg.parser(datapath, version, msg_type,
- msg_len, xid, buf)
msg = super(OFPErrorMsg, cls).parser(datapath, version, msg_type,
msg_len, xid, buf)
- msg.type, msg.code = struct.unpack_from(
- ofproto.OFP_ERROR_MSG_PACK_STR, msg.buf,
- ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ if type_ == ofproto.OFPET_EXPERIMENTER:
+ (msg.type, msg.exp_type, msg.experimenter,
+ msg.data) = cls.parse_experimenter_body(buf)
+ else:
+ (msg.type, msg.code,
+ msg.data) = cls.parse_body(buf)
return msg
- def _serialize_body(self):
- assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR, self.buf,
- ofproto.OFP_HEADER_SIZE, self.type, self.code)
- self.buf += self.data
-
-
-class OFPErrorExperimenterMsg(MsgBase):
- def __init__(self, datapath, type_=None, exp_type=None, experimenter=None,
- data=None):
- super(OFPErrorExperimenterMsg, self).__init__(datapath)
- self.type = ofproto.OFPET_EXPERIMENTER
- self.exp_type = exp_type
- self.experimenter = experimenter
- self.data = data
+ @classmethod
+ def parse_body(cls, buf):
+ type_, code = struct.unpack_from(
+ ofproto.OFP_ERROR_MSG_PACK_STR, buf,
+ ofproto.OFP_HEADER_SIZE)
+ data = buf[ofproto.OFP_ERROR_MSG_SIZE:]
+ return type_, code, data
@classmethod
- def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
- cls.cls_msg_type = msg_type
- msg = super(OFPErrorExperimenterMsg, cls).parser(
- datapath, version, msg_type, msg_len, xid, buf)
- msg.type, msg.exp_type, msg.experimenter = struct.unpack_from(
- ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, msg.buf,
+ def parse_experimenter_body(cls, buf):
+ type_, exp_type, experimenter = struct.unpack_from(
+ ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, buf,
ofproto.OFP_HEADER_SIZE)
- msg.data = msg.buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
- return msg
+ data = buf[ofproto.OFP_ERROR_EXPERIMENTER_MSG_SIZE:]
+ return type_, exp_type, experimenter, data
def _serialize_body(self):
assert self.data is not None
- msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
- self.buf, ofproto.OFP_HEADER_SIZE,
- self.type, self.exp_type, self.experimenter)
- self.buf += self.data
+ if self.type == ofproto.OFPET_EXPERIMENTER:
+ msg_pack_into(ofproto.OFP_ERROR_EXPERIMENTER_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.exp_type, self.experimenter)
+ self.buf += self.data
+ else:
+ msg_pack_into(ofproto.OFP_ERROR_MSG_PACK_STR,
+ self.buf, ofproto.OFP_HEADER_SIZE,
+ self.type, self.code)
+ self.buf += self.data
+
+
+# For the backward compatibility
+def OFPErrorExperimenterMsg(datapath, type_=None, exp_type=None,
+ experimenter=None, data=None):
+ msg = OFPErrorMsg(datapath, data=data)
+ msg.type = ofproto.OFPET_EXPERIMENTER
+ msg.exp_type = exp_type
+ msg.experimenter = experimenter
+ return msg
@_register_parser