libxdas_api_manage.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00039 #include <xdas.h>
00040 #include <xdas_debug.h>
00041
00042 #include "libxdas_impl.h"
00043
00044 #include <stddef.h>
00045 #include <malloc.h>
00046 #include <string.h>
00047
00048
00049
00050 XDASXPC int XDASAPI xdas_create_filter(
00051 int * minor_status,
00052 xdas_audit_ref_t das_ref,
00053 const char * name,
00054 unsigned filter_type,
00055 const char * filter_exp,
00056 const char * filter_act)
00057 {
00058 xdas_session * xs;
00059 int bit_bucket;
00060
00061
00062 if (!minor_status)
00063 minor_status = &bit_bucket;
00064 *minor_status = 0;
00065
00066 xdas_assert(das_ref != 0);
00067 if (das_ref == 0)
00068 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00069
00070 xs = xdas_validate_session(das_ref);
00071 xdas_assert(xs != 0);
00072 if (xs == 0)
00073 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00074
00075 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00076 return XDAS_S_AUTHORIZATION_FAILURE;
00077
00078 xdas_assert(name);
00079 if (!name)
00080 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER;
00081
00082 xdas_assert(filter_type == XDAS_C_INCLUDE || filter_type == XDAS_C_EXCLUDE);
00083 if (filter_type != XDAS_C_INCLUDE && filter_type != XDAS_C_EXCLUDE)
00084 return XDAS_S_INVALID_FILTER_TYPE;
00085
00086 xdas_assert(filter_exp);
00087 if (!filter_exp)
00088 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER_EXPR;
00089
00090 xdas_assert(filter_act);
00091 if (!filter_act)
00092 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER_ACTION;
00093
00094 return xdas_internal_create_filter(minor_status, name,
00095 filter_type, filter_exp, filter_act);
00096 }
00097
00098
00099
00100 XDASXPC int XDASAPI xdas_delete_filter(
00101 int * minor_status,
00102 xdas_audit_ref_t das_ref,
00103 const char * name)
00104 {
00105 xdas_session * xs;
00106 int bit_bucket;
00107
00108
00109 if (!minor_status)
00110 minor_status = &bit_bucket;
00111 *minor_status = 0;
00112
00113 xdas_assert(das_ref != 0);
00114 if (das_ref == 0)
00115 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00116
00117 xs = xdas_validate_session(das_ref);
00118 xdas_assert(xs != 0);
00119 if (xs == 0)
00120 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00121
00122 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00123 return XDAS_S_AUTHORIZATION_FAILURE;
00124
00125 xdas_assert(name);
00126 if (!name)
00127 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER;
00128
00129 return xdas_internal_delete_filter(minor_status, name);
00130 }
00131
00132
00133
00134 XDASXPC int XDASAPI xdas_disable_filter(
00135 int * minor_status,
00136 xdas_audit_ref_t das_ref,
00137 const char * name)
00138 {
00139 xdas_session * xs;
00140 int bit_bucket;
00141
00142
00143 if (!minor_status)
00144 minor_status = &bit_bucket;
00145 *minor_status = 0;
00146
00147 xdas_assert(das_ref != 0);
00148 if (das_ref == 0)
00149 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00150
00151 xs = xdas_validate_session(das_ref);
00152 xdas_assert(xs != 0);
00153 if (xs == 0)
00154 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00155
00156 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00157 return XDAS_S_AUTHORIZATION_FAILURE;
00158
00159 xdas_assert(name);
00160 if (!name)
00161 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER;
00162
00163 return xdas_internal_enable_filter(minor_status, name, 0);
00164 }
00165
00166
00167
00168 XDASXPC int XDASAPI xdas_enable_filter(
00169 int * minor_status,
00170 xdas_audit_ref_t das_ref,
00171 const char * name)
00172 {
00173 xdas_session * xs;
00174 int bit_bucket;
00175
00176
00177 if (!minor_status)
00178 minor_status = &bit_bucket;
00179 *minor_status = 0;
00180
00181 xdas_assert(das_ref != 0);
00182 if (das_ref == 0)
00183 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00184
00185 xs = xdas_validate_session(das_ref);
00186 xdas_assert(xs != 0);
00187 if (xs == 0)
00188 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00189
00190 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00191 return XDAS_S_AUTHORIZATION_FAILURE;
00192
00193 xdas_assert(name);
00194 if (!name)
00195 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER;
00196
00197 return xdas_internal_enable_filter(minor_status, name, 1);
00198 }
00199
00200
00201
00202 XDASXPC int XDASAPI xdas_get_filter(
00203 int * minor_status,
00204 xdas_audit_ref_t das_ref,
00205 const char * name,
00206 unsigned * filter_type,
00207 xdas_buffer_t filter_exp,
00208 xdas_buffer_t filter_act,
00209 unsigned * filter_status)
00210 {
00211 xdas_session * xs;
00212 int bit_bucket;
00213
00214
00215 if (!minor_status)
00216 minor_status = &bit_bucket;
00217 *minor_status = 0;
00218
00219 xdas_assert(das_ref != 0);
00220 if (das_ref == 0)
00221 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00222
00223 xs = xdas_validate_session(das_ref);
00224 xdas_assert(xs != 0);
00225 if (xs == 0)
00226 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00227
00228 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00229 return XDAS_S_AUTHORIZATION_FAILURE;
00230
00231 xdas_assert(name);
00232 if (!name)
00233 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER;
00234
00235 return xdas_internal_get_filter(minor_status, name,
00236 filter_type, filter_exp, filter_act, filter_status);
00237 }
00238
00239
00240
00241 XDASXPC int XDASAPI xdas_list_filters(
00242 int * minor_status,
00243 xdas_audit_ref_t das_ref,
00244 char ** filter_name_list,
00245 size_t * buffer_size)
00246 {
00247 xdas_session * xs;
00248 int bit_bucket;
00249
00250
00251 if (!minor_status)
00252 minor_status = &bit_bucket;
00253 *minor_status = 0;
00254
00255 xdas_assert(das_ref != 0);
00256 if (das_ref == 0)
00257 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00258
00259 xs = xdas_validate_session(das_ref);
00260 xdas_assert(xs != 0);
00261 if (xs == 0)
00262 return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00263
00264 if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_CONTROL))
00265 return XDAS_S_AUTHORIZATION_FAILURE;
00266
00267
00268 xdas_assert(buffer_size);
00269 xdas_assert(filter_name_list || !*buffer_size);
00270 if (!buffer_size || !filter_name_list && *buffer_size)
00271 return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_FILTER_LIST;
00272
00273 return xdas_internal_list_filters(minor_status,
00274 filter_name_list, buffer_size);
00275 }
00276