]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/lib/send_bsr_packet.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / lib / send_bsr_packet.py
CommitLineData
acddc0ed 1# SPDX-License-Identifier: ISC
f40b18e8
KK
2#
3# Copyright (c) 2019 by VMware, Inc. ("VMware")
4# Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
5# ("NetDEF") in this file.
6#
f40b18e8
KK
7
8import sys
9import argparse
10from scapy.all import Raw, sendp
11import binascii
12
13
14def send_packet(packet, iface, interval, count):
15 """
16 Read BSR packet in Raw format and send it to specified interface
17
18 Parameter:
19 ---------
20 * `packet` : BSR packet in raw format
21 * `interface` : Interface from which packet would be send
22 * `interval` : Interval between the packets
23 * `count` : Number of packets to be sent
24 """
25
26 data = binascii.a2b_hex(packet)
27 p = Raw(load=data)
28 p.show()
29 sendp(p, inter=int(interval), iface=iface, count=int(count))
30
31
32if __name__ == "__main__":
33 parser = argparse.ArgumentParser(description="Send BSR Raw packet")
34 parser.add_argument("packet", help="Packet in raw format")
35 parser.add_argument("iface", help="Packet send to this ineterface")
36 parser.add_argument("--interval", help="Interval between packets", default=0)
37 parser.add_argument(
38 "--count", help="Number of times packet is sent repetitively", default=0
39 )
40 args = parser.parse_args()
41
42 if not args.packet or not args.iface:
43 sys.exit(1)
44
45 send_packet(args.packet, args.iface, args.interval, args.count)