of13: use text address for OFPPort.hw_addr and OFPPortMod.hw_addr

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
YAMAMOTO Takashi 2013-08-26 14:34:36 +09:00 committed by FUJITA Tomonori
parent ec23d73770
commit 1a3adadca4

View File

@ -17,6 +17,7 @@
import struct
import itertools
from ryu.lib import addrconv
from ryu.lib import mac
from ryu import utils
from ofproto_parser import StringifyMixin, MsgBase, msg_pack_into, msg_str_attr
@ -1748,6 +1749,9 @@ class OFPPort(ofproto_parser.namedtuple('OFPPort', (
@classmethod
def parser(cls, buf, offset):
port = struct.unpack_from(ofproto_v1_3.OFP_PORT_PACK_STR, buf, offset)
i = cls._fields.index('hw_addr')
port = list(port)
port[i] = addrconv.mac.bin_to_text(port[i])
ofpport = cls(*port)
ofpport._length = ofproto_v1_3.OFP_PORT_SIZE
return ofpport
@ -2416,7 +2420,8 @@ class OFPPortMod(MsgBase):
def _serialize_body(self):
msg_pack_into(ofproto_v1_3.OFP_PORT_MOD_PACK_STR, self.buf,
ofproto_v1_3.OFP_HEADER_SIZE,
self.port_no, self.hw_addr, self.config,
self.port_no, addrconv.mac.text_to_bin(self.hw_addr),
self.config,
self.mask, self.advertise)