|  | Kea 3.0.0
    | 
Derivation of TcpConnection used for Bulk LeaseQuery. More...
#include <lease_query_connection.h>
| Public Member Functions | |
| LeaseQueryConnection (const asiolink::IOServicePtr &io_service, const tcp::TcpConnectionAcceptorPtr &acceptor, const asiolink::TlsContextPtr &tls_context, tcp::TcpConnectionPool &connection_pool, const tcp::TcpConnectionAcceptorCallback &acceptor_callback, const tcp::TcpConnectionFilterCallback &filter_callback, const long idle_timeout, const uint16_t family, const size_t max_concurrent_queries, const size_t read_max=32768) | |
| Constructor. | |
| virtual | ~LeaseQueryConnection () | 
| Destructor. | |
| void | addPendingQuery (BlqQueryPtr query) | 
| Queues a query to the end of the queue of waiting queries. | |
| void | addRunningQuery (BulkLeaseQueryPtr query) | 
| Adds a query to the end of the list of in-progress queries. | |
| bool | canSend () const | 
| Can send (aka stopped) flag. | |
| virtual void | close () | 
| Closes the socket. | |
| virtual tcp::TcpRequestPtr | createRequest () | 
| Creates a new empty request ready to receive data. | |
| bool | findQuery (const Xid &xid) const | 
| Find queries based on Xid in the query list and queue. | |
| size_t | getNumResponses () const | 
| Returns the number of responses in the response queue. | |
| size_t | getNumRunningQueries () const | 
| Returns the number of queries in the in-progress list. | |
| std::string | getRemoteEndpointAddressAsText () const | 
| Export getRemoteEndpointAddressAsText. | |
| asiolink::IOAddress | getRequesterAddress () const | 
| Returns the requester's ip address. | |
| bool | isStopping () const | 
| Stopping flag. | |
| tcp::TcpResponsePtr | makeTcpResponse (BlqResponsePtr blq_response) const | 
| Constructs a ready to send TcpResponse from and BlqResponse. | |
| bool | noPendingQuery () const | 
| Returns True if the queue of waiting queries is empty. | |
| BlqQueryPtr | popPendingQuery () | 
| Pops a query from the queue of waiting queries. | |
| virtual void | post (const BlqPostCbArg &callback) | 
| Posts an event callback to the connection's IOService. | |
| virtual void | processNextQuery () | 
| Process next waiting query. | |
| virtual bool | pushToSend (BlqResponsePtr response) | 
| Adds a response to the connection's outbound queue of responses. | |
| virtual void | queryComplete (const Xid &xid) | 
| Finishes up when a query has been completed (e.g. | |
| void | removeRunningQuery (const Xid &xid) | 
| Removes a query from the in-progress query list. | |
| virtual void | requestReceived (tcp::TcpRequestPtr request) | 
| Processes a completely received request. | |
| virtual bool | responseSent (tcp::TcpResponsePtr response) | 
| Processes a response once it has been sent. | |
| virtual void | sendNextResponse () | 
| Sends the next response in the response queue. | |
| virtual void | shutdown () | 
| Shutdown the socket. | |
| void | startQuery (BlqQueryPtr query_msg) | 
| Start query processing. | |
| virtual void | stopThisConnection () | 
| Stops current connection. | |
| BlqQueryPtr | unpackQuery4 (const uint8_t *buffer, size_t length) const | 
| Unpacks a DHCPv4 packet from a data buffer. | |
| BlqQueryPtr | unpackQuery6 (const uint8_t *buffer, size_t length) const | 
| Unpacks a DHCPv6 packet from a data buffer. | |
| Public Member Functions inherited from isc::tcp::TcpConnection | |
| TcpConnection (const asiolink::IOServicePtr &io_service, const TcpConnectionAcceptorPtr &acceptor, const asiolink::TlsContextPtr &tls_context, TcpConnectionPool &connection_pool, const TcpConnectionAcceptorCallback &acceptor_callback, const TcpConnectionFilterCallback &connection_filter, const long idle_timeout, const size_t read_max=32768) | |
| Constructor. | |
| virtual | ~TcpConnection () | 
| Destructor. | |
| void | asyncAccept () | 
| Asynchronously accepts new connection. | |
| void | doHandshake () | 
| Asynchronously performs TLS handshake. | |
| void | doRead (TcpRequestPtr request=TcpRequestPtr()) | 
| Starts asynchronous read from the socket. | |
| size_t | getReadMax () const | 
| Fetches the maximum number of bytes read during single socket read. | |
| const boost::asio::ip::tcp::endpoint | getRemoteEndpoint () const | 
| Fetches the remote endpoint for the connection's socket. | |
| TcpRequestPtr | postData (TcpRequestPtr request, WireData &input_data) | 
| Appends newly received raw data to the given request. | |
| void | setReadMax (const size_t read_max) | 
| Sets the maximum number of bytes read during single socket read. | |
| Static Public Member Functions | |
| static void | doPost (LeaseQueryConnectionWPtr wptr, const BlqPostCbArg &callback) | 
| Class/static version of post. | |
| static bool | doPushToSend (LeaseQueryConnectionWPtr wptr, BlqResponsePtr response) | 
| Class/static version of pushToSend. | |
| static void | doQueryComplete (LeaseQueryConnectionWPtr wptr, const Xid &xid) | 
| Class/static version of queryComplete. | |
| static void | doSendNextResponse (LeaseQueryConnectionWPtr wptr) | 
| Class/static version of sendNextResponse. | |
| Static Public Member Functions inherited from isc::tcp::TcpConnection | |
| static const boost::asio::ip::tcp::endpoint & | NO_ENDPOINT () | 
| Returns an empty end point. | |
| Protected Attributes | |
| bool | can_send_ | 
| Can send flag. | |
| uint16_t | family_ | 
| Protocol family AF_INET or AF_INET6. | |
| asiolink::IOServicePtr | io_service_ | 
| IOService that drives the connection events. | |
| size_t | max_concurrent_queries_ | 
| Maximum number of concurrent queries allowed. | |
| XidQueue< BlqMsg > | pending_queries_ | 
| Queue of queries waiting to enter processing. | |
| BlqResponsePtr | response_to_send_ | 
| Tracks the response currently being sent. | |
| BlqResponseList | responses_ | 
| List of responses waiting to be sent. | |
| std::mutex | responses_mutex_ | 
| Mutex used to lock during responses access. | |
| XidQueue< BulkLeaseQuery > | running_queries_ | 
| List of in-process queries. | |
| bool | stopping_ | 
| Stopping flag. | |
| Protected Attributes inherited from isc::tcp::TcpConnection | |
| TcpConnectionAcceptorPtr | acceptor_ | 
| Pointer to the TCP acceptor used to accept new connections. | |
| TcpConnectionAcceptorCallback | acceptor_callback_ | 
| External TCP acceptor callback. | |
| TcpConnectionFilterCallback | connection_filter_ | 
| External callback for filtering connections by IP address. | |
| TcpConnectionPool & | connection_pool_ | 
| Connection pool holding this connection. | |
| long | idle_timeout_ | 
| Timeout after which the a TCP connection is shut down by the server. | |
| asiolink::IntervalTimer | idle_timer_ | 
| Timer used to detect idle Timeout. | |
| WireData | input_buf_ | 
| Buffer for a single socket read. | |
| asiolink::IOServicePtr | io_service_ | 
| The IO service used to handle events. | |
| size_t | read_max_ | 
| Maximum bytes to read in a single socket read. | |
| boost::asio::ip::tcp::endpoint | remote_endpoint_ | 
| Remote endpoint. | |
| std::unique_ptr< asiolink::TCPSocket< SocketCallback > > | tcp_socket_ | 
| TCP socket used by this connection. | |
| asiolink::TlsContextPtr | tls_context_ | 
| TLS context. | |
| std::unique_ptr< asiolink::TLSSocket< SocketCallback > > | tls_socket_ | 
| TLS socket used by this connection. | |
| Additional Inherited Members | |
| Protected Member Functions inherited from isc::tcp::TcpConnection | |
| void | acceptorCallback (const boost::system::error_code &ec) | 
| Local callback invoked when new connection is accepted. | |
| void | asyncSendResponse (TcpResponsePtr response) | 
| Sends TCP response asynchronously. | |
| void | doWrite (TcpResponsePtr response) | 
| Starts asynchronous write to the socket. | |
| unsigned char * | getInputBufData () | 
| Returns pointer to the first byte of the input buffer. | |
| size_t | getInputBufSize () const | 
| Returns input buffer size. | |
| std::string | getRemoteEndpointAddressAsText () const | 
| returns remote address in textual form | |
| void | handshakeCallback (const boost::system::error_code &ec) | 
| Local callback invoked when TLS handshake is performed. | |
| void | idleTimeoutCallback () | 
| Callback invoked when the client has been idle. | |
| void | setupIdleTimer () | 
| Reset timer for detecting idle timeout in connections. | |
| void | shutdownCallback (const boost::system::error_code &ec) | 
| Callback invoked when TLS shutdown is performed. | |
| virtual void | shutdownConnection () | 
| Shuts down current connection. | |
| void | socketReadCallback (TcpRequestPtr request, boost::system::error_code ec, size_t length) | 
| Callback invoked when new data is received over the socket. | |
| virtual void | socketWriteCallback (TcpResponsePtr request, boost::system::error_code ec, size_t length) | 
| Callback invoked when data is sent over the socket. | |
Derivation of TcpConnection used for Bulk LeaseQuery.
Definition at line 156 of file lease_query_connection.h.
| isc::lease_query::LeaseQueryConnection::LeaseQueryConnection | ( | const asiolink::IOServicePtr & | io_service, | 
| const tcp::TcpConnectionAcceptorPtr & | acceptor, | ||
| const asiolink::TlsContextPtr & | tls_context, | ||
| tcp::TcpConnectionPool & | connection_pool, | ||
| const tcp::TcpConnectionAcceptorCallback & | acceptor_callback, | ||
| const tcp::TcpConnectionFilterCallback & | filter_callback, | ||
| const long | idle_timeout, | ||
| const uint16_t | family, | ||
| const size_t | max_concurrent_queries, | ||
| const size_t | read_max = 32768 ) | 
Constructor.
| io_service | IO service to be used by the connection. | 
| acceptor | Pointer to the TCP acceptor object used to listen for new TCP connections. | 
| tls_context | TLS context. | 
| connection_pool | Connection pool in which this connection is stored. | 
| acceptor_callback | Callback invoked when new connection is accepted. | 
| filter_callback | Callback invoked prior to handshake which can be used to qualify and reject connections. | 
| idle_timeout | Timeout after which a TCP connection is closed by the server. | 
| family | Protocol family, AF_INET or AF_INET6. | 
| max_concurrent_queries | Maximum number of in-progress queries allowed. | 
| read_max | maximum size of a single socket read. Defaults to 32K. | 
Definition at line 28 of file lease_query_connection.cc.
References isc::tcp::TcpConnection::TcpConnection(), can_send_, family_, io_service_, max_concurrent_queries_, and stopping_.
| 
 | inlinevirtual | 
Destructor.
Definition at line 186 of file lease_query_connection.h.
| 
 | inline | 
Queues a query to the end of the queue of waiting queries.
| query | Query to queue. | 
Definition at line 318 of file lease_query_connection.h.
References pending_queries_.
Referenced by requestReceived().
| 
 | inline | 
Adds a query to the end of the list of in-progress queries.
| query | Query to add. | 
Definition at line 290 of file lease_query_connection.h.
References running_queries_.
Referenced by startQuery().
| 
 | inline | 
Can send (aka stopped) flag.
Definition at line 212 of file lease_query_connection.h.
References can_send_.
| 
 | virtual | 
Closes the socket.
Reimplemented from isc::tcp::TcpConnection.
Definition at line 68 of file lease_query_connection.cc.
References can_send_, isc::tcp::TcpConnection::close(), pending_queries_, response_to_send_, responses_, responses_mutex_, and running_queries_.
| 
 | virtual | 
Creates a new empty request ready to receive data.
Implements isc::tcp::TcpConnection.
Definition at line 100 of file lease_query_connection.cc.
| 
 | inlinestatic | 
Class/static version of post.
| wptr | Weak pointer to a lease query connection. | 
| callback | The callback to post. | 
Definition at line 362 of file lease_query_connection.h.
Referenced by startQuery().
| 
 | inlinestatic | 
Class/static version of pushToSend.
| wptr | Weak pointer to a lease query connection. | 
| response | Pointer to the response to send. | 
Definition at line 344 of file lease_query_connection.h.
Referenced by startQuery().
| 
 | inlinestatic | 
Class/static version of queryComplete.
| wptr | Weak pointer to a lease query connection. | 
| xid | Xid of the query that has finished. | 
Definition at line 381 of file lease_query_connection.h.
Referenced by startQuery().
| 
 | inlinestatic | 
Class/static version of sendNextResponse.
| wptr | Weak pointer to a lease query connection. | 
Definition at line 231 of file lease_query_connection.h.
Referenced by pushToSend().
| 
 | inline | 
Find queries based on Xid in the query list and queue.
| xid | Xid of the query to find. | 
Definition at line 311 of file lease_query_connection.h.
References pending_queries_, and running_queries_.
Referenced by requestReceived().
| size_t isc::lease_query::LeaseQueryConnection::getNumResponses | ( | ) | const | 
Returns the number of responses in the response queue.
Definition at line 427 of file lease_query_connection.cc.
References responses_, and responses_mutex_.
| 
 | inline | 
Returns the number of queries in the in-progress list.
Definition at line 295 of file lease_query_connection.h.
References running_queries_.
Referenced by processNextQuery(), and requestReceived().
| std::string isc::tcp::TcpConnection::getRemoteEndpointAddressAsText | ( | ) | const | 
Export getRemoteEndpointAddressAsText.
Definition at line 407 of file tcp_connection.cc.
Referenced by popPendingQuery(), requestReceived(), sendNextResponse(), startQuery(), unpackQuery4(), and unpackQuery6().
| IOAddress isc::lease_query::LeaseQueryConnection::getRequesterAddress | ( | ) | const | 
Returns the requester's ip address.
Definition at line 433 of file lease_query_connection.cc.
References family_, isc::tcp::TcpConnection::getRemoteEndpoint(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), and isc::tcp::TcpConnection::NO_ENDPOINT().
| 
 | inline | 
Stopping flag.
Definition at line 204 of file lease_query_connection.h.
References stopping_.
| TcpResponsePtr isc::lease_query::LeaseQueryConnection::makeTcpResponse | ( | BlqResponsePtr | blq_response | ) | const | 
Constructs a ready to send TcpResponse from and BlqResponse.
| blq_response | Pointer to the source BlqResponse, cannot be empty. | 
| BadValue | if the input pointer is empty. | 
Definition at line 219 of file lease_query_connection.cc.
References isc_throw.
Referenced by sendNextResponse().
| 
 | inline | 
Returns True if the queue of waiting queries is empty.
Definition at line 323 of file lease_query_connection.h.
References pending_queries_.
Referenced by processNextQuery(), and requestReceived().
| BlqQueryPtr isc::lease_query::LeaseQueryConnection::popPendingQuery | ( | ) | 
Pops a query from the queue of waiting queries.
Definition at line 342 of file lease_query_connection.cc.
References isc::lease_query::BULK_LEASE_QUERY_DEQUEUED, isc::log::DBGLVL_TRACE_BASIC, getRemoteEndpointAddressAsText(), isc::lease_query::lease_query_logger, isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), LOG_DEBUG, and pending_queries_.
Referenced by processNextQuery().
| 
 | virtual | 
