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

Commit a2942f8

Browse files
committed
Add unpack_message method to v0x04
Fix #319
1 parent 86ed828 commit a2942f8

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
@@ -115,3 +115,14 @@ def new_message_from_header(header):
115115
message.header.length = header.length
116116

117117
return message
118+
119+
120+
def unpack_message(buffer):
121+
"""Unpack the whole buffer, including header pack."""
122+
hdr_size = Header().get_size()
123+
hdr_buff, msg_buff = buffer[:hdr_size], buffer[hdr_size:]
124+
header = Header()
125+
header.unpack(hdr_buff)
126+
message = new_message_from_header(header)
127+
message.unpack(msg_buff)
128+
return message

0 commit comments

Comments
 (0)