本文整理汇总了Python中exabgp.bgp.message.update.nlri.cidr.CIDR.pack方法的典型用法代码示例。如果您正苦于以下问题:Python CIDR.pack方法的具体用法?Python CIDR.pack怎么用?Python CIDR.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exabgp.bgp.message.update.nlri.cidr.CIDR
的用法示例。
在下文中一共展示了CIDR.pack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pack
# 需要导入模块: from exabgp.bgp.message.update.nlri.cidr import CIDR [as 别名]
# 或者: from exabgp.bgp.message.update.nlri.cidr.CIDR import pack [as 别名]
def pack (self, addpath=None):
if not self.has_label():
if addpath:
return self.path_info.pack() + CIDR.pack(self)
return CIDR.pack(self)
length = len(self.labels)*8 + len(self.rd)*8 + self.mask
if addpath:
return self.path_info.pack() + chr(length) + self.labels.pack() + self.rd.pack() + CIDR.packed_ip(self)
return chr(length) + self.labels.pack() + self.rd.pack() + CIDR.packed_ip(self)
示例2: IPrefix4
# 需要导入模块: from exabgp.bgp.message.update.nlri.cidr import CIDR [as 别名]
# 或者: from exabgp.bgp.message.update.nlri.cidr.CIDR import pack [as 别名]
class IPrefix4 (IPrefix,IComponent,IPv4):
# not used, just present for simplying the nlri generation
operations = 0x0
# NAME
def __init__ (self,raw,netmask):
self.nlri = CIDR(raw,netmask)
def pack (self):
raw = self.nlri.pack()
return "%s%s" % (chr(self.ID),raw)
def __str__ (self):
return str(self.nlri)
示例3: IPrefix4
# 需要导入模块: from exabgp.bgp.message.update.nlri.cidr import CIDR [as 别名]
# 或者: from exabgp.bgp.message.update.nlri.cidr.CIDR import pack [as 别名]
class IPrefix4 (IPrefix,IComponent,IPv4):
# Must be defined in subclasses
CODE = -1
NAME = ''
# not used, just present for simplying the nlri generation
operations = 0x0
def __init__ (self, raw, netmask):
self.nlri = CIDR(raw,netmask)
def pack (self):
raw = self.nlri.pack()
# ID is defined in subclasses
return "%s%s" % (chr(self.ID),raw) # pylint: disable=E1101
def __str__ (self):
return str(self.nlri)
示例4: pack
# 需要导入模块: from exabgp.bgp.message.update.nlri.cidr import CIDR [as 别名]
# 或者: from exabgp.bgp.message.update.nlri.cidr.CIDR import pack [as 别名]
def pack (self, addpath):
if addpath or True:
return self.path_info.pack() + CIDR.pack(self) if addpath else CIDR.pack(self)
return CIDR.pack(self) if addpath else CIDR.pack(self)
示例5: pack
# 需要导入模块: from exabgp.bgp.message.update.nlri.cidr import CIDR [as 别名]
# 或者: from exabgp.bgp.message.update.nlri.cidr.CIDR import pack [as 别名]
def pack (self, addpath):
return self.path_info.pack() + CIDR.pack(self) if addpath else CIDR.pack(self)