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 #define SEMANAGE_PROTO_DCCP 2 20 #define SEMANAGE_PROTO_SCTP 3 21 22 /* Key */ 23 extern int semanage_port_compare(const semanage_port_t * port, 24 const semanage_port_key_t * key); 25 26 extern int semanage_port_compare2(const semanage_port_t * port, 27 const semanage_port_t * port2); 28 29 extern int semanage_port_key_create(semanage_handle_t * handle, 30 int low, int high, int proto, 31 semanage_port_key_t ** key_ptr); 32 33 extern int semanage_port_key_extract(semanage_handle_t * handle, 34 const semanage_port_t * port, 35 semanage_port_key_t ** key_ptr); 36 37 extern void semanage_port_key_free(semanage_port_key_t * key); 38 39 /* Protocol */ 40 extern int semanage_port_get_proto(const semanage_port_t * port); 41 42 extern void semanage_port_set_proto(semanage_port_t * port, int proto); 43 44 extern const char *semanage_port_get_proto_str(int proto); 45 46 /* Port */ 47 extern int semanage_port_get_low(const semanage_port_t * port); 48 49 extern int semanage_port_get_high(const semanage_port_t * port); 50 51 extern void semanage_port_set_port(semanage_port_t * port, int port_num); 52 53 extern void semanage_port_set_range(semanage_port_t * port, int low, int high); 54 55 /* Context */ 56 extern semanage_context_t *semanage_port_get_con(const semanage_port_t * port); 57 58 extern int semanage_port_set_con(semanage_handle_t * handle, 59 semanage_port_t * port, 60 semanage_context_t * con); 61 62 /* Create/Clone/Destroy */ 63 extern int semanage_port_create(semanage_handle_t * handle, 64 semanage_port_t ** port_ptr); 65 66 extern int semanage_port_clone(semanage_handle_t * handle, 67 const semanage_port_t * port, 68 semanage_port_t ** port_ptr); 69 70 extern void semanage_port_free(semanage_port_t * port); 71 72 #endif 73