Posts an event callback to the connection's IOService.
| callback | The callback to post. | 
Definition at line 393 of file lease_query_connection.cc.
References isc::lease_query::BULK_LEASE_QUERY_PROCESSING_UNEXPECTED_FAILURE, can_send_, io_service_, isc::lease_query::lease_query_logger, LOG_ERROR, responses_mutex_, and stopping_.
Referenced by startQuery().
| 
 | virtual | 
Process next waiting query.
Definition at line 355 of file lease_query_connection.cc.
References can_send_, getNumRunningQueries(), max_concurrent_queries_, noPendingQuery(), popPendingQuery(), responses_mutex_, startQuery(), and stopping_.
Referenced by queryComplete().
| 
 | virtual | 
Adds a response to the connection's outbound queue of responses.
| response | Pointer to the response to send. | 
Definition at line 378 of file lease_query_connection.cc.
References can_send_, doSendNextResponse(), io_service_, responses_, responses_mutex_, and stopping_.
| 
 | virtual | 
Finishes up when a query has been completed (e.g.
reached EOF, failed, was terminated)
| xid | Xid of the query that has finished. | 
Definition at line 415 of file lease_query_connection.cc.
References can_send_, processNextQuery(), removeRunningQuery(), responses_mutex_, and stopping_.
| 
 | inline | 
