Skip to content

Commit 16dc529

Browse files
committed
feat (layer): changed udp bindings between hsrpv1 and hsrpv2
AI-Assisted: no
1 parent 9b5f652 commit 16dc529

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

scapy/layers/hsrp.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,19 @@ def post_build(self, p, pay):
296296

297297
bind_bottom_up(UDP, HSRP, dport=1985)
298298
bind_bottom_up(UDP, HSRP, sport=1985)
299-
bind_bottom_up(UDP, HSRP, dport=2029)
300-
bind_bottom_up(UDP, HSRP, sport=2029)
301299
bind_layers(UDP, HSRP, dport=1985, sport=1985)
302-
bind_layers(UDP, HSRP, dport=2029, sport=2029)
300+
303301
DestIPField.bind_addr(UDP, "224.0.0.2", dport=1985)
302+
"""
303+
since port 1954 (UDP) would be shared by both hsrpv1 and hsprv2 (ipv4),
304+
users building hsrpv2 (ipv4) packets should set IP(dst="224.0.0.102") explicitly to avoid using wrong multicast destination
305+
"""
306+
# DestIPField.bind_addr(UDP, "224.0.0.102", dport=1985)
307+
304308
if conf.ipv6_enabled:
305309
from scapy.layers.inet6 import DestIP6Field
310+
311+
bind_bottom_up(UDP, HSRPv2, dport=2029)
312+
bind_bottom_up(UDP, HSRPv2, sport=2029)
313+
bind_layers(UDP, HSRPv2, dport=2029, sport=2029)
306314
DestIP6Field.bind_addr(UDP, "ff02::66", dport=2029)

0 commit comments

Comments
 (0)