Module Name: src Committed By: rmind Date: Mon Feb 2 00:55:28 UTC 2015
Modified Files: src/lib/libnpf: npf.c npf.h Log Message: libnpf: add npf_rule_getid() and npf_rule_getcode(). Missed in the previous commit. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/lib/libnpf/npf.c cvs rdiff -u -r1.27 -r1.28 src/lib/libnpf/npf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libnpf/npf.c diff -u src/lib/libnpf/npf.c:1.34 src/lib/libnpf/npf.c:1.35 --- src/lib/libnpf/npf.c:1.34 Sun Aug 24 20:37:35 2014 +++ src/lib/libnpf/npf.c Mon Feb 2 00:55:28 2015 @@ -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 @@ npf_rule_getproc(nl_rule_t *rl) 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) { Index: src/lib/libnpf/npf.h diff -u src/lib/libnpf/npf.h:1.27 src/lib/libnpf/npf.h:1.28 --- src/lib/libnpf/npf.h:1.27 Wed Jul 23 01:25:34 2014 +++ src/lib/libnpf/npf.h Mon Feb 2 00:55:28 2015 @@ -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 @@ uint32_t npf_rule_getattr(nl_rule_t *); 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 *);