]> git.ipfire.org Git - thirdparty/lldpd.git/blame - tests/integration/test_pcap.py
test: add tests for 802.3BT additions
[thirdparty/lldpd.git] / tests / integration / test_pcap.py
CommitLineData
d88003ff 1import pytest
ece1209a 2import scapy.all
2063390b
VB
3
4
5def send_pcap(location, interface):
ece1209a
VB
6 packets = scapy.all.rdpcap(location)
7 print(packets)
8 scapy.all.sendp(packets, iface=interface)
2063390b
VB
9
10
ece1209a
VB
11def test_cisco_sg200(request, lldpd1, lldpcli, namespaces):
12 with namespaces(2):
13 send_pcap('data/sg200.pcap', 'eth1')
14 with namespaces(1):
15 out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
16 assert out['lldp.eth0.age'].startswith('0 day, 00:00:')
17 del out['lldp.eth0.age']
18 expected = {
19 "lldp.eth0.via": "LLDP",
20 "lldp.eth0.rid": "1",
21 "lldp.eth0.chassis.mac": "00:35:35:35:35:35",
22 "lldp.eth0.port.ttl": "120",
23 "lldp.eth0.port.ifname": "g1",
24 }
25 if 'Dot3' in request.config.lldpd.features:
26 expected.update({
27 "lldp.eth0.port.auto-negotiation.supported": "yes",
28 "lldp.eth0.port.auto-negotiation.enabled": "yes",
29 "lldp.eth0.port.auto-negotiation.1000Base-T.hd": "no",
30 "lldp.eth0.port.auto-negotiation.1000Base-T.fd": "yes",
31 "lldp.eth0.port.auto-negotiation.current": "unknown",
32 })
33 if 'LLDP-MED' in request.config.lldpd.features:
34 expected.update({
35 "lldp.eth0.lldp-med.device-type":
36 "Network Connectivity Device",
37 "lldp.eth0.lldp-med.Capabilities.available": "yes",
38 "lldp.eth0.lldp-med.Policy.available": "yes",
39 "lldp.eth0.lldp-med.Location.available": "yes",
40 "lldp.eth0.lldp-med.MDI/PSE.available": "yes",
41 "lldp.eth0.lldp-med.Inventory.available": "yes",
42 "lldp.eth0.lldp-med.Civic address.country": "DE",
43 "lldp.eth0.lldp-med.Civic address.city": "Berlin",
44 "lldp.eth0.lldp-med.Civic address.street":
45 "Karl-Liebknecht-Strase",
46 "lldp.eth0.lldp-med.Civic address.building": "42",
47 "lldp.eth0.lldp-med.inventory.hardware": "V02",
48 "lldp.eth0.lldp-med.inventory.software": "1.0.8.3",
49 "lldp.eth0.lldp-med.inventory.firmware": "1.0.8.3",
50 "lldp.eth0.lldp-med.inventory.serial": "XXX11111ZZZ",
51 "lldp.eth0.lldp-med.inventory.manufacturer": "0xbc00",
52 "lldp.eth0.lldp-med.inventory.model": "SG 200-08P",
53 "lldp.eth0.lldp-med.inventory.asset": "1"
54 })
55 assert out == expected
d88003ff
VB
56
57
58@pytest.mark.skipif("'Dot3' not in config.lldpd.features",
59 readon="Dot3 not supported")
60def test_8023bt(lldpd1, lldpcli, namespaces):
61 with namespaces(2):
62 send_pcap('data/8023bt.pcap', 'eth1')
63 with namespaces(1):
64 out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
65 for k in list(out.keys()):
66 if not k.startswith("lldp.eth0.port.power."):
67 del out[k]
68 assert out == {
69 'lldp.eth0.port.power.supported': 'yes',
70 'lldp.eth0.port.power.enabled': 'yes',
71 'lldp.eth0.port.power.paircontrol': 'yes',
72 'lldp.eth0.port.power.device-type': 'PSE',
73 'lldp.eth0.port.power.pairs': 'signal',
74 'lldp.eth0.port.power.class': 'class 4',
75 'lldp.eth0.port.power.power-type': '2',
76 'lldp.eth0.port.power.source': 'PSE',
77 'lldp.eth0.port.power.priority': 'low',
78 'lldp.eth0.port.power.requested': '71000',
79 'lldp.eth0.port.power.allocated': '51000',
80 'lldp.eth0.port.power.requested-a': '35500',
81 'lldp.eth0.port.power.requested-b': '35500',
82 'lldp.eth0.port.power.allocated-a': '25500',
83 'lldp.eth0.port.power.allocated-b': '25500',
84 'lldp.eth0.port.power.pse-powering-status':
85 '4-pair powering single-signature PD',
86 'lldp.eth0.port.power.pd-powering-status': 'Unknown',
87 'lldp.eth0.port.power.power-pairs-ext': 'Both alternatives',
88 'lldp.eth0.port.power.power-class-ext-a': 'Class 4',
89 'lldp.eth0.port.power.power-class-ext-b': 'Class 4',
90 'lldp.eth0.port.power.power-class-ext': 'Dual-signature PD',
91 'lldp.eth0.port.power.power-type-ext': 'Type 3 PSE',
92 'lldp.eth0.port.power.pd-load':
93 ('PD is single- or dual-signature and power '
94 'is not electrically isolated'),
95 'lldp.eth0.port.power.max-power': '51000'
96 }