Skip to content
Snippets Groups Projects
Commit 441c0d66 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

Fix bug: VC message wrongly broadcast

parent ee1f2da7
No related branches found
No related tags found
No related merge requests found
......@@ -17,14 +17,6 @@ def process_packet(new_packet):
# Parse the raw data into a Scapy IP packet
pkt = IP(data)
if pkt.haslayer(Ether) and pkt[Ether].dst == "ff:ff:ff:ff:ff:ff" and pkt.haslayer(Raw) and len(pkt.layers()) == 2:
raw_data = pkt[Raw].load
if len(raw_data) == 28:
magic_hdr_pkt = struct.unpack('!I', raw_data[:4])[0]
if magic_hdr_pkt == magic_hdr:
new_packet.drop()
return
if pkt.haslayer(IP):
# print(f"IP Packet: {pkt.summary()}")
# pkt.show()
......
......@@ -203,7 +203,7 @@ class IdsOpportunistic:
# Update mark rules for new inf on br0
if_utils.delete_mangle_mark(if_utils.BR_CENTER_NAME, private_if, inter_num)
if_utils.add_mangle_mark(if_utils.BR_CENTER_NAME, inter_name, inter_num)
if_utils.map_inf_inside[inter_num] = inter_num
if_utils.map_inf_inside[inter_num] = inter_name
del (IdsOpportunistic.map_tap_inf_for_ids[inter_num])
......
......@@ -72,7 +72,7 @@ def broadcast_packet(message):
for iface in node.interface.keys():
src_mac = node.interface[iface]
dst_mac = "ff:ff:ff:ff:ff:ff"
dst_mac = "00:00:00:00:00:00"
packet = Ether(src=src_mac, dst=dst_mac) / Raw(load=message) # Broadcast MAC address
sendp(packet, iface=iface) # Specify the interface
......@@ -97,7 +97,7 @@ def process_packet(iface, my_mac):
def packet_callback(packet):
if Ether in packet and Raw in packet and len(packet.layers()) == 2:
# print(packet)
if packet[Ether].dst == my_mac or (packet[Ether].src != my_mac and packet[Ether].dst == "ff:ff:ff:ff:ff:ff"):
if packet[Ether].dst == my_mac or (packet[Ether].src != my_mac and packet[Ether].dst == "00:00:00:00:00:00"):
raw_data = packet[Raw].load
print("raw data from iface", iface, ":", raw_data)
magic_hdr_pkt = struct.unpack('!I', raw_data[:4])[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment