Skip to content

Commit

Permalink
added option 20 for testing again
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriWahl committed Jun 2, 2024
1 parent 2082f83 commit ad7c72d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
10 changes: 5 additions & 5 deletions dhcpy6d/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]:
Expand Down
7 changes: 4 additions & 3 deletions dhcpy6d/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dhcpy6d/options/option_20.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions dhcpy6d/options/option_82.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions dhcpy6d/options/option_83.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# DHCPy6d DHCPv6 Daemon
#
# Copyright (C) 2009-2024 Henri Wahl <henri@dhcpy6d.de>
#
# 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

0 comments on commit ad7c72d

Please sign in to comment.