Removes a query from the in-progress query list.
| xid | Xid of the query to remove. | 
Definition at line 302 of file lease_query_connection.h.
References running_queries_.
Referenced by queryComplete().
| 
 | virtual | 
Processes a completely received request.
This function is invoked when the connection has completely received a TCP stream request message and performs the following:
| request | Request to process. | 
Implements isc::tcp::TcpConnection.
Definition at line 105 of file lease_query_connection.cc.
References addPendingQuery(), isc::lease_query::BULK_LEASE_QUERY_AT_MAX_CONCURRENT_QUERIES, isc::lease_query::BULK_LEASE_QUERY_DUPLICATE_XID, isc::lease_query::BULK_LEASE_QUERY_EMPTY_REQUEST, isc::lease_query::BULK_LEASE_QUERY_QUERY_RECEIVED, isc::lease_query::BULK_LEASE_QUERY_UNPACK_ERROR, isc::log::DBGLVL_TRACE_BASIC, family_, findQuery(), getNumRunningQueries(), getRemoteEndpointAddressAsText(), isc_throw, isc::lease_query::lease_query_logger, isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), LOG_DEBUG, LOG_ERROR, LOG_WARN, max_concurrent_queries_, noPendingQuery(), startQuery(), stopThisConnection(), unpackQuery4(), and unpackQuery6().
| 
 | virtual | 
