dazuko_call.h

Go to the documentation of this file.
00001 /* Dazuko. Check parameters of XP calls before making real calls.
00002    Written by John Ogness <jogness@antivir.de>
00003 
00004    Copyright (c) 2003, 2004 H+BEDV Datentechnik GmbH
00005    All rights reserved.
00006 
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010 
00011    1. Redistributions of source code must retain the above copyright notice,
00012    this list of conditions and the following disclaimer.
00013 
00014    2. Redistributions in binary form must reproduce the above copyright notice,
00015    this list of conditions and the following disclaimer in the documentation
00016    and/or other materials provided with the distribution.
00017 
00018    3. Neither the name of Dazuko nor the names of its contributors may be used
00019    to endorse or promote products derived from this software without specific
00020    prior written permission.
00021 
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00026    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00027    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00028    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00029    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00030    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00031    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032    POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 #ifndef DAZUKO_CALL_H
00036 #define DAZUKO_CALL_H
00037 
00038 #include "dazuko_platform.h"
00039 
00040 #include "dazuko_xp.h"
00041 
00042 struct xp_mutex;
00043 struct xp_rwlock;
00044 struct xp_queue;
00045 struct xp_atomic;
00046 struct xp_file;
00047 struct dazuko_file_struct;
00048 struct xp_daemon_id;
00049 
00050 #define call_xp_sys_hook xp_sys_hook
00051 #define call_xp_sys_unhook xp_sys_unhook
00052 #define call_xp_print xp_print
00053 
00054 
00055 /* mutex */
00056 
00057 static inline int call_xp_init_mutex(struct xp_mutex *mutex)
00058 {
00059         if (mutex == NULL)
00060         {
00061                 xp_print("dazuko: xp_init_mutex(NULL)\n");
00062                 return -1;
00063         }
00064 
00065         return xp_init_mutex(mutex);
00066 }
00067 
00068 static inline int call_xp_down(struct xp_mutex *mutex)
00069 {
00070         if (mutex == NULL)
00071         {
00072                 xp_print("dazuko: warning: xp_down(NULL)\n");
00073                 return -1;
00074         }
00075 
00076         return xp_down(mutex);
00077 }
00078 
00079 static inline int call_xp_up(struct xp_mutex *mutex)
00080 {
00081         if (mutex == NULL)
00082         {
00083                 xp_print("dazuko: warning: xp_up(NULL)\n");
00084                 return -1;
00085         }
00086 
00087         return xp_up(mutex);
00088 }
00089 
00090 static inline int call_xp_destroy_mutex(struct xp_mutex *mutex)
00091 {
00092         if (mutex == NULL)
00093         {
00094                 xp_print("dazuko: warning: xp_destroy_mutex(NULL)\n");
00095                 return -1;
00096         }
00097 
00098         return xp_destroy_mutex(mutex);
00099 }
00100 
00101 
00102 /* read-write lock */
00103 
00104 static inline int call_xp_init_rwlock(struct xp_rwlock *rwlock)
00105 {
00106         if (rwlock == NULL)
00107         {
00108                 xp_print("dazuko: warning: xp_init_rwlock(NULL)\n");
00109                 return -1;
00110         }
00111 
00112         return xp_init_rwlock(rwlock);
00113 }
00114 
00115 static inline int call_xp_write_lock(struct xp_rwlock *rwlock)
00116 {
00117         if (rwlock == NULL)
00118         {
00119                 xp_print("dazuko: warning: xp_write_lock(NULL)\n");
00120                 return -1;
00121         }
00122 
00123         return xp_write_lock(rwlock);
00124 }
00125 
00126 static inline int call_xp_write_unlock(struct xp_rwlock *rwlock)
00127 {
00128         if (rwlock == NULL)
00129         {
00130                 xp_print("dazuko: warning: xp_write_unlock(NULL)\n");
00131                 return -1;
00132         }
00133 
00134         return xp_write_unlock(rwlock);
00135 }
00136 
00137 static inline int call_xp_read_lock(struct xp_rwlock *rlock)
00138 {
00139         if (rlock == NULL)
00140         {
00141                 xp_print("dazuko: warning: xp_read_lock(NULL)\n");
00142                 return -1;
00143         }
00144 
00145         return xp_read_lock(rlock);
00146 }
00147 
00148 static inline int call_xp_read_unlock(struct xp_rwlock *rlock)
00149 {
00150         if (rlock == NULL)
00151         {
00152                 xp_print("dazuko: warning: xp_read_unlock(NULL)\n");
00153                 return -1;
00154         }
00155 
00156         return xp_read_unlock(rlock);
00157 }
00158 
00159 static inline int call_xp_destroy_rwlock(struct xp_rwlock *rwlock)
00160 {
00161         if (rwlock == NULL)
00162         {
00163                 xp_print("dazuko: warning: xp_destroy_rwlock(NULL)\n");
00164                 return -1;
00165         }
00166 
00167         return xp_destroy_rwlock(rwlock);
00168 }
00169 
00170 
00171 /* wait-notify queue */
00172 
00173 static inline int call_xp_init_queue(struct xp_queue *queue)
00174 {
00175         if (queue == NULL)
00176         {
00177                 xp_print("dazuko: warning: xp_init_queue(NULL)\n");
00178                 return -1;
00179         }
00180 
00181         return xp_init_queue(queue);
00182 }
00183 
00184 static inline int call_xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt)
00185 {
00186         if (queue == NULL)
00187         {
00188                 xp_print("dazuko: warning: xp_wait_until_condition(queue=NULL)\n");
00189                 return -1;
00190         }
00191 
00192         if (cfunction == NULL)
00193         {
00194                 xp_print("dazuko: warning: xp_wait_until_condition(cfunction=NULL)\n");
00195                 return -1;
00196         }
00197 
00198         return xp_wait_until_condition(queue, cfunction, cparam, allow_interrupt);
00199 }
00200 
00201 static inline int call_xp_notify(struct xp_queue *queue)
00202 {
00203         if (queue == NULL)
00204         {
00205                 xp_print("dazuko: warning: xp_notify(NULL)\n");
00206                 return -1;
00207         }
00208 
00209         return xp_notify(queue);
00210 }
00211 
00212 static inline int call_xp_destroy_queue(struct xp_queue *queue)
00213 {
00214         if (queue == NULL)
00215         {
00216                 xp_print("dazuko: warning: xp_destroy_queue(NULL)\n");
00217                 return -1;
00218         }
00219 
00220         return xp_destroy_queue(queue);
00221 }
00222 
00223 
00224 /* memory */
00225 
00226 static inline void* call_xp_malloc(size_t size)
00227 {
00228         void *ptr;
00229 
00230         if (size < 1)
00231         {
00232                 xp_print("dazuko: warning: xp_malloc(%d)\n", size);
00233                 return NULL;
00234         }
00235 
00236         ptr = xp_malloc(size);
00237 
00238         if (ptr == NULL)
00239                 xp_print("dazuko: warning: xp_malloc(%d) -> NULL\n", size);
00240 
00241         return ptr;
00242 }
00243 
00244 static inline int call_xp_free(void *ptr)
00245 {
00246         if (ptr == NULL)
00247         {
00248                 xp_print("dazuko: warning: xp_free(NULL)\n");
00249                 return 0;
00250         }
00251 
00252         return xp_free(ptr);
00253 }
00254 
00255 static inline int call_xp_copyin(const void *user_src, void *kernel_dest, size_t size)
00256 {
00257         if (user_src == NULL)
00258         {
00259                 xp_print("dazuko: warning: xp_copyin(user_src=NULL)\n");
00260                 return -1;
00261         }
00262 
00263         if (kernel_dest == NULL)
00264         {
00265                 xp_print("dazuko: warning: xp_copyin(kernel_dest=NULL)\n");
00266                 return -1;
00267         }
00268 
00269         if (size < 1)
00270         {
00271                 xp_print("dazuko: warning: xp_copyin(size=%d)\n", size);
00272                 return 0;
00273         }
00274 
00275         return xp_copyin(user_src, kernel_dest, size);
00276 }
00277 
00278 static inline int call_xp_copyout(const void *kernel_src, void *user_dest, size_t size)
00279 {
00280         if (kernel_src == NULL)
00281         {
00282                 xp_print("dazuko: warning: xp_copyout(kernel_src=NULL)\n");
00283                 return -1;
00284         }
00285 
00286         if (user_dest == NULL)
00287         {
00288                 xp_print("dazuko: warning: xp_copyout(user_dest=NULL)\n");
00289                 return -1;
00290         }
00291 
00292         if (size < 1)
00293         {
00294                 xp_print("dazuko: warning: xp_copyout(size=%d)\n", size);
00295                 return 0;
00296         }
00297 
00298         return xp_copyout(kernel_src, user_dest, size);
00299 }
00300 
00301 static inline int call_xp_verify_user_writable(const void *user_ptr, size_t size)
00302 {
00303         if (user_ptr == NULL)
00304         {
00305                 xp_print("dazuko: warning: xp_verify_user_writable(user_ptr=NULL)\n");
00306                 return -1;
00307         }
00308 
00309         if (size < 1)
00310         {
00311                 xp_print("dazuko: warning: xp_verify_user_writable(size=%d)\n", size);
00312                 return -1;
00313         }
00314 
00315         return xp_verify_user_writable(user_ptr, size);
00316 }
00317 
00318 static inline int call_xp_verify_user_readable(const void *user_ptr, size_t size)
00319 {
00320         if (user_ptr == NULL)
00321         {
00322                 xp_print("dazuko: warning: xp_verify_user_readable(user_ptr=NULL)\n");
00323                 return -1;
00324         }
00325 
00326         if (size < 1)
00327         {
00328                 xp_print("dazuko: warning: xp_verify_user_readable(size=%d)\n", size);
00329                 return -1;
00330         }
00331 
00332         return xp_verify_user_readable(user_ptr, size);
00333 }
00334 
00335 
00336 /* path attribute */
00337 
00338 static inline int call_xp_is_absolute_path(const char *path)
00339 {
00340         if (path == NULL)
00341         {
00342                 xp_print("dazuko: warning: xp_is_absolute_path(NULL)\n");
00343                 return 0;
00344         }
00345 
00346         return xp_is_absolute_path(path);
00347 }
00348 
00349 
00350 /* atomic */
00351 
00352 static inline int call_xp_atomic_set(struct xp_atomic *atomic, int value)
00353 {
00354         if (atomic == NULL)
00355         {
00356                 xp_print("dazuko: warning: xp_atomic_set(atomic=NULL)\n");
00357                 return -1;
00358         }
00359 
00360         return xp_atomic_set(atomic, value);
00361 }
00362 
00363 static inline int call_xp_atomic_inc(struct xp_atomic *atomic)
00364 {
00365         if (atomic == NULL)
00366         {
00367                 xp_print("dazuko: warning: xp_atomic_inc(NULL)\n");
00368                 return -1;
00369         }
00370 
00371         return xp_atomic_inc(atomic);
00372 }
00373 
00374 static inline int call_xp_atomic_dec(struct xp_atomic *atomic)
00375 {
00376         if (atomic == NULL)
00377         {
00378                 xp_print("dazuko: warning: xp_atomic_dec(NULL)\n");
00379                 return -1;
00380         }
00381 
00382         return xp_atomic_dec(atomic);
00383 }
00384 
00385 static inline int call_xp_atomic_read(struct xp_atomic *atomic)
00386 {
00387         if (atomic == NULL)
00388         {
00389                 xp_print("dazuko: warning: xp_atomic_read(NULL)\n");
00390                 return -1;
00391         }
00392 
00393         return xp_atomic_read(atomic);
00394 }
00395 
00396 
00397 /* file descriptor */
00398 
00399 static inline int call_xp_copy_file(struct xp_file *dest, struct xp_file *src)
00400 {
00401         if (dest == NULL)
00402         {
00403                 xp_print("dazuko: warning: xp_copy_file(dest=NULL)\n");
00404                 return -1;
00405         }
00406 
00407         if (src == NULL)
00408         {
00409                 xp_print("dazuko: warning: xp_copy_file(src=NULL)\n");
00410                 return -1;
00411         }
00412 
00413         return xp_copy_file(dest, src);
00414 }
00415 
00416 static inline int call_xp_compare_file(struct xp_file *file1, struct xp_file *file2)
00417 {
00418         if (file1 == NULL)
00419         {
00420                 xp_print("dazuko: warning: xp_compare_file(file1=NULL)\n");
00421                 return -1;
00422         }
00423 
00424         if (file2 == NULL)
00425         {
00426                 xp_print("dazuko: warning: xp_compare_file(file2=NULL)\n");
00427                 return -1;
00428         }
00429 
00430         return xp_compare_file(file1, file2);
00431 }
00432 
00433 
00434 /* file structure */
00435 
00436 static inline int call_xp_fill_file_struct(struct dazuko_file_struct *dfs)
00437 {
00438         if (dfs == NULL)
00439         {
00440                 xp_print("dazuko: warning: xp_fill_file_struct(NULL)\n");
00441                 return -1;
00442         }
00443 
00444         return xp_fill_file_struct(dfs);
00445 }
00446 
00447 
00448 /* daemon id */
00449 
00450 static inline int call_xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2)
00451 {
00452         if (id1 == NULL)
00453         {
00454                 xp_print("dazuko: warning: xp_id_compare(id1=NULL)\n");
00455                 return -1;
00456         }
00457 
00458         if (id2 == NULL)
00459         {
00460                 xp_print("dazuko: warning: xp_id_compare(id2=NULL)\n");
00461                 return -1;
00462         }
00463 
00464         return xp_id_compare(id1, id2);
00465 }
00466 
00467 static inline int call_xp_id_free(struct xp_daemon_id *id)
00468 {
00469         if (id == NULL)
00470         {
00471                 xp_print("dazuko: warning: xp_id_free(NULL)\n");
00472                 return 0;
00473         }
00474 
00475         return xp_id_free(id);
00476 }
00477 
00478 static inline struct xp_daemon_id* call_xp_id_copy(struct xp_daemon_id *id)
00479 {
00480         struct xp_daemon_id *ptr;
00481 
00482         if (id == NULL)
00483         {
00484                 xp_print("dazuko: warning: xp_id_copy(NULL)\n");
00485                 return NULL;
00486         }
00487 
00488         ptr = xp_id_copy(id);
00489 
00490         if (ptr == NULL)
00491                 xp_print("dazuko: warning: xp_id_copy() -> NULL\n");
00492 
00493         return ptr;
00494 }
00495 
00496 #endif

Generated on Fri Jun 17 09:45:19 2005 for RSBAC by  doxygen 1.4.2