PennMUSH Community

root/1.8.3/trunk/hdrs/lookup.h

Revision 919, 2.0 kB (checked in by shawnw, 1 year ago)

1.8.3p3

Line 
1 /**
2  * \file lookup.h
3  * \brief Prototypes and data structures for talking with info_slave
4  *
5  * Must be #included after mysocket.h and ident.h to get appropriate
6  * types and constants.
7  *
8  * netmush and info_slave use UDP datagrams to talk to each
9  * other. Each datagram is one recv/send, with a max size of
10  * something like 8K (Less than that on OS X in practice). We're well under
11  * that. Using datagrams instead of streams vastly simplies the communication
12  * code. We should have done it years ago.
13  */
14
15 #ifndef LOOKUP_H
16 #define LOOKUP_H
17
18 #include "copyrite.h"
19
20 /** Datagram sent to info_slave from the mush */
21 struct request_dgram {
22   int fd; /**< The socket descriptor, used as an id number */
23   union sockaddr_u local; /**< The sockaddr struct for the local address */
24   union sockaddr_u remote; /**< The sockaddr struct for the remote address */
25   socklen_t llen; /**< Length of local address */
26   socklen_t rlen; /**< Length of remote address */
27   int use_ident; /**< True to do an ident lookup */
28   int use_dns; /**< True to do hostname lookup */
29   int timeout; /**< Timeout in seconds for lookups */
30 };
31
32 #define IPADDR_LEN 128
33 #define HOSTNAME_LEN 256
34 #define IDENT_LEN 128
35
36 /** Datagram sent by info_slave back to the mush */
37 struct response_dgram {
38   int fd; /**< The socket descriptor, used as an id number */
39   char ipaddr[IPADDR_LEN]; /**< The ip address of the connection */
40   char hostname[HOSTNAME_LEN]; /**< The resolved hostname of the connection */
41   char ident[IDENT_LEN]; /**< The ident name for the connection */
42   Port_t connected_to; /**< The port connected to. */
43 };
44
45 extern pid_t info_slave_pid;
46 extern int info_slave;
47 extern time_t info_queue_time;
48
49 enum is_state { INFO_SLAVE_DOWN, INFO_SLAVE_READY, INFO_SLAVE_PENDING };
50
51 extern enum is_state info_slave_state;
52
53 void init_info_slave(void);
54 void make_info_slave(void);
55 void query_info_slave(int fd);
56 void update_pending_info_slaves(void);
57 void reap_info_slave(void);
58 void kill_info_slave(void);
59
60 #endif                          /* LOOKUP_H */
Note: See TracBrowser for help on using the browser.