• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2005 Red Hat, Inc. */
2 
3 #ifndef _SEMANAGE_NODE_RECORD_H_
4 #define _SEMANAGE_NODE_RECORD_H_
5 
6 #include <semanage/context_record.h>
7 #include <semanage/handle.h>
8 #include <stddef.h>
9 
10 #ifndef _SEMANAGE_NODE_DEFINED_
11 struct semanage_node;
12 struct semanage_node_key;
13 typedef struct semanage_node semanage_node_t;
14 typedef struct semanage_node_key semanage_node_key_t;
15 #define _SEMANAGE_NODE_DEFINED_
16 #endif
17 
18 #define SEMANAGE_PROTO_IP4 0
19 #define SEMANAGE_PROTO_IP6 1
20 
21 /* Key */
22 extern int semanage_node_compare(const semanage_node_t * node,
23 				 const semanage_node_key_t * key);
24 
25 extern int semanage_node_compare2(const semanage_node_t * node,
26 				  const semanage_node_t * node2);
27 
28 extern int semanage_node_key_create(semanage_handle_t * handle,
29 				    const char *addr,
30 				    const char *mask,
31 				    int proto, semanage_node_key_t ** key_ptr);
32 
33 extern int semanage_node_key_extract(semanage_handle_t * handle,
34 				     const semanage_node_t * node,
35 				     semanage_node_key_t ** key_ptr);
36 
37 extern void semanage_node_key_free(semanage_node_key_t * key);
38 
39 /* Address */
40 extern int semanage_node_get_addr(semanage_handle_t * handle,
41 				  const semanage_node_t * node, char **addr);
42 
43 extern int semanage_node_get_addr_bytes(semanage_handle_t * handle,
44 					const semanage_node_t * node,
45 					char **addr, size_t * addr_sz);
46 
47 extern int semanage_node_set_addr(semanage_handle_t * handle,
48 				  semanage_node_t * node,
49 				  int proto, const char *addr);
50 
51 extern int semanage_node_set_addr_bytes(semanage_handle_t * handle,
52 					semanage_node_t * node,
53 					const char *addr, size_t addr_sz);
54 
55 /* Netmask */
56 extern int semanage_node_get_mask(semanage_handle_t * handle,
57 				  const semanage_node_t * node, char **mask);
58 
59 extern int semanage_node_get_mask_bytes(semanage_handle_t * handle,
60 					const semanage_node_t * node,
61 					char **mask, size_t * mask_sz);
62 
63 extern int semanage_node_set_mask(semanage_handle_t * handle,
64 				  semanage_node_t * node,
65 				  int proto, const char *mask);
66 
67 extern int semanage_node_set_mask_bytes(semanage_handle_t * handle,
68 					semanage_node_t * node,
69 					const char *mask, size_t mask_sz);
70 
71 /* Protocol */
72 extern int semanage_node_get_proto(const semanage_node_t * node);
73 
74 extern void semanage_node_set_proto(semanage_node_t * node, int proto);
75 
76 extern const char *semanage_node_get_proto_str(int proto);
77 
78 /* Context */
79 extern semanage_context_t *semanage_node_get_con(const semanage_node_t * node);
80 
81 extern int semanage_node_set_con(semanage_handle_t * handle,
82 				 semanage_node_t * node,
83 				 semanage_context_t * con);
84 
85 /* Create/Clone/Destroy */
86 extern int semanage_node_create(semanage_handle_t * handle,
87 				semanage_node_t ** node_ptr);
88 
89 extern int semanage_node_clone(semanage_handle_t * handle,
90 			       const semanage_node_t * node,
91 			       semanage_node_t ** node_ptr);
92 
93 extern void semanage_node_free(semanage_node_t * node);
94 
95 #endif
96