Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libnpf libnpf: add npf_rule_getid() and npf_rule_getcode().



details:   https://anonhg.NetBSD.org/src/rev/091f83434ec8
branches:  trunk
changeset: 335955:091f83434ec8
user:      rmind <rmind%NetBSD.org@localhost>
date:      Mon Feb 02 00:55:28 2015 +0000

description:
libnpf: add npf_rule_getid() and npf_rule_getcode().
Missed in the previous commit.

diffstat:

 lib/libnpf/npf.c |  27 ++++++++++++++++++++++++---
 lib/libnpf/npf.h |   4 +++-
 2 files changed, 27 insertions(+), 4 deletions(-)

diffs (68 lines):

diff -r 8e93cec37215 -r 091f83434ec8 lib/libnpf/npf.c
--- a/lib/libnpf/npf.c  Mon Feb 02 00:31:39 2015 +0000
+++ b/lib/libnpf/npf.c  Mon Feb 02 00:55:28 2015 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: npf.c,v 1.34 2014/08/24 20:37:35 rmind Exp $   */
+/*     $NetBSD: npf.c,v 1.35 2015/02/02 00:55:28 rmind Exp $   */
 
 /*-
- * Copyright (c) 2010-2014 The NetBSD Foundation, Inc.
+ * Copyright (c) 2010-2015 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This material is based upon work partially supported by The
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.34 2014/08/24 20:37:35 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.35 2015/02/02 00:55:28 rmind Exp $");
 
 #include <sys/types.h>
 #include <netinet/in_systm.h>
@@ -715,6 +715,27 @@
        return rpname;
 }
 
+uint64_t
+npf_rule_getid(nl_rule_t *rl)
+{
+       prop_dictionary_t rldict = rl->nrl_dict;
+       uint64_t id = 0;
+
+       (void)prop_dictionary_get_uint64(rldict, "id", &id);
+       return id;
+}
+
+const void *
+npf_rule_getcode(nl_rule_t *rl, int *type, size_t *len)
+{
+       prop_dictionary_t rldict = rl->nrl_dict;
+       prop_object_t obj = prop_dictionary_get(rldict, "code");
+
+       prop_dictionary_get_uint32(rldict, "code-type", (uint32_t *)type);
+       *len = prop_data_size(obj);
+       return prop_data_data_nocopy(obj);
+}
+
 int
 _npf_ruleset_list(int fd, const char *rname, nl_config_t *ncf)
 {
diff -r 8e93cec37215 -r 091f83434ec8 lib/libnpf/npf.h
--- a/lib/libnpf/npf.h  Mon Feb 02 00:31:39 2015 +0000
+++ b/lib/libnpf/npf.h  Mon Feb 02 00:55:28 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf.h,v 1.27 2014/07/23 01:25:34 rmind Exp $   */
+/*     $NetBSD: npf.h,v 1.28 2015/02/02 00:55:28 rmind Exp $   */
 
 /*-
  * Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -129,6 +129,8 @@
 const char *   npf_rule_getinterface(nl_rule_t *);
 const void *   npf_rule_getinfo(nl_rule_t *, size_t *);
 const char *   npf_rule_getproc(nl_rule_t *);
+uint64_t       npf_rule_getid(nl_rule_t *);
+const void *   npf_rule_getcode(nl_rule_t *, int *, size_t *);
 
 nl_table_t *   npf_table_iterate(nl_config_t *);
 const char *   npf_table_getname(nl_table_t *);



Home | Main Index | Thread Index | Old Index