LIBNPF(3) | Library Functions Manual | LIBNPF(3) |
nl_config_t *
npf_config_create(void);
int
npf_config_submit(nl_config_t *ncf, int fd);
void
npf_config_destroy(nl_config_t *ncf);
int
npf_config_flush(int fd);
nl_rule_t *
npf_rule_create(char *name, uint32_t attr, const char *ifname);
int
npf_rule_setcode(nl_rule_t *rl, int type, const void *code, size_t len);
int
npf_rule_setkey(nl_rule_t *rl, int type, const void *code, size_t len);
bool
npf_rule_exists_p(nl_config_t *ncf, const char *name);
int
npf_rule_insert(nl_config_t *ncf, nl_rule_t *parent, nl_rule_t *rl);
int
npf_rule_setprio(nl_rule_t *rl, pri_t pri);
int
npf_rule_setproc(nl_config_t *ncf, nl_rule_t *rl, const char *name);
void
npf_rule_destroy(nl_rule_t *rl);
nl_rproc_t *
npf_rproc_create(char *name);
bool
npf_rproc_exists_p(nl_config_t *ncf, const char *name);
int
npf_rproc_insert(nl_config_t *ncf, nl_rproc_t *rp);
nl_nat_t *
npf_nat_create(int type, u_int flags, const char *ifname, npf_addr_t *addr, int af, in_port_t port);
int
npf_nat_insert(nl_config_t *ncf, nl_nat_t *nt, pri_t pri);
nl_table_t *
npf_table_create(const char *name, u_int id, int type);
int
npf_table_add_entry(nl_table_t *tl, int af, in_addr_t addr, in_addr_t mask);
int
npf_table_insert(nl_config_t *ncf, nl_table_t *tl);
void
npf_table_destroy(nl_table_t *tl);
Interface is specified by ifname, which is a string. NULL indicates any interface.
Priority is the order of the rule in the ruleset. Lower value means first to process, higher value - last to process. If multiple rules are inserted with the same priority, the order is unspecified.
The special constants NPF_PRI_FIRST and NPF_PRI_LAST can be passed to indicate that the rule should be inserted into the beginning or the end of the priority level 0 in the ruleset. All rules inserted using these constants will have the priority 0 assigned and will share this level in the ordered way.
A bi-directional NAT is obtained by combining two policies. The following flags are supported:
Translation address is specified by addr, and its family by af. Family must be either AF_INET for IPv4 or AF_INET6 for IPv6 address.
August 2, 2014 | NetBSD 7.2 |