Processes a response once it has been sent.
| response | Response that was sent to the remote endpoint. | 
Implements isc::tcp::TcpConnection.
Definition at line 240 of file lease_query_connection.cc.
References response_to_send_, responses_mutex_, and sendNextResponse().
| 
 | virtual | 
Sends the next response in the response queue.
If there is currently no send in progress and there are entries in the response queue, it dequeues a response from the front of the queue and initiates an asynchronous send.
Definition at line 174 of file lease_query_connection.cc.
References isc::tcp::TcpConnection::asyncSendResponse(), isc::lease_query::BULK_LEASE_QUERY_RESPONSE_SEND_ERROR, isc::lease_query::BULK_LEASE_QUERY_RESPONSE_SENT, can_send_, isc::log::DBGLVL_TRACE_BASIC, getRemoteEndpointAddressAsText(), isc::lease_query::lease_query_logger, isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), LOG_DEBUG, LOG_ERROR, makeTcpResponse(), response_to_send_, responses_, responses_mutex_, stopping_, and isc::tcp::TcpConnection::stopThisConnection().
Referenced by responseSent().
| 
 | virtual | 
Shutdown the socket.
Reimplemented from isc::tcp::TcpConnection.
Definition at line 55 of file lease_query_connection.cc.
References can_send_, pending_queries_, response_to_send_, responses_, responses_mutex_, running_queries_, and isc::tcp::TcpConnection::shutdown().
| void isc::lease_query::LeaseQueryConnection::startQuery | ( | BlqQueryPtr | query_msg | ) | 
Start query processing.
A new BulkLeaseQuery instance is created and started.
| query_msg | Query message to process. | 
Definition at line 288 of file lease_query_connection.cc.
References addRunningQuery(), isc::lease_query::BULK_LEASE_QUERY_INVALID_REQUEST, can_send_, doPost(), doPushToSend(), doQueryComplete(), family_, getRemoteEndpointAddressAsText(), isc::lease_query::lease_query_logger, isc::lease_query::BulkLeaseQuery4::leaseQueryLabel(), isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), LOG_ERROR, post(), isc::lease_query::BulkLeaseQuery::processStart(), responses_mutex_, stopping_, and stopThisConnection().
Referenced by processNextQuery(), and requestReceived().
| 
 | virtual | 
