1 /* Copyright (C) 2005 Red Hat, Inc. */
2
3 /* Object: semanage_port_t (Network Port)
4 * Object: semanage_port_key_t (Network Port Key)
5 * Implements: record_t (Database Record)
6 * Implements: record_key_t (Database Record Key)
7 */
8
9 #include <sepol/context_record.h>
10 #include <sepol/port_record.h>
11
12 typedef sepol_context_t semanage_context_t;
13 typedef sepol_port_t semanage_port_t;
14 typedef sepol_port_key_t semanage_port_key_t;
15 #define _SEMANAGE_PORT_DEFINED_
16 #define _SEMANAGE_CONTEXT_DEFINED_
17
18 typedef semanage_port_t record_t;
19 typedef semanage_port_key_t record_key_t;
20 #define DBASE_RECORD_DEFINED
21
22 #include "port_internal.h"
23 #include "handle.h"
24 #include "database.h"
25
26 /* Key */
semanage_port_compare(const semanage_port_t * port,const semanage_port_key_t * key)27 int semanage_port_compare(const semanage_port_t * port,
28 const semanage_port_key_t * key)
29 {
30
31 return sepol_port_compare(port, key);
32 }
33
hidden_def(semanage_port_compare)34 hidden_def(semanage_port_compare)
35
36 int semanage_port_compare2(const semanage_port_t * port,
37 const semanage_port_t * port2)
38 {
39
40 return sepol_port_compare2(port, port2);
41 }
42
hidden_def(semanage_port_compare2)43 hidden_def(semanage_port_compare2)
44
45 hidden int semanage_port_compare2_qsort(const semanage_port_t ** port,
46 const semanage_port_t ** port2)
47 {
48
49 return sepol_port_compare2(*port, *port2);
50 }
51
semanage_port_key_create(semanage_handle_t * handle,int low,int high,int proto,semanage_port_key_t ** key_ptr)52 int semanage_port_key_create(semanage_handle_t * handle,
53 int low, int high, int proto,
54 semanage_port_key_t ** key_ptr)
55 {
56
57 return sepol_port_key_create(handle->sepolh, low, high, proto, key_ptr);
58 }
59
semanage_port_key_extract(semanage_handle_t * handle,const semanage_port_t * port,semanage_port_key_t ** key_ptr)60 int semanage_port_key_extract(semanage_handle_t * handle,
61 const semanage_port_t * port,
62 semanage_port_key_t ** key_ptr)
63 {
64
65 return sepol_port_key_extract(handle->sepolh, port, key_ptr);
66 }
67
hidden_def(semanage_port_key_extract)68 hidden_def(semanage_port_key_extract)
69
70 void semanage_port_key_free(semanage_port_key_t * key)
71 {
72
73 sepol_port_key_free(key);
74 }
75
hidden_def(semanage_port_key_free)76 hidden_def(semanage_port_key_free)
77
78 /* Protocol */
79 int semanage_port_get_proto(const semanage_port_t * port)
80 {
81
82 return sepol_port_get_proto(port);
83 }
84
hidden_def(semanage_port_get_proto)85 hidden_def(semanage_port_get_proto)
86
87 void semanage_port_set_proto(semanage_port_t * port, int proto)
88 {
89
90 sepol_port_set_proto(port, proto);
91 }
92
hidden_def(semanage_port_set_proto)93 hidden_def(semanage_port_set_proto)
94
95 const char *semanage_port_get_proto_str(int proto)
96 {
97
98 return sepol_port_get_proto_str(proto);
99 }
100
hidden_def(semanage_port_get_proto_str)101 hidden_def(semanage_port_get_proto_str)
102
103 /* Port */
104 int semanage_port_get_low(const semanage_port_t * port)
105 {
106
107 return sepol_port_get_low(port);
108 }
109
hidden_def(semanage_port_get_low)110 hidden_def(semanage_port_get_low)
111
112 int semanage_port_get_high(const semanage_port_t * port)
113 {
114
115 return sepol_port_get_high(port);
116 }
117
hidden_def(semanage_port_get_high)118 hidden_def(semanage_port_get_high)
119
120 void semanage_port_set_port(semanage_port_t * port, int port_num)
121 {
122
123 sepol_port_set_port(port, port_num);
124 }
125
hidden_def(semanage_port_set_port)126 hidden_def(semanage_port_set_port)
127
128 void semanage_port_set_range(semanage_port_t * port, int low, int high)
129 {
130
131 sepol_port_set_range(port, low, high);
132 }
133
hidden_def(semanage_port_set_range)134 hidden_def(semanage_port_set_range)
135
136 /* Context */
137 semanage_context_t *semanage_port_get_con(const semanage_port_t * port)
138 {
139
140 return sepol_port_get_con(port);
141 }
142
hidden_def(semanage_port_get_con)143 hidden_def(semanage_port_get_con)
144
145 int semanage_port_set_con(semanage_handle_t * handle,
146 semanage_port_t * port, semanage_context_t * con)
147 {
148
149 return sepol_port_set_con(handle->sepolh, port, con);
150 }
151
hidden_def(semanage_port_set_con)152 hidden_def(semanage_port_set_con)
153
154 /* Create/Clone/Destroy */
155 int semanage_port_create(semanage_handle_t * handle,
156 semanage_port_t ** port_ptr)
157 {
158
159 return sepol_port_create(handle->sepolh, port_ptr);
160 }
161
hidden_def(semanage_port_create)162 hidden_def(semanage_port_create)
163
164 int semanage_port_clone(semanage_handle_t * handle,
165 const semanage_port_t * port,
166 semanage_port_t ** port_ptr)
167 {
168
169 return sepol_port_clone(handle->sepolh, port, port_ptr);
170 }
171
hidden_def(semanage_port_clone)172 hidden_def(semanage_port_clone)
173
174 void semanage_port_free(semanage_port_t * port)
175 {
176
177 sepol_port_free(port);
178 }
179
180 hidden_def(semanage_port_free)
181
182 /* Port base functions */
183 record_table_t SEMANAGE_PORT_RTABLE = {
184 .create = semanage_port_create,
185 .key_extract = semanage_port_key_extract,
186 .key_free = semanage_port_key_free,
187 .clone = semanage_port_clone,
188 .compare = semanage_port_compare,
189 .compare2 = semanage_port_compare2,
190 .compare2_qsort = semanage_port_compare2_qsort,
191 .free = semanage_port_free,
192 };
193