dhcpkit.ipv6.server.listeners.tcp module

Code to keep the receiving and sending sockets together. When receiving traffic on a link-local multicast address the reply should be sent from a link-local address on the receiving interface. This class makes it easy to keep those together.

class dhcpkit.ipv6.server.listeners.tcp.TCPConnection(interface_name: str, connected_socket: socket.socket, write_lock: <bound method BaseContext.Lock of <multiprocessing.context.DefaultContext object at 0x7f70db1d84a8>>, global_address: ipaddress.IPv6Address, marks: Iterable = None)[source]

Bases: dhcpkit.ipv6.server.listeners.Listener

A TCP connection listener for DHCPv6 messages

fileno() → int[source]

The fileno of the listening socket, so this object can be used by select()

Returns:The file descriptor
packet_from_buffer()[source]

Create a packet and replier from the data in the buffer

Returns:The incoming packet data and a replier object
recv_data_into_buffer(amount: int) → int[source]

Receive data into the buffer and do proper error handling

Parameters:amount – How much data do we want?
Returns:How much data did we receive?
recv_request() → Tuple[source]

Receive incoming messages

Returns:The incoming packet data and a replier object
class dhcpkit.ipv6.server.listeners.tcp.TCPConnectionListener(interface_name: str, listen_socket: socket.socket, global_address: ipaddress.IPv6Address = None, marks: Iterable = None, max_connections: int = 10, allow_from: Iterable = None)[source]

Bases: dhcpkit.ipv6.server.listeners.ListenerCreator

Wrapper for a listening TCP socket. This is not a listener in the DHCPKit sense of the concept. DHCPKit listeners receive DHCPv6 messages, which is done on an established connection.

create_listener() → Union[source]

Accept incoming connection

Returns:The connection object
fileno() → int[source]

The fileno of the listening socket, so this object can be used by select()

Returns:The file descriptor
class dhcpkit.ipv6.server.listeners.tcp.TCPReplier(reply_socket: socket.socket, reply_lock: <bound method BaseContext.Lock of <multiprocessing.context.DefaultContext object at 0x7f70db1d84a8>>)[source]

Bases: dhcpkit.ipv6.server.listeners.Replier

A class to send replies to the client

can_send_multiple = True
send_reply(outgoing_message: dhcpkit.ipv6.messages.RelayReplyMessage) → bool[source]

Send a reply to the client

Parameters:outgoing_message – The message to send, including a wrapping RelayReplyMessage
Returns:Whether sending was successful