Stops current connection.
Enforce sequencing with response sending.
Reimplemented from isc::tcp::TcpConnection.
Definition at line 81 of file lease_query_connection.cc.
References can_send_, response_to_send_, responses_mutex_, stopping_, and isc::tcp::TcpConnection::stopThisConnection().
Referenced by requestReceived(), and startQuery().
| BlqQueryPtr isc::lease_query::LeaseQueryConnection::unpackQuery4 | ( | const uint8_t * | buffer, | 
| size_t | length ) const | 
Unpacks a DHCPv4 packet from a data buffer.
| buffer | Buffer containing the packed DHCPv4 packet. | 
| length | Number of bytes in contained in the buffer. | 
Definition at line 252 of file lease_query_connection.cc.
References isc::lease_query::BULK_LEASE_QUERY4_UNSUPPORTED_MSG_TYPE, isc::dhcp::DHCPBULKLEASEQUERY, isc::tcp::TcpConnection::getRemoteEndpoint(), getRemoteEndpointAddressAsText(), isc::lease_query::lease_query_logger, and LOG_ERROR.
Referenced by requestReceived().
| BlqQueryPtr isc::lease_query::LeaseQueryConnection::unpackQuery6 | ( | const uint8_t * | buffer, | 
| size_t | length ) const | 
Unpacks a DHCPv6 packet from a data buffer.
| buffer | Buffer containing the packed DHCPv6 packet. | 
| length | Number of bytes in contained in the buffer. | 
Definition at line 270 of file lease_query_connection.cc.
References isc::lease_query::BULK_LEASE_QUERY6_UNSUPPORTED_MSG_TYPE, DHCPV6_LEASEQUERY, isc::tcp::TcpConnection::getRemoteEndpoint(), getRemoteEndpointAddressAsText(), isc::lease_query::lease_query_logger, and LOG_ERROR.
Referenced by requestReceived().
| 
 | protected | 
