]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socket.h
Much faster hash<string> for case-insensitive hashing, combined copy and lowercase...
[user/henk/code/inspircd.git] / include / socket.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef INSPIRCD_SOCKET_H
18 #define INSPIRCD_SOCKET_H
19
20 #include <arpa/inet.h>
21 #include <sys/time.h>
22 #include <sys/resource.h>
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <poll.h>
30 #include <netdb.h>
31 #include <errno.h>
32
33 #include "inspircd_config.h"
34
35 namespace irc
36 {
37         namespace sockets
38         {
39
40         /* macros to the relevant system address description structs */
41 #ifdef IPV6
42
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
47
48 #else
49
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
54
55 #endif
56
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);
60
61                 const char* insp_ntoa(insp_inaddr n);
62                 int insp_aton(const char* a, insp_inaddr* n);
63
64                 void Blocking(int s);
65                 void NonBlocking(int s);
66
67                 int OpenTCPSocket(); 
68                 bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr);
69                 int BindPorts(bool bail);
70         };
71 };
72
73 #endif