1 #ifndef _IP_SET_TIMEOUT_H
2 #define _IP_SET_TIMEOUT_H
14 #define IPSET_GC_TIME (3 * 60)
17 #define IPSET_GC_PERIOD(timeout) \
18 ((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1)
21 #define IPSET_NO_TIMEOUT UINT_MAX
23 #define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT)
25 #define opt_timeout(opt, map) \
26 (with_timeout((opt)->timeout) ? (opt)->timeout : (map)->timeout)
28 static inline unsigned int
29 ip_set_timeout_uget(
struct nlattr *
tb)
31 unsigned int timeout = ip_set_get_h32(tb);
38 return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 :
timeout;
41 #ifdef IP_SET_BITMAP_TIMEOUT
46 #define IPSET_ELEM_UNSET 0
48 #define IPSET_ELEM_PERMANENT (UINT_MAX/2)
51 ip_set_timeout_test(
unsigned long timeout)
53 return timeout != IPSET_ELEM_UNSET &&
54 (timeout == IPSET_ELEM_PERMANENT ||
59 ip_set_timeout_expired(
unsigned long timeout)
61 return timeout != IPSET_ELEM_UNSET &&
62 timeout != IPSET_ELEM_PERMANENT &&
66 static inline unsigned long
67 ip_set_timeout_set(
u32 timeout)
72 return IPSET_ELEM_PERMANENT;
75 if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT)
83 ip_set_timeout_get(
unsigned long timeout)
85 return timeout == IPSET_ELEM_PERMANENT ? 0 :
94 #define IPSET_ELEM_PERMANENT 0
97 ip_set_timeout_test(
unsigned long timeout)
99 return timeout == IPSET_ELEM_PERMANENT ||
104 ip_set_timeout_expired(
unsigned long timeout)
106 return timeout != IPSET_ELEM_PERMANENT &&
110 static inline unsigned long
111 ip_set_timeout_set(
u32 timeout)
116 return IPSET_ELEM_PERMANENT;
119 if (t == IPSET_ELEM_PERMANENT)
127 ip_set_timeout_get(
unsigned long timeout)
129 return timeout == IPSET_ELEM_PERMANENT ? 0 :