---
name: "bsde_add_rule"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/bsde_add_rule"
---

# bsde\_add\_rule(3)

file system firewall rules list management

## NAME

**bsde\_add\_rule**, **bsde\_get\_rule**, **bsde\_set\_rule**, **bsde\_delete\_rule** – file system firewall rules list management

## LIBRARY

library “libugidfw”

## SYNOPSIS

**#include \<ugidfw.h\>**

*int*\

**bsde\_add\_rule**(*int \*rulenum*, *struct mac\_bsdextended\_rule \*rule*, *size\_t buflen*, *char \*errstr*);

*int*\

**bsde\_get\_rule**(*int rulenum*, *struct mac\_bsdextended\_rule \*rule*, *size\_t errlen*, *char \*errstr*);

*int*\

**bsde\_set\_rule**(*int rulenum*, *struct mac\_bsdextended\_rule \*rule*, *size\_t errlen*, *char \*errstr*);

*int*\

**bsde\_delete\_rule**(*int rulenum*, *size\_t errlen*, *char \*errstr*);

## DESCRIPTION

The **bsde\_add\_rule**() function fills the next available rule (in *struct mac\_bsdextended\_rule* form, either from **bsde\_get\_rule**() or [bsde\_parse\_rule(3)](/bsde_parse_rule/3.md)). If an error occurs, *\*errstr* is filled with the error string (up to *errlen* characters, including the terminating NUL). If successful and *rulenum* is non-NULL, the rule number used will be returned in *\*rulenum*.

The **bsde\_get\_rule**() function fills in *\*rule* with the rule numbered *rulenum*. If an error occurs, *\*errstr* is filled in with the error string (up to *errlen* characters, including the terminating NUL).

The **bsde\_set\_rule**() function fills the slot numbered *rulenum* with the specified rule (in *struct mac\_bsdextended\_rule* form, either from **bsde\_get\_rule**() or [bsde\_parse\_rule(3)](/bsde_parse_rule/3.md)). If an error occurs, *\*errstr* is filled with the error string (up to *errlen* characters, including the terminating NUL).

The **bsde\_delete\_rule**() function deletes the rule numbered *rulenum*. If an error occurs, *\*errstr* is filled with the error string (up to *errlen* characters, including the terminating NUL).

## RETURN VALUES

The **bsde\_get\_rule**(), **bsde\_set\_rule**(), and **bsde\_delete\_rule**() functions return 0 if successful; otherwise the value -1 is returned and the value of *\*errstr* is filled in as documented in DESCRIPTION.

## SEE ALSO

[bsde\_get\_rule\_count(3)](/bsde_get_rule_count/3.md), [bsde\_get\_rule\_slots(3)](/bsde_get_rule_slots/3.md), [bsde\_parse\_rule(3)](/bsde_parse_rule/3.md), [bsde\_parse\_rule\_string(3)](/bsde_parse_rule_string/3.md), [bsde\_rule\_to\_string(3)](/bsde_rule_to_string/3.md), [libugidfw(3)](/libugidfw/3.md), [mac\_bsdextended(4)](/mac_bsdextended/4.md), [ugidfw(8)](/ugidfw/8.md)

## AUTHORS

This software was contributed to the FreeBSD Project by Network Associates Labs, the Security Research Division of Network Associates Inc. under DARPA/SPAWAR contract N66001-01-C-8035 (“CBOSS”), as part of the DARPA CHATS research program.
