/************************************************************************* *** Authentication, authorization, accounting + firewalling package *** (c) 1998-2002 Anton Vinokurov *** (c) 2002-2006 NeTAMS Development Team *** All rights reserved. See 'Copying' file included in distribution *** For latest version and more info, visit this project web page *** located at http://www.netams.com *** *************************************************************************/ /* $Id: lib.h,v 1.4 2007-04-10 06:14:12 jura Exp $ */ #ifndef __LIB_H #define __LIB_H #ifdef SOLARIS int daemon(int nochdir, int noclose); int vasprintf(char **ret, const char *format, va_list ap); int asprintf(char **str, char const *fmt, ...); struct ether_addr *ether_aton(const char *a); char *ether_ntoa(const struct ether_addr *n); char *strcasestr(const char *s, const char *find); #endif ///////////////////////////////////////////////////////////////////////////////////////// //below obtained from flow-tools #define FT_SO_RCV_BUFSIZE (4*1024*1024) /* UDP recv socket buffer size */ int bigsockbuf(int fd, int dir, int size); u_short CRC16(u_char *idx, u_char idx_size); ///////////////////////////////////////////////////////////////////////////////////////// #define POLL_TIMEOUT 1000 #define SET_POLL(socket) struct pollfd pfd; pfd.fd=socket; pfd.events = POLLIN; #define CHECK_POLL(service,status) { \ if ((status = poll(&pfd, 1, POLL_TIMEOUT)) < 0 ) { \ if(errno != EINTR) aLog(D_ERR, "%s:%u poll: %s\n", \ service->getName(), service->instance, strerror(errno)); \ continue; \ } \ } // from codeproject.com #define ntohll(x) (((u_int64_t)(ntohl((u_int32_t)((x << 32) >> 32))) << 32) | \ (u_int32_t)ntohl(((u_int32_t)(x >> 32)))) //By Runner #define htonll(x) ntohll(x) ///////////////////////////////////////////////////////////////////////////////////////// #define STRSTR(str1, str2) (str1 && str2 && strstr(str1, str2)) #define STREQ(str1, str2) (str1 && str2 && !strcasecmp(str1, str2)) #define STRNEQ(str1, str2, n) (str1 && str2 && !strncasecmp(str1, str2, n)) #define STRARG(param, word) \ (param && *(¶m + 1) && !strcasecmp(param, word)) ? \ *(¶m + 1) : NULL #define STRNARG(param, word, n) \ (param && *(¶m + 1) && !strncasecmp(param, word, n)) ? \ *(¶m + 1) : NULL #endif