16cd6a6acSopenharmony_ciNetwork Labeling Statements
26cd6a6acSopenharmony_ci===========================
36cd6a6acSopenharmony_ci
46cd6a6acSopenharmony_ciipaddr
56cd6a6acSopenharmony_ci------
66cd6a6acSopenharmony_ci
76cd6a6acSopenharmony_ciDeclares a named IP address in IPv4 or IPv6 format that may be referenced by other CIL statements (i.e. [`netifcon`](cil_network_labeling_statements.md#netifcon)).
86cd6a6acSopenharmony_ci
96cd6a6acSopenharmony_ciNotes:
106cd6a6acSopenharmony_ci
116cd6a6acSopenharmony_ci-   CIL statements utilising an IP address may reference a named IP address or use an anonymous address, the examples will show each option.
126cd6a6acSopenharmony_ci
136cd6a6acSopenharmony_ci-   IP Addresses may be declared without a previous declaration by enclosing within parentheses e.g. `(127.0.0.1)` or `(::1)`.
146cd6a6acSopenharmony_ci
156cd6a6acSopenharmony_ci**Statement definition:**
166cd6a6acSopenharmony_ci
176cd6a6acSopenharmony_ci```secil
186cd6a6acSopenharmony_ci    (ipaddr ipaddr_id ip_address)
196cd6a6acSopenharmony_ci```
206cd6a6acSopenharmony_ci
216cd6a6acSopenharmony_ci**Where:**
226cd6a6acSopenharmony_ci
236cd6a6acSopenharmony_ci<table>
246cd6a6acSopenharmony_ci<colgroup>
256cd6a6acSopenharmony_ci<col width="25%" />
266cd6a6acSopenharmony_ci<col width="75%" />
276cd6a6acSopenharmony_ci</colgroup>
286cd6a6acSopenharmony_ci<tbody>
296cd6a6acSopenharmony_ci<tr class="odd">
306cd6a6acSopenharmony_ci<td align="left"><p><code>ipaddr</code></p></td>
316cd6a6acSopenharmony_ci<td align="left"><p>The <code>ipaddr</code> keyword.</p></td>
326cd6a6acSopenharmony_ci</tr>
336cd6a6acSopenharmony_ci<tr class="even">
346cd6a6acSopenharmony_ci<td align="left"><p><code>ipaddr_id</code></p></td>
356cd6a6acSopenharmony_ci<td align="left"><p>The IP address identifier.</p></td>
366cd6a6acSopenharmony_ci</tr>
376cd6a6acSopenharmony_ci<tr class="odd">
386cd6a6acSopenharmony_ci<td align="left"><p><code>ip_address</code></p></td>
396cd6a6acSopenharmony_ci<td align="left"><p>A correctly formatted IP address in IPv4 or IPv6 format.</p></td>
406cd6a6acSopenharmony_ci</tr>
416cd6a6acSopenharmony_ci</tbody>
426cd6a6acSopenharmony_ci</table>
436cd6a6acSopenharmony_ci
446cd6a6acSopenharmony_ci**Example:**
456cd6a6acSopenharmony_ci
466cd6a6acSopenharmony_ciThis example declares a named IP address and also passes an 'explicit anonymously declared' IP address to a macro:
476cd6a6acSopenharmony_ci
486cd6a6acSopenharmony_ci```secil
496cd6a6acSopenharmony_ci    (ipaddr netmask_1 255.255.255.0)
506cd6a6acSopenharmony_ci    (context netlabel_1 (system.user object_r unconfined.object low_low))
516cd6a6acSopenharmony_ci
526cd6a6acSopenharmony_ci    (call build_nodecon ((192.168.1.64) netmask_1))
536cd6a6acSopenharmony_ci
546cd6a6acSopenharmony_ci    (macro build_nodecon ((ipaddr ARG1) (ipaddr ARG2))
556cd6a6acSopenharmony_ci        (nodecon ARG1 ARG2  netlabel_1))
566cd6a6acSopenharmony_ci```
576cd6a6acSopenharmony_ci
586cd6a6acSopenharmony_cinetifcon
596cd6a6acSopenharmony_ci--------
606cd6a6acSopenharmony_ci
616cd6a6acSopenharmony_ciLabel network interface objects (e.g. `eth0`).
626cd6a6acSopenharmony_ci
636cd6a6acSopenharmony_ci**Statement definition:**
646cd6a6acSopenharmony_ci
656cd6a6acSopenharmony_ci```secil
666cd6a6acSopenharmony_ci    (netifcon netif_name netif_context_id packet_context_id)
676cd6a6acSopenharmony_ci```
686cd6a6acSopenharmony_ci
696cd6a6acSopenharmony_ci**Where:**
706cd6a6acSopenharmony_ci
716cd6a6acSopenharmony_ci<table>
726cd6a6acSopenharmony_ci<colgroup>
736cd6a6acSopenharmony_ci<col width="25%" />
746cd6a6acSopenharmony_ci<col width="75%" />
756cd6a6acSopenharmony_ci</colgroup>
766cd6a6acSopenharmony_ci<tbody>
776cd6a6acSopenharmony_ci<tr class="odd">
786cd6a6acSopenharmony_ci<td align="left"><p><code>netifcon</code></p></td>
796cd6a6acSopenharmony_ci<td align="left"><p>The <code>netifcon</code> keyword.</p></td>
806cd6a6acSopenharmony_ci</tr>
816cd6a6acSopenharmony_ci<tr class="even">
826cd6a6acSopenharmony_ci<td align="left"><p><code>netif_name</code></p></td>
836cd6a6acSopenharmony_ci<td align="left"><p>The network interface name (e.g. <code>wlan0</code>).</p></td>
846cd6a6acSopenharmony_ci</tr>
856cd6a6acSopenharmony_ci<tr class="odd">
866cd6a6acSopenharmony_ci<td align="left"><p><code>netif_context_id</code></p></td>
876cd6a6acSopenharmony_ci<td align="left"><p>The security context to be allocated to the network interface.</p>
886cd6a6acSopenharmony_ci<p>A previously declared <code>context</code> identifier or an anonymous security context (<code>user role type levelrange</code>), the range MUST be defined whether the policy is MLS/MCS enabled or not.</p></td>
896cd6a6acSopenharmony_ci</tr>
906cd6a6acSopenharmony_ci<tr class="even">
916cd6a6acSopenharmony_ci<td align="left"><p><code>packet_context_id</code></p></td>
926cd6a6acSopenharmony_ci<td align="left"><p>The security context to be allocated to packets. Note that these are defined but currently unused as the <strong><code>iptables</code></strong><code>(8)</code> SECMARK services should be used to label packets.</p>
936cd6a6acSopenharmony_ci<p>A previously declared <code>context</code> identifier or an anonymous security context (<code>user role type levelrange</code>), the range MUST be defined whether the policy is MLS/MCS enabled or not.</p></td>
946cd6a6acSopenharmony_ci</tr>
956cd6a6acSopenharmony_ci</tbody>
966cd6a6acSopenharmony_ci</table>
976cd6a6acSopenharmony_ci
986cd6a6acSopenharmony_ci**Examples:**
996cd6a6acSopenharmony_ci
1006cd6a6acSopenharmony_ciThese examples show named and anonymous [`netifcon`](cil_network_labeling_statements.md#netifcon) statements:
1016cd6a6acSopenharmony_ci
1026cd6a6acSopenharmony_ci```secil
1036cd6a6acSopenharmony_ci    (context context_1 (unconfined.user object_r unconfined.object low_low))
1046cd6a6acSopenharmony_ci    (context context_2 (unconfined.user object_r unconfined.object (systemlow level_2)))
1056cd6a6acSopenharmony_ci
1066cd6a6acSopenharmony_ci    (netifcon eth0 context_1 (unconfined.user object_r unconfined.object levelrange_1))
1076cd6a6acSopenharmony_ci    (netifcon eth1 context_1 (unconfined.user object_r unconfined.object ((s0) level_1)))
1086cd6a6acSopenharmony_ci    (netifcon eth3 context_1 context_2)
1096cd6a6acSopenharmony_ci```
1106cd6a6acSopenharmony_ci
1116cd6a6acSopenharmony_cinodecon
1126cd6a6acSopenharmony_ci-------
1136cd6a6acSopenharmony_ci
1146cd6a6acSopenharmony_ciLabel network address objects that represent IPv4 or IPv6 IP addresses and network masks.
1156cd6a6acSopenharmony_ci
1166cd6a6acSopenharmony_ciIP Addresses may be declared without a previous declaration by enclosing within parentheses e.g. `(127.0.0.1)` or `(::1)`.
1176cd6a6acSopenharmony_ci
1186cd6a6acSopenharmony_ci**Statement definition:**
1196cd6a6acSopenharmony_ci
1206cd6a6acSopenharmony_ci```secil
1216cd6a6acSopenharmony_ci    (nodecon subnet_id netmask_id context_id)
1226cd6a6acSopenharmony_ci```
1236cd6a6acSopenharmony_ci
1246cd6a6acSopenharmony_ci**Where:**
1256cd6a6acSopenharmony_ci
1266cd6a6acSopenharmony_ci<table>
1276cd6a6acSopenharmony_ci<colgroup>
1286cd6a6acSopenharmony_ci<col width="25%" />
1296cd6a6acSopenharmony_ci<col width="75%" />
1306cd6a6acSopenharmony_ci</colgroup>
1316cd6a6acSopenharmony_ci<tbody>
1326cd6a6acSopenharmony_ci<tr class="odd">
1336cd6a6acSopenharmony_ci<td align="left"><p><code>nodecon</code></p></td>
1346cd6a6acSopenharmony_ci<td align="left"><p>The <code>nodecon</code> keyword.</p></td>
1356cd6a6acSopenharmony_ci</tr>
1366cd6a6acSopenharmony_ci<tr class="even">
1376cd6a6acSopenharmony_ci<td align="left"><p><code>subnet_id</code></p></td>
1386cd6a6acSopenharmony_ci<td align="left"><p>A previously declared <code>ipaddr</code> identifier, or an anonymous IPv4 or IPv6 formatted address.</p></td>
1396cd6a6acSopenharmony_ci</tr>
1406cd6a6acSopenharmony_ci<tr class="odd">
1416cd6a6acSopenharmony_ci<td align="left"><p><code>netmask_id</code></p></td>
1426cd6a6acSopenharmony_ci<td align="left"><p>A previously declared <code>ipaddr</code> identifier, or an anonymous IPv4 or IPv6 formatted address.</p></td>
1436cd6a6acSopenharmony_ci</tr>
1446cd6a6acSopenharmony_ci<tr class="even">
1456cd6a6acSopenharmony_ci<td align="left"><p><code>context_id</code></p></td>
1466cd6a6acSopenharmony_ci<td align="left"><p>A previously declared <code>context</code> identifier or an anonymous security context (<code>user role type levelrange</code>), the range MUST be defined whether the policy is MLS/MCS enabled or not.</p></td>
1476cd6a6acSopenharmony_ci</tr>
1486cd6a6acSopenharmony_ci</tbody>
1496cd6a6acSopenharmony_ci</table>
1506cd6a6acSopenharmony_ci
1516cd6a6acSopenharmony_ci**Examples:**
1526cd6a6acSopenharmony_ci
1536cd6a6acSopenharmony_ciThese examples show named and anonymous [`nodecon`](cil_network_labeling_statements.md#nodecon) statements:
1546cd6a6acSopenharmony_ci
1556cd6a6acSopenharmony_ci```secil
1566cd6a6acSopenharmony_ci    (context context_1 (unconfined.user object_r unconfined.object low_low))
1576cd6a6acSopenharmony_ci    (context context_2 (unconfined.user object_r unconfined.object (systemlow level_2)))
1586cd6a6acSopenharmony_ci
1596cd6a6acSopenharmony_ci    (ipaddr netmask_1 255.255.255.255)
1606cd6a6acSopenharmony_ci    (ipaddr ipv4_1 192.0.2.64)
1616cd6a6acSopenharmony_ci
1626cd6a6acSopenharmony_ci    (nodecon ipv4_1 netmask_1 context_2)
1636cd6a6acSopenharmony_ci    (nodecon (192.0.2.64) (255.255.255.255) context_1)
1646cd6a6acSopenharmony_ci    (nodecon (192.0.2.64) netmask_1 (unconfined.user object_r unconfined.object ((s0) (s0 (c0)))))
1656cd6a6acSopenharmony_ci
1666cd6a6acSopenharmony_ci    (context context_3 (sys.id sys.role my48prefix.node ((s0)(s0))))
1676cd6a6acSopenharmony_ci
1686cd6a6acSopenharmony_ci    (ipaddr netmask_2 ffff:ffff:ffff:0:0:0:0:0)
1696cd6a6acSopenharmony_ci    (ipaddr ipv6_2  2001:db8:1:0:0:0:0:0)
1706cd6a6acSopenharmony_ci
1716cd6a6acSopenharmony_ci    (nodecon ipv6_2 netmask_2 context_3)
1726cd6a6acSopenharmony_ci    (nodecon (2001:db8:1:0:0:0:0:0) (ffff:ffff:ffff:0:0:0:0:0) context_3)
1736cd6a6acSopenharmony_ci    (nodecon (2001:db8:1:0:0:0:0:0) netmask_2 (sys.id sys.role my48prefix.node ((s0)(s0))))
1746cd6a6acSopenharmony_ci```
1756cd6a6acSopenharmony_ci
1766cd6a6acSopenharmony_ciportcon
1776cd6a6acSopenharmony_ci-------
1786cd6a6acSopenharmony_ci
1796cd6a6acSopenharmony_ciLabel a udp, tcp, dccp or sctp port.
1806cd6a6acSopenharmony_ci
1816cd6a6acSopenharmony_ci**Statement definition:**
1826cd6a6acSopenharmony_ci
1836cd6a6acSopenharmony_ci```secil
1846cd6a6acSopenharmony_ci    (portcon protocol port|(port_low port_high) context_id)
1856cd6a6acSopenharmony_ci```
1866cd6a6acSopenharmony_ci
1876cd6a6acSopenharmony_ci**Where:**
1886cd6a6acSopenharmony_ci
1896cd6a6acSopenharmony_ci<table>
1906cd6a6acSopenharmony_ci<colgroup>
1916cd6a6acSopenharmony_ci<col width="25%" />
1926cd6a6acSopenharmony_ci<col width="75%" />
1936cd6a6acSopenharmony_ci</colgroup>
1946cd6a6acSopenharmony_ci<tbody>
1956cd6a6acSopenharmony_ci<tr class="odd">
1966cd6a6acSopenharmony_ci<td align="left"><p><code>portcon</code></p></td>
1976cd6a6acSopenharmony_ci<td align="left"><p>The <code>portcon</code> keyword.</p></td>
1986cd6a6acSopenharmony_ci</tr>
1996cd6a6acSopenharmony_ci<tr class="even">
2006cd6a6acSopenharmony_ci<td align="left"><p><code>protocol</code></p></td>
2016cd6a6acSopenharmony_ci<td align="left"><p>The protocol keyword <code>tcp</code>, <code>udp</code>, <code>dccp</code> or <code>sctp</code>.</p></td>
2026cd6a6acSopenharmony_ci</tr>
2036cd6a6acSopenharmony_ci<tr class="odd">
2046cd6a6acSopenharmony_ci<td align="left"><p><code>port |</code></p>
2056cd6a6acSopenharmony_ci<p><code>(port_low port_high)</code></p></td>
2066cd6a6acSopenharmony_ci<td align="left"><p>A single port to apply the context, or a range of ports.</p>
2076cd6a6acSopenharmony_ci<p>The entries must consist of numerics <code>[0-9]</code>.</p></td>
2086cd6a6acSopenharmony_ci</tr>
2096cd6a6acSopenharmony_ci<tr class="even">
2106cd6a6acSopenharmony_ci<td align="left"><p><code>context_id</code></p></td>
2116cd6a6acSopenharmony_ci<td align="left"><p>A previously declared <code>context</code> identifier or an anonymous security context (<code>user role type levelrange</code>), the range MUST be defined whether the policy is MLS/MCS enabled or not.</p></td>
2126cd6a6acSopenharmony_ci</tr>
2136cd6a6acSopenharmony_ci</tbody>
2146cd6a6acSopenharmony_ci</table>
2156cd6a6acSopenharmony_ci
2166cd6a6acSopenharmony_ci**Examples:**
2176cd6a6acSopenharmony_ci
2186cd6a6acSopenharmony_ciThese examples show named and anonymous [`portcon`](cil_network_labeling_statements.md#portcon) statements:
2196cd6a6acSopenharmony_ci
2206cd6a6acSopenharmony_ci```secil
2216cd6a6acSopenharmony_ci    (portcon tcp 1111 (unconfined.user object_r unconfined.object ((s0) (s0 (c0)))))
2226cd6a6acSopenharmony_ci    (portcon tcp 2222 (unconfined.user object_r unconfined.object levelrange_2))
2236cd6a6acSopenharmony_ci    (portcon tcp 3333 (unconfined.user object_r unconfined.object levelrange_1))
2246cd6a6acSopenharmony_ci    (portcon udp 4444 (unconfined.user object_r unconfined.object ((s0) level_2)))
2256cd6a6acSopenharmony_ci    (portcon tcp (2000 20000) (unconfined.user object_r unconfined.object (systemlow level_3)))
2266cd6a6acSopenharmony_ci    (portcon dccp (6840 6880) (unconfined.user object_r unconfined.object ((s0) level_2)))
2276cd6a6acSopenharmony_ci    (portcon sctp (1024 1035) (unconfined.user object_r unconfined.object ((s0) level_2)))
2286cd6a6acSopenharmony_ci```
229