00001 /** 00002 ** @file hi_util.h 00003 ** 00004 ** @author Daniel Roelker <droelker@sourcefire.com> 00005 ** 00006 ** @brief HttpInspect utility functions. 00007 ** 00008 ** Contains function prototype and inline utility functions. 00009 ** 00010 ** NOTES: 00011 ** - Initial development. DJR 00012 */ 00013 00014 #ifndef __HI_UTIL_H__ 00015 #define __HI_UTIL_H__ 00016 00017 #include "hi_include.h" 00018 00019 /* 00020 ** NAME 00021 ** hi_util_in_bounds:: 00022 */ 00023 /** 00024 ** This function checks for in bounds condition on buffers. 00025 ** 00026 ** This is very important for much of what we do here, since inspecting 00027 ** data buffers is mainly what we do. So we always make sure that we are 00028 ** within the buffer. 00029 ** 00030 ** This checks a half-open interval with the end pointer being one char 00031 ** after the end of the buffer. 00032 ** 00033 ** @param start the start of the buffer. 00034 ** @param end the end of the buffer. 00035 ** @param p the pointer within the buffer 00036 ** 00037 ** @return integer 00038 ** 00039 ** @retval 1 within bounds 00040 ** @retval 0 not within bounds 00041 */ 00042 static INLINE int hi_util_in_bounds(u_char *start, u_char *end, u_char *p) 00043 { 00044 if(p >= start && p < end) 00045 { 00046 return 1; 00047 } 00048 00049 return 0; 00050 } 00051 00052 #endif 00053