summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/send_bsr_packet.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/lib/send_bsr_packet.py')
-rwxr-xr-xtests/topotests/lib/send_bsr_packet.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/topotests/lib/send_bsr_packet.py b/tests/topotests/lib/send_bsr_packet.py
index c11de64b1e..7f9d3e8d2d 100755
--- a/tests/topotests/lib/send_bsr_packet.py
+++ b/tests/topotests/lib/send_bsr_packet.py
@@ -23,16 +23,28 @@ def send_packet(packet, iface, interval, count):
* `count` : Number of packets to be sent
"""
- data = binascii.a2b_hex(packet)
+ try:
+ data = binascii.a2b_hex(packet)
+ except binascii.Error:
+ print("Invalid packet format. Please provide a hexadecimal-encoded string.")
+ sys.exit(1)
+
p = Raw(load=data)
p.show()
- sendp(p, inter=int(interval), iface=iface, count=int(count))
+ try:
+ sendp(p, inter=int(interval), iface=iface, count=int(count))
+ except ValueError:
+ print("Invalid interval or count value. Please provide integers.")
+ sys.exit(1)
+ except Exception as error:
+ print(f"Error sending packet: {error}")
+ sys.exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Send BSR Raw packet")
parser.add_argument("packet", help="Packet in raw format")
- parser.add_argument("iface", help="Packet send to this ineterface")
+ parser.add_argument("iface", help="Packet send to this interface")
parser.add_argument("--interval", help="Interval between packets", default=0)
parser.add_argument(
"--count", help="Number of times packet is sent repetitively", default=0
@@ -40,6 +52,7 @@ if __name__ == "__main__":
args = parser.parse_args()
if not args.packet or not args.iface:
+ print("Please provide both a packet and an interface.")
sys.exit(1)
send_packet(args.packet, args.iface, args.interval, args.count)