dhcpkit.ipv6.server.extensions.leasequery package¶
Implementation of the Leasequery and Bulk Leasequery extensions.
-
class
dhcpkit.ipv6.server.extensions.leasequery.
LeasequeryHandler
(store: dhcpkit.ipv6.server.extensions.leasequery.LeasequeryStore, allow_from: Iterable = None, sensitive_options: Iterable = None)[source]¶ Bases:
dhcpkit.ipv6.server.handlers.Handler
Handle leasequery requests and analyse replies that we send out to store any observed leases.
-
analyse_post
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle)[source]¶ Watch outgoing replies and store observed leases in the store.
Parameters: bundle – The transaction bundle containing the outgoing reply
-
static
generate_data_messages
(transaction_id: bytes, leases: Iterator) → Iterator[source]¶ Generate a leasequery data message for each of the leases, followed by a leasequery done message.
Parameters: - transaction_id – The transaction ID to use in the messages
- leases – An open iterator for the data we still need to return
Returns: Leasequery messages to send to the client
-
handle
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle)[source]¶ Perform leasequery if requested.
Parameters: bundle – The transaction bundle
-
-
class
dhcpkit.ipv6.server.extensions.leasequery.
LeasequeryStore
[source]¶ Bases:
object
Base class for leasequery stores
-
build_relay_data_option_from_relay_data
(relay_data: bytes) → Union[source]¶ The relay data includes the outer relay message, which is generated inside the server to keep track of where we got the request from. When returning relay data to the leasequery client we build the LQRelayDataOption using this internal relay message only including the real relay messages we received.
Parameters: relay_data – The raw relay data Returns: The LQRelayDataOption if applicable
-
static
decode_duid
(duid_str: str) → dhcpkit.ipv6.duids.DUID[source]¶ Decode DUID from a string.
Parameters: duid_str – The DUID string Returns: The DUID object
-
static
decode_options
(data: bytes) → Iterable[source]¶ Decode a list of options from bytes.
Parameters: data – The bytes Returns: The list of options
-
static
decode_relay_messages
(data: bytes) → Union[source]¶ Decode a chain of relay messages from bytes.
Parameters: data – The bytes Returns: The relay message
-
static
decode_remote_id
(remote_id_str: str) → dhcpkit.ipv6.extensions.remote_id.RemoteIdOption[source]¶ Decode remote id from a string.
Parameters: remote_id_str – The remote-id string Returns: The remote-id option
-
static
encode_duid
(duid: dhcpkit.ipv6.duids.DUID) → str[source]¶ Encode DUID as a string.
Parameters: duid – The DUID object Returns: The string representing the DUID
-
encode_options
(options: Iterable) → bytes[source]¶ Encode a list of options as bytes.
Parameters: options – The list of options Returns: The bytes
-
encode_relay_messages
(relay_chain: Union) → bytes[source]¶ Encode a chain of relay messages as bytes.
Parameters: relay_chain – The incoming relay messages Returns: The bytes
-
static
encode_remote_id
(remote_id_option: dhcpkit.ipv6.extensions.remote_id.RemoteIdOption) → str[source]¶ Encode remote id as a string.
Parameters: remote_id_option – The remote-id option Returns: The string representing the remote-id
-
static
filter_options
(options: Iterable, unwanted_option_types: Iterable) → Iterable[source]¶ Remove unwanted data from the options.
Parameters: - options – The options to filter
- unwanted_option_types – List of option types to filter out
Returns: The filtered options
-
filter_requested_options
(options: Iterable, requested_options: Iterable)[source]¶ Only return options that are requested by the leasequery client.
Parameters: - options – The original list of options
- requested_options – The list of requested options
Returns: The filtered list
-
filter_sensitive_options
(options: Iterable) → Iterable[source]¶ Remove sensitive data from the options.
Parameters: options – The options to filter Returns: The filtered options
-
filter_storable_options
(options: Iterable) → Iterable[source]¶ Only include storable data from the options.
Parameters: options – The options to filter Returns: The filtered options
-
find_leases
(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → Tuple[source]¶ Find all leases that match the given query.
Parameters: query – The query Returns: The number of leases and an iterator over tuples of link-address and corresponding client data
-
get_address_leases
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle) → Iterator[source]¶ Search through the reply and return all addresses given to the client.
Parameters: bundle – The transaction bundle Returns: The address options
-
get_prefix_leases
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle) → Iterator[source]¶ Search through the reply and return all prefixes given to the client.
Parameters: bundle – The transaction bundle Returns: The prefix options
-
static
get_relay_ids
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle) → Iterator[source]¶ Go through all the relay messages and return all relay-ids found as lowercase hex strings
Parameters: bundle – The transaction bundle Returns: The relay-ids as hex strings
-
get_remote_ids
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle) → Iterator[source]¶ Go through all the relay messages and return all remote-ids found as lowercase hex strings
Parameters: bundle – The transaction bundle Returns: The remote-ids as hex strings
-
static
is_accepted
(element: Union) → bool[source]¶ Check if there is no status code that signals rejection.
Parameters: element – The element to look in Returns: Whether the status is ok
-
remember_lease
(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle)[source]¶ Remember the leases in the given transaction bundle so they can be queried later.
Parameters: bundle – The transaction to remember
-
worker_init
(sensitive_options: Iterable)[source]¶ Separate initialisation that will be called in each worker process that is created. Things that can’t be forked (think database connections etc) have to be initialised here.
Parameters: sensitive_options – The options that are not allowed to be stored
-
-
class
dhcpkit.ipv6.server.extensions.leasequery.
UnansweredLeasequeryHandler
[source]¶ Bases:
dhcpkit.ipv6.server.handlers.Handler
When there are leasequeries that haven’t been handled at the end of the handling phase that means that no handler understood the query.