Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Multipart Flag Error #529

Closed
jondef95 opened this issue Sep 18, 2018 · 0 comments
Closed

Multipart Flag Error #529

jondef95 opened this issue Sep 18, 2018 · 0 comments
Assignees
Milestone

Comments

@jondef95
Copy link

Unpacking a MultipartRequest (in this case OFPMP_PORT_DESC, type = 13) with flag=0x0 results in an UnpackException, also noted in #429 :

Traceback (most recent call last):
File "hello.py", line 27, in
print(unpack_message(data[:16]).header.message_type)
File "/usr/local/lib/python3.6/dist-packages/python_openflow-2018.2b1-py3.6.egg/pyof/v0x04/common/utils.py", line 183, in unpack_message
message.unpack(msg_buff)
File "/usr/local/lib/python3.6/dist-packages/python_openflow-2018.2b1-py3.6.egg/pyof/v0x04/controller2switch/multipart_request.py", line 118, in unpack
super().unpack(buff[offset:])
File "/usr/local/lib/python3.6/dist-packages/python_openflow-2018.2b1-py3.6.egg/pyof/foundation/base.py", line 824, in unpack
size = self._unpack_attribute(name, value, buff, begin)
File "/usr/local/lib/python3.6/dist-packages/python_openflow-2018.2b1-py3.6.egg/pyof/foundation/base.py", line 636, in _unpack_attribute
raise UnpackException(msg)
pyof.foundation.exceptions.UnpackException: MultipartRequest.flags; 0 is not a valid MultipartRequestFlags; fmt = !H, buff = b'\x00\r\x00\x00\x00\x00\x00\x00', offset = 2.

The MultipartRequestFlags enum does not have a value for when the flag is 0x0, the end of a MultipartRequest. I imagine this is because the OpenFlow specifications only mention OFPMPF_REQ_MORE = 1 << 0. I found a solution is to simply add a 0x0 value in the enum class:

class MultipartRequestFlags(Enum):
    """Flags for MultipartRequest."""

    #: No more requests to follow
    OFPMPF_REQ_NONE = 0

    #: More requests to follow
    OFPMPF_REQ_MORE = 1 << 0

While this is not explicitly specified in the OpenFlow 1.3 specs, it feels like an appropriate way to handle a flag that is not raised. I'm unsure of how to handle flags that are not raised further up the chain, like in pack() or unpack().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants