11import logging
2+ from threading import Lock
23from threading import Timer
34
45from mld .utils import TYPE_CHECKING
@@ -36,6 +37,10 @@ def __init__(self, interface: 'InterfaceMLD'):
3637 self .group_state = {}
3738 self .group_state_lock = RWLockWrite ()
3839
40+ # instances to notify membership timeout and report or done packet reception
41+ self .to_notify_list = []
42+ self .to_notify_list_lock = Lock ()
43+
3944 # send general query
4045 packet = PacketMLDHeader (type = mld_globals .MULTICAST_LISTENER_QUERY_TYPE ,
4146 max_resp_delay = mld_globals .QUERY_RESPONSE_INTERVAL * 1000 )
@@ -139,13 +144,15 @@ def receive_report(self, packet: ReceivedPacket):
139144 """
140145 mld_group = packet .payload .group_address
141146 self .get_group_state (mld_group ).receive_report ()
147+ self .notify_report (packet )
142148
143149 def receive_done (self , packet : ReceivedPacket ):
144150 """
145151 Received MLD Done packet
146152 """
147153 mld_group = packet .payload .group_address
148154 self .get_group_state (mld_group ).receive_done ()
155+ self .notify_done (packet )
149156
150157 def receive_query (self , packet : ReceivedPacket ):
151158 """
@@ -163,8 +170,51 @@ def remove(self):
163170 """
164171 Remove this MLD interface
165172 Clear all state
173+ Notify all interested entries that this interface is no longer managed
166174 """
167175 for group in self .group_state .values ():
168176 group .remove ()
169177 self .clear_general_query_timer ()
170178 self .clear_other_querier_present_timer ()
179+ for to_notify in self .to_notify_list :
180+ to_notify .notify_removal ()
181+ del self .to_notify_list [:]
182+
183+ ###########################################
184+ # Notify Membership packets and Membership timeouts
185+ ###########################################
186+ def notify_done (self , packet : ReceivedPacket ):
187+ """
188+ Notify all entries interested in this router
189+ """
190+ for to_notify in self .to_notify_list :
191+ to_notify .notify_done (packet = packet )
192+
193+ def notify_report (self , packet : ReceivedPacket ):
194+ """
195+ Notify all entries interested in this router
196+ """
197+ for to_notify in self .to_notify_list :
198+ to_notify .notify_report (packet = packet )
199+
200+ def notify_timeout (self , group_ip ):
201+ """
202+ Notify all entries interested in this router
203+ """
204+ for to_notify in self .to_notify_list :
205+ to_notify .notify_timeout (group_ip )
206+
207+ def add_to_notify_entry (self , to_notify_entry ):
208+ """
209+ A new entry monitoring membership informations
210+ """
211+ with self .to_notify_list_lock :
212+ self .to_notify_list .append (to_notify_entry )
213+
214+ def remove_to_notify_entry (self , to_notify_entry ):
215+ """
216+ A entry is no longer monitoring membership informations
217+ Remove this entry from this object
218+ """
219+ with self .to_notify_list_lock :
220+ self .to_notify_list .remove (to_notify_entry )
0 commit comments