コード例 #1
0
ファイル: test_mpls_vpn.py プロジェクト: c0ns0le/yabgp
 def test_parse_mpls_label_stack(self):
     label_bin = b'\x00\x01\x41'
     self.assertEqual([20], MPLSVPN.parse_mpls_label_stack(label_bin))
     label_bin = b'\x00\x01\x10\x00\x01\x31'
     self.assertEqual([17, 19], MPLSVPN.parse_mpls_label_stack(label_bin))
     label_bin = b'\x80\x00\x00'
     self.assertEqual([524288], MPLSVPN.parse_mpls_label_stack(label_bin))
コード例 #2
0
ファイル: test_mpls_vpn.py プロジェクト: zhangqi887/yabgp
 def test_parse_mpls_label_stack(self):
     label_bin = b'\x00\x01\x41'
     self.assertEqual([20], MPLSVPN.parse_mpls_label_stack(label_bin))
     label_bin = b'\x00\x01\x10\x00\x01\x31'
     self.assertEqual([17, 19], MPLSVPN.parse_mpls_label_stack(label_bin))
     label_bin = b'\x80\x00\x00'
     self.assertEqual([524288], MPLSVPN.parse_mpls_label_stack(label_bin))
コード例 #3
0
 def parse(cls, value, iswithdraw=False):
     route = dict()
     # rd
     offset = 8
     route['rd'] = cls.parse_rd(value[0:offset])
     # esi
     route['esi'] = int(binascii.b2a_hex(value[offset:offset + 10]), 16)
     offset += 10
     # ethernet tag id
     route['eth_tag_id'] = struct.unpack('!I', value[offset:offset + 4])[0]
     offset += 5
     # mac address
     route['mac'] = str(
         netaddr.EUI(int(binascii.b2a_hex(value[offset:offset + 6]), 16)))
     offset += 6
     ip_addr_len = ord(value[offset:offset + 1])
     offset += 1
     # ip address
     if ip_addr_len != 0:
         route['ip'] = str(
             netaddr.IPAddress(
                 int(
                     binascii.b2a_hex(value[offset:offset +
                                            int(ip_addr_len / 8)]), 16)))
         offset += int(ip_addr_len / 8)
     # label
     route['label'] = MPLSVPN.parse_mpls_label_stack(value[offset:])
     return route
コード例 #4
0
ファイル: evpn.py プロジェクト: c0ns0le/yabgp
 def parse(cls, data):
     route = dict()
     route['rd'] = cls.parse_rd(data[0:8])
     offset = 8
     route['esi'] = int(binascii.b2a_hex(data[offset: offset+10]), 16)
     offset += 10
     # ethernet tag id
     route['eth_tag_id'] = struct.unpack('!I', data[offset: offset+4])[0]
     offset += 4
     route['label'] = MPLSVPN.parse_mpls_label_stack(data[offset:])
     return route
コード例 #5
0
 def parse(cls, value, iswithdraw=False):
     route = dict()
     route['rd'] = cls.parse_rd(value[0:8])
     offset = 8
     route['esi'] = int(binascii.b2a_hex(value[offset:offset + 10]), 16)
     offset += 10
     # ethernet tag id
     route['eth_tag_id'] = struct.unpack('!I', value[offset:offset + 4])[0]
     offset += 4
     route['label'] = MPLSVPN.parse_mpls_label_stack(value[offset:])
     return route
コード例 #6
0
ファイル: evpn.py プロジェクト: c0ns0le/yabgp
 def parse(cls, data):
     route = dict()
     # rd
     offset = 8
     route['rd'] = cls.parse_rd(data[0:offset])
     # esi
     route['esi'] = int(binascii.b2a_hex(data[offset: offset+10]), 16)
     offset += 10
     # ethernet tag id
     route['eth_tag_id'] = struct.unpack('!I', data[offset: offset+4])[0]
     offset += 5
     # mac address
     route['mac'] = str(netaddr.EUI(int(binascii.b2a_hex(data[offset: offset+6]), 16)))
     offset += 6
     ip_addr_len = ord(data[offset: offset + 1])
     offset += 1
     # ip address
     if ip_addr_len != 0:
         route['ip'] = str(netaddr.IPAddress(int(binascii.b2a_hex(data[offset: offset + int(ip_addr_len / 8)]), 16)))
         offset += int(ip_addr_len / 8)
     # label
     route['label'] = MPLSVPN.parse_mpls_label_stack(data[offset:])
     return route