Home | History | Annotate | Download | only in src
      1 /* Copyright (C) 2017 Mellanox Technologies Inc. */
      2 
      3 /* Object: semanage_ibpkey_t (Infiniband Pkey)
      4  * Object: semanage_ibpkey_key_t (Infiniband Pkey 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/ibpkey_record.h>
     11 
     12 typedef sepol_context_t semanage_context_t;
     13 typedef sepol_ibpkey_t semanage_ibpkey_t;
     14 typedef sepol_ibpkey_key_t semanage_ibpkey_key_t;
     15 #define _SEMANAGE_IBPKEY_DEFINED_
     16 #define _SEMANAGE_CONTEXT_DEFINED_
     17 
     18 typedef semanage_ibpkey_t record_t;
     19 typedef semanage_ibpkey_key_t record_key_t;
     20 #define DBASE_RECORD_DEFINED
     21 
     22 #include "ibpkey_internal.h"
     23 #include "handle.h"
     24 #include "database.h"
     25 
     26 int semanage_ibpkey_compare(const semanage_ibpkey_t *ibpkey,
     27 			    const semanage_ibpkey_key_t *key)
     28 {
     29 	return sepol_ibpkey_compare(ibpkey, key);
     30 }
     31 
     32 hidden_def(semanage_ibpkey_compare)
     33 
     34 int semanage_ibpkey_compare2(const semanage_ibpkey_t *ibpkey,
     35 			     const semanage_ibpkey_t *ibpkey2)
     36 {
     37 	return sepol_ibpkey_compare2(ibpkey, ibpkey2);
     38 }
     39 
     40 hidden_def(semanage_ibpkey_compare2)
     41 
     42 hidden int semanage_ibpkey_compare2_qsort(const semanage_ibpkey_t **ibpkey,
     43 					  const semanage_ibpkey_t **ibpkey2)
     44 {
     45 	return sepol_ibpkey_compare2(*ibpkey, *ibpkey2);
     46 }
     47 
     48 int semanage_ibpkey_key_create(semanage_handle_t *handle,
     49 			       const char *subnet_prefix,
     50 			       int low, int high,
     51 			       semanage_ibpkey_key_t **key_ptr)
     52 {
     53 	return sepol_ibpkey_key_create(handle->sepolh, subnet_prefix, low, high, key_ptr);
     54 }
     55 
     56 int semanage_ibpkey_key_extract(semanage_handle_t *handle,
     57 				const semanage_ibpkey_t *ibpkey,
     58 				semanage_ibpkey_key_t **key_ptr)
     59 {
     60 	return sepol_ibpkey_key_extract(handle->sepolh, ibpkey, key_ptr);
     61 }
     62 
     63 hidden_def(semanage_ibpkey_key_extract)
     64 
     65 void semanage_ibpkey_key_free(semanage_ibpkey_key_t *key)
     66 {
     67 	sepol_ibpkey_key_free(key);
     68 }
     69 
     70 hidden_def(semanage_ibpkey_key_free)
     71 
     72 int semanage_ibpkey_get_subnet_prefix(semanage_handle_t *handle,
     73 				      const semanage_ibpkey_t *ibpkey,
     74 				      char **subnet_prefix_ptr)
     75 {
     76 	return sepol_ibpkey_get_subnet_prefix(handle->sepolh, ibpkey, subnet_prefix_ptr);
     77 }
     78 
     79 hidden_def(semanage_ibpkey_get_subnet_prefix)
     80 
     81 uint64_t semanage_ibpkey_get_subnet_prefix_bytes(const semanage_ibpkey_t *ibpkey)
     82 {
     83 	return sepol_ibpkey_get_subnet_prefix_bytes(ibpkey);
     84 }
     85 
     86 hidden_def(semanage_ibpkey_get_subnet_prefix_bytes)
     87 
     88 int semanage_ibpkey_set_subnet_prefix(semanage_handle_t *handle,
     89 				      semanage_ibpkey_t *ibpkey,
     90 				      const char *subnet_prefix)
     91 {
     92 	return sepol_ibpkey_set_subnet_prefix(handle->sepolh, ibpkey, subnet_prefix);
     93 }
     94 
     95 hidden_def(semanage_ibpkey_set_subnet_prefix)
     96 
     97 void semanage_ibpkey_set_subnet_prefix_bytes(semanage_ibpkey_t *ibpkey,
     98 					     uint64_t subnet_prefix)
     99 {
    100 	return sepol_ibpkey_set_subnet_prefix_bytes(ibpkey, subnet_prefix);
    101 }
    102 
    103 hidden_def(semanage_ibpkey_set_subnet_prefix_bytes)
    104 
    105 int semanage_ibpkey_get_low(const semanage_ibpkey_t *ibpkey)
    106 {
    107 	return sepol_ibpkey_get_low(ibpkey);
    108 }
    109 
    110 hidden_def(semanage_ibpkey_get_low)
    111 
    112 int semanage_ibpkey_get_high(const semanage_ibpkey_t *ibpkey)
    113 {
    114 	return sepol_ibpkey_get_high(ibpkey);
    115 }
    116 
    117 hidden_def(semanage_ibpkey_get_high)
    118 
    119 void semanage_ibpkey_set_pkey(semanage_ibpkey_t *ibpkey, int ibpkey_num)
    120 {
    121 	sepol_ibpkey_set_pkey(ibpkey, ibpkey_num);
    122 }
    123 
    124 hidden_def(semanage_ibpkey_set_pkey)
    125 
    126 void semanage_ibpkey_set_range(semanage_ibpkey_t *ibpkey, int low, int high)
    127 {
    128 	sepol_ibpkey_set_range(ibpkey, low, high);
    129 }
    130 
    131 hidden_def(semanage_ibpkey_set_range)
    132 
    133 semanage_context_t *semanage_ibpkey_get_con(const semanage_ibpkey_t *ibpkey)
    134 {
    135 	return sepol_ibpkey_get_con(ibpkey);
    136 }
    137 
    138 hidden_def(semanage_ibpkey_get_con)
    139 
    140 int semanage_ibpkey_set_con(semanage_handle_t *handle,
    141 			    semanage_ibpkey_t *ibpkey, semanage_context_t *con)
    142 {
    143 	return sepol_ibpkey_set_con(handle->sepolh, ibpkey, con);
    144 }
    145 
    146 hidden_def(semanage_ibpkey_set_con)
    147 
    148 int semanage_ibpkey_create(semanage_handle_t *handle,
    149 			   semanage_ibpkey_t **ibpkey_ptr)
    150 {
    151 	return sepol_ibpkey_create(handle->sepolh, ibpkey_ptr);
    152 }
    153 
    154 hidden_def(semanage_ibpkey_create)
    155 
    156 int semanage_ibpkey_clone(semanage_handle_t *handle,
    157 			  const semanage_ibpkey_t *ibpkey,
    158 			  semanage_ibpkey_t **ibpkey_ptr)
    159 {
    160 	return sepol_ibpkey_clone(handle->sepolh, ibpkey, ibpkey_ptr);
    161 }
    162 
    163 hidden_def(semanage_ibpkey_clone)
    164 
    165 void semanage_ibpkey_free(semanage_ibpkey_t *ibpkey)
    166 {
    167 	sepol_ibpkey_free(ibpkey);
    168 }
    169 
    170 hidden_def(semanage_ibpkey_free)
    171 
    172 /* key base functions */
    173 record_table_t SEMANAGE_IBPKEY_RTABLE = {
    174 	.create = semanage_ibpkey_create,
    175 	.key_extract = semanage_ibpkey_key_extract,
    176 	.key_free = semanage_ibpkey_key_free,
    177 	.clone = semanage_ibpkey_clone,
    178 	.compare = semanage_ibpkey_compare,
    179 	.compare2 = semanage_ibpkey_compare2,
    180 	.compare2_qsort = semanage_ibpkey_compare2_qsort,
    181 	.free = semanage_ibpkey_free,
    182 };
    183