本文整理汇总了Python中ryu.ofproto.ofproto_parser.msg_pack_into函数的典型用法代码示例。如果您正苦于以下问题:Python msg_pack_into函数的具体用法?Python msg_pack_into怎么用?Python msg_pack_into使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg_pack_into函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: serialize
def serialize(self):
# fixup
self.length = len(self.value)
buf = bytearray()
msg_pack_into(self._PACK_STR, buf, 0, self.type, self.length)
return buf + bytes(self.value)
开发者ID:Yokoloki,项目名称:RouteFlow,代码行数:7,代码来源:bgp.py
示例2: serialize_value
def serialize_value(self):
buf = bytearray()
ifaddr = ipv4.text_to_bin(self.ifaddr)
area_id = ipv4.text_to_bin(self.area_id)
router_id = ipv4.text_to_bin(self.router_id)
msg_pack_into(self._VALUE_PACK_STR, buf, 0, ifaddr, area_id, router_id, status, 0)
return buf
开发者ID:LittleHippo,项目名称:SegmentRouting-Ryu,代码行数:7,代码来源:ospfapi.py
示例3: serialize_value
def serialize_value(self):
args = []
for f in self._VALUE_FIELDS:
args.append(getattr(self, f))
buf = bytearray()
msg_pack_into(self._VALUE_PACK_STR, buf, 0, *args)
return buf
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:7,代码来源:bgp.py
示例4: serialize_value
def serialize_value(self):
buf = bytearray()
for comm in self.communities:
bincomm = bytearray()
msg_pack_into(self._VALUE_PACK_STR, bincomm, 0, comm)
buf += bincomm
return buf
开发者ID:MichalPalatinus,项目名称:ryu,代码行数:7,代码来源:bgp.py
示例5: serialize_cap_value
def serialize_cap_value(self):
# fixup
self.reserved = 0
buf = bytearray()
msg_pack_into(self._CAP_PACK_STR, buf, 0,
self.afi, self.reserved, self.safi)
return buf
开发者ID:MichalPalatinus,项目名称:ryu,代码行数:8,代码来源:bgp.py
示例6: _serialize_subfield
def _serialize_subfield(subfield):
(field, ofs) = subfield
buf = bytearray()
n = ofp.oxm_from_user_header(field)
ofp.oxm_serialize_header(n, buf, 0)
assert len(buf) == 4 # only 4-bytes NXM/OXM are defined
msg_pack_into('!H', buf, 4, ofs)
return buf
开发者ID:cloudysunny14,项目名称:ryu,代码行数:8,代码来源:nx_actions.py
示例7: serialize
def serialize(self):
# fixup
value = self.serialize_value()
self.length = len(value)
buf = bytearray()
msg_pack_into(self._PACK_STR, buf, 0, self.type, self.length)
return buf + value
开发者ID:ashishtanwer,项目名称:ryu,代码行数:8,代码来源:bgp.py
示例8: serialize_value
def serialize_value(self):
# fixup
cap_value = self.serialize_cap_value()
self.cap_length = len(cap_value)
buf = bytearray()
msg_pack_into(self._CAP_HDR_PACK_STR, buf, 0, self.cap_code,
self.cap_length)
return buf + cap_value
开发者ID:ashishtanwer,项目名称:ryu,代码行数:9,代码来源:bgp.py
示例9: serialize
def serialize(self, buf, offset):
""" Serialize PushGPRSNS action into buffer. """
super(GPRSActionPushGPRSNS,self).serialize(buf, offset)
imsi_bytes = imsi_to_bytes(self.imsi)
LOG.debug("push_gprsns.serialize self="+pprint.pformat(self))
ofproto_parser.msg_pack_into("!HxxIHBBHBBBBBBBBBx", buf, offset+8,
self.subtype, self.tlli, self.bvci, self.sapi, self.nsapi, self.drx_param,
len(imsi_bytes), *imsi_bytes)
开发者ID:unifycore,项目名称:ryu,代码行数:10,代码来源:magic.py
示例10: serialize
def serialize(self, buf, offset):
# fixup
data = bytearray()
msg_pack_into(NXActionRegMove._fmt_str, data, 0,
self.n_bits, self.src_ofs, self.dst_ofs)
# src field
n = ofp.oxm_from_user_header(self.src_field)
ofp.oxm_serialize_header(n, data, len(data))
# dst field
n = ofp.oxm_from_user_header(self.dst_field)
ofp.oxm_serialize_header(n, data, len(data))
payload_offset = (
ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE +
struct.calcsize(NXAction._fmt_str)
)
self.len = utils.round_up(payload_offset + len(data), 8)
super(NXActionRegMove, self).serialize(buf, offset)
msg_pack_into('!%ds' % len(data), buf, offset + payload_offset,
bytes(data))
开发者ID:cloudysunny14,项目名称:ryu,代码行数:19,代码来源:nx_actions.py
示例11: _test_msg_pack_into
def _test_msg_pack_into(self, offset_type='e'):
fmt = '!HH'
len_ = struct.calcsize(fmt)
buf = bytearray(len_)
offset = len_
arg1 = 1
arg2 = 2
if offset_type == 'l':
offset += 1
elif offset_type == 'g':
offset -= 1
ofproto_parser.msg_pack_into(fmt, buf, offset, arg1, arg2)
check_offset = len(buf) - len_
res = struct.unpack_from(fmt, buffer(buf), check_offset)
eq_(arg1, res[0])
eq_(arg2, res[1])
return True
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:22,代码来源:test_ofproto_parser.py
示例12: serialize_tail
def serialize_tail(self):
# fixup
binroutes = bytearray()
for r in self.withdrawn_routes:
binroutes += r.serialize()
self.withdrawn_routes_len = len(binroutes)
binpathattrs = bytearray()
for pa in self.path_attributes:
binpathattrs += pa.serialize()
self.total_path_attribute_len = len(binpathattrs)
binnlri = bytearray()
for n in self.nlri:
binnlri += n.serialize()
msg = bytearray()
offset = 0
msg_pack_into('!H', msg, offset, self.withdrawn_routes_len)
msg += binroutes
offset += 2 + self.withdrawn_routes_len
msg_pack_into('!H', msg, offset, self.total_path_attribute_len)
msg += binpathattrs
offset += 2 + self.total_path_attribute_len
msg += binnlri
return msg
开发者ID:ashishtanwer,项目名称:ryu,代码行数:24,代码来源:bgp.py
示例13: serialize
def serialize(self, buf, offset):
""" Serialize PushGPRSNS action into buffer. """
super(GPRSActionPushGPRSNS,self).serialize(buf, offset)
ofproto_parser.msg_pack_into("!HxxIHBBxxxx", buf, offset+8,
self.subtype, self.tlli, self.bvci, self.sapi, self.nsapi)
开发者ID:MichalPalatinus,项目名称:ryu,代码行数:5,代码来源:experimenter_switch.py
示例14: serialize
def serialize(self):
buf = bytearray()
msg_pack_into(self._PACK_STR, buf, 0, self.type,
bytes(self.serialize_value()))
return buf
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:5,代码来源:bgp.py
示例15: serialize_cap_value
def serialize_cap_value(self):
buf = bytearray()
msg_pack_into(self._CAP_PACK_STR, buf, 0, self.as_number)
return buf
开发者ID:ashishtanwer,项目名称:ryu,代码行数:4,代码来源:bgp.py
注:本文中的ryu.ofproto.ofproto_parser.msg_pack_into函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论