1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef INSPIRCD_SOCKET_H
18 #define INSPIRCD_SOCKET_H
20 #include <arpa/inet.h>
22 #include <sys/resource.h>
23 #include <sys/types.h>
24 #include <sys/socket.h>
26 #include <netinet/in.h>
33 #include "inspircd_config.h"
40 /* macros to the relevant system address description structs */
43 typedef struct sockaddr_in6 insp_sockaddr;
44 typedef struct in6_addr insp_inaddr;
45 #define AF_FAMILY AF_INET6
46 #define PF_PROTOCOL PF_INET6
50 typedef struct sockaddr_in insp_sockaddr;
51 typedef struct in_addr insp_inaddr;
52 #define AF_FAMILY AF_INET
53 #define PF_PROTOCOL PF_INET
57 bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits);
58 bool MatchCIDR(const char* address, const char* cidr_mask);
59 bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username);
61 const char* insp_ntoa(insp_inaddr n);
62 int insp_aton(const char* a, insp_inaddr* n);
65 void NonBlocking(int s);
68 bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr);
69 int BindPorts(bool bail);