• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
34 
semanage_port_compare2(const semanage_port_t * port,const semanage_port_t * port2)35 int semanage_port_compare2(const semanage_port_t * port,
36 			   const semanage_port_t * port2)
37 {
38 
39 	return sepol_port_compare2(port, port2);
40 }
41 
42 
semanage_port_compare2_qsort(const semanage_port_t ** port,const semanage_port_t ** port2)43  int semanage_port_compare2_qsort(const semanage_port_t ** port,
44 					const semanage_port_t ** port2)
45 {
46 
47 	return sepol_port_compare2(*port, *port2);
48 }
49 
semanage_port_key_create(semanage_handle_t * handle,int low,int high,int proto,semanage_port_key_t ** key_ptr)50 int semanage_port_key_create(semanage_handle_t * handle,
51 			     int low, int high, int proto,
52 			     semanage_port_key_t ** key_ptr)
53 {
54 
55 	return sepol_port_key_create(handle->sepolh, low, high, proto, key_ptr);
56 }
57 
semanage_port_key_extract(semanage_handle_t * handle,const semanage_port_t * port,semanage_port_key_t ** key_ptr)58 int semanage_port_key_extract(semanage_handle_t * handle,
59 			      const semanage_port_t * port,
60 			      semanage_port_key_t ** key_ptr)
61 {
62 
63 	return sepol_port_key_extract(handle->sepolh, port, key_ptr);
64 }
65 
66 
semanage_port_key_free(semanage_port_key_t * key)67 void semanage_port_key_free(semanage_port_key_t * key)
68 {
69 
70 	sepol_port_key_free(key);
71 }
72 
73 
74 /* Protocol */
semanage_port_get_proto(const semanage_port_t * port)75 int semanage_port_get_proto(const semanage_port_t * port)
76 {
77 
78 	return sepol_port_get_proto(port);
79 }
80 
81 
semanage_port_set_proto(semanage_port_t * port,int proto)82 void semanage_port_set_proto(semanage_port_t * port, int proto)
83 {
84 
85 	sepol_port_set_proto(port, proto);
86 }
87 
88 
semanage_port_get_proto_str(int proto)89 const char *semanage_port_get_proto_str(int proto)
90 {
91 
92 	return sepol_port_get_proto_str(proto);
93 }
94 
95 
96 /* Port */
semanage_port_get_low(const semanage_port_t * port)97 int semanage_port_get_low(const semanage_port_t * port)
98 {
99 
100 	return sepol_port_get_low(port);
101 }
102 
103 
semanage_port_get_high(const semanage_port_t * port)104 int semanage_port_get_high(const semanage_port_t * port)
105 {
106 
107 	return sepol_port_get_high(port);
108 }
109 
110 
semanage_port_set_port(semanage_port_t * port,int port_num)111 void semanage_port_set_port(semanage_port_t * port, int port_num)
112 {
113 
114 	sepol_port_set_port(port, port_num);
115 }
116 
117 
semanage_port_set_range(semanage_port_t * port,int low,int high)118 void semanage_port_set_range(semanage_port_t * port, int low, int high)
119 {
120 
121 	sepol_port_set_range(port, low, high);
122 }
123 
124 
125 /* Context */
semanage_port_get_con(const semanage_port_t * port)126 semanage_context_t *semanage_port_get_con(const semanage_port_t * port)
127 {
128 
129 	return sepol_port_get_con(port);
130 }
131 
132 
semanage_port_set_con(semanage_handle_t * handle,semanage_port_t * port,semanage_context_t * con)133 int semanage_port_set_con(semanage_handle_t * handle,
134 			  semanage_port_t * port, semanage_context_t * con)
135 {
136 
137 	return sepol_port_set_con(handle->sepolh, port, con);
138 }
139 
140 
141 /* Create/Clone/Destroy */
semanage_port_create(semanage_handle_t * handle,semanage_port_t ** port_ptr)142 int semanage_port_create(semanage_handle_t * handle,
143 			 semanage_port_t ** port_ptr)
144 {
145 
146 	return sepol_port_create(handle->sepolh, port_ptr);
147 }
148 
149 
semanage_port_clone(semanage_handle_t * handle,const semanage_port_t * port,semanage_port_t ** port_ptr)150 int semanage_port_clone(semanage_handle_t * handle,
151 			const semanage_port_t * port,
152 			semanage_port_t ** port_ptr)
153 {
154 
155 	return sepol_port_clone(handle->sepolh, port, port_ptr);
156 }
157 
158 
semanage_port_free(semanage_port_t * port)159 void semanage_port_free(semanage_port_t * port)
160 {
161 
162 	sepol_port_free(port);
163 }
164 
165 
166 /* Port base functions */
167 record_table_t SEMANAGE_PORT_RTABLE = {
168 	.create = semanage_port_create,
169 	.key_extract = semanage_port_key_extract,
170 	.key_free = semanage_port_key_free,
171 	.clone = semanage_port_clone,
172 	.compare = semanage_port_compare,
173 	.compare2 = semanage_port_compare2,
174 	.compare2_qsort = semanage_port_compare2_qsort,
175 	.free = semanage_port_free,
176 };
177