/* * ---------------------------------------------------------------- * Night Light IRC Proxy - Ident Daemon - Listener Header * ---------------------------------------------------------------- * Copyright (C) 1997-2007 Jonas Kvinge * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Last modified by: * Jonas Kvinge (25.11.2007) * */ #ifdef IDENT_LISTEN_H #warning "ident_listen.h already included." #else #define IDENT_LISTEN_H struct in_addr; struct in6_addr; struct hostent; /* DEFINES - JONAS (03.07.2003) */ #define IDENTLISTEN_INTERVAL 60 #define IDENTLISTEN_SOCKKEEPALIVE TRUE #define IDENTLISTEN_SOCKREUSEADDR TRUE /* BIT MASKS - JONAS (03.07.2003) */ #define IDENTLISTEN_BITMASK_IPV6 2 #define IDENTLISTEN_BITMASK_REMOVE 4 #define IDENTLISTEN_BITMASK_RESOLVING 2 #define IDENTLISTEN_BITMASK_RESOLVED 4 #define IDENTLISTEN_BITMASK_SOCKET 8 #define IDENTLISTEN_BITMASK_LISTENING 16 /* MACROS - JONAS (03.07.2003) */ #define IdentListen_SetIPv6(x) ((x)->PermFlags |= IDENTLISTEN_BITMASK_IPV6) #define IdentListen_SetRemove(x) ((x)->PermFlags |= IDENTLISTEN_BITMASK_REMOVE) #define IdentListen_ClearIPv6(x) ((x)->PermFlags &= ~IDENTLISTEN_BITMASK_IPV6) #define IdentListen_ClearRemove(x) ((x)->PermFlags &= ~IDENTLISTEN_BITMASK_REMOVE) #define IdentListen_IsIPv6(x) ((x)->PermFlags & IDENTLISTEN_BITMASK_IPV6) #define IdentListen_IsRemove(x) ((x)->PermFlags & IDENTLISTEN_BITMASK_REMOVE) #define IdentListen_SetResolving(x) ((x)->Flags |= IDENTLISTEN_BITMASK_RESOLVING) #define IdentListen_SetResolved(x) ((x)->Flags |= IDENTLISTEN_BITMASK_RESOLVED) #define IdentListen_SetSocket(x) ((x)->Flags |= IDENTLISTEN_BITMASK_SOCKET) #define IdentListen_SetListening(x) ((x)->Flags |= IDENTLISTEN_BITMASK_LISTENING) #define IdentListen_ClearResolving(x) ((x)->Flags &= ~IDENTLISTEN_BITMASK_RESOLVING) #define IdentListen_ClearResolved(x) ((x)->Flags &= ~IDENTLISTEN_BITMASK_RESOLVED) #define IdentListen_ClearSocket(x) ((x)->Flags &= ~IDENTLISTEN_BITMASK_SOCKET) #define IdentListen_ClearListening(x) ((x)->Flags &= ~IDENTLISTEN_BITMASK_LISTENING) #define IdentListen_IsResolving(x) ((x)->Flags & IDENTLISTEN_BITMASK_RESOLVING) #define IdentListen_IsResolved(x) ((x)->Flags & IDENTLISTEN_BITMASK_RESOLVED) #define IdentListen_IsSocket(x) ((x)->Flags & IDENTLISTEN_BITMASK_SOCKET) #define IdentListen_IsListening(x) ((x)->Flags & IDENTLISTEN_BITMASK_LISTENING) /* STRUCTURES - JONAS (03.07.2003) */ struct IdentListen_Struct { char *Host; unsigned long int PermFlags; unsigned long int Flags; char *HostIPS; struct in_addr INAddr; #if IPV6_SUPPORT struct in6_addr INAddr6; #endif unsigned long int PortH; unsigned long int PortN; signed long int FD; time_t Time; unsigned short int Tries; struct IdentListen_Struct *Prev; struct IdentListen_Struct *Next; }; /* FUNCTION PROTOTYPES - JONAS (03.07.2003) */ struct IdentListen_Struct *ident_listen_add(const char *const HostPT, const unsigned long int Port); void ident_listen_rem(struct IdentListen_Struct *IdentListenS); void ident_listen_init(struct IdentListen_Struct *IdentListenS); struct IdentListen_Struct *ident_get(const char *const HostPT, const unsigned long int Port); void ident_listen_start(struct IdentListen_Struct *IdentListenS); #if HAVE_CARES_CALLBACK_TIMEOUTS void ident_listen_hosttoip(void *ArgPT, unsigned short int ErrNo, int Timeouts, struct hostent *HostEnt); #else void ident_listen_hosttoip(void *ArgPT, unsigned short int ErrNo, struct hostent *HostEnt); #endif void ident_listen_stop(struct IdentListen_Struct *IdentListenS); void ident_listen_fds(fd_set *ReadFDS, fd_set *WriteFDS, unsigned long int *FDS); void ident_listen_io(fd_set *ReadFDS, fd_set *WriteFDS, unsigned long int *FDS); unsigned short int ident_listen_closeall(const char *const MessagePT, ...) __attribute__ ((format (printf, 1, 2))); #endif