int state; /*!< Current state machine state */
uint16_t expect_data; /*!< How much data do we need to switch to the
next state */
- uint16_t max_size; /*!< Max PROXYv2 header size including its payload */
+ size_t max_size; /*!< Max PROXYv2 header size including its payload */
isc_proxy2_handler_cb_t cb; /*!< Data processing callback. */
void *cbarg; /*!< Callback argument. */
status value. */
isc_mem_t *mctx;
- uint16_t header_size; /*!< Total PROXYv2 header size (including the
- payload. */
- uint16_t tlv_data_size; /*!< The size of TLVs payload size */
+ size_t header_size; /*!< Total PROXYv2 header size (including the
+ payload. */
+ size_t tlv_data_size; /*!< The size of TLVs payload size */
isc_proxy2_command_t cmd; /*!< The decoded PROXYv2 command */
isc_proxy2_addrfamily_t proxy_addr_family; /*!< The decoded PROXYv2
void
isc_proxy2_handler_init(isc_proxy2_handler_t *restrict handler, isc_mem_t *mctx,
- const uint16_t max_size, isc_proxy2_handler_cb_t cb,
+ const size_t max_size, isc_proxy2_handler_cb_t cb,
void *cbarg);
/*!<
* \brief Initialise the given 'isc_proxy2_handler_t' object, attach
* Requires:
*\li 'handler' is not NULL;
*\li 'mctx' is not NULL;
- *\li 'max_size' is >= `ISC_PROXY2_HEADER_SIZE` or is 0;
+ *\li 'max_size' is >= `ISC_PROXY2_HEADER_SIZE` &&
+ * is <= `ISC_PROXY2_MAX_SIZE`, or is 0;
*\li 'cb' is not NULL.
*/
*/
isc_proxy2_handler_t *
-isc_proxy2_handler_new(isc_mem_t *mctx, const uint16_t max_size,
+isc_proxy2_handler_new(isc_mem_t *mctx, const size_t max_size,
isc_proxy2_handler_cb_t cb, void *cbarg);
/*!<
* \brief Allocate and initialise a new 'isc_proxy2_handler_t'
*
* Requires:
*\li 'mctx' is not NULL;
- *\li 'max_size' is >= `ISC_PROXY2_HEADER_SIZE` or is 0;
+ *\li 'max_size' is >= `ISC_PROXY2_HEADER_SIZE` &&
+ * is <= `ISC_PROXY2_MAX_SIZE`, or is 0;
*\li 'cb' is not NULL.
*/
static inline void
isc__proxy2_handler_init_direct(isc_proxy2_handler_t *restrict handler,
- const uint16_t max_size,
+ const size_t max_size,
const isc_region_t *restrict data,
isc_proxy2_handler_cb_t cb, void *cbarg) {
*handler = (isc_proxy2_handler_t){ .result = ISC_R_UNSET,
void
isc_proxy2_handler_init(isc_proxy2_handler_t *restrict handler, isc_mem_t *mctx,
- const uint16_t max_size, isc_proxy2_handler_cb_t cb,
+ const size_t max_size, isc_proxy2_handler_cb_t cb,
void *cbarg) {
REQUIRE(handler != NULL);
REQUIRE(mctx != NULL);
- REQUIRE(max_size == 0 || max_size >= ISC_PROXY2_HEADER_SIZE);
+ REQUIRE(max_size == 0 || (max_size >= ISC_PROXY2_HEADER_SIZE &&
+ max_size <= ISC_PROXY2_MAX_SIZE));
REQUIRE(cb != NULL);
isc__proxy2_handler_init_direct(handler, max_size, NULL, cb, cbarg);
}
isc_proxy2_handler_t *
-isc_proxy2_handler_new(isc_mem_t *mctx, const uint16_t max_size,
+isc_proxy2_handler_new(isc_mem_t *mctx, const size_t max_size,
isc_proxy2_handler_cb_t cb, void *cbarg) {
isc_proxy2_handler_t *newhandler;
len = isc_buffer_getuint16(&handler->hdrbuf);
if (handler->max_size > 0 &&
- (len + ISC_PROXY2_HEADER_SIZE) > handler->max_size)
+ ((size_t)len + ISC_PROXY2_HEADER_SIZE) > handler->max_size)
{
goto error_range;
}