static struct {
const char *algo;
struct crypto_hash *tfm;
- int size;
+ unsigned int size;
struct hash_desc desc;
} crypto = {
.algo = "hmac(sha256)",
/**
* @return: the epoch minute
*/
-static int
+static unsigned int
get_epoch_minute(void)
{
struct timespec t = CURRENT_TIME;
* @return: hashtable
*/
static struct list_head *
-alloc_hashtable(int size)
+alloc_hashtable(unsigned int size)
{
struct list_head *hash = NULL;
unsigned int i;
* @return: 1 time exceeded, 0 still valid
*/
static inline bool
-is_time_exceeded(const struct peer *peer, int max_time)
+is_time_exceeded(const struct peer *peer, unsigned int max_time)
{
return peer && time_after(jiffies/HZ, peer->timestamp + max_time);
}
static void
peer_gc(unsigned long r)
{
- int i;
+ unsigned int i;
struct ipt_pknock_rule *rule = (struct ipt_pknock_rule *)r;
struct peer *peer = NULL;
struct list_head *pos = NULL, *n = NULL;
{
struct ipt_pknock_rule *rule = NULL;
struct list_head *pos = NULL, *n = NULL;
- int hash = pknock_hash(info->rule_name, info->rule_name_len,
+ unsigned int hash = pknock_hash(info->rule_name, info->rule_name_len,
ipt_pknock_hash_rnd, rule_hashsize);
list_for_each_safe(pos, n, &rule_hashtable[hash]) {
{
struct ipt_pknock_rule *rule = NULL;
struct list_head *pos = NULL, *n = NULL;
- int hash = pknock_hash(info->rule_name, info->rule_name_len,
+ unsigned int hash = pknock_hash(info->rule_name, info->rule_name_len,
ipt_pknock_hash_rnd, rule_hashsize);
list_for_each_safe(pos, n, &rule_hashtable[hash]) {
struct ipt_pknock_rule *rule = NULL;
struct list_head *pos = NULL, *n = NULL;
struct peer *peer = NULL;
- int i;
+ unsigned int i = 0;
int found = 0;
- int hash = pknock_hash(info->rule_name, info->rule_name_len,
+ unsigned int hash = pknock_hash(info->rule_name, info->rule_name_len,
ipt_pknock_hash_rnd, rule_hashsize);
if (list_empty(&rule_hashtable[hash])) return;
{
struct peer *peer = NULL;
struct list_head *pos = NULL, *n = NULL;
- int hash;
+ unsigned int hash;
ip = ntohl(ip);
static inline void
add_peer(struct peer *peer, struct ipt_pknock_rule *rule)
{
- int hash = pknock_hash(&peer->ip, sizeof(peer->ip),
+ unsigned int hash = pknock_hash(&peer->ip, sizeof(peer->ip),
ipt_pknock_hash_rnd, peer_hashsize);
list_add(&peer->head, &rule->peer_head[hash]);
}
* @size
*/
static void
-crypt_to_hex(char *out, const char *crypt, int size)
+crypt_to_hex(char *out, const char *crypt, unsigned int size)
{
- int i;
+ unsigned int i;
for (i=0; i < size; i++) {
unsigned char c = crypt[i];
*out++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
* @return: 1 success, 0 failure
*/
static int
-has_secret(const unsigned char *secret, int secret_len, uint32_t ipsrc,
- const unsigned char *payload, int payload_len)
+has_secret(const unsigned char *secret, unsigned int secret_len, uint32_t ipsrc,
+ const unsigned char *payload, unsigned int payload_len)
{
struct scatterlist sg[2];
char result[64]; // 64 bytes * 8 = 512 bits
char *hexresult = NULL;
- int hexa_size;
+ unsigned int hexa_size;
int ret = 0;
- int epoch_min;
+ unsigned int epoch_min;
if (payload_len == 0)
return 0;
*/
static bool
pass_security(struct peer *peer, const struct ipt_pknock *info,
- const unsigned char *payload, int payload_len)
+ const unsigned char *payload, unsigned int payload_len)
{
if (is_allowed(peer))
return true;
*/
static inline bool
is_close_knock(const struct peer *peer, const struct ipt_pknock *info,
- const unsigned char *payload, int payload_len)
+ const unsigned char *payload, unsigned int payload_len)
{
/* Check for CLOSE secret. */
if (has_secret(info->close_secret,
struct ipt_pknock_rule *rule = NULL;
struct peer *peer = NULL;
const struct iphdr *iph = ip_hdr(skb);
- int hdr_len = 0;
+ unsigned int hdr_len = 0;
__be16 _ports[2];
const __be16 *pptr = NULL;
struct transport_data hdr = {0, 0, 0, NULL};