| 1 |
#ifndef _SEPOL_PORT_RECORD_H_ |
| 2 |
#define _SEPOL_PORT_RECORD_H_ |
| 3 |
|
| 4 |
#include <sepol/context_record.h> |
| 5 |
#include <sepol/handle.h> |
| 6 |
|
| 7 |
#ifdef __cplusplus |
| 8 |
extern "C" { |
| 9 |
#endif |
| 10 |
|
| 11 |
struct sepol_port; |
| 12 |
struct sepol_port_key; |
| 13 |
typedef struct sepol_port sepol_port_t; |
| 14 |
typedef struct sepol_port_key sepol_port_key_t; |
| 15 |
|
| 16 |
#define SEPOL_PROTO_UDP 0 |
| 17 |
#define SEPOL_PROTO_TCP 1 |
| 18 |
#define SEPOL_PROTO_DCCP 2 |
| 19 |
#define SEPOL_PROTO_SCTP 3 |
| 20 |
|
| 21 |
/* Key */ |
| 22 |
extern int sepol_port_compare(const sepol_port_t * port, |
| 23 |
const sepol_port_key_t * key); |
| 24 |
|
| 25 |
extern int sepol_port_compare2(const sepol_port_t * port, |
| 26 |
const sepol_port_t * port2); |
| 27 |
|
| 28 |
extern int sepol_port_key_create(sepol_handle_t * handle, |
| 29 |
int low, int high, int proto, |
| 30 |
sepol_port_key_t ** key_ptr); |
| 31 |
|
| 32 |
extern void sepol_port_key_unpack(const sepol_port_key_t * key, |
| 33 |
int *low, int *high, int *proto); |
| 34 |
|
| 35 |
extern int sepol_port_key_extract(sepol_handle_t * handle, |
| 36 |
const sepol_port_t * port, |
| 37 |
sepol_port_key_t ** key_ptr); |
| 38 |
|
| 39 |
extern void sepol_port_key_free(sepol_port_key_t * key); |
| 40 |
|
| 41 |
/* Protocol */ |
| 42 |
extern int sepol_port_get_proto(const sepol_port_t * port); |
| 43 |
|
| 44 |
extern void sepol_port_set_proto(sepol_port_t * port, int proto); |
| 45 |
|
| 46 |
extern const char *sepol_port_get_proto_str(int proto); |
| 47 |
|
| 48 |
/* Port */ |
| 49 |
extern int sepol_port_get_low(const sepol_port_t * port); |
| 50 |
|
| 51 |
extern int sepol_port_get_high(const sepol_port_t * port); |
| 52 |
|
| 53 |
extern void sepol_port_set_port(sepol_port_t * port, int port_num); |
| 54 |
|
| 55 |
extern void sepol_port_set_range(sepol_port_t * port, int low, int high); |
| 56 |
|
| 57 |
/* Context */ |
| 58 |
extern sepol_context_t *sepol_port_get_con(const sepol_port_t * port); |
| 59 |
|
| 60 |
extern int sepol_port_set_con(sepol_handle_t * handle, |
| 61 |
sepol_port_t * port, sepol_context_t * con); |
| 62 |
|
| 63 |
/* Create/Clone/Destroy */ |
| 64 |
extern int sepol_port_create(sepol_handle_t * handle, sepol_port_t ** port_ptr); |
| 65 |
|
| 66 |
extern int sepol_port_clone(sepol_handle_t * handle, |
| 67 |
const sepol_port_t * port, |
| 68 |
sepol_port_t ** port_ptr); |
| 69 |
|
| 70 |
extern void sepol_port_free(sepol_port_t * port); |
| 71 |
|
| 72 |
#ifdef __cplusplus |
| 73 |
} |
| 74 |
#endif |
| 75 |
|
| 76 |
#endif |