コード例 #1
0
ファイル: evpn.py プロジェクト: gautamgitspace/yabgp
 def construct(cls, value, iswithdraw=False):
     # rd
     value_hex = b''
     value_hex += MPLSVPN.construct_rd(value['rd'])
     # esi
     value_hex += b'\x00\x00' + struct.pack('!d', value['esi'])
     # ethernet tag
     value_hex += struct.pack('!I', value['eth_tag_id'])
     value_hex += MPLSVPN.construct_mpls_label_stack(value['label'])
     return value_hex
コード例 #2
0
ファイル: evpn.py プロジェクト: c0ns0le/yabgp
 def construct(cls, data):
     # rd
     data_hex = b''
     data_hex += MPLSVPN.construct_rd(data['rd'])
     # esi
     data_hex += b'\x00\x00' + struct.pack('!d', data['esi'])
     # ethernet tag
     data_hex += struct.pack('!I', data['eth_tag_id'])
     data_hex += MPLSVPN.construct_mpls_label_stack(data['label'])
     return data_hex
コード例 #3
0
 def construct(cls, value, iswithdraw=False):
     # rd
     value_hex = b''
     value_hex += MPLSVPN.construct_rd(value['rd'])
     # esi
     value_hex += b'\x00\x00' + struct.pack('!d', value['esi'])
     # ethernet tag
     value_hex += struct.pack('!I', value['eth_tag_id'])
     value_hex += MPLSVPN.construct_mpls_label_stack(value['label'])
     return value_hex
コード例 #4
0
 def construct(cls, data):
     # rd
     data_hex = b''
     data_hex += MPLSVPN.construct_rd(data['rd'])
     # esi
     data_hex += b'\x00\x00' + struct.pack('!d', data['esi'])
     # ethernet tag
     data_hex += struct.pack('!I', data['eth_tag_id'])
     data_hex += MPLSVPN.construct_mpls_label_stack(data['label'])
     return data_hex
コード例 #5
0
ファイル: evpn.py プロジェクト: c0ns0le/yabgp
 def construct(cls, data):
     # rd
     data_hex = b''
     data_hex += MPLSVPN.construct_rd(data['rd'])
     # esi
     data_hex += b'\x00\x00' + struct.pack('!d', data['esi'])
     # ethernet tag
     data_hex += struct.pack('!I', data['eth_tag_id'])
     # mac address len and address
     mac_hex = b''.join([struct.pack('!B', (int(i, 16))) for i in data['mac'].split("-")])
     data_hex += struct.pack('!B', len(mac_hex) * 8) + mac_hex
     # ip address len and address
     if data.get('ip'):
         ip_hex = netaddr.IPAddress(data['ip']).packed
         data_hex += struct.pack('!B', len(ip_hex) * 8) + ip_hex
     else:
         data_hex += b'\x00'
     if data.get('label'):
         data_hex += MPLSVPN.construct_mpls_label_stack(data['label'])
     return data_hex
コード例 #6
0
ファイル: evpn.py プロジェクト: gautamgitspace/yabgp
 def construct(cls, value, iswithdraw=False):
     # rd
     value_hex = b''
     value_hex += MPLSVPN.construct_rd(value['rd'])
     # esi
     value_hex += b'\x00\x00' + struct.pack('!d', value['esi'])
     # ethernet tag
     value_hex += struct.pack('!I', value['eth_tag_id'])
     # mac address len and address
     mac_hex = b''.join([struct.pack('!B', (int(i, 16))) for i in value['mac'].split("-")])
     value_hex += struct.pack('!B', len(mac_hex) * 8) + mac_hex
     # ip address len and address
     if value.get('ip'):
         ip_hex = netaddr.IPAddress(value['ip']).packed
         value_hex += struct.pack('!B', len(ip_hex) * 8) + ip_hex
     else:
         value_hex += b'\x00'
     if value.get('label'):
         value_hex += MPLSVPN.construct_mpls_label_stack(value['label'])
     return value_hex
コード例 #7
0
 def construct(cls, value, iswithdraw=False):
     # rd
     value_hex = b''
     value_hex += MPLSVPN.construct_rd(value['rd'])
     # esi
     value_hex += b'\x00\x00' + struct.pack('!d', value['esi'])
     # ethernet tag
     value_hex += struct.pack('!I', value['eth_tag_id'])
     # mac address len and address
     mac_hex = b''.join(
         [struct.pack('!B', (int(i, 16))) for i in value['mac'].split("-")])
     value_hex += struct.pack('!B', len(mac_hex) * 8) + mac_hex
     # ip address len and address
     if value.get('ip'):
         ip_hex = netaddr.IPAddress(value['ip']).packed
         value_hex += struct.pack('!B', len(ip_hex) * 8) + ip_hex
     else:
         value_hex += b'\x00'
     if value.get('label'):
         value_hex += MPLSVPN.construct_mpls_label_stack(value['label'])
     return value_hex
コード例 #8
0
 def construct(cls, data):
     # rd
     data_hex = b''
     data_hex += MPLSVPN.construct_rd(data['rd'])
     # esi
     data_hex += b'\x00\x00' + struct.pack('!d', data['esi'])
     # ethernet tag
     data_hex += struct.pack('!I', data['eth_tag_id'])
     # mac address len and address
     mac_hex = b''.join(
         [struct.pack('!B', (int(i, 16))) for i in data['mac'].split("-")])
     data_hex += struct.pack('!B', len(mac_hex) * 8) + mac_hex
     # ip address len and address
     if data.get('ip'):
         ip_hex = netaddr.IPAddress(data['ip']).packed
         data_hex += struct.pack('!B', len(ip_hex) * 8) + ip_hex
     else:
         data_hex += b'\x00'
     if data.get('label'):
         data_hex += MPLSVPN.construct_mpls_label_stack(data['label'])
     return data_hex
コード例 #9
0
ファイル: test_mpls_vpn.py プロジェクト: c0ns0le/yabgp
 def test_construct_mpls_label_stack(self):
     label_bin = b'\x00\x01\x41'
     self.assertEqual(label_bin, MPLSVPN.construct_mpls_label_stack(labels=[20]))
コード例 #10
0
ファイル: test_mpls_vpn.py プロジェクト: zhangqi887/yabgp
 def test_construct_mpls_label_stack(self):
     label_bin = b'\x00\x01\x41'
     self.assertEqual(label_bin,
                      MPLSVPN.construct_mpls_label_stack(labels=[20]))