[insert project logo here (125x200px max)] Navigator Mailinglists Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums. Copyright and Licensing Information Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL). All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License. All sourcecode is made publicly available. Acknowledgement Splash and the Splash website are hosted by SourceForge.net |
Splash - DocumentationSNMP Plus a Lightweight API for SNAP Handlingsnap-1.1-wjdb/lib/dyncheck.hGo to the documentation of this file.00001 /* $Id: dyncheck.h,v 1.1.1.1 2002/12/04 18:59:42 wdebruij Exp $ */ 00002 00003 #ifndef _SNAP_DYNCHECK_H_ 00004 #define _SNAP_DYNCHECK_H_ 00005 00006 #ifdef __KERNEL__ 00007 #include <linux/kernel.h> 00008 #include <linux/types.h> 00009 #include <linux/icmp.h> 00010 #define __STRING(x) #x 00011 #endif /* __KERNEL__ */ 00012 00013 #ifndef NDYNCHECK 00014 #ifndef __KERNEL__ 00015 #define DYNCHECK_RET(expr,retv) \ 00016 { if (!(expr)) { \ 00017 fprintf(stderr,"%s:%d: dynamic check '%s' failed, dropping packet\n", \ 00018 __FILE__,__LINE__,__STRING(expr)); \ 00019 fflush(stderr); \ 00020 return (retv); \ 00021 } \ 00022 } 00023 #else 00024 #define DYNCHECK_RET(expr,retv) \ 00025 { if (!(expr)) { \ 00026 printk(KERN_WARNING "%s:%d: dynamic check '%s' failed, dropping packet\n", \ 00027 __FILE__,__LINE__,__STRING(expr)); \ 00028 return (retv); \ 00029 } \ 00030 } 00031 #endif /* !__KERNEL__ */ 00032 #ifdef __KERNEL__ 00033 #define DYNCHECK(expr) DYNCHECK_RET(expr,-ICMP_PARAMETERPROB) 00034 #else 00035 #define DYNCHECK(expr) DYNCHECK_RET(expr,-1) 00036 #endif /* __KERNEL__ */ 00037 #else 00038 #define DYNCHECK(expr) /**/ 00039 #define DYNCHECK_RET(expr,retv) /**/ 00040 #endif /* !NDYNCHECK */ 00041 00042 #define DYNCHECK_IN_HEAP(ho) \ 00043 DYNCHECK((((void *)(ho) >= p->heap_min) && \ 00044 ((void *)(ho) < p->heap_max) && \ 00045 (((void *)(ho) + \ 00046 ((ho)->len + sizeof(heap_obj))) <= p->heap_max)) || \ 00047 (((void *)(ho) >= (void *)p->stack_max) && \ 00048 ((void *)(ho) < p->h_alloc_heap_max) && \ 00049 (((void *)(ho) + \ 00050 ((ho)->len + sizeof(heap_obj))) <= p->h_alloc_heap_max))) 00051 00052 #define DYNCHECK_ADDR_IN_HEAP(ho) \ 00053 DYNCHECK((((void *)(ho) >= p->heap_min) && \ 00054 ((void *)(ho) < p->heap_max) && \ 00055 (((void *)(ho) + sizeof(uint32) + \ 00056 sizeof(heap_obj)) <= p->heap_max)) || \ 00057 (((void *)(ho) >= (void *)p->stack_max) && \ 00058 ((void *)(ho) < p->h_alloc_heap_max) && \ 00059 (((void *)(ho) + sizeof(uint32) + \ 00060 sizeof(heap_obj)) <= p->h_alloc_heap_max))) 00061 00062 00063 #endif /* !_SNAP_DYNCHECK_H_ */ |