42#include "nl-default.h"
45#include <netlink/netlink.h>
46#include <netlink/cache.h>
47#include <netlink/object.h>
48#include <netlink/xfrm/selector.h>
49#include <netlink/xfrm/lifetime.h>
50#include <netlink/xfrm/template.h>
51#include <netlink/xfrm/sp.h>
54#include "nl-priv-dynamic-core/object-api.h"
55#include "nl-priv-dynamic-core/nl-core.h"
56#include "nl-priv-dynamic-core/cache-api.h"
57#include "nl-aux-core/nl-core.h"
58#include "nl-aux-xfrm/nl-xfrm.h"
80 uint32_t nr_user_tmpl;
87#define XFRM_SP_ATTR_SEL 0x01
88#define XFRM_SP_ATTR_LTIME_CFG 0x02
89#define XFRM_SP_ATTR_LTIME_CUR 0x04
90#define XFRM_SP_ATTR_PRIO 0x08
91#define XFRM_SP_ATTR_INDEX 0x10
92#define XFRM_SP_ATTR_DIR 0x20
93#define XFRM_SP_ATTR_ACTION 0x40
94#define XFRM_SP_ATTR_FLAGS 0x80
95#define XFRM_SP_ATTR_SHARE 0x100
96#define XFRM_SP_ATTR_POLTYPE 0x200
97#define XFRM_SP_ATTR_SECCTX 0x400
98#define XFRM_SP_ATTR_TMPL 0x800
99#define XFRM_SP_ATTR_MARK 0x1000
100#define XFRM_SP_ATTR_IF_ID 0x2000
102static struct nl_cache_ops xfrmnl_sp_ops;
103static struct nl_object_ops xfrm_sp_obj_ops;
106static void xfrm_sp_alloc_data(
struct nl_object *c)
108 struct xfrmnl_sp* sp = nl_object_priv (c);
116 nl_init_list_head(&sp->usertmpl_list);
121static void xfrm_sp_free_data(
struct nl_object *c)
123 struct xfrmnl_sp* sp = nl_object_priv (c);
129 xfrmnl_sel_put (sp->sel);
130 xfrmnl_ltime_cfg_put (sp->lft);
136 nl_list_for_each_entry_safe(utmpl, tmp, &sp->usertmpl_list, utmpl_list) {
137 xfrmnl_sp_remove_usertemplate (sp, utmpl);
138 xfrmnl_user_tmpl_free (utmpl);
142static int xfrm_sp_clone(
struct nl_object *_dst,
struct nl_object *_src)
144 struct xfrmnl_sp* dst = nl_object_priv(_dst);
145 struct xfrmnl_sp* src = nl_object_priv(_src);
152 nl_init_list_head(&dst->usertmpl_list);
167 if ((dst->sec_ctx = malloc (len)) == NULL)
169 memcpy(dst->sec_ctx, src->sec_ctx, len);
172 nl_list_for_each_entry(utmpl, &src->usertmpl_list, utmpl_list) {
176 xfrmnl_sp_add_usertemplate(dst,
new);
182static uint64_t xfrm_sp_compare(
struct nl_object *_a,
struct nl_object *_b,
183 uint64_t attrs,
int flags)
190#define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ATTR, a, b, EXPR)
192 diff |= _DIFF(XFRM_SP_ATTR_LTIME_CFG,
194 diff |= _DIFF(XFRM_SP_ATTR_PRIO, a->priority != b->priority);
195 diff |= _DIFF(XFRM_SP_ATTR_INDEX, a->index != b->index);
196 diff |= _DIFF(XFRM_SP_ATTR_DIR, a->dir != b->dir);
197 diff |= _DIFF(XFRM_SP_ATTR_ACTION, a->action != b->action);
198 diff |= _DIFF(XFRM_SP_ATTR_FLAGS, a->flags != b->flags);
199 diff |= _DIFF(XFRM_SP_ATTR_SHARE, a->share != b->share);
200 diff |= _DIFF(XFRM_SP_ATTR_SECCTX,
201 ((a->sec_ctx->len != b->sec_ctx->len) ||
202 (a->sec_ctx->exttype != b->sec_ctx->exttype) ||
203 (a->sec_ctx->ctx_alg != b->sec_ctx->ctx_alg) ||
204 (a->sec_ctx->ctx_doi != b->sec_ctx->ctx_doi) ||
205 (a->sec_ctx->ctx_len != b->sec_ctx->ctx_len) ||
206 strcmp(a->sec_ctx->ctx, b->sec_ctx->ctx)));
207 diff |= _DIFF(XFRM_SP_ATTR_POLTYPE, (a->uptype.type != b->uptype.type));
208 diff |= _DIFF(XFRM_SP_ATTR_TMPL, (a->nr_user_tmpl != b->nr_user_tmpl));
209 diff |= _DIFF(XFRM_SP_ATTR_MARK,
210 (a->mark.m != b->mark.m) || (a->mark.v != b->mark.v));
211 diff |= _DIFF(XFRM_SP_ATTR_IF_ID, a->if_id != b->if_id);
214 nl_list_for_each_entry(tmpl_b, &b->usertmpl_list, utmpl_list)
215 nl_list_for_each_entry(tmpl_a, &a->usertmpl_list, utmpl_list)
226static const struct trans_tbl sp_attrs[] = {
227 __ADD(XFRM_SP_ATTR_SEL, selector),
228 __ADD(XFRM_SP_ATTR_LTIME_CFG, lifetime_cfg),
229 __ADD(XFRM_SP_ATTR_LTIME_CUR, lifetime_cur),
230 __ADD(XFRM_SP_ATTR_PRIO, priority),
231 __ADD(XFRM_SP_ATTR_INDEX, index),
232 __ADD(XFRM_SP_ATTR_DIR, direction),
233 __ADD(XFRM_SP_ATTR_ACTION, action),
234 __ADD(XFRM_SP_ATTR_FLAGS, flags),
235 __ADD(XFRM_SP_ATTR_SHARE, share),
236 __ADD(XFRM_SP_ATTR_POLTYPE, policy_type),
237 __ADD(XFRM_SP_ATTR_SECCTX, security_context),
238 __ADD(XFRM_SP_ATTR_TMPL, user_template),
239 __ADD(XFRM_SP_ATTR_MARK, mark),
240 __ADD(XFRM_SP_ATTR_IF_ID, if_id),
243static char* xfrm_sp_attrs2str(
int attrs,
char *buf,
size_t len)
245 return __flags2str (attrs, buf, len, sp_attrs, ARRAY_SIZE(sp_attrs));
253static const struct trans_tbl sa_actions[] = {
254 __ADD(XFRM_POLICY_ALLOW, allow),
255 __ADD(XFRM_POLICY_BLOCK, block),
258char* xfrmnl_sp_action2str(
int action,
char *buf,
size_t len)
260 return __type2str (action, buf, len, sa_actions, ARRAY_SIZE(sa_actions));
263int xfrmnl_sp_str2action(
const char *name)
265 return __str2type (name, sa_actions, ARRAY_SIZE(sa_actions));
273static const struct trans_tbl sp_flags[] = {
274 __ADD(XFRM_POLICY_LOCALOK, allow policy
override by user),
275 __ADD(XFRM_POLICY_ICMP,
auto include ICMP in policy),
278char* xfrmnl_sp_flags2str(
int flags,
char *buf,
size_t len)
280 return __flags2str (flags, buf, len, sp_flags, ARRAY_SIZE(sp_flags));
283int xfrmnl_sp_str2flag(
const char *name)
285 return __str2flags(name, sp_flags, ARRAY_SIZE(sp_flags));
293static const struct trans_tbl sp_types[] = {
294 __ADD(XFRM_POLICY_TYPE_MAIN, main),
295 __ADD(XFRM_POLICY_TYPE_SUB, sub),
296 __ADD(XFRM_POLICY_TYPE_MAX, max),
297 __ADD(XFRM_POLICY_TYPE_ANY, any),
300char* xfrmnl_sp_type2str(
int type,
char *buf,
size_t len)
302 return __type2str(type, buf, len, sp_types, ARRAY_SIZE(sp_types));
305int xfrmnl_sp_str2type(
const char *name)
307 return __str2type(name, sp_types, ARRAY_SIZE(sp_types));
315static const struct trans_tbl sp_dir[] = {
316 __ADD(XFRM_POLICY_IN, in),
317 __ADD(XFRM_POLICY_OUT, out),
318 __ADD(XFRM_POLICY_FWD, fwd),
319 __ADD(XFRM_POLICY_MASK, mask),
322char* xfrmnl_sp_dir2str(
int dir,
char *buf,
size_t len)
324 return __type2str (dir, buf, len, sp_dir, ARRAY_SIZE(sp_dir));
327int xfrmnl_sp_str2dir(
const char *name)
329 return __str2type (name, sp_dir, ARRAY_SIZE(sp_dir));
332int xfrmnl_sp_index2dir (
unsigned int index)
342static const struct trans_tbl sp_share[] = {
343 __ADD(XFRM_SHARE_ANY, any),
344 __ADD(XFRM_SHARE_SESSION, session),
345 __ADD(XFRM_SHARE_USER, user),
346 __ADD(XFRM_SHARE_UNIQUE, unique),
349char* xfrmnl_sp_share2str(
int share,
char *buf,
size_t len)
351 return __type2str (share, buf, len, sp_share, ARRAY_SIZE(sp_share));
354int xfrmnl_sp_str2share(
const char *name)
356 return __str2type (name, sp_share, ARRAY_SIZE(sp_share));
360static void xfrm_sp_dump_line(
struct nl_object *a,
struct nl_dump_params *p)
363 char dir[32], action[32], share[32], flags[32];
364 char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
365 time_t add_time, use_time;
366 struct tm *add_time_tm, *use_time_tm;
369 nl_addr2str(xfrmnl_sel_get_saddr (sp->sel), src,
sizeof(src));
370 nl_addr2str (xfrmnl_sel_get_daddr (sp->sel), dst, sizeof (dst));
371 nl_af2str (xfrmnl_sel_get_family (sp->sel), dir, 32);
372 nl_dump_line(p,
"src %s dst %s family: %s\n", src, dst, dir);
373 nl_dump_line (p,
"src port/mask: %d/%d dst port/mask: %d/%d\n",
374 xfrmnl_sel_get_dport (sp->sel), xfrmnl_sel_get_dportmask (sp->sel),
375 xfrmnl_sel_get_sport (sp->sel), xfrmnl_sel_get_sportmask (sp->sel));
376 nl_dump_line (p,
"protocol: %s ifindex: %u uid: %u\n",
377 nl_ip_proto2str (xfrmnl_sel_get_proto (sp->sel), dir,
sizeof(dir)),
378 xfrmnl_sel_get_ifindex (sp->sel),
379 xfrmnl_sel_get_userid (sp->sel));
381 xfrmnl_sp_dir2str (sp->dir, dir, 32);
382 xfrmnl_sp_action2str (sp->action, action, 32);
383 xfrmnl_sp_share2str (sp->share, share, 32);
384 xfrmnl_sp_flags2str (sp->flags, flags, 32);
385 nl_dump_line(p,
"\tdir: %s action: %s index: %u priority: %u share: %s flags: %s(0x%x) \n",
386 dir, action, sp->index, sp->priority, share, flags, sp->flags);
388 nl_dump_line(p,
"\tlifetime configuration: \n");
389 if (sp->lft->soft_byte_limit == XFRM_INF)
390 sprintf (dir,
"INF");
392 sprintf (dir,
"%" PRIu64, sp->lft->soft_byte_limit);
393 if (sp->lft->soft_packet_limit == XFRM_INF)
394 sprintf (action,
"INF");
396 sprintf (action,
"%" PRIu64, sp->lft->soft_packet_limit);
397 if (sp->lft->hard_byte_limit == XFRM_INF)
398 sprintf (flags,
"INF");
400 sprintf (flags,
"%" PRIu64, sp->lft->hard_byte_limit);
401 if (sp->lft->hard_packet_limit == XFRM_INF)
402 sprintf (share,
"INF");
404 sprintf (share,
"%" PRIu64, sp->lft->hard_packet_limit);
405 nl_dump_line(p,
"\t\tsoft limit: %s (bytes), %s (packets) \n", dir,
407 nl_dump_line(p,
"\t\thard limit: %s (bytes), %s (packets) \n", flags,
411 "\t\tsoft add_time: %llu (seconds), soft use_time: %llu (seconds) \n",
412 (
long long unsigned)sp->lft->soft_add_expires_seconds,
413 (
long long unsigned)sp->lft->soft_use_expires_seconds);
416 "\t\thard add_time: %llu (seconds), hard use_time: %llu (seconds) \n",
417 (
long long unsigned)sp->lft->hard_add_expires_seconds,
418 (
long long unsigned)sp->lft->hard_use_expires_seconds);
420 nl_dump_line(p,
"\tlifetime current: \n");
421 nl_dump_line(p,
"\t\t%llu bytes, %llu packets\n",
422 (
long long unsigned)sp->curlft.bytes,
423 (
long long unsigned)sp->curlft.packets);
425 if (sp->curlft.add_time != 0)
427 add_time = sp->curlft.add_time;
428 add_time_tm = gmtime_r (&add_time, &tm_buf);
429 strftime (dst, INET6_ADDRSTRLEN+5,
"%Y-%m-%d %H-%M-%S", add_time_tm);
433 sprintf (dst,
"%s",
"-");
436 if (sp->curlft.use_time != 0)
438 use_time = sp->curlft.use_time;
439 use_time_tm = gmtime_r (&use_time, &tm_buf);
440 strftime (src, INET6_ADDRSTRLEN+5,
"%Y-%m-%d %H-%M-%S", use_time_tm);
444 sprintf (src,
"%s",
"-");
446 nl_dump_line(p,
"\t\tadd_time: %s, use_time: %s\n", dst, src);
448 if (sp->ce_mask & XFRM_SP_ATTR_SECCTX)
450 nl_dump_line(p,
"\tUser security context: \n");
451 nl_dump_line(p,
"\t\tlen: %d exttype: %d Algo: %d DOI: %d ctxlen: %d\n",
452 sp->sec_ctx->len, sp->sec_ctx->exttype,
453 sp->sec_ctx->ctx_alg, sp->sec_ctx->ctx_doi, sp->sec_ctx->ctx_len);
454 nl_dump_line (p,
"\t\tctx: %s \n", sp->sec_ctx->ctx);
457 xfrmnl_sp_type2str (sp->uptype.type, flags, 32);
458 if (sp->ce_mask & XFRM_SP_ATTR_POLTYPE)
459 nl_dump_line(p,
"\tUser policy type: %s\n", flags);
461 if (sp->ce_mask & XFRM_SP_ATTR_TMPL)
465 nl_dump_line(p,
"\tUser template: \n");
467 nl_list_for_each_entry(utmpl, &sp->usertmpl_list, utmpl_list)
468 xfrmnl_user_tmpl_dump (utmpl, p);
471 if (sp->ce_mask & XFRM_SP_ATTR_MARK)
472 nl_dump_line(p,
"\tMark mask: 0x%x Mark value: 0x%x\n", sp->mark.m, sp->mark.v);
475 if (sp->ce_mask & XFRM_SP_ATTR_IF_ID)
476 nl_dump_line(p,
"\tXFRM interface ID: 0x%x\n", sp->if_id);
481static void xfrm_sp_dump_details(
struct nl_object *a,
struct nl_dump_params *p)
483 xfrm_sp_dump_line(a, p);
486static void xfrm_sp_dump_stats(
struct nl_object *a,
struct nl_dump_params *p)
488 xfrm_sp_dump_details(a, p);
525int xfrmnl_sp_alloc_cache(
struct nl_sock *sock,
struct nl_cache **result)
537struct xfrmnl_sp* xfrmnl_sp_get(
struct nl_cache* cache,
unsigned int index,
unsigned int dir)
546 if (sp->index == index && sp->dir == dir)
560static struct nla_policy xfrm_sp_policy[XFRMA_MAX+1] = {
561 [XFRMA_POLICY] = { .minlen =
sizeof(
struct xfrm_userpolicy_info)},
562 [XFRMA_SEC_CTX] = { .minlen =
sizeof(
struct xfrm_sec_ctx) },
563 [XFRMA_TMPL] = { .minlen =
sizeof(
struct xfrm_user_tmpl) },
564 [XFRMA_POLICY_TYPE] = { .minlen =
sizeof(
struct xfrm_userpolicy_type)},
565 [XFRMA_MARK] = { .minlen =
sizeof(
struct xfrm_mark) },
566 [XFRMA_IF_ID] = { .type =
NLA_U32 },
569static int xfrm_sp_request_update(
struct nl_cache *c,
struct nl_sock *h)
571 return nl_send_simple (h, XFRM_MSG_GETPOLICY, NLM_F_DUMP, NULL, 0);
574int xfrmnl_sp_parse(
struct nlmsghdr *n,
struct xfrmnl_sp **result)
576 _nl_auto_nl_addr
struct nl_addr *addr1 = NULL;
577 _nl_auto_nl_addr
struct nl_addr *addr2 = NULL;
578 _nl_auto_xfrmnl_sp
struct xfrmnl_sp *sp = NULL;
579 struct nlattr *tb[XFRMA_MAX + 1];
580 struct xfrm_userpolicy_info *sp_info;
583 sp = xfrmnl_sp_alloc();
587 sp->ce_msgtype = n->nlmsg_type;
588 if (n->nlmsg_type == XFRM_MSG_DELPOLICY)
589 sp_info = (
struct xfrm_userpolicy_info*)((
char *)
nlmsg_data(n) +
sizeof (
struct xfrm_userpolicy_id) + NLA_HDRLEN);
593 err =
nlmsg_parse(n,
sizeof(
struct xfrm_userpolicy_info), tb, XFRMA_MAX, xfrm_sp_policy);
597 if (!(addr1 = _nl_addr_build(sp_info->sel.family, &sp_info->sel.daddr)))
600 xfrmnl_sel_set_daddr (sp->sel, addr1);
601 xfrmnl_sel_set_prefixlen_d (sp->sel, sp_info->sel.prefixlen_d);
603 if (!(addr2 = _nl_addr_build(sp_info->sel.family, &sp_info->sel.saddr)))
606 xfrmnl_sel_set_saddr (sp->sel, addr2);
607 xfrmnl_sel_set_prefixlen_s (sp->sel, sp_info->sel.prefixlen_s);
609 xfrmnl_sel_set_dport (sp->sel, ntohs (sp_info->sel.dport));
610 xfrmnl_sel_set_dportmask (sp->sel, ntohs (sp_info->sel.dport_mask));
611 xfrmnl_sel_set_sport (sp->sel, ntohs (sp_info->sel.sport));
612 xfrmnl_sel_set_sportmask (sp->sel, ntohs (sp_info->sel.sport_mask));
613 xfrmnl_sel_set_family (sp->sel, sp_info->sel.family);
614 xfrmnl_sel_set_proto (sp->sel, sp_info->sel.proto);
615 xfrmnl_sel_set_ifindex (sp->sel, sp_info->sel.ifindex);
616 xfrmnl_sel_set_userid (sp->sel, sp_info->sel.user);
617 sp->ce_mask |= XFRM_SP_ATTR_SEL;
619 sp->lft->soft_byte_limit = sp_info->lft.soft_byte_limit;
620 sp->lft->hard_byte_limit = sp_info->lft.hard_byte_limit;
621 sp->lft->soft_packet_limit = sp_info->lft.soft_packet_limit;
622 sp->lft->hard_packet_limit = sp_info->lft.hard_packet_limit;
623 sp->lft->soft_add_expires_seconds = sp_info->lft.soft_add_expires_seconds;
624 sp->lft->hard_add_expires_seconds = sp_info->lft.hard_add_expires_seconds;
625 sp->lft->soft_use_expires_seconds = sp_info->lft.soft_use_expires_seconds;
626 sp->lft->hard_use_expires_seconds = sp_info->lft.hard_use_expires_seconds;
627 sp->ce_mask |= XFRM_SP_ATTR_LTIME_CFG;
629 sp->curlft.bytes = sp_info->curlft.bytes;
630 sp->curlft.packets = sp_info->curlft.packets;
631 sp->curlft.add_time = sp_info->curlft.add_time;
632 sp->curlft.use_time = sp_info->curlft.use_time;
633 sp->ce_mask |= XFRM_SP_ATTR_LTIME_CUR;
635 sp->priority = sp_info->priority;
636 sp->index = sp_info->index;
637 sp->dir = sp_info->dir;
638 sp->action = sp_info->action;
639 sp->flags = sp_info->flags;
640 sp->share = sp_info->share;
641 sp->ce_mask |= (XFRM_SP_ATTR_PRIO | XFRM_SP_ATTR_INDEX |
642 XFRM_SP_ATTR_DIR | XFRM_SP_ATTR_ACTION |
643 XFRM_SP_ATTR_FLAGS | XFRM_SP_ATTR_SHARE);
645 if (tb[XFRMA_SEC_CTX]) {
646 struct xfrm_user_sec_ctx* ctx =
nla_data(tb[XFRMA_SEC_CTX]);
649 if ((sp->sec_ctx = calloc (1, len)) == NULL)
651 memcpy ((
void *)sp->sec_ctx, (
void *)ctx, len);
652 sp->ce_mask |= XFRM_SP_ATTR_SECCTX;
655 if (tb[XFRMA_POLICY_TYPE]) {
656 struct xfrm_userpolicy_type* up =
nla_data(tb[XFRMA_POLICY_TYPE]);
658 memcpy ((
void *)&sp->uptype, (
void *)up, sizeof (
struct xfrm_userpolicy_type));
659 sp->ce_mask |= XFRM_SP_ATTR_POLTYPE;
662 if (tb[XFRMA_TMPL]) {
663 struct xfrm_user_tmpl* tmpl =
nla_data(tb[XFRMA_TMPL]);
665 uint32_t num_tmpls =
nla_len(tb[XFRMA_TMPL]) /
sizeof (*tmpl);
667 for (i = 0; (i < num_tmpls) && (tmpl); i ++, tmpl++)
670 _nl_auto_nl_addr
struct nl_addr *addr1 = NULL;
671 _nl_auto_nl_addr
struct nl_addr *addr2 = NULL;
676 if (!(addr1 = _nl_addr_build(tmpl->family, &tmpl->id.daddr)))
678 xfrmnl_user_tmpl_set_daddr (sputmpl, addr1);
679 xfrmnl_user_tmpl_set_spi (sputmpl, ntohl(tmpl->id.spi));
680 xfrmnl_user_tmpl_set_proto (sputmpl, tmpl->id.proto);
681 xfrmnl_user_tmpl_set_family (sputmpl, tmpl->family);
683 if (!(addr2 = _nl_addr_build(tmpl->family, &tmpl->saddr)))
685 xfrmnl_user_tmpl_set_saddr (sputmpl, addr2);
687 xfrmnl_user_tmpl_set_reqid (sputmpl, tmpl->reqid);
688 xfrmnl_user_tmpl_set_mode (sputmpl, tmpl->mode);
689 xfrmnl_user_tmpl_set_share (sputmpl, tmpl->share);
690 xfrmnl_user_tmpl_set_optional (sputmpl, tmpl->optional);
691 xfrmnl_user_tmpl_set_aalgos (sputmpl, tmpl->aalgos);
692 xfrmnl_user_tmpl_set_ealgos (sputmpl, tmpl->ealgos);
693 xfrmnl_user_tmpl_set_calgos (sputmpl, tmpl->calgos);
694 xfrmnl_sp_add_usertemplate (sp, _nl_steal_pointer(&sputmpl));
696 sp->ce_mask |= XFRM_SP_ATTR_TMPL;
700 if (tb[XFRMA_MARK]) {
701 struct xfrm_mark* m =
nla_data(tb[XFRMA_MARK]);
704 sp->ce_mask |= XFRM_SP_ATTR_MARK;
707 if (tb[XFRMA_IF_ID]) {
709 sp->ce_mask |= XFRM_SP_ATTR_IF_ID;
712 *result = _nl_steal_pointer(&sp);
716static int xfrm_sp_msg_parser(
struct nl_cache_ops *ops,
struct sockaddr_nl *who,
717 struct nlmsghdr *n,
struct nl_parser_param *pp)
722 if ((err = xfrmnl_sp_parse(n, &sp)) < 0)
724 printf (
"received error: %d \n", err);
728 err = pp->pp_cb((
struct nl_object *) sp, pp);
739int xfrmnl_sp_build_get_request(
unsigned int index,
unsigned int dir,
unsigned int mark_v,
unsigned int mark_m,
struct nl_msg **result)
742 struct xfrm_userpolicy_id spid;
743 struct xfrm_mark mark;
745 memset(&spid, 0,
sizeof(spid));
752 if (
nlmsg_append(msg, &spid,
sizeof(spid), NLMSG_ALIGNTO) < 0)
753 goto nla_put_failure;
755 if ((mark_m & mark_v) != 0)
757 memset(&mark, 0,
sizeof(
struct xfrm_mark));
761 NLA_PUT (msg, XFRMA_MARK,
sizeof (
struct xfrm_mark), &mark);
772int xfrmnl_sp_get_kernel(
struct nl_sock* sock,
unsigned int index,
unsigned int dir,
unsigned int mark_v,
unsigned int mark_m,
struct xfrmnl_sp** result)
774 struct nl_msg *msg = NULL;
775 struct nl_object *obj;
778 if ((err = xfrmnl_sp_build_get_request(index, dir, mark_m, mark_v, &msg)) < 0)
786 if ((err =
nl_pickup(sock, &xfrm_sp_msg_parser, &obj)) < 0)
801static int build_xfrm_sp_message(
struct xfrmnl_sp *tmpl,
int cmd,
int flags,
struct nl_msg **result)
804 struct xfrm_userpolicy_info sp_info;
806 struct nl_addr* addr;
808 if (!(tmpl->ce_mask & XFRM_SP_ATTR_DIR) ||
809 (!(tmpl->ce_mask & XFRM_SP_ATTR_INDEX) &&
810 !(tmpl->ce_mask & XFRM_SP_ATTR_SEL)))
811 return -NLE_MISSING_ATTR;
813 memset ((
void*)&sp_info, 0,
sizeof (sp_info));
814 if (tmpl->ce_mask & XFRM_SP_ATTR_SEL)
816 addr = xfrmnl_sel_get_daddr (tmpl->sel);
818 addr = xfrmnl_sel_get_saddr (tmpl->sel);
820 sp_info.sel.dport = htons (xfrmnl_sel_get_dport (tmpl->sel));
821 sp_info.sel.dport_mask = htons (xfrmnl_sel_get_dportmask (tmpl->sel));
822 sp_info.sel.sport = htons (xfrmnl_sel_get_sport (tmpl->sel));
823 sp_info.sel.sport_mask = htons (xfrmnl_sel_get_sportmask (tmpl->sel));
824 sp_info.sel.family = xfrmnl_sel_get_family (tmpl->sel);
825 sp_info.sel.prefixlen_d = xfrmnl_sel_get_prefixlen_d (tmpl->sel);
826 sp_info.sel.prefixlen_s = xfrmnl_sel_get_prefixlen_s (tmpl->sel);
827 sp_info.sel.proto = xfrmnl_sel_get_proto (tmpl->sel);
828 sp_info.sel.ifindex = xfrmnl_sel_get_ifindex (tmpl->sel);
829 sp_info.sel.user = xfrmnl_sel_get_userid (tmpl->sel);
832 if (tmpl->ce_mask & XFRM_SP_ATTR_LTIME_CFG)
834 sp_info.lft.soft_byte_limit = xfrmnl_ltime_cfg_get_soft_bytelimit (tmpl->lft);
835 sp_info.lft.hard_byte_limit = xfrmnl_ltime_cfg_get_hard_bytelimit (tmpl->lft);
836 sp_info.lft.soft_packet_limit = xfrmnl_ltime_cfg_get_soft_packetlimit (tmpl->lft);
837 sp_info.lft.hard_packet_limit = xfrmnl_ltime_cfg_get_hard_packetlimit (tmpl->lft);
838 sp_info.lft.soft_add_expires_seconds = xfrmnl_ltime_cfg_get_soft_addexpires (tmpl->lft);
839 sp_info.lft.hard_add_expires_seconds = xfrmnl_ltime_cfg_get_hard_addexpires (tmpl->lft);
840 sp_info.lft.soft_use_expires_seconds = xfrmnl_ltime_cfg_get_soft_useexpires (tmpl->lft);
841 sp_info.lft.hard_use_expires_seconds = xfrmnl_ltime_cfg_get_hard_useexpires (tmpl->lft);
846 if (tmpl->ce_mask & XFRM_SP_ATTR_PRIO)
847 sp_info.priority = tmpl->priority;
849 if (tmpl->ce_mask & XFRM_SP_ATTR_INDEX)
850 sp_info.index = tmpl->index;
852 if (tmpl->ce_mask & XFRM_SP_ATTR_DIR)
853 sp_info.dir = tmpl->dir;
855 if (tmpl->ce_mask & XFRM_SP_ATTR_ACTION)
856 sp_info.action = tmpl->action;
858 if (tmpl->ce_mask & XFRM_SP_ATTR_FLAGS)
859 sp_info.flags = tmpl->flags;
861 if (tmpl->ce_mask & XFRM_SP_ATTR_SHARE)
862 sp_info.share = tmpl->share;
868 if (
nlmsg_append(msg, &sp_info,
sizeof(sp_info), NLMSG_ALIGNTO) < 0)
869 goto nla_put_failure;
871 if (tmpl->ce_mask & XFRM_SP_ATTR_SECCTX) {
872 len = (
sizeof (
struct xfrm_user_sec_ctx)) + tmpl->sec_ctx->ctx_len;
873 NLA_PUT (msg, XFRMA_SEC_CTX, len, tmpl->sec_ctx);
876 if (tmpl->ce_mask & XFRM_SP_ATTR_POLTYPE) {
877 len =
sizeof (
struct xfrm_userpolicy_type);
878 NLA_PUT (msg, XFRMA_POLICY_TYPE, len, &tmpl->uptype);
881 if (tmpl->ce_mask & XFRM_SP_ATTR_TMPL) {
882 struct nlattr* tmpls;
884 struct nl_addr* addr;
887 goto nla_put_failure;
889 nl_list_for_each_entry(utmpl, &tmpl->usertmpl_list, utmpl_list) {
890 struct xfrm_user_tmpl* tmpl;
894 goto nla_put_failure;
895 addr = xfrmnl_user_tmpl_get_daddr (utmpl);
898 tmpl->id.spi = htonl(xfrmnl_user_tmpl_get_spi (utmpl));
899 tmpl->id.proto = xfrmnl_user_tmpl_get_proto (utmpl);
900 tmpl->family = xfrmnl_user_tmpl_get_family (utmpl);
901 addr = xfrmnl_user_tmpl_get_saddr (utmpl);
904 tmpl->reqid = xfrmnl_user_tmpl_get_reqid (utmpl);
905 tmpl->mode = xfrmnl_user_tmpl_get_mode (utmpl);
906 tmpl->share = xfrmnl_user_tmpl_get_share (utmpl);
907 tmpl->optional = xfrmnl_user_tmpl_get_optional (utmpl);
908 tmpl->aalgos = xfrmnl_user_tmpl_get_aalgos (utmpl);
909 tmpl->ealgos = xfrmnl_user_tmpl_get_ealgos (utmpl);
910 tmpl->calgos = xfrmnl_user_tmpl_get_calgos (utmpl);
915 if (tmpl->ce_mask & XFRM_SP_ATTR_MARK) {
916 NLA_PUT (msg, XFRMA_MARK,
sizeof (
struct xfrm_mark), &tmpl->mark);
919 if (tmpl->ce_mask & XFRM_SP_ATTR_IF_ID) {
936int xfrmnl_sp_build_add_request(
struct xfrmnl_sp* tmpl,
int flags,
struct nl_msg **result)
938 return build_xfrm_sp_message (tmpl, XFRM_MSG_NEWPOLICY, flags, result);
941int xfrmnl_sp_add(
struct nl_sock* sk,
struct xfrmnl_sp* tmpl,
int flags)
946 if ((err = xfrmnl_sp_build_add_request(tmpl, flags, &msg)) < 0)
962int xfrmnl_sp_build_update_request(
struct xfrmnl_sp* tmpl,
int flags,
struct nl_msg **result)
964 return build_xfrm_sp_message (tmpl, XFRM_MSG_UPDPOLICY, flags, result);
967int xfrmnl_sp_update(
struct nl_sock* sk,
struct xfrmnl_sp* tmpl,
int flags)
972 if ((err = xfrmnl_sp_build_update_request(tmpl, flags, &msg)) < 0)
998static int build_xfrm_sp_delete_message(
struct xfrmnl_sp *tmpl,
int cmd,
int flags,
struct nl_msg **result)
1001 struct xfrm_userpolicy_id spid;
1002 struct nl_addr* addr;
1005 if (!(tmpl->ce_mask & XFRM_SP_ATTR_DIR) ||
1006 (!(tmpl->ce_mask & XFRM_SP_ATTR_INDEX) &&
1007 !(tmpl->ce_mask & XFRM_SP_ATTR_SEL)))
1008 return -NLE_MISSING_ATTR;
1010 memset(&spid, 0,
sizeof(spid));
1011 spid.dir = tmpl->dir;
1012 if(tmpl->ce_mask & XFRM_SP_ATTR_INDEX)
1013 spid.index = tmpl->index;
1015 if (tmpl->ce_mask & XFRM_SP_ATTR_SEL)
1017 addr = xfrmnl_sel_get_daddr (tmpl->sel);
1019 addr = xfrmnl_sel_get_saddr (tmpl->sel);
1021 spid.sel.dport = htons (xfrmnl_sel_get_dport (tmpl->sel));
1022 spid.sel.dport_mask = htons (xfrmnl_sel_get_dportmask (tmpl->sel));
1023 spid.sel.sport = htons (xfrmnl_sel_get_sport (tmpl->sel));
1024 spid.sel.sport_mask = htons (xfrmnl_sel_get_sportmask (tmpl->sel));
1025 spid.sel.family = xfrmnl_sel_get_family (tmpl->sel);
1026 spid.sel.prefixlen_d = xfrmnl_sel_get_prefixlen_d (tmpl->sel);
1027 spid.sel.prefixlen_s = xfrmnl_sel_get_prefixlen_s (tmpl->sel);
1028 spid.sel.proto = xfrmnl_sel_get_proto (tmpl->sel);
1029 spid.sel.ifindex = xfrmnl_sel_get_ifindex (tmpl->sel);
1030 spid.sel.user = xfrmnl_sel_get_userid (tmpl->sel);
1037 if (
nlmsg_append(msg, &spid,
sizeof(spid), NLMSG_ALIGNTO) < 0)
1038 goto nla_put_failure;
1040 if (tmpl->ce_mask & XFRM_SP_ATTR_SECCTX) {
1041 len = (
sizeof (
struct xfrm_user_sec_ctx)) + tmpl->sec_ctx->ctx_len;
1042 NLA_PUT (msg, XFRMA_SEC_CTX, len, tmpl->sec_ctx);
1045 if (tmpl->ce_mask & XFRM_SP_ATTR_MARK) {
1046 len =
sizeof (
struct xfrm_mark);
1047 NLA_PUT (msg, XFRMA_MARK, len, &tmpl->mark);
1050 if (tmpl->ce_mask & XFRM_SP_ATTR_IF_ID) {
1059 return -NLE_MSGSIZE;
1067int xfrmnl_sp_build_delete_request(
struct xfrmnl_sp* tmpl,
int flags,
struct nl_msg **result)
1069 return build_xfrm_sp_delete_message (tmpl, XFRM_MSG_DELPOLICY, flags, result);
1072int xfrmnl_sp_delete(
struct nl_sock* sk,
struct xfrmnl_sp* tmpl,
int flags)
1077 if ((err = xfrmnl_sp_build_delete_request(tmpl, flags, &msg)) < 0)
1098 if (sp->ce_mask & XFRM_SP_ATTR_SEL)
1108 xfrmnl_sel_put (sp->sel);
1111 xfrmnl_sel_get (sel);
1113 sp->ce_mask |= XFRM_SP_ATTR_SEL;
1120 if (sp->ce_mask & XFRM_SP_ATTR_LTIME_CFG)
1130 xfrmnl_ltime_cfg_put (sp->lft);
1133 xfrmnl_ltime_cfg_get (ltime);
1135 sp->ce_mask |= XFRM_SP_ATTR_LTIME_CFG;
1140int xfrmnl_sp_get_curlifetime (
struct xfrmnl_sp* sp,
unsigned long long int* curr_bytes,
1141 unsigned long long int* curr_packets,
unsigned long long int* curr_add_time,
unsigned long long int* curr_use_time)
1143 if (sp == NULL || curr_bytes == NULL || curr_packets == NULL || curr_add_time == NULL || curr_use_time == NULL)
1146 *curr_bytes = sp->curlft.bytes;
1147 *curr_packets = sp->curlft.packets;
1148 *curr_add_time = sp->curlft.add_time;
1149 *curr_use_time = sp->curlft.use_time;
1154int xfrmnl_sp_get_priority (
struct xfrmnl_sp* sp)
1156 if (sp->ce_mask & XFRM_SP_ATTR_PRIO)
1157 return sp->priority;
1162int xfrmnl_sp_set_priority (
struct xfrmnl_sp* sp,
unsigned int prio)
1164 sp->priority = prio;
1165 sp->ce_mask |= XFRM_SP_ATTR_PRIO;
1170int xfrmnl_sp_get_index (
struct xfrmnl_sp* sp)
1172 if (sp->ce_mask & XFRM_SP_ATTR_INDEX)
1178int xfrmnl_sp_set_index (
struct xfrmnl_sp* sp,
unsigned int index)
1181 sp->ce_mask |= XFRM_SP_ATTR_INDEX;
1186int xfrmnl_sp_get_dir (
struct xfrmnl_sp* sp)
1188 if (sp->ce_mask & XFRM_SP_ATTR_DIR)
1194int xfrmnl_sp_set_dir (
struct xfrmnl_sp* sp,
unsigned int dir)
1197 sp->ce_mask |= XFRM_SP_ATTR_DIR;
1202int xfrmnl_sp_get_action (
struct xfrmnl_sp* sp)
1204 if (sp->ce_mask & XFRM_SP_ATTR_ACTION)
1210int xfrmnl_sp_set_action (
struct xfrmnl_sp* sp,
unsigned int action)
1212 sp->action = action;
1213 sp->ce_mask |= XFRM_SP_ATTR_ACTION;
1218int xfrmnl_sp_get_flags (
struct xfrmnl_sp* sp)
1220 if (sp->ce_mask & XFRM_SP_ATTR_FLAGS)
1226int xfrmnl_sp_set_flags (
struct xfrmnl_sp* sp,
unsigned int flags)
1229 sp->ce_mask |= XFRM_SP_ATTR_FLAGS;
1234int xfrmnl_sp_get_share (
struct xfrmnl_sp* sp)
1236 if (sp->ce_mask & XFRM_SP_ATTR_SHARE)
1242int xfrmnl_sp_set_share (
struct xfrmnl_sp* sp,
unsigned int share)
1245 sp->ce_mask |= XFRM_SP_ATTR_SHARE;
1271int xfrmnl_sp_get_sec_ctx (
struct xfrmnl_sp* sp,
unsigned int* len,
unsigned int* exttype,
unsigned int* alg,
unsigned int* doi,
unsigned int* ctx_len,
char* ctx_str)
1273 if (sp->ce_mask & XFRM_SP_ATTR_SECCTX)
1278 *exttype = sp->sec_ctx->exttype;
1280 *alg = sp->sec_ctx->ctx_alg;
1282 *doi = sp->sec_ctx->ctx_doi;
1284 *ctx_len = sp->sec_ctx->ctx_len;
1286 memcpy ((
void *)ctx_str, (
void *)sp->sec_ctx->ctx, sp->sec_ctx->ctx_len);
1306int xfrmnl_sp_set_sec_ctx (
struct xfrmnl_sp* sp,
unsigned int len,
unsigned int exttype,
unsigned int alg,
unsigned int doi,
unsigned int ctx_len,
char* ctx_str)
1311 if ((sp->sec_ctx = calloc (1,
sizeof (
struct xfrmnl_user_sec_ctx) + 1 + ctx_len)) == NULL)
1316 sp->sec_ctx->exttype = exttype;
1317 sp->sec_ctx->ctx_alg = alg;
1318 sp->sec_ctx->ctx_doi = doi;
1319 sp->sec_ctx->ctx_len = ctx_len;
1320 memcpy ((
void *)sp->sec_ctx->ctx, (
void *)ctx_str, ctx_len);
1321 sp->sec_ctx->ctx[ctx_len] =
'\0';
1323 sp->ce_mask |= XFRM_SP_ATTR_SECCTX;
1328int xfrmnl_sp_get_userpolicy_type (
struct xfrmnl_sp* sp)
1330 if (sp->ce_mask & XFRM_SP_ATTR_POLTYPE)
1331 return sp->uptype.type;
1336int xfrmnl_sp_set_userpolicy_type (
struct xfrmnl_sp* sp,
unsigned int type)
1338 sp->uptype.type = type;
1339 sp->ce_mask |= XFRM_SP_ATTR_POLTYPE;
1346 nl_list_add_tail(&utmpl->utmpl_list, &sp->usertmpl_list);
1348 sp->ce_mask |= XFRM_SP_ATTR_TMPL;
1353 if (sp->ce_mask & XFRM_SP_ATTR_TMPL) {
1355 nl_list_del(&utmpl->utmpl_list);
1356 if (sp->nr_user_tmpl == 0)
1357 sp->ce_mask &= ~XFRM_SP_ATTR_TMPL;
1363 if (sp->ce_mask & XFRM_SP_ATTR_TMPL)
1364 return &sp->usertmpl_list;
1369int xfrmnl_sp_get_nusertemplates(
struct xfrmnl_sp *sp)
1371 if (sp->ce_mask & XFRM_SP_ATTR_TMPL)
1372 return sp->nr_user_tmpl;
1377void xfrmnl_sp_foreach_usertemplate(
struct xfrmnl_sp *r,
1383 if (r->ce_mask & XFRM_SP_ATTR_TMPL) {
1384 nl_list_for_each_entry(utmpl, &r->usertmpl_list, utmpl_list) {
1394 if (r->ce_mask & XFRM_SP_ATTR_TMPL && n >= 0 &&
1395 ((
unsigned)n) < r->nr_user_tmpl) {
1399 nl_list_for_each_entry(utmpl, &r->usertmpl_list, utmpl_list) {
1400 if (i == ((
unsigned)n))
1408int xfrmnl_sp_get_mark (
struct xfrmnl_sp* sp,
unsigned int* mark_mask,
unsigned int* mark_value)
1410 if (mark_mask == NULL || mark_value == NULL)
1413 if (sp->ce_mask & XFRM_SP_ATTR_MARK)
1415 *mark_mask = sp->mark.m;
1416 *mark_value = sp->mark.v;
1424int xfrmnl_sp_set_mark (
struct xfrmnl_sp* sp,
unsigned int value,
unsigned int mask)
1428 sp->ce_mask |= XFRM_SP_ATTR_MARK;
1433int xfrmnl_sp_get_if_id (
struct xfrmnl_sp* sp, uint32_t* if_id)
1438 if (!(sp->ce_mask & XFRM_SP_ATTR_IF_ID))
1446int xfrmnl_sp_set_if_id (
struct xfrmnl_sp* sp, uint32_t if_id)
1449 sp->ce_mask |= XFRM_SP_ATTR_IF_ID;
1456static struct nl_object_ops xfrm_sp_obj_ops = {
1457 .oo_name =
"xfrm/sp",
1459 .oo_constructor = xfrm_sp_alloc_data,
1460 .oo_free_data = xfrm_sp_free_data,
1461 .oo_clone = xfrm_sp_clone,
1467 .oo_compare = xfrm_sp_compare,
1468 .oo_attrs2str = xfrm_sp_attrs2str,
1469 .oo_id_attrs = (XFRM_SP_ATTR_SEL | XFRM_SP_ATTR_INDEX | XFRM_SP_ATTR_DIR),
1472static struct nl_af_group xfrm_sp_groups[] = {
1473 { AF_UNSPEC, XFRMNLGRP_POLICY },
1474 { END_OF_GROUP_LIST },
1477static struct nl_cache_ops xfrmnl_sp_ops = {
1478 .co_name =
"xfrm/sp",
1479 .co_hdrsize =
sizeof(
struct xfrm_userpolicy_info),
1481 { XFRM_MSG_NEWPOLICY, NL_ACT_NEW,
"new" },
1482 { XFRM_MSG_DELPOLICY, NL_ACT_DEL,
"del" },
1483 { XFRM_MSG_GETPOLICY, NL_ACT_GET,
"get" },
1484 { XFRM_MSG_UPDPOLICY, NL_ACT_NEW,
"update" },
1485 END_OF_MSGTYPES_LIST,
1487 .co_protocol = NETLINK_XFRM,
1488 .co_groups = xfrm_sp_groups,
1489 .co_request_update = xfrm_sp_request_update,
1490 .co_msg_parser = xfrm_sp_msg_parser,
1491 .co_obj_ops = &xfrm_sp_obj_ops,
1499static void _nl_init xfrm_sp_init(
void)
1504static void _nl_exit xfrm_sp_exit(
void)
struct xfrmnl_user_tmpl * xfrmnl_user_tmpl_clone(struct xfrmnl_user_tmpl *utmpl)
Clone existing user template object.
int xfrmnl_sel_cmp(struct xfrmnl_sel *a, struct xfrmnl_sel *b)
Compares two selector objects.
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.
struct xfrmnl_sel * xfrmnl_sel_alloc()
Allocate new selector object.
int xfrmnl_user_tmpl_cmp(struct xfrmnl_user_tmpl *a, struct xfrmnl_user_tmpl *b)
Compares two user template objects.
struct xfrmnl_sel * xfrmnl_sel_clone(struct xfrmnl_sel *sel)
Clone existing selector object.
struct xfrmnl_user_tmpl * xfrmnl_user_tmpl_alloc()
Allocate new user template object.
void nl_addr_set_prefixlen(struct nl_addr *addr, int prefixlen)
Set the prefix length of an abstract address.
void * nl_addr_get_binary_addr(const struct nl_addr *addr)
Get binary address of abstract address object.
char * nl_addr2str(const struct nl_addr *addr, char *buf, size_t size)
Convert abstract address object to character string.
unsigned int nl_addr_get_len(const struct nl_addr *addr)
Get length of binary address of abstract address object.
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
void * nla_data(const struct nlattr *nla)
Return pointer to the payload section.
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
int nla_len(const struct nlattr *nla)
Return length of the payload .
int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
Finalize nesting of attributes.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
struct nl_object * nl_cache_get_next(struct nl_object *obj)
Return the next element in the cache.
int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock, struct nl_cache **result)
Allocate new cache and fill it.
struct nl_object * nl_cache_get_first(struct nl_cache *cache)
Return the first element in the cache.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
void * nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
Reserve room for additional data in a netlink message.
void nlmsg_free(struct nl_msg *msg)
Release a reference from an netlink message.
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
parse attributes of a netlink message
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
int nl_send_auto(struct nl_sock *sk, struct nl_msg *msg)
Finalize and transmit Netlink message.
int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
int nl_pickup(struct nl_sock *sk, int(*parser)(struct nl_cache_ops *, struct sockaddr_nl *, struct nlmsghdr *, struct nl_parser_param *), struct nl_object **result)
Pickup netlink answer, parse is and return object.
int nl_wait_for_ack(struct nl_sock *sk)
Wait for ACK.
int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, size_t size)
Construct and transmit a Netlink message.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
@ NL_DUMP_STATS
Dump all attributes including statistics.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.