---
name: "semanage_port"
section: "3"
platform: "linux"
package: "libsemanage-dev"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/semanage_port"
---

# semanage\_port(3)

SELinux Network Ports Management API

## NAME

semanage\_port - SELinux Network Ports Management API

## SYNOPSIS

**#include \<semanage/port\_record.h\>**\
 **#include \<semanage/ports\_policy.h\>**\
 **#include \<semanage/ports\_local.h\>**

This object contains properties associated with a range of network ports.

For details on a specific function, see its manual page.

## Record API Overview

**semanage\_port\_create**(3)**-**\
 create a port range

**semanage\_port\_free**(3)**-**\
 release resources for this port range

**semanage\_port\_key\_create**(3)**-**\
 create a key, which can be used to identify a port range

**semanage\_port\_key\_free**(3)**-**\
 release resources for this port range key

**semanage\_port\_key\_extract**(3)**-**\
 create a key matching this port range

**semanage\_port\_clone**(3)**-**\
 create an identical port range (deep-copy clone)

**semanage\_port\_compare**(3)**-**\
 compare this port range to the provided key

**semanage\_port\_compare2**(3)**-**\
 compare this port range to another

## Properties API Overview

**semanage\_port\_get\_proto**(3)**-**\
 return the protocol for this port range

**semanage\_port\_get\_proto\_str**(3)**-**\
 return a string representation of the given port protocol

**semanage\_port\_set\_proto**(3)**-**\
 set the protocol for this port range

**semanage\_port\_get\_low**(3)**-**\
 return the low port number for this port range

**semanage\_port\_get\_high**(3)**-**\
 return the high port number for this port range

**semanage\_port\_set\_port**(3)**-**\
 set the port number (same low and high) for this port range

**semanage\_port\_set\_range**(3)**-**\
 set the low and high port number for this port range

**semanage\_port\_get\_con**(3)**-**\
 return the SELinux context for this port range

**semanage\_port\_set\_con**(3)**-**\
 set the SELinux context for this port range

## Record Store API Overview

[**semanage\_port\_modify\_local**(3)](/semanage_port_modify_local/3.md)**-**\
 add or update a port range in the local store

[**semanage\_port\_del\_local**(3)](/semanage_port_del_local/3.md)**-**\
 delete a port range from the local store

[**semanage\_port\_exists**(3)](/semanage_port_exists/3.md)**-**\
 check if a port range is defined in the persistent policy

[**semanage\_port\_exists\_local**(3)](/semanage_port_exists_local/3.md)**-**\
 check if a port range is defined in the local store

[**semanage\_port\_query**(3)](/semanage_port_query/3.md)**-**\
 query a port range in the persistent policy

[**semanage\_port\_query\_local**(3)](/semanage_port_query_local/3.md)**-**\
 query a port range in the local store

[**semanage\_port\_count**(3)](/semanage_port_count/3.md)**-**\
 count the number of port ranges defined in the persistent policy

[**semanage\_port\_count\_local**(3)](/semanage_port_count_local/3.md)**-**\
 count the number of port ranges defined in the local store

[**semanage\_port\_iterate**(3)](/semanage_port_iterate/3.md)**-**\
 execute a callback for each port range in the persistent policy

[**semanage\_port\_iterate\_local**(3)](/semanage_port_iterate_local/3.md)**-**\
 execute a callback for each port range in the local store

[**semanage\_port\_list**(3)](/semanage_port_list/3.md)**-**\
 return an array containing all port ranges in the persistent policy

[**semanage\_port\_list\_local**(3)](/semanage_port_list_local/3.md)**-**\
 return an array containing all port ranges in the local store
