This commit was generated by cvs2svn to compensate for changes in r2,
[ircu2.10.12-pk.git] / include / s_bsd.h
1 #ifndef S_BSD_H
2 #define S_BSD_H
3
4 #include <netdb.h>
5 #include "s_conf.h"
6
7 /*=============================================================================
8  * Macro's
9  */
10
11 #define FLAGS_PINGSENT   0x0001 /* Unreplied ping sent */
12 #define FLAGS_DEADSOCKET 0x0002 /* Local socket is dead--Exiting soon */
13 #define FLAGS_KILLED     0x0004 /* Prevents "QUIT" from being sent for this */
14 #define FLAGS_OPER       0x0008 /* Operator */
15 #define FLAGS_LOCOP      0x0010 /* Local operator -- SRB */
16 #define FLAGS_INVISIBLE  0x0020 /* makes user invisible */
17 #define FLAGS_WALLOP     0x0040 /* send wallops to them */
18 #define FLAGS_SERVNOTICE 0x0080 /* server notices such as kill */
19 #define FLAGS_BLOCKED    0x0100 /* socket is in a blocked condition */
20 #define FLAGS_UNIX       0x0200 /* socket is in the unix domain, not inet */
21 #define FLAGS_CLOSING    0x0400 /* set when closing to suppress errors */
22 #define FLAGS_LISTEN     0x0800 /* used to mark clients which we listen() on */
23 #define FLAGS_CHKACCESS  0x1000 /* ok to check clients access if set */
24 #define FLAGS_DOINGDNS   0x2000 /* client is waiting for a DNS response */
25 #define FLAGS_AUTH       0x4000 /* client is waiting on rfc931 response */
26 #define FLAGS_WRAUTH     0x8000 /* set if we havent writen to ident server */
27 #define FLAGS_LOCAL     0x00010000      /* set for local clients */
28 #define FLAGS_GOTID     0x00020000      /* successful ident lookup achieved */
29 #define FLAGS_DOID      0x00040000      /* I-lines say must use ident return */
30 #define FLAGS_NONL      0x00080000      /* No \n in buffer */
31 #define FLAGS_TS8       0x00100000      /* Why do you want to know? */
32 #define FLAGS_PING      0x00200000      /* Socket needs to send udp pings */
33 #define FLAGS_ASKEDPING 0x00400000      /* Client asked for udp ping */
34 #define FLAGS_MAP       0x00800000      /* Show server on the map */
35 #define FLAGS_JUNCTION  0x01000000      /* Junction causing the net.burst */
36 #define FLAGS_DEAF      0x02000000      /* Makes user deaf */
37 #define FLAGS_CHSERV    0x04000000      /* Disallow KICK or MODE -o on the user;
38                                            don't display channels in /whois */
39 #define FLAGS_BURST     0x08000000      /* Server is receiving a net.burst */
40 #define FLAGS_BURST_ACK 0x10000000      /* Server is waiting for eob ack */
41 #define FLAGS_DEBUG     0x20000000      /* send global debug/anti-hack info */
42 #define FLAGS_IPCHECK   0x40000000      /* Added or updated IPregistry data */
43
44 #define SEND_UMODES \
45     (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP|FLAGS_DEAF|FLAGS_CHSERV|FLAGS_DEBUG)
46 #define ALL_UMODES (SEND_UMODES|FLAGS_SERVNOTICE|FLAGS_LOCOP)
47 #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID)
48
49 /*
50  * flags macros.
51  */
52 #define IsOper(x)               ((x)->flags & FLAGS_OPER)
53 #define IsLocOp(x)              ((x)->flags & FLAGS_LOCOP)
54 #define IsInvisible(x)          ((x)->flags & FLAGS_INVISIBLE)
55 #define IsDeaf(x)               ((x)->flags & FLAGS_DEAF)
56 #define IsChannelService(x)     ((x)->flags & FLAGS_CHSERV)
57 #define IsAnOper(x)             ((x)->flags & (FLAGS_OPER|FLAGS_LOCOP))
58 #define IsPrivileged(x)         (IsAnOper(x) || IsServer(x))
59 #define SendWallops(x)          ((x)->flags & FLAGS_WALLOP)
60 #define SendDebug(x)            ((x)->flags & FLAGS_DEBUG)
61 #define SendServNotice(x)       ((x)->flags & FLAGS_SERVNOTICE)
62 #define IsUnixSocket(x)         ((x)->flags & FLAGS_UNIX)
63 #define IsListening(x)          ((x)->flags & FLAGS_LISTEN)
64 #define DoAccess(x)             ((x)->flags & FLAGS_CHKACCESS)
65 #define IsLocal(x)              ((x)->flags & FLAGS_LOCAL)
66 #define IsDead(x)               ((x)->flags & FLAGS_DEADSOCKET)
67 #define IsJunction(x)           ((x)->flags & FLAGS_JUNCTION)
68 #define IsBurst(x)              ((x)->flags & FLAGS_BURST)
69 #define IsBurstAck(x)           ((x)->flags & FLAGS_BURST_ACK)
70 #define IsBurstOrBurstAck(x)    ((x)->flags & (FLAGS_BURST|FLAGS_BURST_ACK))
71 #define IsIPChecked(x)          ((x)->flags & FLAGS_IPCHECK)
72
73 #define SetOper(x)              ((x)->flags |= FLAGS_OPER)
74 #define SetLocOp(x)             ((x)->flags |= FLAGS_LOCOP)
75 #define SetInvisible(x)         ((x)->flags |= FLAGS_INVISIBLE)
76 #define SetWallops(x)           ((x)->flags |= FLAGS_WALLOP)
77 #define SetDebug(x)             ((x)->flags |= FLAGS_DEBUG)
78 #define SetUnixSock(x)          ((x)->flags |= FLAGS_UNIX)
79 #define SetDNS(x)               ((x)->flags |= FLAGS_DOINGDNS)
80 #define DoingDNS(x)             ((x)->flags & FLAGS_DOINGDNS)
81 #define SetAccess(x)            ((x)->flags |= FLAGS_CHKACCESS)
82 #define DoingAuth(x)            ((x)->flags & FLAGS_AUTH)
83 #define NoNewLine(x)            ((x)->flags & FLAGS_NONL)
84 #define DoPing(x)               ((x)->flags & FLAGS_PING)
85 #define SetAskedPing(x)         ((x)->flags |= FLAGS_ASKEDPING)
86 #define AskedPing(x)            ((x)->flags & FLAGS_ASKEDPING)
87 #define SetJunction(x)          ((x)->flags |= FLAGS_JUNCTION)
88 #define SetBurst(x)             ((x)->flags |= FLAGS_BURST)
89 #define SetBurstAck(x)          ((x)->flags |= FLAGS_BURST_ACK)
90 #define SetIPChecked(x)         ((x)->flags |= FLAGS_IPCHECK)
91
92 #define ClearOper(x)            ((x)->flags &= ~FLAGS_OPER)
93 #define ClearLocOp(x)           ((x)->flags &= ~FLAGS_LOCOP)
94 #define ClearInvisible(x)       ((x)->flags &= ~FLAGS_INVISIBLE)
95 #define ClearWallops(x)         ((x)->flags &= ~FLAGS_WALLOP)
96 #define ClearDebug(x)           ((x)->flags &= ~FLAGS_DEBUG)
97 #define ClearDNS(x)             ((x)->flags &= ~FLAGS_DOINGDNS)
98 #define ClearAuth(x)            ((x)->flags &= ~FLAGS_AUTH)
99 #define ClearAccess(x)          ((x)->flags &= ~FLAGS_CHKACCESS)
100 #define ClearPing(x)            ((x)->flags &= ~FLAGS_PING)
101 #define ClearAskedPing(x)       ((x)->flags &= ~FLAGS_ASKEDPING)
102 #define ClearBurst(x)           ((x)->flags &= ~FLAGS_BURST)
103 #define ClearBurstAck(x)        ((x)->flags &= ~FLAGS_BURST_ACK)
104
105 /* used for async dns values */
106
107 #define ASYNC_NONE      0
108 #define ASYNC_CLIENT    1
109 #define ASYNC_CONNECT   2
110 #define ASYNC_CONF      3
111 #define ASYNC_PING      4
112
113 /* server notice stuff */
114
115 #define SNO_ADD         1
116 #define SNO_DEL         2
117 #define SNO_SET         3
118                                 /* DON'T CHANGE THESE VALUES ! */
119                                 /* THE CLIENTS DEPEND ON IT  ! */
120 #define SNO_OLDSNO      0x1     /* unsorted old messages */
121 #define SNO_SERVKILL    0x2     /* server kills (nick collisions) */
122 #define SNO_OPERKILL    0x4     /* oper kills */
123 #define SNO_HACK2       0x8     /* desyncs */
124 #define SNO_HACK3       0x10    /* temporary desyncs */
125 #define SNO_UNAUTH      0x20    /* unauthorized connections */
126 #define SNO_TCPCOMMON   0x40    /* common TCP or socket errors */
127 #define SNO_TOOMANY     0x80    /* too many connections */
128 #define SNO_HACK4       0x100   /* Uworld actions on channels */
129 #define SNO_GLINE       0x200   /* glines */
130 #define SNO_NETWORK     0x400   /* net join/break, etc */
131 #define SNO_IPMISMATCH  0x800   /* IP mismatches */
132 #define SNO_THROTTLE    0x1000  /* host throttle add/remove notices */
133 #define SNO_OLDREALOP   0x2000  /* old oper-only messages */
134 #define SNO_CONNEXIT    0x4000  /* client connect/exit (ugh) */
135
136 #define SNO_ALL         0x7fff  /* Don't make it larger then significant,
137                                  * that looks nicer */
138
139 #define SNO_USER        (SNO_ALL & ~SNO_OPER)
140
141 #define SNO_DEFAULT (SNO_NETWORK|SNO_OPERKILL|SNO_GLINE)
142 #define SNO_OPERDEFAULT (SNO_DEFAULT|SNO_HACK2|SNO_HACK4|SNO_THROTTLE|SNO_OLDSNO)
143 #define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP)
144 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
145
146 /*
147  * simple defines to differentiate between a tty and socket for
148  * add_connection()  -Simon
149  */
150
151 #define ADCON_TTY 0
152 #define ADCON_SOCKET 1
153
154 /*=============================================================================
155  * Proto types
156  */
157
158 extern int setsnomask(aClient *cptr, snomask_t newmask, int what);
159 extern snomask_t umode_make_snomask(snomask_t oldmask, char *arg, int what);
160 extern int connect_server(aConfItem *aconf, aClient *by, struct hostent *hp);
161 extern void report_error(char *text, aClient *cptr);
162 extern int inetport(aClient *cptr, char *name, unsigned short int port);
163 extern int add_listener(aConfItem *aconf);
164 extern void close_listeners(void);
165 extern void init_sys(void);
166 extern void write_pidfile(void);
167 extern enum AuthorizationCheckResult check_client(aClient *cptr);
168 extern int check_server(aClient *cptr);
169 extern void close_connection(aClient *cptr);
170 extern int get_sockerr(aClient *cptr);
171 extern void set_non_blocking(int fd, aClient *cptr);
172 extern aClient *add_connection(aClient *cptr, int fd, int type);
173 extern int read_message(time_t delay);
174 extern void get_my_name(aClient *cptr, char *name, size_t len);
175 extern int setup_ping(void);
176
177 extern int highest_fd, resfd;
178 extern unsigned int readcalls;
179 extern aClient *loc_clients[MAXCONNECTIONS];
180 #ifdef VIRTUAL_HOST
181 extern struct sockaddr_in vserv;
182 #endif
183
184 #endif /* S_BSD_H */