Home | History | Annotate | Download | only in src
      1 /* Copyright (C) 2005 Red Hat, Inc. */
      2 
      3 /* Object: semanage_iface_t (Network Interface)
      4  * Object: semanage_iface_key_t (Network Interface 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/iface_record.h>
     11 
     12 typedef sepol_context_t semanage_context_t;
     13 typedef sepol_iface_t semanage_iface_t;
     14 typedef sepol_iface_key_t semanage_iface_key_t;
     15 #define _SEMANAGE_CONTEXT_DEFINED_
     16 #define _SEMANAGE_IFACE_DEFINED_
     17 
     18 typedef sepol_iface_t record_t;
     19 typedef sepol_iface_key_t record_key_t;
     20 #define DBASE_RECORD_DEFINED
     21 
     22 #include "iface_internal.h"
     23 #include "handle.h"
     24 #include "database.h"
     25 
     26 /* Key */
     27 int semanage_iface_compare(const semanage_iface_t * iface,
     28 			   const semanage_iface_key_t * key)
     29 {
     30 
     31 	return sepol_iface_compare(iface, key);
     32 }
     33 
     34 hidden_def(semanage_iface_compare)
     35 
     36 int semanage_iface_compare2(const semanage_iface_t * iface,
     37 			    const semanage_iface_t * iface2)
     38 {
     39 
     40 	return sepol_iface_compare2(iface, iface2);
     41 }
     42 
     43 hidden_def(semanage_iface_compare2)
     44 
     45 static int semanage_iface_compare2_qsort(const semanage_iface_t ** iface,
     46 					 const semanage_iface_t ** iface2)
     47 {
     48 
     49 	return sepol_iface_compare2(*iface, *iface2);
     50 }
     51 
     52 int semanage_iface_key_create(semanage_handle_t * handle,
     53 			      const char *name, semanage_iface_key_t ** key_ptr)
     54 {
     55 
     56 	return sepol_iface_key_create(handle->sepolh, name, key_ptr);
     57 }
     58 
     59 int semanage_iface_key_extract(semanage_handle_t * handle,
     60 			       const semanage_iface_t * iface,
     61 			       semanage_iface_key_t ** key_ptr)
     62 {
     63 
     64 	return sepol_iface_key_extract(handle->sepolh, iface, key_ptr);
     65 }
     66 
     67 hidden_def(semanage_iface_key_extract)
     68 
     69 void semanage_iface_key_free(semanage_iface_key_t * key)
     70 {
     71 
     72 	sepol_iface_key_free(key);
     73 }
     74 
     75 hidden_def(semanage_iface_key_free)
     76 
     77 /* Name */
     78 const char *semanage_iface_get_name(const semanage_iface_t * iface)
     79 {
     80 
     81 	return sepol_iface_get_name(iface);
     82 }
     83 
     84 hidden_def(semanage_iface_get_name)
     85 
     86 int semanage_iface_set_name(semanage_handle_t * handle,
     87 			    semanage_iface_t * iface, const char *name)
     88 {
     89 
     90 	return sepol_iface_set_name(handle->sepolh, iface, name);
     91 }
     92 
     93 hidden_def(semanage_iface_set_name)
     94 
     95 /* Context */
     96 semanage_context_t *semanage_iface_get_ifcon(const semanage_iface_t * iface)
     97 {
     98 
     99 	return sepol_iface_get_ifcon(iface);
    100 }
    101 
    102 hidden_def(semanage_iface_get_ifcon)
    103 
    104 int semanage_iface_set_ifcon(semanage_handle_t * handle,
    105 			     semanage_iface_t * iface, semanage_context_t * con)
    106 {
    107 
    108 	return sepol_iface_set_ifcon(handle->sepolh, iface, con);
    109 }
    110 
    111 hidden_def(semanage_iface_set_ifcon)
    112 
    113 semanage_context_t *semanage_iface_get_msgcon(const semanage_iface_t * iface)
    114 {
    115 
    116 	return sepol_iface_get_msgcon(iface);
    117 }
    118 
    119 hidden_def(semanage_iface_get_msgcon)
    120 
    121 int semanage_iface_set_msgcon(semanage_handle_t * handle,
    122 			      semanage_iface_t * iface,
    123 			      semanage_context_t * con)
    124 {
    125 
    126 	return sepol_iface_set_msgcon(handle->sepolh, iface, con);
    127 }
    128 
    129 hidden_def(semanage_iface_set_msgcon)
    130 
    131 /* Create/Clone/Destroy */
    132 int semanage_iface_create(semanage_handle_t * handle,
    133 			  semanage_iface_t ** iface_ptr)
    134 {
    135 
    136 	return sepol_iface_create(handle->sepolh, iface_ptr);
    137 }
    138 
    139 hidden_def(semanage_iface_create)
    140 
    141 int semanage_iface_clone(semanage_handle_t * handle,
    142 			 const semanage_iface_t * iface,
    143 			 semanage_iface_t ** iface_ptr)
    144 {
    145 
    146 	return sepol_iface_clone(handle->sepolh, iface, iface_ptr);
    147 }
    148 
    149 hidden_def(semanage_iface_clone)
    150 
    151 void semanage_iface_free(semanage_iface_t * iface)
    152 {
    153 
    154 	sepol_iface_free(iface);
    155 }
    156 
    157 hidden_def(semanage_iface_free)
    158 
    159 /* Record base functions */
    160 record_table_t SEMANAGE_IFACE_RTABLE = {
    161 	.create = semanage_iface_create,
    162 	.key_extract = semanage_iface_key_extract,
    163 	.key_free = semanage_iface_key_free,
    164 	.clone = semanage_iface_clone,
    165 	.compare = semanage_iface_compare,
    166 	.compare2 = semanage_iface_compare2,
    167 	.compare2_qsort = semanage_iface_compare2_qsort,
    168 	.free = semanage_iface_free,
    169 };
    170