Can send flag.
Definition at line 409 of file lease_query_connection.h.
Referenced by LeaseQueryConnection(), canSend(), close(), post(), processNextQuery(), pushToSend(), queryComplete(), sendNextResponse(), shutdown(), startQuery(), and stopThisConnection().
| 
 | protected | 
Protocol family AF_INET or AF_INET6.
Definition at line 400 of file lease_query_connection.h.
Referenced by LeaseQueryConnection(), getRequesterAddress(), requestReceived(), and startQuery().
| 
 | protected | 
IOService that drives the connection events.
Definition at line 403 of file lease_query_connection.h.
Referenced by LeaseQueryConnection(), post(), and pushToSend().
| 
 | protected | 
Maximum number of concurrent queries allowed.
Zero means unlimited.
Definition at line 432 of file lease_query_connection.h.
Referenced by LeaseQueryConnection(), processNextQuery(), and requestReceived().
Queue of queries waiting to enter processing.
When the in-process query list is full (size >= maximum), received queries are queued. When a query was processed a queued query is popped and processed.
Definition at line 419 of file lease_query_connection.h.
Referenced by addPendingQuery(), close(), findQuery(), noPendingQuery(), popPendingQuery(), and shutdown().
| 
 | protected | 
Tracks the response currently being sent.
Definition at line 428 of file lease_query_connection.h.
Referenced by close(), responseSent(), sendNextResponse(), shutdown(), and stopThisConnection().
| 
 | protected | 
List of responses waiting to be sent.
Definition at line 422 of file lease_query_connection.h.
Referenced by close(), getNumResponses(), pushToSend(), sendNextResponse(), and shutdown().
| 
 | mutableprotected | 
Mutex used to lock during responses access.
Definition at line 425 of file lease_query_connection.h.
Referenced by close(), getNumResponses(), post(), processNextQuery(), pushToSend(), queryComplete(), responseSent(), sendNextResponse(), shutdown(), startQuery(), and stopThisConnection().
| 
 | protected | 
List of in-process queries.
Definition at line 412 of file lease_query_connection.h.
Referenced by addRunningQuery(), close(), findQuery(), getNumRunningQueries(), removeRunningQuery(), and shutdown().
| 
 | protected | 
Stopping flag.
Definition at line 406 of file lease_query_connection.h.
Referenced by LeaseQueryConnection(), isStopping(), post(), processNextQuery(), pushToSend(), queryComplete(), sendNextResponse(), startQuery(), and stopThisConnection().