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

Commit f81d25b

Browse files
authored
Merge pull request #320 from renanrodrigo/add_unpack_method
Add unpack_message method to v0x04
2 parents 9a7a786 + a2942f8 commit f81d25b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pyof/v0x04/common/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pyof.v0x04.asynchronous.packet_in import PacketIn
1212
from pyof.v0x04.asynchronous.port_status import PortStatus
1313
# Importing controller2switch messages
14-
from pyof.v0x04.common.header import Type
14+
from pyof.v0x04.common.header import Header, Type
1515
from pyof.v0x04.controller2switch.barrier_reply import BarrierReply
1616
from pyof.v0x04.controller2switch.barrier_request import BarrierRequest
1717
from pyof.v0x04.controller2switch.features_reply import FeaturesReply
@@ -161,3 +161,14 @@ def new_message_from_header(header):
161161
message.header.length = header.length
162162

163163
return message
164+
165+
166+
def unpack_message(buffer):
167+
"""Unpack the whole buffer, including header pack."""
168+
hdr_size = Header().get_size()
169+
hdr_buff, msg_buff = buffer[:hdr_size], buffer[hdr_size:]
170+
header = Header()
171+
header.unpack(hdr_buff)
172+
message = new_message_from_header(header)
173+
message.unpack(msg_buff)
174+
return message

0 commit comments

Comments
 (0)