Skip to content

Commit

Permalink
Allow enabling/disabling StateRefresh on previously disabled/enabled …
Browse files Browse the repository at this point in the history
…PIM-DM interfaces without having to remove them
  • Loading branch information
pedrofran12 committed Mar 22, 2020
1 parent 93f8717 commit 1e75e8f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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.


Expand Down Expand Up @@ -59,8 +60,6 @@ After starting the protocol process you can enable the protocol in specific inte
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

To remove a previously added interface, you need run the following commands:
Expand Down
10 changes: 2 additions & 8 deletions pimdm/InterfacePIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def __init__(self, interface_name: str, vif_index:int, state_refresh_capable:boo
super()._enable()
self.force_send_hello()


def get_ip(self):
return self.ip_interface

Expand All @@ -91,11 +90,9 @@ def _receive(self, raw_bytes):
packet = ReceivedPacket(raw_bytes, self)
self.PKT_FUNCTIONS[packet.payload.get_pim_type()](self, packet)


def send(self, data: bytes, group_ip: str=MCAST_GRP):
super().send(data=data, group_ip=group_ip)


#Random interval for initial Hello message on bootup or triggered Hello message to a rebooting neighbor
def force_send_hello(self):
if self.hello_timer is not None:
Expand Down Expand Up @@ -142,7 +139,6 @@ def remove(self):
Main.kernel.interface_change_number_of_neighbors()
super().remove()


def check_number_of_neighbors(self):
has_neighbors = len(self.neighbors) > 0
if has_neighbors != self._had_neighbors:
Expand Down Expand Up @@ -177,6 +173,8 @@ def remove_neighbor(self, ip):
self.interface_logger.debug("Remove neighbor: " + ip)
self.check_number_of_neighbors()

def set_state_refresh_capable(self, value):
self._state_refresh_capable = value

def is_state_refresh_enabled(self):
return self._state_refresh_capable
Expand Down Expand Up @@ -245,7 +243,6 @@ def receive_hello(self, packet):

neighbor.receive_hello(generation_id, hello_hold_time, state_refresh_capable)


def receive_assert(self, packet):
pkt_assert = packet.payload.payload # type: PacketPimAssert
source = pkt_assert.source_address
Expand All @@ -257,7 +254,6 @@ def receive_assert(self, packet):
except:
traceback.print_exc()


def receive_join_prune(self, packet):
pkt_join_prune = packet.payload.payload # type: PacketPimJoinPrune

Expand Down Expand Up @@ -299,7 +295,6 @@ def receive_graft(self, packet):
traceback.print_exc()
continue


def receive_graft_ack(self, packet):
pkt_join_prune = packet.payload.payload # type: PacketPimGraftAck

Expand Down Expand Up @@ -330,7 +325,6 @@ def receive_state_refresh(self, packet):
traceback.print_exc()



PKT_FUNCTIONS = {
0: receive_hello,
3: receive_join_prune,
Expand Down
1 change: 1 addition & 0 deletions pimdm/Kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def create_pim_interface(self, interface_name: str, state_refresh_capable:bool):
vif_already_exists = pim_interface or igmp_interface
if pim_interface:
# already exists
pim_interface.set_state_refresh_capable(state_refresh_capable)
return
elif igmp_interface:
index = igmp_interface.vif_index
Expand Down
2 changes: 1 addition & 1 deletion pimdm/Run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import argparse
import traceback

VERSION = "1.0.3"
VERSION = "1.0.4"

def client_socket(data_to_send):
# Create a UDS socket
Expand Down
2 changes: 0 additions & 2 deletions pimdm/tree/KernelEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ def recv_state_refresh_msg(self, index, packet):
prune_indicator_flag = packet.payload.payload.prune_indicator_flag #P
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)

self.interface_state[index].recv_state_refresh_msg(received_metric, prune_indicator_flag)


iif = packet.interface.vif_index
if iif != self.inbound_interface_index:
return
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
description="PIM-DM protocol",
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router",
version="1.0.3",
keywords="PIM-DM Multicast Routing Protocol Dense-Mode Router RFC3973",
version="1.0.4",
url="http://github.com/pedrofran12/pim_dm",
author='Pedro Oliveira',
author_email='pedro.francisco.oliveira@tecnico.ulisboa.pt',
author="Pedro Oliveira",
author_email="pedro.francisco.oliveira@tecnico.ulisboa.pt",
license="MIT",
install_requires=dependencies,
packages=find_packages(exclude=["docs"]),
Expand Down Expand Up @@ -46,5 +46,5 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
python_requires='>=3.2',
python_requires=">=3.2",
)

0 comments on commit 1e75e8f

Please sign in to comment.