/linux-2.6.21.1-rsbac-1.3.4/include/rsbac/lists.h

Go to the documentation of this file.
00001 /*************************************************** */
00002 /* Rule Set Based Access Control                     */
00003 /* Author and (c) 1999-2007: Amon Ott <ao@rsbac.org> */
00004 /* Generic List Management                           */
00005 /* Last modified: 12/Feb/2007                        */
00006 /*************************************************** */
00007 
00008 /* Note: lol = list of lists, a two-level list structure */
00009 
00010 #ifndef __RSBAC_LISTS_H
00011 #define __RSBAC_LISTS_H
00012 
00013 #include <linux/init.h>
00014 #include <linux/vmalloc.h>
00015 //#include <rsbac/types.h>
00016 #include <rsbac/rkmem.h>
00017 
00018 #define RSBAC_LIST_VERSION 3
00019 
00020 typedef void *rsbac_list_handle_t;
00021 typedef __u32 rsbac_list_key_t;
00022 
00023 /* Maximum length for list (file)names */
00024 #define RSBAC_LIST_MAX_FILENAME 15
00025 
00026 /* Limit for max_age_in_seconds: ca. 10 years */
00027 #define RSBAC_LIST_MAX_AGE_LIMIT (3600 * 24 * 366 * 10)
00028 
00029 /* Maximum desc_size + data_size: 8K - some space for metadata */
00030 #define RSBAC_LIST_MAX_ITEM_SIZE (8192 - 64)
00031 
00032 #define RSBAC_LIST_MIN_MAX_HASHES 8
00033 
00034 /* standard hash functions */
00035 u_int rsbac_list_hash_u32(void * desc, __u32 nr_hashes);
00036 u_int rsbac_list_hash_fd(void * desc, __u32 nr_hashes);
00037 u_int rsbac_list_hash_pid(void * desc, __u32 nr_hashes);
00038 u_int rsbac_list_hash_uid(void * desc, __u32 nr_hashes);
00039 u_int rsbac_list_hash_gid(void * desc, __u32 nr_hashes);
00040 u_int rsbac_list_hash_ipc(void * desc, __u32 nr_hashes);
00041 u_int rsbac_list_hash_dev(void * desc, __u32 nr_hashes);
00042 u_int rsbac_list_hash_nettemp(void * desc, __u32 nr_hashes);
00043 u_int rsbac_list_hash_netobj(void * desc, __u32 nr_hashes);
00044 
00045 /****************************/
00046 /* List Registration Flags: */
00047 
00048 /* Make persistent, i.e., save to and restore from disk */
00049 #define RSBAC_LIST_PERSIST 1
00050 
00051 /* Ignore old list contents (still checks key, if list exists on disk) */
00052 #define RSBAC_LIST_IGNORE_OLD 2
00053 
00054 /* Ignore old list contents, if version upconversion is not supported
00055  * (no get_conv, or get_conv returned NULL) - without this flag, registration fails, if
00056  * list cannot be converted.
00057  */
00058 #define RSBAC_LIST_IGNORE_UNSUPP_VERSION 4
00059 
00060 /* Temporarily disallow writing list to disk, e.g. for upgrade tests */
00061 #define RSBAC_LIST_NO_WRITE 8
00062 
00063 /* Provide a binary backup file as /proc/rsbac-info/backup/filename */
00064 #define RSBAC_LIST_BACKUP 16
00065 
00066 /* Use provided default data, return it for unexisting items and
00067    automatically create and cleanup items with default data as necessary.
00068    (only items with 0 ttl (unlimited) get removed)
00069    (lol items with default data only get removed, if they have no subitems) */
00070 #define RSBAC_LIST_DEF_DATA 32
00071 
00072 /* Use provided default subitem data, return it for unexisting subitems and
00073    automatically create and cleanup subitems with default data as necessary.
00074    (only subitems with 0 ttl (unlimited) get removed) */
00075 #define RSBAC_LIST_DEF_SUBDATA 64
00076 
00077 /* Replicate list to replication partners.
00078    Must be enabled in config. */
00079 #define RSBAC_LIST_REPLICATE 128
00080 
00081 /* Allow automatic online resizing of the list hashing table.
00082    Requires that the provided hash function uses the nr_hashes parameter. */
00083 #define RSBAC_LIST_AUTO_HASH_RESIZE 256
00084 
00085 /* Disable limit of RSBAC_LIST_MAX_NR_ITEMS items per single list. */
00086 #define RSBAC_LIST_NO_MAX 512
00087 
00088 /* Disable warning if max_entries prevents adding of items */
00089 #define RSBAC_LIST_NO_MAX_WARN 1024
00090 
00091 /****************************/
00092 /* Function prototypes */
00093 
00094 /* Function to compare two descriptors, returns 0, if equal, a negative value,
00095  * if desc1 < desc2 and a positive value, if desc1 > desc2 (like memcmp).
00096  * Used for lookup and list optimization.
00097  * Note: Non-0 values are only used for list optimization and do not necessarily
00098  * imply a real order of values.
00099  */
00100 typedef int rsbac_list_compare_function_t(void *desc1, void *desc2);
00101 
00102 int rsbac_list_compare_u32(void * desc1, void * desc2);
00103 
00104 /* Function to compare two datas, returns 0, if equal, and another value,
00105  * if not.
00106  * Used for lookup by data.
00107  * Note: list optimization is based on descriptors, so data lookup is always
00108  * linear search from first to last element in list order.
00109  */
00110 typedef int rsbac_list_data_compare_function_t(void *data1, void *data2);
00111 
00112 /* conversion function to upconvert old on-disk descs and datas to actual version */
00113 /* must return 0 on success or error otherwise */
00114 /* Attention: if old or new data_size is 0, the respective data pointer is NULL! */
00115 typedef int rsbac_list_conv_function_t(void *old_desc,
00116                                        void *old_data,
00117                                        void *new_desc, void *new_data);
00118 
00119 /* callback function to return an upconvert function for on-disk-version, if versions differ */
00120 /* Note: Lists implementation does not assume anything about your version number apart
00121    from being of type rsbac_version_t. Use it as you like. */
00122 typedef rsbac_list_conv_function_t *rsbac_list_get_conv_t(rsbac_version_t
00123                                                           old_version);
00124 
00125 /* hash function to return a hash for the descriptor in the range 0 to nr_hashes-1 */
00126 typedef u_int rsbac_list_hash_function_t(void * desc, __u32 nr_hashes);
00127 
00128 /* get generic list registration version */
00129 rsbac_version_t rsbac_list_version(void);
00130 
00131 
00132 /* List info: This struct will be written to disk */
00133 /*
00134  * list_version: a simple __u32 version number for the list. If old on-disk version is
00135    different, conversion is tried (depending on flags and get_conv function)
00136  * key: secret __u32 key, which must be the same as in on-disk version, if persistent
00137  * desc_size: size of the descriptor (error is returned, if list exists and value differs)
00138               internally reset to sizeof(__u32) for u32 call variants
00139  * data_size: size of data (error is returned, if list exists and value differs)
00140               set to 0 for sets without data
00141  * subdesc_size: size of the descriptor of the sublist (error is returned, if list exists
00142               and value differs), internally reset to sizeof(__u32) for u32 call variants
00143  * subdata_size: size of sublist data (error is returned, if list exists and value differs)
00144               set to 0 for sets without data
00145  * max_age: seconds until unchanged list file (no add or remove) will be purged.
00146    Maximum value is RSBAC_LIST_MAX_AGE_LIMIT (s.a.), use 0 for unlimited lifetime.
00147    (purging not yet implemented - only reused without key, please cleanup by hand)
00148  */
00149 struct rsbac_list_info_t {
00150         rsbac_version_t version;
00151         rsbac_list_key_t key;
00152         __u32 desc_size;
00153         __u32 data_size;
00154         rsbac_time_t max_age;
00155 };
00156 
00157 struct rsbac_list_lol_info_t {
00158         rsbac_version_t version;
00159         rsbac_list_key_t key;
00160         __u32 desc_size;
00161         __u32 data_size;
00162         __u32 subdesc_size;
00163         __u32 subdata_size;
00164         rsbac_time_t max_age;
00165 };
00166 
00167 
00168 /* register a new list */
00169 /*
00170  * If list with same name exists in memory, error -RSBAC_EEXISTS is returned.
00171  * If list with same name and key exists on device, it is restored depending on
00172    the flags.
00173  * If list with same name, but different key exists on disk, access is denied
00174    (error -EPERM).
00175  *
00176  * ds_version: for binary modules, must be RSBAC_LIST_VERSION. If version
00177    differs, return error.
00178  * handle_p: for all list accesses, an opaque handle is put into *handle_p.
00179  * flags: see flag values
00180  * compare: for lookup and list optimization, can be NULL, then
00181    memcmp(desc1, desc2, desc_size) is used
00182  * subcompare: for item lookup and optimization of sublist, can be NULL, then
00183    memcmp(desc1, desc2, desc_size) is used
00184  * get_conv: function to deliver conversion function for given version
00185  * get_subconv: function to deliver sublist item conversion function for given
00186    version
00187  * def_data: default data value for flag RSBAC_LIST_DEF_DATA
00188    (if NULL, flag is cleared)
00189  * def_subdata: default subdata value for flag RSBAC_LIST_DEF_SUBDATA
00190    (if NULL, flag is cleared)
00191  * name: the on-disk name, should be distinct and max. 7 or 8.2 chars
00192    (maxlen of RSBAC_LIST_MAX_FILENAME supported) (only used for statistics, if
00193    non-persistent)
00194  * device: the device to read list from or to save list to - use 0 for root dev
00195    (ignored, if non-persistent)
00196  * nr_hashes: Number of hashes for this list, maximum is RSBAC_LIST_MAX_HASHES,
00197    which is derived from CONFIG_RSBAC_LIST_MAX_HASHES.
00198    If > maximum, it will be reduced to maximum automatically.
00199    8 <= RSBAC_LIST_MAX_HASHES <= 256 in all cases, see above.
00200    Thus,  it is safe to use nr_hashes <= 8 without checks.
00201    Value may vary between registrations.
00202  * hash_function: Hash function for desc, must always return a value
00203    from 0 to nr_hashes-1.
00204  * old_base_name: If not NULL and persistent list with name cannot be read,
00205    try to read all old_base_name<n> with n from 0 to 31.
00206  */
00207 
00208 int rsbac_list_register_hashed(rsbac_version_t ds_version,
00209                         rsbac_list_handle_t * handle_p,
00210                         struct rsbac_list_info_t *info_p,
00211                         u_int flags,
00212                         rsbac_list_compare_function_t * compare,
00213                         rsbac_list_get_conv_t * get_conv,
00214                         void *def_data, char *name, kdev_t device,
00215                         u_int nr_hashes,
00216                         rsbac_list_hash_function_t hash_function,
00217                         char * old_base_name);
00218 
00219 int rsbac_list_lol_register_hashed(rsbac_version_t ds_version,
00220                         rsbac_list_handle_t * handle_p,
00221                         struct rsbac_list_lol_info_t *info_p,
00222                         u_int flags,
00223                         rsbac_list_compare_function_t * compare,
00224                         rsbac_list_compare_function_t * subcompare,
00225                         rsbac_list_get_conv_t * get_conv,
00226                         rsbac_list_get_conv_t * get_subconv,
00227                         void *def_data,
00228                         void *def_subdata, char *name, kdev_t device,
00229                         u_int nr_hashes,
00230                         rsbac_list_hash_function_t hash_function,
00231                         char * old_base_name);
00232 
00233 /* Old and simpler registration function, sets nr_hashes to 1,
00234  * hash_function to NULL and old_base_name to NULL.
00235  */
00236 
00237 int rsbac_list_register(rsbac_version_t ds_version,
00238                         rsbac_list_handle_t * handle_p,
00239                         struct rsbac_list_info_t *info_p,
00240                         u_int flags,
00241                         rsbac_list_compare_function_t * compare,
00242                         rsbac_list_get_conv_t * get_conv,
00243                         void *def_data, char *name, kdev_t device);
00244 
00245 int rsbac_list_lol_register(rsbac_version_t ds_version,
00246                             rsbac_list_handle_t * handle_p,
00247                             struct rsbac_list_lol_info_t *info_p,
00248                             u_int flags,
00249                             rsbac_list_compare_function_t * compare,
00250                             rsbac_list_compare_function_t * subcompare,
00251                             rsbac_list_get_conv_t * get_conv,
00252                             rsbac_list_get_conv_t * get_subconv,
00253                             void *def_data,
00254                             void *def_subdata, char *name, kdev_t device);
00255 
00256 /* destroy list */
00257 /* list is destroyed, disk file is deleted */
00258 /* list must have been opened with register */
00259 int rsbac_list_destroy(rsbac_list_handle_t * handle_p,
00260                        rsbac_list_key_t key);
00261 
00262 int rsbac_list_lol_destroy(rsbac_list_handle_t * handle_p,
00263                            rsbac_list_key_t key);
00264 
00265 /* detach from list */
00266 /* list is saved (if persistent) and removed from memory. Call register for new access. */
00267 int rsbac_list_detach(rsbac_list_handle_t * handle_p,
00268                       rsbac_list_key_t key);
00269 
00270 int rsbac_list_lol_detach(rsbac_list_handle_t * handle_p,
00271                           rsbac_list_key_t key);
00272 
00273 /* set list's no_write flag */
00274 /* TRUE: do not write to disk, FALSE: writing allowed */
00275 int rsbac_list_no_write
00276     (rsbac_list_handle_t handle, rsbac_list_key_t key,
00277      rsbac_boolean_t no_write);
00278 
00279 int rsbac_list_lol_no_write
00280     (rsbac_list_handle_t handle, rsbac_list_key_t key,
00281      rsbac_boolean_t no_write);
00282 
00283 /* Set max_items_per_hash */
00284 int rsbac_list_max_items(rsbac_list_handle_t handle, rsbac_list_key_t key,
00285                         u_int max_items);
00286 
00287 int rsbac_list_lol_max_items(rsbac_list_handle_t handle, rsbac_list_key_t key,
00288                         u_int max_items, u_int max_subitems);
00289 
00290 /* Single list checking, good for cleanup of items with ttl in the past. */
00291 /* This functionality is also included in the big rsbac_check(). */
00292 
00293 int rsbac_list_check(rsbac_list_handle_t handle, int correct);
00294 
00295 int rsbac_list_lol_check(rsbac_list_handle_t handle, int correct);
00296 
00297 /* Transaction Support */
00298 #ifdef CONFIG_RSBAC_LIST_TRANS
00299 int rsbac_list_ta_begin(rsbac_time_t ttl,
00300                         rsbac_list_ta_number_t * ta_number_p,
00301                         rsbac_uid_t commit_uid, char *password);
00302 
00303 int rsbac_list_ta_refresh(rsbac_time_t ttl,
00304                           rsbac_list_ta_number_t ta_number,
00305                           char *password);
00306 
00307 int rsbac_list_ta_commit(rsbac_list_ta_number_t ta_number, char *password);
00308 
00309 int rsbac_list_ta_forget(rsbac_list_ta_number_t ta_number, char *password);
00310 #endif
00311 
00312 /* add with time-to-live - after this time in seconds the item gets automatically removed */
00313 /* set to 0 for unlimited (default), RSBAC_LIST_TTL_KEEP to keep previous setting */
00314 int rsbac_ta_list_add_ttl(rsbac_list_ta_number_t ta_number,
00315                           rsbac_list_handle_t handle,
00316                           rsbac_time_t ttl, void *desc, void *data);
00317 
00318 static inline int rsbac_list_add_ttl(rsbac_list_handle_t handle,
00319                        rsbac_time_t ttl, void *desc, void *data)
00320 {
00321         return rsbac_ta_list_add_ttl(0, handle, ttl, desc, data);
00322 }
00323 
00324 static inline int rsbac_list_add(rsbac_list_handle_t handle, void *desc, void *data)
00325 {
00326         return rsbac_ta_list_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP, desc,
00327                                      data);
00328 }
00329 
00330 /* Add list of lists sublist item, item for desc must exist */
00331 int rsbac_ta_list_lol_subadd_ttl(rsbac_list_ta_number_t ta_number,
00332                                  rsbac_list_handle_t handle,
00333                                  rsbac_time_t ttl,
00334                                  void *desc, void *subdesc, void *subdata);
00335 
00336 static inline int rsbac_list_lol_subadd_ttl(rsbac_list_handle_t handle,
00337                               rsbac_time_t ttl,
00338                               void *desc, void *subdesc, void *subdata)
00339 {
00340         return rsbac_ta_list_lol_subadd_ttl(0, handle, ttl, desc, subdesc,
00341                                             subdata);
00342 }
00343 
00344 static inline int rsbac_list_lol_subadd(rsbac_list_handle_t handle,
00345                           void *desc, void *subdesc, void *subdata)
00346 {
00347         return rsbac_ta_list_lol_subadd_ttl(0, handle, RSBAC_LIST_TTL_KEEP,
00348                                             desc, subdesc, subdata);
00349 }
00350 
00351 /* add with time-to-live - after this time in seconds the item gets automatically removed */
00352 int rsbac_ta_list_lol_add_ttl(rsbac_list_ta_number_t ta_number,
00353                               rsbac_list_handle_t handle,
00354                               rsbac_time_t ttl, void *desc, void *data);
00355 
00356 static inline int rsbac_list_lol_add_ttl(rsbac_list_handle_t handle,
00357                            rsbac_time_t ttl, void *desc, void *data)
00358 {
00359         return rsbac_ta_list_lol_add_ttl(0, handle, ttl, desc, data);
00360 }
00361 
00362 static inline int rsbac_list_lol_add(rsbac_list_handle_t handle, void *desc, void *data)
00363 {
00364         return rsbac_ta_list_lol_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP,
00365                                          desc, data);
00366 }
00367 
00368 /* remove item */
00369 int rsbac_ta_list_remove(rsbac_list_ta_number_t ta_number,
00370                          rsbac_list_handle_t handle, void *desc);
00371 
00372 static inline int rsbac_list_remove(rsbac_list_handle_t handle, void *desc)
00373 {
00374         return rsbac_ta_list_remove(0, handle, desc);
00375 }
00376 
00377 /* remove all items */
00378 int rsbac_ta_list_remove_all(rsbac_list_ta_number_t ta_number,
00379                              rsbac_list_handle_t handle);
00380 
00381 static inline int rsbac_list_remove_all(rsbac_list_handle_t handle)
00382 {
00383         return rsbac_ta_list_remove_all(0, handle);
00384 }
00385 
00386 /* remove item from sublist - also succeeds, if item for desc or subdesc does not exist */
00387 int rsbac_ta_list_lol_subremove(rsbac_list_ta_number_t ta_number,
00388                                 rsbac_list_handle_t handle,
00389                                 void *desc, void *subdesc);
00390 
00391 static inline int rsbac_list_lol_subremove(rsbac_list_handle_t handle,
00392                              void *desc, void *subdesc)
00393 {
00394         return rsbac_ta_list_lol_subremove(0, handle, desc, subdesc);
00395 }
00396 
00397 int rsbac_ta_list_lol_subremove_count(rsbac_list_ta_number_t ta_number,
00398                                       rsbac_list_handle_t handle,
00399                                       void *desc, u_long count);
00400 
00401 
00402 /* remove same subitem from all sublists */
00403 int rsbac_ta_list_lol_subremove_from_all(rsbac_list_ta_number_t ta_number,
00404                                          rsbac_list_handle_t handle,
00405                                          void *subdesc);
00406 
00407 static inline int rsbac_list_lol_subremove_from_all(rsbac_list_handle_t handle,
00408                                       void *subdesc)
00409 {
00410         return rsbac_ta_list_lol_subremove_from_all(0, handle, subdesc);
00411 }
00412 
00413 /* remove all subitems from list */
00414 int rsbac_ta_list_lol_subremove_all(rsbac_list_ta_number_t ta_number,
00415                                     rsbac_list_handle_t handle,
00416                                     void *desc);
00417 
00418 static inline int rsbac_list_lol_subremove_all(rsbac_list_handle_t handle, void *desc)
00419 {
00420         return rsbac_ta_list_lol_subremove_all(0, handle, desc);
00421 }
00422 
00423 int rsbac_ta_list_lol_remove(rsbac_list_ta_number_t ta_number,
00424                              rsbac_list_handle_t handle, void *desc);
00425 
00426 static inline int rsbac_list_lol_remove(rsbac_list_handle_t handle, void *desc)
00427 {
00428         return rsbac_ta_list_lol_remove(0, handle, desc);
00429 }
00430 
00431 int rsbac_ta_list_lol_remove_all(rsbac_list_ta_number_t ta_number,
00432                                  rsbac_list_handle_t handle);
00433 
00434 static inline int rsbac_list_lol_remove_all(rsbac_list_handle_t handle)
00435 {
00436         return rsbac_ta_list_lol_remove_all(0, handle);
00437 }
00438 
00439 
00440 /* get item data */
00441 /* Item data is copied - we cannot give a pointer, because item could be
00442  * removed */
00443 /* also get time-to-live - after this time in seconds the item gets automatically removed */
00444 /* both ttl_p and data can be NULL, they are then simply not returned */
00445 int rsbac_ta_list_get_data_ttl(rsbac_list_ta_number_t ta_number,
00446                                rsbac_list_handle_t handle,
00447                                rsbac_time_t * ttl_p,
00448                                void *desc, void *data);
00449 
00450 static inline int rsbac_list_get_data_ttl(rsbac_list_handle_t handle,
00451                             rsbac_time_t * ttl_p, void *desc, void *data)
00452 {
00453         return rsbac_ta_list_get_data_ttl(0, handle, ttl_p, desc, data);
00454 }
00455 
00456 static inline int rsbac_list_get_data(rsbac_list_handle_t handle, void *desc, void *data)
00457 {
00458         return rsbac_ta_list_get_data_ttl(0, handle, NULL, desc, data);
00459 }
00460 
00461 /* get data from a subitem */
00462 /* also get time-to-live - after this time in seconds the item gets automatically removed */
00463 /* both ttl_p and data can be NULL, they are then simply not returned */
00464 int rsbac_ta_list_lol_get_subdata_ttl(rsbac_list_ta_number_t ta_number,
00465                                       rsbac_list_handle_t handle,
00466                                       rsbac_time_t * ttl_p,
00467                                       void *desc,
00468                                       void *subdesc, void *subdata);
00469 
00470 static inline int rsbac_list_lol_get_subdata_ttl(rsbac_list_handle_t handle,
00471                                    rsbac_time_t * ttl_p,
00472                                    void *desc,
00473                                    void *subdesc, void *subdata)
00474 {
00475         return rsbac_ta_list_lol_get_subdata_ttl(0, handle,
00476                                                  ttl_p, desc, subdesc,
00477                                                  subdata);
00478 }
00479 
00480 static inline int rsbac_list_lol_get_subdata(rsbac_list_handle_t handle,
00481                                void *desc, void *subdesc, void *subdata)
00482 {
00483         return rsbac_ta_list_lol_get_subdata_ttl(0, handle, NULL, desc,
00484                                                  subdesc, subdata);
00485 }
00486 
00487 /* also get time-to-live - after this time in seconds the item gets automatically removed */
00488 /* both ttl_p and data can be NULL, they are then simply not returned */
00489 int rsbac_ta_list_lol_get_data_ttl(rsbac_list_ta_number_t ta_number,
00490                                    rsbac_list_handle_t handle,
00491                                    rsbac_time_t * ttl_p,
00492                                    void *desc, void *data);
00493 
00494 static inline int rsbac_list_lol_get_data_ttl(rsbac_list_handle_t handle,
00495                                 rsbac_time_t * ttl_p,
00496                                 void *desc, void *data)
00497 {
00498         return rsbac_ta_list_lol_get_data_ttl(0, handle, ttl_p, desc,
00499                                               data);
00500 }
00501 
00502 static inline int rsbac_list_lol_get_data(rsbac_list_handle_t handle,
00503                             void *desc, void *data)
00504 {
00505         return rsbac_ta_list_lol_get_data_ttl(0, handle, NULL, desc, data);
00506 }
00507 
00508 /* get item desc by data */
00509 /* Item desc is copied - we cannot give a pointer, because item could be
00510  * removed.
00511  * If no compare function is provided (NULL value), memcmp is used.
00512  * Note: The data value given here is always used as second parameter to the
00513  *       compare function, so you can use different types for storage and
00514  *       lookup.
00515  */
00516 int rsbac_ta_list_get_desc(rsbac_list_ta_number_t ta_number,
00517                            rsbac_list_handle_t handle,
00518                            void *desc,
00519                            void *data,
00520                            rsbac_list_data_compare_function_t compare);
00521 
00522 static inline int rsbac_list_get_desc(rsbac_list_handle_t handle,
00523                         void *desc,
00524                         void *data,
00525                         rsbac_list_data_compare_function_t compare)
00526 {
00527         return rsbac_ta_list_get_desc(0, handle, desc, data, compare);
00528 }
00529 
00530 int rsbac_ta_list_lol_get_desc(rsbac_list_ta_number_t ta_number,
00531                                rsbac_list_handle_t handle,
00532                                void *desc,
00533                                void *data,
00534                                rsbac_list_data_compare_function_t compare);
00535 
00536 static inline int rsbac_list_lol_get_desc(rsbac_list_handle_t handle,
00537                             void *desc,
00538                             void *data,
00539                             rsbac_list_data_compare_function_t compare)
00540 {
00541         return rsbac_ta_list_lol_get_desc(0, handle, desc, data, compare);
00542 }
00543 
00544 /* get maximum desc (uses compare function) */
00545 int rsbac_ta_list_get_max_desc(rsbac_list_ta_number_t ta_number,
00546                                rsbac_list_handle_t handle, void *desc);
00547 
00548 static inline int rsbac_list_get_max_desc(rsbac_list_handle_t handle, void *desc)
00549 {
00550         return rsbac_ta_list_get_max_desc(0, handle, desc);
00551 }
00552 
00553 int rsbac_ta_list_lol_get_max_subdesc(rsbac_list_ta_number_t ta_number,
00554                                       rsbac_list_handle_t handle,
00555                                       void *desc, void *subdesc);
00556 
00557 /* get next desc (uses compare function) */
00558 int rsbac_ta_list_get_next_desc(rsbac_list_ta_number_t ta_number,
00559                                 rsbac_list_handle_t handle,
00560                                 void *old_desc, void *next_desc);
00561 
00562 static inline int rsbac_list_get_next_desc(rsbac_list_handle_t handle, void *old_desc,
00563                              void *next_desc)
00564 {
00565         return rsbac_ta_list_get_next_desc(0, handle, old_desc, next_desc);
00566 }
00567 
00568 int rsbac_ta_list_lol_get_next_desc(rsbac_list_ta_number_t ta_number,
00569                                     rsbac_list_handle_t handle,
00570                                     void *old_desc, void *next_desc);
00571 
00572 static inline int rsbac_list_lol_get_next_desc(rsbac_list_handle_t handle,
00573                                  void *old_desc, void *next_desc)
00574 {
00575         return rsbac_ta_list_lol_get_next_desc(0, handle, old_desc,
00576                                                next_desc);
00577 }
00578 
00579 /* does item exist? */
00580 /* returns TRUE, if item exists, FALSE, if not or error */
00581 int rsbac_ta_list_exist(rsbac_list_ta_number_t ta_number,
00582                         rsbac_list_handle_t handle, void *desc);
00583 
00584 static inline int rsbac_list_exist(rsbac_list_handle_t handle, void *desc)
00585 {
00586         return rsbac_ta_list_exist(0, handle, desc);
00587 }
00588 
00589 int rsbac_ta_list_lol_subexist(rsbac_list_ta_number_t ta_number,
00590                                rsbac_list_handle_t handle,
00591                                void *desc, void *subdesc);
00592 
00593 static inline int rsbac_list_lol_subexist(rsbac_list_handle_t handle,
00594                             void *desc, void *subdesc)
00595 {
00596         return rsbac_ta_list_lol_subexist(0, handle, desc, subdesc);
00597 }
00598 
00599 int rsbac_ta_list_lol_exist(rsbac_list_ta_number_t ta_number,
00600                             rsbac_list_handle_t handle, void *desc);
00601 
00602 static inline int rsbac_list_lol_exist(rsbac_list_handle_t handle, void *desc)
00603 {
00604         return rsbac_ta_list_lol_exist(0, handle, desc);
00605 }
00606 
00607 /*
00608  * Note: The subdesc/data value given here is always used as second parameter to the
00609  *       given subdesc compare function, so you can use different types for storage and
00610  *       lookup. If compare is NULL, call is forwarded to rsbac_list_lol_subexist.
00611  * Warning: This function does not use the list optimization when searching the sublist!
00612  */
00613 int rsbac_ta_list_lol_subexist_compare(rsbac_list_ta_number_t ta_number,
00614                                        rsbac_list_handle_t handle,
00615                                        void *desc,
00616                                        void *subdesc,
00617                                        rsbac_list_compare_function_t
00618                                        compare);
00619 
00620 static inline int rsbac_list_lol_subexist_compare(rsbac_list_handle_t handle,
00621                                     void *desc,
00622                                     void *subdesc,
00623                                     rsbac_list_compare_function_t compare)
00624 {
00625         return rsbac_ta_list_lol_subexist_compare(0, handle,
00626                                                   desc, subdesc, compare);
00627 }
00628 
00629 /* count number of elements */
00630 /* returns number of elements or negative error code */
00631 long rsbac_ta_list_count(rsbac_list_ta_number_t ta_number,
00632                          rsbac_list_handle_t handle);
00633 
00634 static inline long rsbac_list_count(rsbac_list_handle_t handle)
00635 {
00636         return rsbac_ta_list_count(0, handle);
00637 }
00638 
00639 long rsbac_ta_list_lol_subcount(rsbac_list_ta_number_t ta_number,
00640                                 rsbac_list_handle_t handle, void *desc);
00641 
00642 static inline long rsbac_list_lol_subcount(rsbac_list_handle_t handle, void *desc)
00643 {
00644         return rsbac_ta_list_lol_subcount(0, handle, desc);
00645 }
00646 
00647 long rsbac_ta_list_lol_all_subcount(rsbac_list_ta_number_t ta_number,
00648                                     rsbac_list_handle_t handle);
00649 
00650 static inline long rsbac_list_lol_all_subcount(rsbac_list_handle_t handle)
00651 {
00652         return rsbac_ta_list_lol_all_subcount(0, handle);
00653 }
00654 
00655 long rsbac_ta_list_lol_count(rsbac_list_ta_number_t ta_number,
00656                              rsbac_list_handle_t handle);
00657 
00658 static inline long rsbac_list_lol_count(rsbac_list_handle_t handle)
00659 {
00660         return rsbac_ta_list_lol_count(0, handle);
00661 }
00662 
00663 
00664 /* Get array of all descriptors */
00665 /* Returns number of elements or negative error code */
00666 /* If return value > 0, *array_p contains a pointer to a vmalloc'd array of descs,
00667    otherwise *array_p is set to NULL. If *array_p has been set, caller must call
00668    vfree(*array_p) after use! */
00669 
00670 long rsbac_ta_list_get_all_desc(rsbac_list_ta_number_t ta_number,
00671                                 rsbac_list_handle_t handle,
00672                                 void **array_p);
00673 
00674 static inline long rsbac_list_get_all_desc(rsbac_list_handle_t handle, void **array_p)
00675 {
00676         return rsbac_ta_list_get_all_desc(0, handle, array_p);
00677 }
00678 
00679 long rsbac_ta_list_lol_get_all_subdesc_ttl(rsbac_list_ta_number_t
00680                                            ta_number,
00681                                            rsbac_list_handle_t handle,
00682                                            void *desc, void **array_p,
00683                                            rsbac_time_t ** ttl_array_p);
00684 
00685 static inline long rsbac_list_lol_get_all_subdesc(rsbac_list_handle_t handle, void *desc,
00686                                     void **array_p)
00687 {
00688         return rsbac_ta_list_lol_get_all_subdesc_ttl(0, handle,
00689                                                      desc, array_p, NULL);
00690 }
00691 
00692 static inline long rsbac_list_lol_get_all_subdesc_ttl(rsbac_list_handle_t handle,
00693                                         void *desc,
00694                                         void **array_p,
00695                                         rsbac_time_t ** ttl_array_p)
00696 {
00697         return rsbac_ta_list_lol_get_all_subdesc_ttl(0,
00698                                                      handle,
00699                                                      desc,
00700                                                      array_p, ttl_array_p);
00701 }
00702 
00703 long rsbac_ta_list_lol_get_all_desc(rsbac_list_ta_number_t ta_number,
00704                                     rsbac_list_handle_t handle,
00705                                     void **array_p);
00706 
00707 static inline long rsbac_list_lol_get_all_desc(rsbac_list_handle_t handle,
00708                                  void **array_p)
00709 {
00710         return rsbac_ta_list_lol_get_all_desc(0, handle, array_p);
00711 }
00712 
00713 /* Get array of all datas */
00714 /* Returns number of elements or negative error code */
00715 /* If return value > 0, *array_p contains a pointer to a vmalloc'd array of datas,
00716    otherwise *array_p is set to NULL. If *array_p has been set, caller must call
00717    vfree(*array_p) after use! */
00718 
00719 long rsbac_ta_list_get_all_data(rsbac_list_ta_number_t ta_number,
00720                                 rsbac_list_handle_t handle,
00721                                 void **array_p);
00722 
00723 static inline long rsbac_list_get_all_data(rsbac_list_handle_t handle, void **array_p)
00724 {
00725         return rsbac_ta_list_get_all_data(0, handle, array_p);
00726 }
00727 
00728 long rsbac_ta_list_lol_get_all_subdata(rsbac_list_ta_number_t ta_number,
00729                                        rsbac_list_handle_t handle,
00730                                        void *desc, void **array_p);
00731 
00732 static inline long rsbac_list_lol_get_all_subdata(rsbac_list_handle_t handle,
00733                                     void *desc, void **array_p)
00734 {
00735         return rsbac_ta_list_lol_get_all_subdata(0, handle, desc, array_p);
00736 }
00737 
00738 long rsbac_ta_list_lol_get_all_data(rsbac_list_ta_number_t ta_number,
00739                                     rsbac_list_handle_t handle,
00740                                     void **array_p);
00741 
00742 static inline long rsbac_list_lol_get_all_data(rsbac_list_handle_t handle,
00743                                  void **array_p)
00744 {
00745         return rsbac_ta_list_lol_get_all_data(0, handle, array_p);
00746 }
00747 
00748 /* Get item size */
00749 
00750 int rsbac_list_get_item_size(rsbac_list_handle_t handle);
00751 
00752 int rsbac_list_lol_get_subitem_size(rsbac_list_handle_t handle);
00753 
00754 int rsbac_list_lol_get_item_size(rsbac_list_handle_t handle);
00755 
00756 /* Get array of all items */
00757 /* Returns number of items or negative error code */
00758 /* If return value > 0, *array_p contains a pointer to a vmalloc'd array of items,
00759    where desc and data are placed directly behind each other.
00760    If *array_p has been set, caller must call vfree(*array_p) after use! */
00761 
00762 long rsbac_ta_list_get_all_items_ttl(rsbac_list_ta_number_t ta_number,
00763                                      rsbac_list_handle_t handle,
00764                                      void **array_p,
00765                                      rsbac_time_t ** ttl_array_p);
00766 
00767 static inline long rsbac_list_get_all_items_ttl(rsbac_list_handle_t handle,
00768                                   void **array_p,
00769                                   rsbac_time_t ** ttl_array_p)
00770 {
00771         return rsbac_ta_list_get_all_items_ttl(0, handle, array_p,
00772                                                ttl_array_p);
00773 }
00774 
00775 static inline long rsbac_list_get_all_items(rsbac_list_handle_t handle, void **array_p)
00776 {
00777         return rsbac_ta_list_get_all_items_ttl(0, handle, array_p, NULL);
00778 }
00779 
00780 long rsbac_ta_list_lol_get_all_subitems_ttl(rsbac_list_ta_number_t
00781                                             ta_number,
00782                                             rsbac_list_handle_t handle,
00783                                             void *desc, void **array_p,
00784                                             rsbac_time_t ** ttl_array_p);
00785 
00786 static inline long rsbac_list_lol_get_all_subitems_ttl(rsbac_list_handle_t handle,
00787                                          void *desc,
00788                                          void **array_p,
00789                                          rsbac_time_t ** ttl_array_p)
00790 {
00791         return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
00792                                                       array_p,
00793                                                       ttl_array_p);
00794 }
00795 
00796 static inline long rsbac_list_lol_get_all_subitems(rsbac_list_handle_t handle,
00797                                      void *desc, void **array_p)
00798 {
00799         return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
00800                                                       array_p, NULL);
00801 }
00802 
00803 long rsbac_ta_list_lol_get_all_items(rsbac_list_ta_number_t ta_number,
00804                                      rsbac_list_handle_t handle,
00805                                      void **array_p);
00806 
00807 static inline long rsbac_list_lol_get_all_items(rsbac_list_handle_t handle,
00808                                   void **array_p)
00809 {
00810         return rsbac_ta_list_lol_get_all_items(0, handle, array_p);
00811 }
00812 
00813 /* Copy a complete list
00814  * Both lists must have been registered with same desc and data sizes,
00815  * nr_hashes may differ. Old target list items are removed before copying.
00816  * If ta_number is set and transactions are enabled, the complete
00817  * target list content is in the same transaction. Forgetting the
00818  * transaction will restore the old to_list.
00819  */
00820 
00821 long rsbac_list_copy(rsbac_list_ta_number_t ta_number,
00822                         rsbac_list_handle_t from_handle,
00823                         rsbac_list_handle_t to_handle);
00824 
00825 long rsbac_list_lol_copy(rsbac_list_ta_number_t ta_number,
00826                         rsbac_list_handle_t from_handle,
00827                         rsbac_list_handle_t to_handle);
00828 
00829 /* Get the current number of hashes - may vary when resized */
00830 long rsbac_list_get_nr_hashes(rsbac_list_handle_t handle);
00831 
00832 long rsbac_list_lol_get_nr_hashes(rsbac_list_handle_t handle);
00833 
00834 #endif
00835 /* end of lists.h */

Generated on Wed May 16 11:53:27 2007 for RSBAC by  doxygen 1.5.1