Commit 7c857dfb authored by Karel Slaný's avatar Karel Slaný

Cookie input check functions are ordinary function now.

parent 109ad5f2
......@@ -21,6 +21,18 @@
#include "libknot/errcode.h"
#include "libknot/rrtype/opt-cookie.h"
_public_
bool knot_cc_input_is_valid(const struct knot_cc_input *input)
{
/*
* RFC7873 4.1 -- Client cookie should be generated from
* client IP address, server IP address and a secret quantity.
*/
return input && (input->clnt_sockaddr || input->srvr_sockaddr) &&
input->secret_data && input->secret_len > 0;
}
_public_
int knot_cc_check(const uint8_t *cc, uint16_t cc_len,
const struct knot_cc_input *input,
......
......@@ -38,16 +38,7 @@ struct knot_cc_input {
* \retval true if input contains at least one socket and secret data
* \retval false if input is insufficient or NULL pointer passed
*/
static inline bool knot_cc_input_is_valid(const struct knot_cc_input *input)
{
/*
* RFC7873 4.1 -- Client cookie should be generated from
* client IP address, server IP address and a secret quantity.
*/
return input && (input->clnt_sockaddr || input->srvr_sockaddr) &&
input->secret_data && input->secret_len > 0;
}
bool knot_cc_input_is_valid(const struct knot_cc_input *input);
/*!
* \brief Client cookie generator function type.
......
......@@ -21,6 +21,18 @@
#include "libknot/errcode.h"
#include "libknot/rrtype/opt-cookie.h"
_public_
bool knot_sc_input_is_valid(const struct knot_sc_input *input)
{
/*
* RFC7873 4.2 -- Server cookie should be generated from request
* source IP address, a secret quantity and request client cookie.
*/
return input && input->cc && input->cc_len > 0 && input->srvr_data &&
input->srvr_data->secret_data && input->srvr_data->secret_len > 0;
}
_public_
int knot_sc_parse(uint16_t nonce_len, const uint8_t *sc, uint16_t sc_len,
struct knot_sc_content *content)
......
......@@ -75,16 +75,7 @@ struct knot_sc_input {
* \retval true if input contains client cookie and server secret data
* \retval false if input is insufficient or NULL pointer passed
*/
static inline bool knot_sc_input_is_valid(const struct knot_sc_input *input)
{
/*
* RFC7873 4.2 -- Server should be generated from request
* source IP address, a secret quantity and request client cookie.
*/
return input && input->cc && input->cc_len > 0 && input->srvr_data &&
input->srvr_data->secret_data && input->srvr_data->secret_len > 0;
}
bool knot_sc_input_is_valid(const struct knot_sc_input *input);
/*!
* \brief Reads a server cookie that contains \a nonce_len bytes of data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment