/*
* ----------------------------------------------------------------
* Night Light IRC Proxy - Listen Header
* ----------------------------------------------------------------
* Copyright (C) 1997-2007 Jonas Kvinge <jonas@night-light.net>
* 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 (24.11.2007)
*
*/
#ifdef LISTEN_H
#warning "listen.h already included."
#else
#define LISTEN_H
struct in_addr;
#if IPV6_SUPPORT
struct in6_addr;
#endif
/* DEFINES - JONAS (18.07.2001) */
#define LISTEN_INTERVAL 60
#define LISTEN_SOCKKEEPALIVE TRUE
#define LISTEN_SOCKREUSEADDR TRUE
/* BIT MASKS - JONAS (18.07.2001) */
#define LISTEN_BITMASK_IPV6 2
#define LISTEN_BITMASK_SSL 4
#define LISTEN_BITMASK_REMOVE 8
#define LISTEN_BITMASK_RESOLVING 2
#define LISTEN_BITMASK_RESOLVED 4
#define LISTEN_BITMASK_SOCKET 8
#define LISTEN_BITMASK_LISTENING 16
/* MACROS - JONAS (18.07.2001) */
#define Listen_SetIPv6(x) ((x)->PermFlags |= LISTEN_BITMASK_IPV6)
#define Listen_SetSSL(x) ((x)->PermFlags |= LISTEN_BITMASK_SSL)
#define Listen_SetRemove(x) ((x)->PermFlags |= LISTEN_BITMASK_REMOVE)
#define Listen_ClearIPv6(x) ((x)->PermFlags &= ~LISTEN_BITMASK_IPV6)
#define Listen_ClearSSL(x) ((x)->PermFlags &= ~LISTEN_BITMASK_SSL)
#define Listen_ClearRemove(x) ((x)->PermFlags &= ~LISTEN_BITMASK_REMOVE)
#define Listen_IsIPv6(x) ((x)->PermFlags & LISTEN_BITMASK_IPV6)
#define Listen_IsSSL(x) ((x)->PermFlags & LISTEN_BITMASK_SSL)
#define Listen_IsRemove(x) ((x)->PermFlags & LISTEN_BITMASK_REMOVE)
#define Listen_SetResolving(x) ((x)->Flags |= LISTEN_BITMASK_RESOLVING)
#define Listen_SetResolved(x) ((x)->Flags |= LISTEN_BITMASK_RESOLVED)
#define Listen_SetSocket(x) ((x)->Flags |= LISTEN_BITMASK_SOCKET)
#define Listen_SetListening(x) ((x)->Flags |= LISTEN_BITMASK_LISTENING)
#define Listen_ClearResolving(x) ((x)->Flags &= ~LISTEN_BITMASK_RESOLVING)
#define Listen_ClearResolved(x) ((x)->Flags &= ~LISTEN_BITMASK_RESOLVED)
#define Listen_ClearSocket(x) ((x)->Flags &= ~LISTEN_BITMASK_SOCKET)
#define Listen_ClearListening(x) ((x)->Flags &= ~LISTEN_BITMASK_LISTENING)
#define Listen_IsResolving(x) ((x)->Flags & LISTEN_BITMASK_RESOLVING)
#define Listen_IsResolved(x) ((x)->Flags & LISTEN_BITMASK_RESOLVED)
#define Listen_IsSocket(x) ((x)->Flags & LISTEN_BITMASK_SOCKET)
#define Listen_IsListening(x) ((x)->Flags & LISTEN_BITMASK_LISTENING)
/* STRUCTURES - JONAS (18.07.2001) */
struct Listen_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 Listen_Struct *Prev;
struct Listen_Struct *Next;
};
/* FUNCTION PROTOTYPES - JONAS (18.07.2001) */
struct Listen_Struct *listen_add(const char *const HostPT, const unsigned long int Port);
void listen_rem(struct Listen_Struct *ListenS);
void listen_init(struct Listen_Struct *ListenS);
struct Listen_Struct *listen_get(const char *const HostPT, const unsigned long int Port);
#endif
syntax highlighted by Code2HTML, v. 0.9.1