Commit 1e75e8f6 authored by Pedro Oliveira's avatar Pedro Oliveira

Allow enabling/disabling StateRefresh on previously disabled/enabled PIM-DM...

Allow enabling/disabling StateRefresh on previously disabled/enabled PIM-DM interfaces without having to remove them
parent 93f87171
# PIM-DM # PIM-DM
We have implemented the specification of PIM-DM ([RFC3973](https://tools.ietf.org/html/rfc3973)). We have implemented PIM-DM specification ([RFC3973](https://tools.ietf.org/html/rfc3973)).
This repository stores the implementation of this protocol. The implementation is written in Python language and is destined to Linux systems. This repository stores the implementation of this protocol. The implementation is written in Python language and is destined to Linux systems.
...@@ -59,8 +60,6 @@ After starting the protocol process you can enable the protocol in specific inte ...@@ -59,8 +60,6 @@ After starting the protocol process you can enable the protocol in specific inte
sudo pim-dm -aiigmp INTERFACE_NAME sudo pim-dm -aiigmp INTERFACE_NAME
``` ```
If you have previously enabled PIM-DM on an interface without State-Refresh and want to enable it, you first need to disable this interface, and then run the command -aisr. The same happens when you want to disable State Refresh in a previously enabled StateRefresh interface.
#### Remove interface #### Remove interface
To remove a previously added interface, you need run the following commands: To remove a previously added interface, you need run the following commands:
......
...@@ -82,7 +82,6 @@ class InterfacePim(Interface): ...@@ -82,7 +82,6 @@ class InterfacePim(Interface):
super()._enable() super()._enable()
self.force_send_hello() self.force_send_hello()
def get_ip(self): def get_ip(self):
return self.ip_interface return self.ip_interface
...@@ -91,11 +90,9 @@ class InterfacePim(Interface): ...@@ -91,11 +90,9 @@ class InterfacePim(Interface):
packet = ReceivedPacket(raw_bytes, self) packet = ReceivedPacket(raw_bytes, self)
self.PKT_FUNCTIONS[packet.payload.get_pim_type()](self, packet) self.PKT_FUNCTIONS[packet.payload.get_pim_type()](self, packet)
def send(self, data: bytes, group_ip: str=MCAST_GRP): def send(self, data: bytes, group_ip: str=MCAST_GRP):
super().send(data=data, group_ip=group_ip) super().send(data=data, group_ip=group_ip)
#Random interval for initial Hello message on bootup or triggered Hello message to a rebooting neighbor #Random interval for initial Hello message on bootup or triggered Hello message to a rebooting neighbor
def force_send_hello(self): def force_send_hello(self):
if self.hello_timer is not None: if self.hello_timer is not None:
...@@ -142,7 +139,6 @@ class InterfacePim(Interface): ...@@ -142,7 +139,6 @@ class InterfacePim(Interface):
Main.kernel.interface_change_number_of_neighbors() Main.kernel.interface_change_number_of_neighbors()
super().remove() super().remove()
def check_number_of_neighbors(self): def check_number_of_neighbors(self):
has_neighbors = len(self.neighbors) > 0 has_neighbors = len(self.neighbors) > 0
if has_neighbors != self._had_neighbors: if has_neighbors != self._had_neighbors:
...@@ -177,6 +173,8 @@ class InterfacePim(Interface): ...@@ -177,6 +173,8 @@ class InterfacePim(Interface):
self.interface_logger.debug("Remove neighbor: " + ip) self.interface_logger.debug("Remove neighbor: " + ip)
self.check_number_of_neighbors() self.check_number_of_neighbors()
def set_state_refresh_capable(self, value):
self._state_refresh_capable = value
def is_state_refresh_enabled(self): def is_state_refresh_enabled(self):
return self._state_refresh_capable return self._state_refresh_capable
...@@ -245,7 +243,6 @@ class InterfacePim(Interface): ...@@ -245,7 +243,6 @@ class InterfacePim(Interface):
neighbor.receive_hello(generation_id, hello_hold_time, state_refresh_capable) neighbor.receive_hello(generation_id, hello_hold_time, state_refresh_capable)
def receive_assert(self, packet): def receive_assert(self, packet):
pkt_assert = packet.payload.payload # type: PacketPimAssert pkt_assert = packet.payload.payload # type: PacketPimAssert
source = pkt_assert.source_address source = pkt_assert.source_address
...@@ -257,7 +254,6 @@ class InterfacePim(Interface): ...@@ -257,7 +254,6 @@ class InterfacePim(Interface):
except: except:
traceback.print_exc() traceback.print_exc()
def receive_join_prune(self, packet): def receive_join_prune(self, packet):
pkt_join_prune = packet.payload.payload # type: PacketPimJoinPrune pkt_join_prune = packet.payload.payload # type: PacketPimJoinPrune
...@@ -299,7 +295,6 @@ class InterfacePim(Interface): ...@@ -299,7 +295,6 @@ class InterfacePim(Interface):
traceback.print_exc() traceback.print_exc()
continue continue
def receive_graft_ack(self, packet): def receive_graft_ack(self, packet):
pkt_join_prune = packet.payload.payload # type: PacketPimGraftAck pkt_join_prune = packet.payload.payload # type: PacketPimGraftAck
...@@ -330,7 +325,6 @@ class InterfacePim(Interface): ...@@ -330,7 +325,6 @@ class InterfacePim(Interface):
traceback.print_exc() traceback.print_exc()
PKT_FUNCTIONS = { PKT_FUNCTIONS = {
0: receive_hello, 0: receive_hello,
3: receive_join_prune, 3: receive_join_prune,
......
...@@ -128,6 +128,7 @@ class Kernel: ...@@ -128,6 +128,7 @@ class Kernel:
vif_already_exists = pim_interface or igmp_interface vif_already_exists = pim_interface or igmp_interface
if pim_interface: if pim_interface:
# already exists # already exists
pim_interface.set_state_refresh_capable(state_refresh_capable)
return return
elif igmp_interface: elif igmp_interface:
index = igmp_interface.vif_index index = igmp_interface.vif_index
......
...@@ -9,7 +9,7 @@ import os ...@@ -9,7 +9,7 @@ import os
import argparse import argparse
import traceback import traceback
VERSION = "1.0.3" VERSION = "1.0.4"
def client_socket(data_to_send): def client_socket(data_to_send):
# Create a UDS socket # Create a UDS socket
......
...@@ -112,10 +112,8 @@ class KernelEntry: ...@@ -112,10 +112,8 @@ class KernelEntry:
prune_indicator_flag = packet.payload.payload.prune_indicator_flag #P prune_indicator_flag = packet.payload.payload.prune_indicator_flag #P
interval = packet.payload.payload.interval interval = packet.payload.payload.interval
received_metric = AssertMetric(metric_preference=metric_preference, route_metric=metric, ip_address=source_of_state_refresh, state_refresh_interval=interval) received_metric = AssertMetric(metric_preference=metric_preference, route_metric=metric, ip_address=source_of_state_refresh, state_refresh_interval=interval)
self.interface_state[index].recv_state_refresh_msg(received_metric, prune_indicator_flag) self.interface_state[index].recv_state_refresh_msg(received_metric, prune_indicator_flag)
iif = packet.interface.vif_index iif = packet.interface.vif_index
if iif != self.inbound_interface_index: if iif != self.inbound_interface_index:
return return
......
...@@ -12,11 +12,11 @@ setup( ...@@ -12,11 +12,11 @@ setup(
description="PIM-DM protocol", description="PIM-DM protocol",
long_description=open("README.md", "r").read(), long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router", keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router RFC3973",
version="1.0.3", version="1.0.4",
url="http://github.com/pedrofran12/pim_dm", url="http://github.com/pedrofran12/pim_dm",
author='Pedro Oliveira', author="Pedro Oliveira",
author_email='pedro.francisco.oliveira@tecnico.ulisboa.pt', author_email="pedro.francisco.oliveira@tecnico.ulisboa.pt",
license="MIT", license="MIT",
install_requires=dependencies, install_requires=dependencies,
packages=find_packages(exclude=["docs"]), packages=find_packages(exclude=["docs"]),
...@@ -46,5 +46,5 @@ setup( ...@@ -46,5 +46,5 @@ setup(
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
], ],
python_requires='>=3.2', python_requires=">=3.2",
) )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment