1 #ifndef INCLUDED_ircd_network_h
2 #define INCLUDED_ircd_network_h
4 * IRC - Internet Relay Chat, include/ircd_network.h
5 * Copyright (C) 2001 Kevin L. Mitchell <klmitch@mit.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef INCLUDED_config_h
27 #ifndef INCLUDED_time_h
28 #include <time.h> /* struct timespec */
29 #define INCLUDED_time_h
32 #ifndef HAVE_STRUCT_TIMESPEC
34 long int tv_sec; /* seconds */
35 long int tv_nsec; /* nanoseconds */
37 #endif /* !HAVE_STRUCT_TIMESPEC */
39 typedef void (*EventCallBack)(struct Event*);
42 SS_CONNECTING, /* Connection in progress on socket */
43 SS_LISTENING, /* Socket is a listening socket */
44 SS_CONNECTED, /* Socket is a connected socket */
45 SS_DATAGRAM, /* Socket is a datagram socket */
46 SS_CONNECTDG /* Socket is a connected datagram socket */
50 TT_ABSOLUTE, /* timer that runs at a specific time */
51 TT_RELATIVE, /* timer that runs so many seconds in the future */
52 TT_PERIODIC /* timer that runs periodically */
56 ET_READ, /* Readable event detected */
57 ET_WRITE, /* Writable event detected */
58 ET_ACCEPT, /* Connection can be accepted */
59 ET_CONNECT, /* Connection completed */
60 ET_EOF, /* End-of-file on connection */
61 ET_ERROR, /* Error condition detected */
62 ET_SIGNAL, /* A signal was received */
63 ET_TIMER /* A timer expired */
67 struct Socket* s_next; /* linked list of sockets */
68 struct Socket** s_prev_p;
69 enum SocketState s_state; /* state socket's in */
70 unsigned int s_flags; /* socket flags */
71 int s_fd; /* file descriptor for socket */
72 EventCallBack s_callback; /* single callback for socket */
73 void* s_data; /* data for socket--struct Client, etc. */
76 #define SOCK_EVENT_READABLE 0x0001 /* interested in readable */
77 #define SOCK_EVENT_WRITABLE 0x0002 /* interested in writable */
78 #define SOCK_FLAG_CLOSED 0x0010 /* socket got closed at some point */
81 struct Signal* sig_next; /* linked list of signals */
82 struct Signal** sig_prev_p;
83 int sig_signal; /* signal number */
84 unsigned int sig_count; /* count of number of signals */
85 EventCallBack sig_callback; /* signal callback function */
86 void* sig_data; /* data for signal */
90 struct Timer* t_next; /* linked list of timers */
91 struct Timer** t_prev_p;
92 enum TimerType t_type; /* what type of timer this is */
93 struct timespec t_value; /* value timer was added with */
94 struct timespec t_expire; /* time at which timer expires */
95 EventCallBack t_callback; /* timer callback function */
96 void* t_data; /* data for timer--struct Auth, whatever */
100 struct Event* ev_next; /* linked list of events on queue */
101 struct Event** ev_prev_p;
102 enum EventType ev_type; /* Event type */
103 EventCallBack ev_callback; /* Event callback function */
105 struct Socket* gen_socket; /* Socket generating event */
106 struct Signal* gen_signal; /* signal generating event */
107 struct Timer* gen_timer; /* Timer generating event */
108 } ev_gen; /* object generating event */
111 void event_generate(enum EventType type, void* gen);
113 #endif /* INCLUDED_ircd_network_h */