diff --git a/dhcpy6d/config.py b/dhcpy6d/config.py index b5ce0ef..d8d0ec8 100644 --- a/dhcpy6d/config.py +++ b/dhcpy6d/config.py @@ -125,7 +125,7 @@ def __init__(self): # SOL_MAX_RT Option 82 # see https://www.rfc-editor.org/rfc/rfc8415.html#page-127 - self.MAX_SOLICITATION_REFRESH_TIME = '1200' + self.SOLICITATION_REFRESH_TIME = '1200' # config type # one of file, mysql, sqlite or none @@ -732,11 +732,11 @@ def read_config(self, configfile): 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: + if not self.SOLICITATION_REFRESH_TIME.isdigit(): + error_exit(f"{msg_prefix} Max solicitation refresh time '{self.SOLICITATION_REFRESH_TIME}' is invalid.") + elif not 60 <= int(self.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.") + f"'{self.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]: diff --git a/dhcpy6d/handler.py b/dhcpy6d/handler.py index 707b245..bfc2468 100644 --- a/dhcpy6d/handler.py +++ b/dhcpy6d/handler.py @@ -498,9 +498,6 @@ def build_response(self, message_type_response, transaction, options_request, st response_string += build_option(CONST.OPTION.STATUS_CODE, f'{CONST.STATUS.NO_ADDRESSES_AVAILABLE:04x}') - # just a test for https://github.com/HenriWahl/dhcpy6d/issues/64 - response_string += build_option(CONST.OPTION.RECONF_ACCEPT) - # options in answer to be logged options_answer.append(CONST.OPTION.STATUS_CODE) @@ -525,6 +522,10 @@ def build_response(self, message_type_response, transaction, options_request, st log.info(f'{CONST.MESSAGE_DICT[message_type_response]} | ' f'transaction: {transaction.id} | ' f'options: {options_answer}') + + # just a test for https://github.com/HenriWahl/dhcpy6d/issues/64 + response_string += build_option(CONST.OPTION.RECONF_ACCEPT, '') + # handler self.response = binascii.unhexlify(response_string) diff --git a/dhcpy6d/options/option_20.py b/dhcpy6d/options/option_20.py index 160142c..7b93b62 100644 --- a/dhcpy6d/options/option_20.py +++ b/dhcpy6d/options/option_20.py @@ -27,4 +27,4 @@ class Option(OptionTemplate): def build(self, **kwargs): response_string_part = self.convert_to_string(self.number, '') # options in answer to be logged - return response_string_part, self.number + return response_string_part, self.number \ No newline at end of file diff --git a/dhcpy6d/options/option_82.py b/dhcpy6d/options/option_82.py index c5ce0c1..de1884a 100644 --- a/dhcpy6d/options/option_82.py +++ b/dhcpy6d/options/option_82.py @@ -22,9 +22,9 @@ class Option(OptionTemplate): """ - Option 32 Information Refresh Time + Option 82 SOL_MAX_RT (sic!) """ def build(self, **kwargs): - response_string_part = self.convert_to_string(self.number, f'{int(cfg.MAX_SOLICITATION_REFRESH_TIME):08x}') + response_string_part = self.convert_to_string(self.number, f'{int(cfg.SOLICITATION_REFRESH_TIME):08x}') # options in answer to be logged return response_string_part, self.number diff --git a/dhcpy6d/options/option_83.py b/dhcpy6d/options/option_83.py new file mode 100644 index 0000000..5500da8 --- /dev/null +++ b/dhcpy6d/options/option_83.py @@ -0,0 +1,30 @@ +# DHCPy6d DHCPv6 Daemon +# +# Copyright (C) 2009-2024 Henri Wahl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from dhcpy6d.config import cfg +from dhcpy6d.options import OptionTemplate + + +class Option(OptionTemplate): + """ + Option 83 INF_MAX_RT (sic!) + """ + def build(self, **kwargs): + response_string_part = self.convert_to_string(self.number, f'{int(cfg.INFORMATION_REFRESH_TIME):08x}') + # options in answer to be logged + return response_string_part, self.number