1 /* Copyright (C) 2005 Red Hat, Inc. */ 2 3 #ifndef _SEMANAGE_PORT_RECORD_H_ 4 #define _SEMANAGE_PORT_RECORD_H_ 5 6 #include <semanage/context_record.h> 7 #include <semanage/handle.h> 8 9 #ifndef _SEMANAGE_PORT_DEFINED_ 10 struct semanage_port; 11 struct semanage_port_key; 12 typedef struct semanage_port semanage_port_t; 13 typedef struct semanage_port_key semanage_port_key_t; 14 #define _SEMANAGE_PORT_DEFINED_ 15 #endif 16 17 #define SEMANAGE_PROTO_UDP 0 18 #define SEMANAGE_PROTO_TCP 1 19 20 /* Key */ 21 extern int semanage_port_compare(const semanage_port_t * port, 22 const semanage_port_key_t * key); 23 24 extern int semanage_port_compare2(const semanage_port_t * port, 25 const semanage_port_t * port2); 26 27 extern int semanage_port_key_create(semanage_handle_t * handle, 28 int low, int high, int proto, 29 semanage_port_key_t ** key_ptr); 30 31 extern int semanage_port_key_extract(semanage_handle_t * handle, 32 const semanage_port_t * port, 33 semanage_port_key_t ** key_ptr); 34 35 extern void semanage_port_key_free(semanage_port_key_t * key); 36 37 /* Protocol */ 38 extern int semanage_port_get_proto(const semanage_port_t * port); 39 40 extern void semanage_port_set_proto(semanage_port_t * port, int proto); 41 42 extern const char *semanage_port_get_proto_str(int proto); 43 44 /* Port */ 45 extern int semanage_port_get_low(const semanage_port_t * port); 46 47 extern int semanage_port_get_high(const semanage_port_t * port); 48 49 extern void semanage_port_set_port(semanage_port_t * port, int port_num); 50 51 extern void semanage_port_set_range(semanage_port_t * port, int low, int high); 52 53 /* Context */ 54 extern semanage_context_t *semanage_port_get_con(const semanage_port_t * port); 55 56 extern int semanage_port_set_con(semanage_handle_t * handle, 57 semanage_port_t * port, 58 semanage_context_t * con); 59 60 /* Create/Clone/Destroy */ 61 extern int semanage_port_create(semanage_handle_t * handle, 62 semanage_port_t ** port_ptr); 63 64 extern int semanage_port_clone(semanage_handle_t * handle, 65 const semanage_port_t * port, 66 semanage_port_t ** port_ptr); 67 68 extern void semanage_port_free(semanage_port_t * port); 69 70 #endif 71