xfrm: style-fixes
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
9171544708
commit
51941b1356
8 changed files with 3027 additions and 3025 deletions
|
@ -1005,226 +1005,226 @@ struct idiagnl_req {
|
|||
|
||||
/* Selector, used as selector both on policy rules (SPD) and SAs. */
|
||||
struct xfrmnl_sel {
|
||||
uint32_t refcnt;
|
||||
struct nl_addr* daddr;
|
||||
struct nl_addr* saddr;
|
||||
uint16_t dport;
|
||||
uint16_t dport_mask;
|
||||
uint16_t sport;
|
||||
uint16_t sport_mask;
|
||||
uint16_t family;
|
||||
uint8_t prefixlen_d;
|
||||
uint8_t prefixlen_s;
|
||||
uint8_t proto;
|
||||
int32_t ifindex;
|
||||
uint32_t user;
|
||||
uint32_t refcnt;
|
||||
struct nl_addr* daddr;
|
||||
struct nl_addr* saddr;
|
||||
uint16_t dport;
|
||||
uint16_t dport_mask;
|
||||
uint16_t sport;
|
||||
uint16_t sport_mask;
|
||||
uint16_t family;
|
||||
uint8_t prefixlen_d;
|
||||
uint8_t prefixlen_s;
|
||||
uint8_t proto;
|
||||
int32_t ifindex;
|
||||
uint32_t user;
|
||||
};
|
||||
|
||||
/* Lifetime configuration, used for both policy rules (SPD) and SAs. */
|
||||
struct xfrmnl_ltime_cfg {
|
||||
uint32_t refcnt;
|
||||
uint64_t soft_byte_limit;
|
||||
uint64_t hard_byte_limit;
|
||||
uint64_t soft_packet_limit;
|
||||
uint64_t hard_packet_limit;
|
||||
uint64_t soft_add_expires_seconds;
|
||||
uint64_t hard_add_expires_seconds;
|
||||
uint64_t soft_use_expires_seconds;
|
||||
uint64_t hard_use_expires_seconds;
|
||||
uint32_t refcnt;
|
||||
uint64_t soft_byte_limit;
|
||||
uint64_t hard_byte_limit;
|
||||
uint64_t soft_packet_limit;
|
||||
uint64_t hard_packet_limit;
|
||||
uint64_t soft_add_expires_seconds;
|
||||
uint64_t hard_add_expires_seconds;
|
||||
uint64_t soft_use_expires_seconds;
|
||||
uint64_t hard_use_expires_seconds;
|
||||
};
|
||||
|
||||
/* Current lifetime, used for both policy rules (SPD) and SAs. */
|
||||
struct xfrmnl_lifetime_cur {
|
||||
uint64_t bytes;
|
||||
uint64_t packets;
|
||||
uint64_t add_time;
|
||||
uint64_t use_time;
|
||||
uint64_t bytes;
|
||||
uint64_t packets;
|
||||
uint64_t add_time;
|
||||
uint64_t use_time;
|
||||
};
|
||||
|
||||
struct xfrmnl_replay_state {
|
||||
uint32_t oseq;
|
||||
uint32_t seq;
|
||||
uint32_t bitmap;
|
||||
uint32_t oseq;
|
||||
uint32_t seq;
|
||||
uint32_t bitmap;
|
||||
};
|
||||
|
||||
struct xfrmnl_replay_state_esn {
|
||||
uint32_t bmp_len;
|
||||
uint32_t oseq;
|
||||
uint32_t seq;
|
||||
uint32_t oseq_hi;
|
||||
uint32_t seq_hi;
|
||||
uint32_t replay_window;
|
||||
uint32_t bmp[0];
|
||||
uint32_t bmp_len;
|
||||
uint32_t oseq;
|
||||
uint32_t seq;
|
||||
uint32_t oseq_hi;
|
||||
uint32_t seq_hi;
|
||||
uint32_t replay_window;
|
||||
uint32_t bmp[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_mark {
|
||||
uint32_t v; /* value */
|
||||
uint32_t m; /* mask */
|
||||
uint32_t v; /* value */
|
||||
uint32_t m; /* mask */
|
||||
};
|
||||
|
||||
/* XFRM AE related definitions */
|
||||
|
||||
struct xfrmnl_sa_id {
|
||||
struct nl_addr* daddr;
|
||||
uint32_t spi;
|
||||
uint16_t family;
|
||||
uint8_t proto;
|
||||
struct nl_addr* daddr;
|
||||
uint32_t spi;
|
||||
uint16_t family;
|
||||
uint8_t proto;
|
||||
};
|
||||
|
||||
struct xfrmnl_ae {
|
||||
NLHDR_COMMON
|
||||
NLHDR_COMMON
|
||||
|
||||
struct xfrmnl_sa_id sa_id;
|
||||
struct nl_addr* saddr;
|
||||
uint32_t flags;
|
||||
uint32_t reqid;
|
||||
struct xfrmnl_mark mark;
|
||||
struct xfrmnl_lifetime_cur lifetime_cur;
|
||||
uint32_t replay_maxage;
|
||||
uint32_t replay_maxdiff;
|
||||
struct xfrmnl_replay_state replay_state;
|
||||
struct xfrmnl_replay_state_esn* replay_state_esn;
|
||||
struct xfrmnl_sa_id sa_id;
|
||||
struct nl_addr* saddr;
|
||||
uint32_t flags;
|
||||
uint32_t reqid;
|
||||
struct xfrmnl_mark mark;
|
||||
struct xfrmnl_lifetime_cur lifetime_cur;
|
||||
uint32_t replay_maxage;
|
||||
uint32_t replay_maxdiff;
|
||||
struct xfrmnl_replay_state replay_state;
|
||||
struct xfrmnl_replay_state_esn* replay_state_esn;
|
||||
};
|
||||
|
||||
/* XFRM SA related definitions */
|
||||
|
||||
struct xfrmnl_id {
|
||||
struct nl_addr* daddr;
|
||||
uint32_t spi;
|
||||
uint8_t proto;
|
||||
struct nl_addr* daddr;
|
||||
uint32_t spi;
|
||||
uint8_t proto;
|
||||
};
|
||||
|
||||
struct xfrmnl_stats {
|
||||
uint32_t replay_window;
|
||||
uint32_t replay;
|
||||
uint32_t integrity_failed;
|
||||
uint32_t replay_window;
|
||||
uint32_t replay;
|
||||
uint32_t integrity_failed;
|
||||
};
|
||||
|
||||
struct xfrmnl_algo_aead {
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
uint32_t alg_icv_len; /* in bits */
|
||||
char alg_key[0];
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
uint32_t alg_icv_len; /* in bits */
|
||||
char alg_key[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_algo_auth {
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
uint32_t alg_trunc_len; /* in bits */
|
||||
char alg_key[0];
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
uint32_t alg_trunc_len; /* in bits */
|
||||
char alg_key[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_algo {
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
char alg_key[0];
|
||||
char alg_name[64];
|
||||
uint32_t alg_key_len; /* in bits */
|
||||
char alg_key[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_encap_tmpl {
|
||||
uint16_t encap_type;
|
||||
uint16_t encap_sport;
|
||||
uint16_t encap_dport;
|
||||
struct nl_addr* encap_oa;
|
||||
uint16_t encap_type;
|
||||
uint16_t encap_sport;
|
||||
uint16_t encap_dport;
|
||||
struct nl_addr* encap_oa;
|
||||
};
|
||||
|
||||
struct xfrmnl_sec_ctx {
|
||||
uint8_t ctx_doi;
|
||||
uint8_t ctx_alg;
|
||||
uint16_t ctx_len;
|
||||
uint32_t ctx_sid;
|
||||
char ctx_str[0];
|
||||
uint8_t ctx_doi;
|
||||
uint8_t ctx_alg;
|
||||
uint16_t ctx_len;
|
||||
uint32_t ctx_sid;
|
||||
char ctx_str[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_sa {
|
||||
NLHDR_COMMON
|
||||
NLHDR_COMMON
|
||||
|
||||
struct xfrmnl_sel* sel;
|
||||
struct xfrmnl_id id;
|
||||
struct nl_addr* saddr;
|
||||
struct xfrmnl_ltime_cfg* lft;
|
||||
struct xfrmnl_lifetime_cur curlft;
|
||||
struct xfrmnl_stats stats;
|
||||
uint32_t seq;
|
||||
uint32_t reqid;
|
||||
uint16_t family;
|
||||
uint8_t mode; /* XFRM_MODE_xxx */
|
||||
uint8_t replay_window;
|
||||
uint8_t flags;
|
||||
struct xfrmnl_algo_aead* aead;
|
||||
struct xfrmnl_algo_auth* auth;
|
||||
struct xfrmnl_algo* crypt;
|
||||
struct xfrmnl_algo* comp;
|
||||
struct xfrmnl_encap_tmpl* encap;
|
||||
uint32_t tfcpad;
|
||||
struct nl_addr* coaddr;
|
||||
struct xfrmnl_mark mark;
|
||||
struct xfrmnl_sec_ctx* sec_ctx;
|
||||
uint32_t replay_maxage;
|
||||
uint32_t replay_maxdiff;
|
||||
struct xfrmnl_replay_state replay_state;
|
||||
struct xfrmnl_replay_state_esn* replay_state_esn;
|
||||
uint8_t hard;
|
||||
struct xfrmnl_sel* sel;
|
||||
struct xfrmnl_id id;
|
||||
struct nl_addr* saddr;
|
||||
struct xfrmnl_ltime_cfg* lft;
|
||||
struct xfrmnl_lifetime_cur curlft;
|
||||
struct xfrmnl_stats stats;
|
||||
uint32_t seq;
|
||||
uint32_t reqid;
|
||||
uint16_t family;
|
||||
uint8_t mode; /* XFRM_MODE_xxx */
|
||||
uint8_t replay_window;
|
||||
uint8_t flags;
|
||||
struct xfrmnl_algo_aead* aead;
|
||||
struct xfrmnl_algo_auth* auth;
|
||||
struct xfrmnl_algo* crypt;
|
||||
struct xfrmnl_algo* comp;
|
||||
struct xfrmnl_encap_tmpl* encap;
|
||||
uint32_t tfcpad;
|
||||
struct nl_addr* coaddr;
|
||||
struct xfrmnl_mark mark;
|
||||
struct xfrmnl_sec_ctx* sec_ctx;
|
||||
uint32_t replay_maxage;
|
||||
uint32_t replay_maxdiff;
|
||||
struct xfrmnl_replay_state replay_state;
|
||||
struct xfrmnl_replay_state_esn* replay_state_esn;
|
||||
uint8_t hard;
|
||||
};
|
||||
|
||||
struct xfrmnl_usersa_flush {
|
||||
uint8_t proto;
|
||||
uint8_t proto;
|
||||
};
|
||||
|
||||
|
||||
/* XFRM SP related definitions */
|
||||
|
||||
struct xfrmnl_userpolicy_id {
|
||||
struct xfrmnl_sel sel;
|
||||
uint32_t index;
|
||||
uint8_t dir;
|
||||
struct xfrmnl_sel sel;
|
||||
uint32_t index;
|
||||
uint8_t dir;
|
||||
};
|
||||
|
||||
struct xfrmnl_user_sec_ctx {
|
||||
uint16_t len;
|
||||
uint16_t exttype;
|
||||
uint8_t ctx_alg;
|
||||
uint8_t ctx_doi;
|
||||
uint16_t ctx_len;
|
||||
char ctx[0];
|
||||
uint16_t len;
|
||||
uint16_t exttype;
|
||||
uint8_t ctx_alg;
|
||||
uint8_t ctx_doi;
|
||||
uint16_t ctx_len;
|
||||
char ctx[0];
|
||||
};
|
||||
|
||||
struct xfrmnl_userpolicy_type {
|
||||
uint8_t type;
|
||||
uint16_t reserved1;
|
||||
uint16_t reserved2;
|
||||
uint8_t type;
|
||||
uint16_t reserved1;
|
||||
uint16_t reserved2;
|
||||
};
|
||||
|
||||
struct xfrmnl_user_tmpl {
|
||||
struct xfrmnl_id id;
|
||||
uint16_t family;
|
||||
struct nl_addr* saddr;
|
||||
uint32_t reqid;
|
||||
uint8_t mode;
|
||||
uint8_t share;
|
||||
uint8_t optional;
|
||||
uint32_t aalgos;
|
||||
uint32_t ealgos;
|
||||
uint32_t calgos;
|
||||
struct nl_list_head utmpl_list;
|
||||
struct xfrmnl_id id;
|
||||
uint16_t family;
|
||||
struct nl_addr* saddr;
|
||||
uint32_t reqid;
|
||||
uint8_t mode;
|
||||
uint8_t share;
|
||||
uint8_t optional;
|
||||
uint32_t aalgos;
|
||||
uint32_t ealgos;
|
||||
uint32_t calgos;
|
||||
struct nl_list_head utmpl_list;
|
||||
};
|
||||
|
||||
struct xfrmnl_sp {
|
||||
NLHDR_COMMON
|
||||
NLHDR_COMMON
|
||||
|
||||
struct xfrmnl_sel* sel;
|
||||
struct xfrmnl_ltime_cfg* lft;
|
||||
struct xfrmnl_lifetime_cur curlft;
|
||||
uint32_t priority;
|
||||
uint32_t index;
|
||||
uint8_t dir;
|
||||
uint8_t action;
|
||||
uint8_t flags;
|
||||
uint8_t share;
|
||||
struct xfrmnl_user_sec_ctx* sec_ctx;
|
||||
struct xfrmnl_userpolicy_type uptype;
|
||||
uint32_t nr_user_tmpl;
|
||||
struct nl_list_head usertmpl_list;
|
||||
struct xfrmnl_mark mark;
|
||||
struct xfrmnl_sel* sel;
|
||||
struct xfrmnl_ltime_cfg* lft;
|
||||
struct xfrmnl_lifetime_cur curlft;
|
||||
uint32_t priority;
|
||||
uint32_t index;
|
||||
uint8_t dir;
|
||||
uint8_t action;
|
||||
uint8_t flags;
|
||||
uint8_t share;
|
||||
struct xfrmnl_user_sec_ctx* sec_ctx;
|
||||
struct xfrmnl_userpolicy_type uptype;
|
||||
uint32_t nr_user_tmpl;
|
||||
struct nl_list_head usertmpl_list;
|
||||
struct xfrmnl_mark mark;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@ extern "C" {
|
|||
|
||||
struct xfrmnl_ae;
|
||||
|
||||
extern struct xfrmnl_ae* xfrmnl_ae_alloc(void);
|
||||
extern struct xfrmnl_ae*xfrmnl_ae_alloc(void);
|
||||
extern void xfrmnl_ae_put(struct xfrmnl_ae *);
|
||||
|
||||
extern int xfrmnl_ae_get_kernel(struct nl_sock*, struct nl_addr*, unsigned int, unsigned int,
|
||||
|
|
1052
lib/xfrm/ae.c
1052
lib/xfrm/ae.c
File diff suppressed because it is too large
Load diff
|
@ -50,16 +50,16 @@
|
|||
|
||||
static void ltime_cfg_destroy(struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
if (!ltime)
|
||||
return;
|
||||
if (!ltime)
|
||||
return;
|
||||
|
||||
if (ltime->refcnt != 1)
|
||||
{
|
||||
fprintf(stderr, "BUG: %s:%d\n", __FILE__, __LINE__);
|
||||
assert(0);
|
||||
}
|
||||
if (ltime->refcnt != 1)
|
||||
{
|
||||
fprintf(stderr, "BUG: %s:%d\n", __FILE__, __LINE__);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
free(ltime);
|
||||
free(ltime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,32 +73,32 @@ static void ltime_cfg_destroy(struct xfrmnl_ltime_cfg* ltime)
|
|||
*/
|
||||
struct xfrmnl_ltime_cfg* xfrmnl_ltime_cfg_alloc()
|
||||
{
|
||||
struct xfrmnl_ltime_cfg* ltime;
|
||||
struct xfrmnl_ltime_cfg* ltime;
|
||||
|
||||
ltime = calloc(1, sizeof(struct xfrmnl_ltime_cfg));
|
||||
if (!ltime)
|
||||
return NULL;
|
||||
ltime = calloc(1, sizeof(struct xfrmnl_ltime_cfg));
|
||||
if (!ltime)
|
||||
return NULL;
|
||||
|
||||
ltime->refcnt = 1;
|
||||
ltime->refcnt = 1;
|
||||
|
||||
return ltime;
|
||||
return ltime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone existing lifetime config object.
|
||||
* @arg ltime Selector object.
|
||||
* @arg ltime Selector object.
|
||||
* @return Newly allocated lifetime config object being a duplicate of the
|
||||
* specified lifetime config object or NULL if a failure occured.
|
||||
*/
|
||||
struct xfrmnl_ltime_cfg* xfrmnl_ltime_cfg_clone(struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
struct xfrmnl_ltime_cfg* new;
|
||||
struct xfrmnl_ltime_cfg* new;
|
||||
|
||||
new = xfrmnl_ltime_cfg_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)ltime, sizeof (struct xfrmnl_ltime_cfg));
|
||||
new = xfrmnl_ltime_cfg_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)ltime, sizeof (struct xfrmnl_ltime_cfg));
|
||||
|
||||
return new;
|
||||
return new;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -110,30 +110,30 @@ struct xfrmnl_ltime_cfg* xfrmnl_ltime_cfg_clone(struct xfrmnl_ltime_cfg* ltime)
|
|||
|
||||
struct xfrmnl_ltime_cfg* xfrmnl_ltime_cfg_get(struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
ltime->refcnt++;
|
||||
ltime->refcnt++;
|
||||
|
||||
return ltime;
|
||||
return ltime;
|
||||
}
|
||||
|
||||
void xfrmnl_ltime_cfg_put(struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
if (!ltime)
|
||||
return;
|
||||
if (!ltime)
|
||||
return;
|
||||
|
||||
if (ltime->refcnt == 1)
|
||||
ltime_cfg_destroy(ltime);
|
||||
else
|
||||
ltime->refcnt--;
|
||||
if (ltime->refcnt == 1)
|
||||
ltime_cfg_destroy(ltime);
|
||||
else
|
||||
ltime->refcnt--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether an lifetime config object is shared.
|
||||
* @arg addr Selector object.
|
||||
* @arg addr Selector object.
|
||||
* @return Non-zero if the lifetime config object is shared, otherwise 0.
|
||||
*/
|
||||
int xfrmnl_ltime_cfg_shared(struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->refcnt > 1;
|
||||
return ltime->refcnt > 1;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -145,27 +145,27 @@ int xfrmnl_ltime_cfg_shared(struct xfrmnl_ltime_cfg* ltime)
|
|||
|
||||
/**
|
||||
* Compares two lifetime config objects.
|
||||
* @arg a A lifetime config object.
|
||||
* @arg b Another lifetime config object.
|
||||
* @arg a A lifetime config object.
|
||||
* @arg b Another lifetime config object.
|
||||
*
|
||||
* @return Non zero if difference is found, 0 otherwise if both
|
||||
* the objects are identical.
|
||||
*/
|
||||
int xfrmnl_ltime_cfg_cmp(struct xfrmnl_ltime_cfg* a, struct xfrmnl_ltime_cfg* b)
|
||||
{
|
||||
/* Check for any differences */
|
||||
if ((a->soft_byte_limit != b->soft_byte_limit) ||
|
||||
(a->soft_packet_limit != b->soft_packet_limit) ||
|
||||
(a->hard_byte_limit != b->hard_byte_limit) ||
|
||||
(a->hard_packet_limit != b->hard_packet_limit) ||
|
||||
(a->soft_add_expires_seconds != b->soft_add_expires_seconds) ||
|
||||
(a->hard_add_expires_seconds != b->hard_add_expires_seconds) ||
|
||||
(a->soft_use_expires_seconds != b->soft_use_expires_seconds) ||
|
||||
(a->hard_use_expires_seconds != b->hard_use_expires_seconds))
|
||||
return 1;
|
||||
/* Check for any differences */
|
||||
if ((a->soft_byte_limit != b->soft_byte_limit) ||
|
||||
(a->soft_packet_limit != b->soft_packet_limit) ||
|
||||
(a->hard_byte_limit != b->hard_byte_limit) ||
|
||||
(a->hard_packet_limit != b->hard_packet_limit) ||
|
||||
(a->soft_add_expires_seconds != b->soft_add_expires_seconds) ||
|
||||
(a->hard_add_expires_seconds != b->hard_add_expires_seconds) ||
|
||||
(a->soft_use_expires_seconds != b->soft_use_expires_seconds) ||
|
||||
(a->hard_use_expires_seconds != b->hard_use_expires_seconds))
|
||||
return 1;
|
||||
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -176,98 +176,98 @@ int xfrmnl_ltime_cfg_cmp(struct xfrmnl_ltime_cfg* a, struct xfrmnl_ltime_cfg* b)
|
|||
*/
|
||||
unsigned long long xfrmnl_ltime_cfg_get_soft_bytelimit (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->soft_byte_limit;
|
||||
return ltime->soft_byte_limit;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_soft_bytelimit (struct xfrmnl_ltime_cfg* ltime, unsigned long long soft_byte_limit)
|
||||
{
|
||||
ltime->soft_byte_limit = soft_byte_limit;
|
||||
ltime->soft_byte_limit = soft_byte_limit;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_hard_bytelimit (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->hard_byte_limit;
|
||||
return ltime->hard_byte_limit;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_hard_bytelimit (struct xfrmnl_ltime_cfg* ltime, unsigned long long hard_byte_limit)
|
||||
{
|
||||
ltime->hard_byte_limit = hard_byte_limit;
|
||||
ltime->hard_byte_limit = hard_byte_limit;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_soft_packetlimit (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->soft_packet_limit;
|
||||
return ltime->soft_packet_limit;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_soft_packetlimit (struct xfrmnl_ltime_cfg* ltime, unsigned long long soft_packet_limit)
|
||||
{
|
||||
ltime->soft_packet_limit = soft_packet_limit;
|
||||
ltime->soft_packet_limit = soft_packet_limit;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_hard_packetlimit (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->hard_packet_limit;
|
||||
return ltime->hard_packet_limit;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_hard_packetlimit (struct xfrmnl_ltime_cfg* ltime, unsigned long long hard_packet_limit)
|
||||
{
|
||||
ltime->hard_packet_limit = hard_packet_limit;
|
||||
ltime->hard_packet_limit = hard_packet_limit;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_soft_addexpires (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->soft_add_expires_seconds;
|
||||
return ltime->soft_add_expires_seconds;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_soft_addexpires (struct xfrmnl_ltime_cfg* ltime, unsigned long long soft_add_expires_seconds)
|
||||
{
|
||||
ltime->soft_add_expires_seconds = soft_add_expires_seconds;
|
||||
ltime->soft_add_expires_seconds = soft_add_expires_seconds;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_hard_addexpires (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->hard_add_expires_seconds;
|
||||
return ltime->hard_add_expires_seconds;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_hard_addexpires (struct xfrmnl_ltime_cfg* ltime, unsigned long long hard_add_expires_seconds)
|
||||
{
|
||||
ltime->hard_add_expires_seconds = hard_add_expires_seconds;
|
||||
ltime->hard_add_expires_seconds = hard_add_expires_seconds;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_soft_useexpires (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->soft_use_expires_seconds;
|
||||
return ltime->soft_use_expires_seconds;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_soft_useexpires (struct xfrmnl_ltime_cfg* ltime, unsigned long long soft_use_expires_seconds)
|
||||
{
|
||||
ltime->soft_use_expires_seconds = soft_use_expires_seconds;
|
||||
ltime->soft_use_expires_seconds = soft_use_expires_seconds;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long xfrmnl_ltime_cfg_get_hard_useexpires (struct xfrmnl_ltime_cfg* ltime)
|
||||
{
|
||||
return ltime->hard_use_expires_seconds;
|
||||
return ltime->hard_use_expires_seconds;
|
||||
}
|
||||
|
||||
int xfrmnl_ltime_cfg_set_hard_useexpires (struct xfrmnl_ltime_cfg* ltime, unsigned long long hard_use_expires_seconds)
|
||||
{
|
||||
ltime->hard_use_expires_seconds = hard_use_expires_seconds;
|
||||
ltime->hard_use_expires_seconds = hard_use_expires_seconds;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
2660
lib/xfrm/sa.c
2660
lib/xfrm/sa.c
File diff suppressed because it is too large
Load diff
|
@ -50,18 +50,18 @@
|
|||
|
||||
static void sel_destroy(struct xfrmnl_sel* sel)
|
||||
{
|
||||
if (!sel)
|
||||
return;
|
||||
if (!sel)
|
||||
return;
|
||||
|
||||
if (sel->refcnt != 1)
|
||||
{
|
||||
fprintf(stderr, "BUG: %s:%d\n", __FILE__, __LINE__);
|
||||
assert(0);
|
||||
}
|
||||
if (sel->refcnt != 1)
|
||||
{
|
||||
fprintf(stderr, "BUG: %s:%d\n", __FILE__, __LINE__);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
nl_addr_put (sel->daddr);
|
||||
nl_addr_put (sel->saddr);
|
||||
free(sel);
|
||||
nl_addr_put (sel->daddr);
|
||||
nl_addr_put (sel->saddr);
|
||||
free(sel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,35 +75,35 @@ static void sel_destroy(struct xfrmnl_sel* sel)
|
|||
*/
|
||||
struct xfrmnl_sel* xfrmnl_sel_alloc()
|
||||
{
|
||||
struct xfrmnl_sel* sel;
|
||||
struct xfrmnl_sel* sel;
|
||||
|
||||
sel = calloc(1, sizeof(struct xfrmnl_sel));
|
||||
if (!sel)
|
||||
return NULL;
|
||||
sel = calloc(1, sizeof(struct xfrmnl_sel));
|
||||
if (!sel)
|
||||
return NULL;
|
||||
|
||||
sel->refcnt = 1;
|
||||
sel->refcnt = 1;
|
||||
|
||||
return sel;
|
||||
return sel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone existing selector object.
|
||||
* @arg sel Selector object.
|
||||
* @arg sel Selector object.
|
||||
* @return Newly allocated selector object being a duplicate of the
|
||||
* specified selector object or NULL if a failure occured.
|
||||
*/
|
||||
struct xfrmnl_sel* xfrmnl_sel_clone(struct xfrmnl_sel* sel)
|
||||
{
|
||||
struct xfrmnl_sel* new;
|
||||
struct xfrmnl_sel* new;
|
||||
|
||||
new = xfrmnl_sel_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)sel, sizeof (struct xfrmnl_sel));
|
||||
new = xfrmnl_sel_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)sel, sizeof (struct xfrmnl_sel));
|
||||
|
||||
new->daddr = nl_addr_clone(sel->daddr);
|
||||
new->saddr = nl_addr_clone(sel->saddr);
|
||||
new->daddr = nl_addr_clone(sel->daddr);
|
||||
new->saddr = nl_addr_clone(sel->saddr);
|
||||
|
||||
return new;
|
||||
return new;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -115,30 +115,30 @@ struct xfrmnl_sel* xfrmnl_sel_clone(struct xfrmnl_sel* sel)
|
|||
|
||||
struct xfrmnl_sel* xfrmnl_sel_get(struct xfrmnl_sel* sel)
|
||||
{
|
||||
sel->refcnt++;
|
||||
sel->refcnt++;
|
||||
|
||||
return sel;
|
||||
return sel;
|
||||
}
|
||||
|
||||
void xfrmnl_sel_put(struct xfrmnl_sel* sel)
|
||||
{
|
||||
if (!sel)
|
||||
return;
|
||||
if (!sel)
|
||||
return;
|
||||
|
||||
if (sel->refcnt == 1)
|
||||
sel_destroy(sel);
|
||||
else
|
||||
sel->refcnt--;
|
||||
if (sel->refcnt == 1)
|
||||
sel_destroy(sel);
|
||||
else
|
||||
sel->refcnt--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether an selector object is shared.
|
||||
* @arg addr Selector object.
|
||||
* @arg addr Selector object.
|
||||
* @return Non-zero if the selector object is shared, otherwise 0.
|
||||
*/
|
||||
int xfrmnl_sel_shared(struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->refcnt > 1;
|
||||
return sel->refcnt > 1;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -150,42 +150,42 @@ int xfrmnl_sel_shared(struct xfrmnl_sel* sel)
|
|||
|
||||
/**
|
||||
* Compares two selector objects.
|
||||
* @arg a A selector object.
|
||||
* @arg b Another selector object.
|
||||
* @arg a A selector object.
|
||||
* @arg b Another selector object.
|
||||
*
|
||||
* @return Non zero if difference is found, 0 otherwise if both
|
||||
* the objects are identical.
|
||||
*/
|
||||
int xfrmnl_sel_cmp(struct xfrmnl_sel* a, struct xfrmnl_sel* b)
|
||||
{
|
||||
/* Check for any differences */
|
||||
if ((nl_addr_cmp_prefix (a->daddr, b->daddr) != 0) ||
|
||||
(nl_addr_cmp_prefix (a->saddr, b->saddr) != 0) ||
|
||||
((a->sport & a->sport_mask) != (b->sport & b->sport_mask)) ||
|
||||
((a->dport & a->dport_mask) != (b->dport & b->dport_mask)) ||
|
||||
(a->family != b->family) ||
|
||||
(a->proto && (a->proto != b->proto)) ||
|
||||
(a->ifindex && a->ifindex != b->ifindex) ||
|
||||
(a->user != b->user))
|
||||
return 1;
|
||||
/* Check for any differences */
|
||||
if ((nl_addr_cmp_prefix (a->daddr, b->daddr) != 0) ||
|
||||
(nl_addr_cmp_prefix (a->saddr, b->saddr) != 0) ||
|
||||
((a->sport & a->sport_mask) != (b->sport & b->sport_mask)) ||
|
||||
((a->dport & a->dport_mask) != (b->dport & b->dport_mask)) ||
|
||||
(a->family != b->family) ||
|
||||
(a->proto && (a->proto != b->proto)) ||
|
||||
(a->ifindex && a->ifindex != b->ifindex) ||
|
||||
(a->user != b->user))
|
||||
return 1;
|
||||
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xfrmnl_sel_dump(struct xfrmnl_sel* sel, struct nl_dump_params *p)
|
||||
{
|
||||
char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
|
||||
char buf [128];
|
||||
char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
|
||||
char buf [128];
|
||||
|
||||
nl_dump_line(p, "\t\tsrc %s dst %s family: %s\n", nl_addr2str(sel->saddr, src, sizeof(src)),
|
||||
nl_addr2str (sel->daddr, dst, sizeof (dst)), nl_af2str (sel->family, buf, 128));
|
||||
nl_dump_line (p, "\t\tsrc port/mask: %d/%d dst port/mask: %d/%d\n",
|
||||
sel->dport, sel->dport_mask, sel->sport, sel->sport_mask);
|
||||
nl_dump_line (p, "\t\tprotocol: %s ifindex: %u user: %u\n",
|
||||
nl_ip_proto2str (sel->proto, buf, sizeof(buf)), sel->ifindex, sel->user);
|
||||
nl_dump_line(p, "\t\tsrc %s dst %s family: %s\n", nl_addr2str(sel->saddr, src, sizeof(src)),
|
||||
nl_addr2str (sel->daddr, dst, sizeof (dst)), nl_af2str (sel->family, buf, 128));
|
||||
nl_dump_line (p, "\t\tsrc port/mask: %d/%d dst port/mask: %d/%d\n",
|
||||
sel->dport, sel->dport_mask, sel->sport, sel->sport_mask);
|
||||
nl_dump_line (p, "\t\tprotocol: %s ifindex: %u user: %u\n",
|
||||
nl_ip_proto2str (sel->proto, buf, sizeof(buf)), sel->ifindex, sel->user);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,153 +197,153 @@ void xfrmnl_sel_dump(struct xfrmnl_sel* sel, struct nl_dump_params *p)
|
|||
*/
|
||||
struct nl_addr* xfrmnl_sel_get_daddr (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->daddr;
|
||||
return sel->daddr;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_daddr (struct xfrmnl_sel* sel, struct nl_addr* addr)
|
||||
{
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while selector in use */
|
||||
nl_addr_get(addr);
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while selector in use */
|
||||
nl_addr_get(addr);
|
||||
|
||||
sel->daddr = addr;
|
||||
sel->daddr = addr;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct nl_addr* xfrmnl_sel_get_saddr (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->saddr;
|
||||
return sel->saddr;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_saddr (struct xfrmnl_sel* sel, struct nl_addr* addr)
|
||||
{
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while selector in use */
|
||||
nl_addr_get(addr);
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while selector in use */
|
||||
nl_addr_get(addr);
|
||||
|
||||
sel->saddr = addr;
|
||||
sel->saddr = addr;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_dport (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->dport;
|
||||
return sel->dport;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_dport (struct xfrmnl_sel* sel, unsigned int dport)
|
||||
{
|
||||
sel->dport = dport;
|
||||
sel->dport = dport;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_dportmask (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->dport_mask;
|
||||
return sel->dport_mask;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_dportmask (struct xfrmnl_sel* sel, unsigned int dport_mask)
|
||||
{
|
||||
sel->dport_mask = dport_mask;
|
||||
sel->dport_mask = dport_mask;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_sport (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->sport;
|
||||
return sel->sport;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_sport (struct xfrmnl_sel* sel, unsigned int sport)
|
||||
{
|
||||
sel->sport = sport;
|
||||
sel->sport = sport;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_sportmask (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->sport_mask;
|
||||
return sel->sport_mask;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_sportmask (struct xfrmnl_sel* sel, unsigned int sport_mask)
|
||||
{
|
||||
sel->sport_mask = sport_mask;
|
||||
sel->sport_mask = sport_mask;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_family(struct xfrmnl_sel *sel)
|
||||
{
|
||||
return sel->family;
|
||||
return sel->family;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_family(struct xfrmnl_sel *sel, int family)
|
||||
{
|
||||
sel->family = family;
|
||||
sel->family = family;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_prefixlen_d (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->prefixlen_d;
|
||||
return sel->prefixlen_d;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_prefixlen_d (struct xfrmnl_sel* sel, unsigned int prefixlen)
|
||||
{
|
||||
sel->prefixlen_d = prefixlen;
|
||||
sel->prefixlen_d = prefixlen;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_prefixlen_s (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->prefixlen_s;
|
||||
return sel->prefixlen_s;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_prefixlen_s (struct xfrmnl_sel* sel, unsigned int prefixlen)
|
||||
{
|
||||
sel->prefixlen_s = prefixlen;
|
||||
sel->prefixlen_s = prefixlen;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_proto (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->proto;
|
||||
return sel->proto;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_proto (struct xfrmnl_sel* sel, unsigned int protocol)
|
||||
{
|
||||
sel->proto = protocol;
|
||||
sel->proto = protocol;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_ifindex (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->ifindex;
|
||||
return sel->ifindex;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_ifindex (struct xfrmnl_sel* sel, unsigned int ifindex)
|
||||
{
|
||||
sel->ifindex = ifindex;
|
||||
sel->ifindex = ifindex;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_get_userid (struct xfrmnl_sel* sel)
|
||||
{
|
||||
return sel->user;
|
||||
return sel->user;
|
||||
}
|
||||
|
||||
int xfrmnl_sel_set_userid (struct xfrmnl_sel* sel, unsigned int userid)
|
||||
{
|
||||
sel->user = userid;
|
||||
return 0;
|
||||
sel->user = userid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
1518
lib/xfrm/sp.c
1518
lib/xfrm/sp.c
File diff suppressed because it is too large
Load diff
|
@ -50,12 +50,12 @@
|
|||
|
||||
void xfrmnl_user_tmpl_free(struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
if (!utmpl)
|
||||
return;
|
||||
if (!utmpl)
|
||||
return;
|
||||
|
||||
nl_addr_put (utmpl->id.daddr);
|
||||
nl_addr_put (utmpl->saddr);
|
||||
free(utmpl);
|
||||
nl_addr_put (utmpl->id.daddr);
|
||||
nl_addr_put (utmpl->saddr);
|
||||
free(utmpl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,35 +69,35 @@ void xfrmnl_user_tmpl_free(struct xfrmnl_user_tmpl* utmpl)
|
|||
*/
|
||||
struct xfrmnl_user_tmpl* xfrmnl_user_tmpl_alloc()
|
||||
{
|
||||
struct xfrmnl_user_tmpl* utmpl;
|
||||
struct xfrmnl_user_tmpl* utmpl;
|
||||
|
||||
utmpl = calloc(1, sizeof(struct xfrmnl_user_tmpl));
|
||||
if (!utmpl)
|
||||
return NULL;
|
||||
utmpl = calloc(1, sizeof(struct xfrmnl_user_tmpl));
|
||||
if (!utmpl)
|
||||
return NULL;
|
||||
|
||||
nl_init_list_head(&utmpl->utmpl_list);
|
||||
nl_init_list_head(&utmpl->utmpl_list);
|
||||
|
||||
return utmpl;
|
||||
return utmpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone existing user template object.
|
||||
* @arg utmpl Selector object.
|
||||
* @arg utmpl Selector object.
|
||||
* @return Newly allocated user template object being a duplicate of the
|
||||
* specified user template object or NULL if a failure occured.
|
||||
*/
|
||||
struct xfrmnl_user_tmpl* xfrmnl_user_tmpl_clone(struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
struct xfrmnl_user_tmpl* new;
|
||||
struct xfrmnl_user_tmpl* new;
|
||||
|
||||
new = xfrmnl_user_tmpl_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)utmpl, sizeof (struct xfrmnl_user_tmpl));
|
||||
new = xfrmnl_user_tmpl_alloc();
|
||||
if (new)
|
||||
memcpy ((void*)new, (void*)utmpl, sizeof (struct xfrmnl_user_tmpl));
|
||||
|
||||
new->id.daddr = nl_addr_clone (utmpl->id.daddr);
|
||||
new->saddr = nl_addr_clone (utmpl->saddr);
|
||||
new->id.daddr = nl_addr_clone (utmpl->id.daddr);
|
||||
new->saddr = nl_addr_clone (utmpl->saddr);
|
||||
|
||||
return new;
|
||||
return new;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -107,21 +107,21 @@ struct xfrmnl_user_tmpl* xfrmnl_user_tmpl_clone(struct xfrmnl_user_tmpl* utmpl)
|
|||
* @{
|
||||
*/
|
||||
static const struct trans_tbl tmpl_modes[] = {
|
||||
__ADD(XFRM_MODE_TRANSPORT, transport)
|
||||
__ADD(XFRM_MODE_TUNNEL, tunnel)
|
||||
__ADD(XFRM_MODE_ROUTEOPTIMIZATION, route optimization)
|
||||
__ADD(XFRM_MODE_IN_TRIGGER, in trigger)
|
||||
__ADD(XFRM_MODE_BEET, beet)
|
||||
__ADD(XFRM_MODE_TRANSPORT, transport)
|
||||
__ADD(XFRM_MODE_TUNNEL, tunnel)
|
||||
__ADD(XFRM_MODE_ROUTEOPTIMIZATION, route optimization)
|
||||
__ADD(XFRM_MODE_IN_TRIGGER, in trigger)
|
||||
__ADD(XFRM_MODE_BEET, beet)
|
||||
};
|
||||
|
||||
char* xfrmnl_user_tmpl_mode2str(int mode, char *buf, size_t len)
|
||||
{
|
||||
return __type2str (mode, buf, len, tmpl_modes, ARRAY_SIZE(tmpl_modes));
|
||||
return __type2str (mode, buf, len, tmpl_modes, ARRAY_SIZE(tmpl_modes));
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_str2mode(const char *name)
|
||||
{
|
||||
return __str2type (name, tmpl_modes, ARRAY_SIZE(tmpl_modes));
|
||||
return __str2type (name, tmpl_modes, ARRAY_SIZE(tmpl_modes));
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
@ -132,49 +132,49 @@ int xfrmnl_user_tmpl_str2mode(const char *name)
|
|||
|
||||
/**
|
||||
* Compares two user template objects.
|
||||
* @arg a A user template object.
|
||||
* @arg b Another user template object.
|
||||
* @arg a A user template object.
|
||||
* @arg b Another user template object.
|
||||
*
|
||||
* @return Non zero if difference is found, 0 otherwise if both
|
||||
* the objects are identical.
|
||||
*/
|
||||
int xfrmnl_user_tmpl_cmp(struct xfrmnl_user_tmpl* a, struct xfrmnl_user_tmpl* b)
|
||||
{
|
||||
/* Check for any differences */
|
||||
if ((nl_addr_cmp_prefix (a->id.daddr, b->id.daddr) != 0) ||
|
||||
(a->id.spi != b->id.spi) ||
|
||||
(a->id.proto && (a->id.proto != b->id.proto)) ||
|
||||
(nl_addr_cmp_prefix (a->saddr, b->saddr) != 0) ||
|
||||
(a->family != b->family) ||
|
||||
(a->reqid != b->reqid) ||
|
||||
(a->mode != b->mode) ||
|
||||
(a->share != b->share) ||
|
||||
(a->aalgos != b->aalgos) ||
|
||||
(a->ealgos != b->ealgos) ||
|
||||
(a->calgos != b->calgos))
|
||||
return 1;
|
||||
/* Check for any differences */
|
||||
if ((nl_addr_cmp_prefix (a->id.daddr, b->id.daddr) != 0) ||
|
||||
(a->id.spi != b->id.spi) ||
|
||||
(a->id.proto && (a->id.proto != b->id.proto)) ||
|
||||
(nl_addr_cmp_prefix (a->saddr, b->saddr) != 0) ||
|
||||
(a->family != b->family) ||
|
||||
(a->reqid != b->reqid) ||
|
||||
(a->mode != b->mode) ||
|
||||
(a->share != b->share) ||
|
||||
(a->aalgos != b->aalgos) ||
|
||||
(a->ealgos != b->ealgos) ||
|
||||
(a->calgos != b->calgos))
|
||||
return 1;
|
||||
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
/* The objects are identical */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xfrmnl_user_tmpl_dump(struct xfrmnl_user_tmpl* tmpl, struct nl_dump_params *p)
|
||||
{
|
||||
char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
|
||||
char buf [128];
|
||||
char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
|
||||
char buf [128];
|
||||
|
||||
nl_dump_line(p, "\t\tsrc %s dst %s family: %s \n",
|
||||
nl_addr2str(tmpl->saddr, src, sizeof(src)),
|
||||
nl_addr2str (tmpl->id.daddr, dst, sizeof (dst)),
|
||||
nl_af2str (tmpl->family, buf, 128));
|
||||
nl_dump_line (p, "\t\tprotocol: %s spi: 0x%x reqid: %u mode: %s\n",
|
||||
nl_ip_proto2str (tmpl->id.proto, buf, sizeof(buf)),
|
||||
tmpl->id.spi, tmpl->reqid,
|
||||
xfrmnl_user_tmpl_mode2str (tmpl->mode, buf, 128));
|
||||
nl_dump_line (p, "\t\tAuth Algo: 0x%x Crypto Algo: 0x%x Compr Algo: 0x%x\n",
|
||||
tmpl->aalgos, tmpl->ealgos, tmpl->calgos);
|
||||
nl_dump_line(p, "\t\tsrc %s dst %s family: %s \n",
|
||||
nl_addr2str(tmpl->saddr, src, sizeof(src)),
|
||||
nl_addr2str (tmpl->id.daddr, dst, sizeof (dst)),
|
||||
nl_af2str (tmpl->family, buf, 128));
|
||||
nl_dump_line (p, "\t\tprotocol: %s spi: 0x%x reqid: %u mode: %s\n",
|
||||
nl_ip_proto2str (tmpl->id.proto, buf, sizeof(buf)),
|
||||
tmpl->id.spi, tmpl->reqid,
|
||||
xfrmnl_user_tmpl_mode2str (tmpl->mode, buf, 128));
|
||||
nl_dump_line (p, "\t\tAuth Algo: 0x%x Crypto Algo: 0x%x Compr Algo: 0x%x\n",
|
||||
tmpl->aalgos, tmpl->ealgos, tmpl->calgos);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -185,154 +185,154 @@ void xfrmnl_user_tmpl_dump(struct xfrmnl_user_tmpl* tmpl, struct nl_dump_params
|
|||
*/
|
||||
struct nl_addr* xfrmnl_user_tmpl_get_daddr (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->id.daddr;
|
||||
return utmpl->id.daddr;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_daddr (struct xfrmnl_user_tmpl* utmpl, struct nl_addr* addr)
|
||||
{
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while user template in use */
|
||||
nl_addr_get(addr);
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while user template in use */
|
||||
nl_addr_get(addr);
|
||||
|
||||
utmpl->id.daddr = addr;
|
||||
utmpl->id.daddr = addr;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_spi (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->id.spi;
|
||||
return utmpl->id.spi;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_spi (struct xfrmnl_user_tmpl* utmpl, unsigned int spi)
|
||||
{
|
||||
utmpl->id.spi = spi;
|
||||
utmpl->id.spi = spi;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_proto (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->id.proto;
|
||||
return utmpl->id.proto;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_proto (struct xfrmnl_user_tmpl* utmpl, unsigned int protocol)
|
||||
{
|
||||
utmpl->id.proto = protocol;
|
||||
utmpl->id.proto = protocol;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_family(struct xfrmnl_user_tmpl *utmpl)
|
||||
{
|
||||
return utmpl->family;
|
||||
return utmpl->family;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_family(struct xfrmnl_user_tmpl *utmpl, int family)
|
||||
{
|
||||
utmpl->family = family;
|
||||
utmpl->family = family;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct nl_addr* xfrmnl_user_tmpl_get_saddr (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->saddr;
|
||||
return utmpl->saddr;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_saddr (struct xfrmnl_user_tmpl* utmpl, struct nl_addr* addr)
|
||||
{
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while user template in use */
|
||||
nl_addr_get(addr);
|
||||
/* Increment reference counter on this to keep this address
|
||||
* object around while user template in use */
|
||||
nl_addr_get(addr);
|
||||
|
||||
utmpl->saddr = addr;
|
||||
utmpl->saddr = addr;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_reqid (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->reqid;
|
||||
return utmpl->reqid;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_reqid (struct xfrmnl_user_tmpl* utmpl, unsigned int reqid)
|
||||
{
|
||||
utmpl->reqid = reqid;
|
||||
utmpl->reqid = reqid;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_mode (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->mode;
|
||||
return utmpl->mode;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_mode (struct xfrmnl_user_tmpl* utmpl, unsigned int mode)
|
||||
{
|
||||
utmpl->mode = mode;
|
||||
utmpl->mode = mode;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_share (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->share;
|
||||
return utmpl->share;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_share (struct xfrmnl_user_tmpl* utmpl, unsigned int share)
|
||||
{
|
||||
utmpl->share = share;
|
||||
utmpl->share = share;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_optional (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->optional;
|
||||
return utmpl->optional;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_optional (struct xfrmnl_user_tmpl* utmpl, unsigned int optional)
|
||||
{
|
||||
utmpl->optional = optional;
|
||||
utmpl->optional = optional;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_aalgos (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->aalgos;
|
||||
return utmpl->aalgos;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_aalgos (struct xfrmnl_user_tmpl* utmpl, unsigned int aalgos)
|
||||
{
|
||||
utmpl->aalgos = aalgos;
|
||||
utmpl->aalgos = aalgos;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_ealgos (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->ealgos;
|
||||
return utmpl->ealgos;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_ealgos (struct xfrmnl_user_tmpl* utmpl, unsigned int ealgos)
|
||||
{
|
||||
utmpl->ealgos = ealgos;
|
||||
utmpl->ealgos = ealgos;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_get_calgos (struct xfrmnl_user_tmpl* utmpl)
|
||||
{
|
||||
return utmpl->calgos;
|
||||
return utmpl->calgos;
|
||||
}
|
||||
|
||||
int xfrmnl_user_tmpl_set_calgos (struct xfrmnl_user_tmpl* utmpl, unsigned int calgos)
|
||||
{
|
||||
utmpl->calgos = calgos;
|
||||
utmpl->calgos = calgos;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Reference in a new issue