50#include <netlink/xfrm/lifetime.h>
51#include <netlink-private/netlink.h>
53static void ltime_cfg_destroy(
struct xfrmnl_ltime_cfg* ltime)
58 if (ltime->refcnt != 1)
60 fprintf(stderr,
"BUG: %s:%d\n", __FILE__, __LINE__);
78 struct xfrmnl_ltime_cfg* ltime;
80 ltime = calloc(1,
sizeof(
struct xfrmnl_ltime_cfg));
97 struct xfrmnl_ltime_cfg*
new;
101 memcpy ((
void*)
new, (
void*)ltime,
sizeof (
struct xfrmnl_ltime_cfg));
113struct xfrmnl_ltime_cfg* xfrmnl_ltime_cfg_get(
struct xfrmnl_ltime_cfg* ltime)
120void xfrmnl_ltime_cfg_put(
struct xfrmnl_ltime_cfg* ltime)
125 if (ltime->refcnt == 1)
126 ltime_cfg_destroy(ltime);
138 return ltime->refcnt > 1;
159 if ((a->soft_byte_limit != b->soft_byte_limit) ||
160 (a->soft_packet_limit != b->soft_packet_limit) ||
161 (a->hard_byte_limit != b->hard_byte_limit) ||
162 (a->hard_packet_limit != b->hard_packet_limit) ||
163 (a->soft_add_expires_seconds != b->soft_add_expires_seconds) ||
164 (a->hard_add_expires_seconds != b->hard_add_expires_seconds) ||
165 (a->soft_use_expires_seconds != b->soft_use_expires_seconds) ||
166 (a->hard_use_expires_seconds != b->hard_use_expires_seconds))
179unsigned long long xfrmnl_ltime_cfg_get_soft_bytelimit (
struct xfrmnl_ltime_cfg* ltime)
181 return ltime->soft_byte_limit;
184int xfrmnl_ltime_cfg_set_soft_bytelimit (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long soft_byte_limit)
186 ltime->soft_byte_limit = soft_byte_limit;
191unsigned long long xfrmnl_ltime_cfg_get_hard_bytelimit (
struct xfrmnl_ltime_cfg* ltime)
193 return ltime->hard_byte_limit;
196int xfrmnl_ltime_cfg_set_hard_bytelimit (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long hard_byte_limit)
198 ltime->hard_byte_limit = hard_byte_limit;
203unsigned long long xfrmnl_ltime_cfg_get_soft_packetlimit (
struct xfrmnl_ltime_cfg* ltime)
205 return ltime->soft_packet_limit;
208int xfrmnl_ltime_cfg_set_soft_packetlimit (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long soft_packet_limit)
210 ltime->soft_packet_limit = soft_packet_limit;
215unsigned long long xfrmnl_ltime_cfg_get_hard_packetlimit (
struct xfrmnl_ltime_cfg* ltime)
217 return ltime->hard_packet_limit;
220int xfrmnl_ltime_cfg_set_hard_packetlimit (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long hard_packet_limit)
222 ltime->hard_packet_limit = hard_packet_limit;
227unsigned long long xfrmnl_ltime_cfg_get_soft_addexpires (
struct xfrmnl_ltime_cfg* ltime)
229 return ltime->soft_add_expires_seconds;
232int xfrmnl_ltime_cfg_set_soft_addexpires (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long soft_add_expires_seconds)
234 ltime->soft_add_expires_seconds = soft_add_expires_seconds;
239unsigned long long xfrmnl_ltime_cfg_get_hard_addexpires (
struct xfrmnl_ltime_cfg* ltime)
241 return ltime->hard_add_expires_seconds;
244int xfrmnl_ltime_cfg_set_hard_addexpires (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long hard_add_expires_seconds)
246 ltime->hard_add_expires_seconds = hard_add_expires_seconds;
251unsigned long long xfrmnl_ltime_cfg_get_soft_useexpires (
struct xfrmnl_ltime_cfg* ltime)
253 return ltime->soft_use_expires_seconds;
256int xfrmnl_ltime_cfg_set_soft_useexpires (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long soft_use_expires_seconds)
258 ltime->soft_use_expires_seconds = soft_use_expires_seconds;
263unsigned long long xfrmnl_ltime_cfg_get_hard_useexpires (
struct xfrmnl_ltime_cfg* ltime)
265 return ltime->hard_use_expires_seconds;
268int xfrmnl_ltime_cfg_set_hard_useexpires (
struct xfrmnl_ltime_cfg* ltime,
unsigned long long hard_use_expires_seconds)
270 ltime->hard_use_expires_seconds = hard_use_expires_seconds;
struct xfrmnl_ltime_cfg * xfrmnl_ltime_cfg_alloc()
Allocate new lifetime config object.
int xfrmnl_ltime_cfg_cmp(struct xfrmnl_ltime_cfg *a, struct xfrmnl_ltime_cfg *b)
Compares two lifetime config objects.
struct xfrmnl_ltime_cfg * xfrmnl_ltime_cfg_clone(struct xfrmnl_ltime_cfg *ltime)
Clone existing lifetime config object.
int xfrmnl_ltime_cfg_shared(struct xfrmnl_ltime_cfg *ltime)
Check whether an lifetime config object is shared.