Skip to content

Commit

Permalink
added MAX_SOLICITATION_REFRESH_TIME
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriWahl committed May 27, 2024
1 parent 4a2613b commit ac345cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion dhcpy6d/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ def __init__(self):

# INFORMATION REFRESH TIME option 32 for option 11 (INFORMATION REQUEST)
# see RFC http://tools.ietf.org/html/rfc4242
self.INFORMATION_REFRESH_TIME = '6000'
self.INFORMATION_REFRESH_TIME = '600'

# SOL_MAX_RT Option 82
# see https://www.rfc-editor.org/rfc/rfc8415.html#page-127
self.MAX_SOLICITATION_REFRESH_TIME = '1200'

# config type
# one of file, mysql, sqlite or none
Expand Down Expand Up @@ -727,6 +731,13 @@ def read_config(self, configfile):
error_exit(f"{msg_prefix} Information refresh time preference "
f"'{self.INFORMATION_REFRESH_TIME}' is pretty short.")

# check max solicitation refresh time
if not self.MAX_SOLICITATION_REFRESH_TIME.isdigit():
error_exit(f"{msg_prefix} Max solicitation refresh time '{self.MAX_SOLICITATION_REFRESH_TIME}' is invalid.")
elif not 60 <= int(self.MAX_SOLICITATION_REFRESH_TIME) <= 86400:
error_exit(f"{msg_prefix} Max solicitation refresh time preference "
f"'{self.MAX_SOLICITATION_REFRESH_TIME}' is not greater or equal to 60 and neither smaller or equal to 86400.")

# check validity of configuration source
if self.STORE_CONFIG not in ['mysql', 'postgresql', 'sqlite', 'file', False]:
error_exit(f"{msg_prefix} Unknown config storage type '{self.STORAGE}' is invalid.")
Expand Down
2 changes: 1 addition & 1 deletion dhcpy6d/options/option_82.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class Option(OptionTemplate):
Option 32 Information Refresh Time
"""
def build(self, **kwargs):
response_string_part = self.convert_to_string(self.number, f'{int(cfg.INFORMATION_REFRESH_TIME):08x}')
response_string_part = self.convert_to_string(self.number, f'{int(cfg.MAX_SOLICITATION_REFRESH_TIME):08x}')
# options in answer to be logged
return response_string_part, self.number

0 comments on commit ac345cb

Please sign in to comment.