mux/src/interface.h

Go to the documentation of this file.
00001 // interface.h
00002 //
00003 // $Id: interface.h,v 1.24 2006/01/08 06:16:08 sdennis Exp $
00004 //
00005 
00006 #include "copyright.h"
00007 
00008 #ifndef __INTERFACE__H
00009 #define __INTERFACE__H
00010 
00011 #include <sys/types.h>
00012 
00013 #ifndef WIN32
00014 #include <netinet/in.h>
00015 #include <arpa/inet.h>
00016 #include <netdb.h>
00017 #ifdef HAVE_SYS_SELECT_H
00018 #include <sys/select.h>
00019 #endif // HAVE_SYS_SELECT_H
00020 #endif // !WIN32
00021 
00022 /* these symbols must be defined by the interface */
00023 
00024 /* Disconnection reason codes */
00025 
00026 #define R_QUIT      1   /* User quit */
00027 #define R_TIMEOUT   2   /* Inactivity timeout */
00028 #define R_BOOT      3   /* Victim of @boot, @toad, or @destroy */
00029 #define R_SOCKDIED  4   /* Other end of socked closed it */
00030 #define R_GOING_DOWN    5   /* Game is going down */
00031 #define R_BADLOGIN  6   /* Too many failed login attempts */
00032 #define R_GAMEDOWN  7   /* Not admitting users now */
00033 #define R_LOGOUT    8   /* Logged out w/o disconnecting */
00034 #define R_GAMEFULL  9   /* Too many players logged in */
00035 
00036 /* Logged out command table definitions */
00037 
00038 #define CMD_QUIT    1
00039 #define CMD_WHO     2
00040 #define CMD_DOING   3
00041 #define CMD_PREFIX  5
00042 #define CMD_SUFFIX  6
00043 #define CMD_LOGOUT  7
00044 #define CMD_SESSION 8
00045 #define CMD_PUEBLOCLIENT 9
00046 #define CMD_INFO    10
00047 
00048 #define CMD_MASK    0xff
00049 #define CMD_NOxFIX  0x100
00050 
00051 extern NAMETAB logout_cmdtable[];
00052 
00053 typedef struct cmd_block CBLK;
00054 typedef struct cmd_block_hdr
00055 {
00056     struct cmd_block *nxt;
00057 } CBLKHDR;
00058 
00059 typedef struct cmd_block
00060 {
00061     CBLKHDR hdr;
00062     char    cmd[LBUF_SIZE - sizeof(CBLKHDR)];
00063 } CBLK;
00064 
00065 typedef struct text_block TBLOCK;
00066 typedef struct text_block_hdr
00067 {
00068     struct text_block *nxt;
00069     char    *start;
00070     char    *end;
00071     int nchars;
00072 }   TBLOCKHDR;
00073 
00074 typedef struct text_block
00075 {
00076     TBLOCKHDR hdr;
00077     char    data[OUTPUT_BLOCK_SIZE - sizeof(TBLOCKHDR)];
00078 } TBLOCK;
00079 
00080 typedef struct prog_data PROG;
00081 struct prog_data {
00082     dbref wait_enactor;
00083     char *wait_regs[MAX_GLOBAL_REGS];
00084 };
00085 
00086 // Input state
00087 //
00088 #define NVT_IS_NORMAL          0
00089 #define NVT_IS_HAVE_IAC        1
00090 #define NVT_IS_HAVE_IAC_WILL   2
00091 #define NVT_IS_HAVE_IAC_WONT   3
00092 #define NVT_IS_HAVE_IAC_DO     4
00093 #define NVT_IS_HAVE_IAC_DONT   5
00094 #define NVT_IS_HAVE_IAC_SB     6
00095 #define NVT_IS_HAVE_IAC_SB_IAC 7
00096 
00097 // Character Names
00098 //
00099 #define NVT_BS   '\x08'
00100 #define NVT_DEL  '\x7F'
00101 #define NVT_EOR  '\xEF'
00102 #define NVT_NOP  '\xF1'
00103 #define NVT_GA   '\xF9'
00104 #define NVT_WILL '\xFB'
00105 #define NVT_WONT '\xFC'
00106 #define NVT_DO   '\xFD'
00107 #define NVT_DONT '\xFE'
00108 #define NVT_IAC  '\xFF'
00109 
00110 // Telnet Options
00111 //
00112 #define TELNET_SGA  '\x03'
00113 #define TELNET_EOR  '\x19'
00114 #define TELNET_NAWS '\x1F'
00115 
00116 // Telnet Option Negotiation States
00117 //
00118 #define OPTION_NO               0
00119 #define OPTION_YES              1
00120 #define OPTION_WANTNO_EMPTY     2
00121 #define OPTION_WANTNO_OPPOSITE  3
00122 #define OPTION_WANTYES_EMPTY    4
00123 #define OPTION_WANTYES_OPPOSITE 5
00124 
00125 typedef struct descriptor_data DESC;
00126 struct descriptor_data
00127 {
00128   CLinearTimeAbsolute connected_at;
00129   CLinearTimeAbsolute last_time;
00130 
00131   SOCKET descriptor;
00132 #ifdef WIN32
00133   // these are for the Windows NT TCP/IO
00134 #define SIZEOF_OVERLAPPED_BUFFERS 512
00135   char input_buffer[SIZEOF_OVERLAPPED_BUFFERS];         // buffer for reading
00136   char output_buffer[SIZEOF_OVERLAPPED_BUFFERS];        // buffer for writing
00137   OVERLAPPED InboundOverlapped;   // for asynchronous reading
00138   OVERLAPPED OutboundOverlapped;  // for asynchronous writing
00139   bool bWritePending;             // true if in process of writing
00140   bool bConnectionDropped;        // true if we cannot send to player
00141   bool bConnectionShutdown;       // true if connection has been shutdown
00142   bool bCallProcessOutputLater;   // Does the socket need priming for output.
00143 #endif // WIN32
00144 
00145   int flags;
00146   int retries_left;
00147   int command_count;
00148   int timeout;
00149   int host_info;
00150   dbref player;
00151   char *output_prefix;
00152   char *output_suffix;
00153   int output_size;
00154   int output_tot;
00155   int output_lost;
00156   TBLOCK *output_head;
00157   TBLOCK *output_tail;
00158   int input_size;
00159   int input_tot;
00160   int input_lost;
00161   CBLK *input_head;
00162   CBLK *input_tail;
00163   CBLK *raw_input;
00164   char *raw_input_at;
00165   size_t        nOption;
00166   unsigned char aOption[SBUF_SIZE];
00167   int raw_input_state;
00168   int nvt_sga_him_state;
00169   int nvt_sga_us_state;
00170   int nvt_eor_him_state;
00171   int nvt_eor_us_state;
00172   int nvt_naws_him_state;
00173   int nvt_naws_us_state;
00174   int width;
00175   int height;
00176   int quota;
00177   int wait_for_input;       /* Used by @prog */
00178   dbref wait_enactor;       /* Used by @prog */
00179   PROG *program_data;
00180   struct descriptor_data *hashnext;
00181   struct descriptor_data *next;
00182   struct descriptor_data **prev;
00183 
00184   struct sockaddr_in address;   /* added 3/6/90 SCG */
00185 
00186   char addr[51];
00187   char username[11];
00188   char doing[SIZEOF_DOING_STRING];
00189 };
00190 
00191 int HimState(DESC *d, unsigned char chOption);
00192 int UsState(DESC *d, unsigned char chOption);
00193 void EnableHim(DESC *d, unsigned char chOption);
00194 void DisableHim(DESC *d, unsigned char chOption);
00195 void EnableUs(DESC *d, unsigned char chOption);
00196 void DisableUs(DESC *d, unsigned char chOption);
00197 
00198 /* flags in the flag field */
00199 #define DS_CONNECTED    0x0001      // player is connected.
00200 #define DS_AUTODARK     0x0002      // Wizard was auto set dark.
00201 #define DS_PUEBLOCLIENT 0x0004      // Client is Pueblo-enhanced.
00202 
00203 extern DESC *descriptor_list;
00204 
00205 /* from the net interface */
00206 
00207 extern void emergency_shutdown(void);
00208 extern void shutdownsock(DESC *, int);
00209 extern void SetupPorts(int *pnPorts, PortInfo aPorts[], IntArray *pia);
00210 #ifdef WIN32
00211 extern void shovechars9x(int nPorts, PortInfo aPorts[]);
00212 extern void shovecharsNT(int nPorts, PortInfo aPorts[]);
00213 void process_output9x(void *, int);
00214 void process_outputNT(void *, int);
00215 extern FTASK *process_output;
00216 #else // WIN32
00217 extern void shovechars(int nPorts, PortInfo aPorts[]);
00218 extern void process_output(void *, int);
00219 extern void dump_restart_db(void);
00220 #endif // WIN32
00221 
00222 extern void BuildSignalNamesTable(void);
00223 extern void set_signals(void);
00224 
00225 // From netcommon.cpp
00226 //
00227 extern void make_ulist(dbref, char *, char **, bool);
00228 extern void make_port_ulist(dbref, char *, char **);
00229 extern int fetch_session(dbref target);
00230 extern int fetch_idle(dbref target);
00231 extern int fetch_connect(dbref target);
00232 extern int fetch_height(dbref target);
00233 extern int fetch_width(dbref target);
00234 extern const char *time_format_1(int Seconds, size_t maxWidth);
00235 extern const char *time_format_2(int Seconds);
00236 extern void update_quotas(CLinearTimeAbsolute& tLast, const CLinearTimeAbsolute& tCurrent);
00237 extern void raw_notify(dbref, const char *);
00238 extern void raw_notify_newline(dbref);
00239 extern void clearstrings(DESC *);
00240 extern void queue_write_LEN(DESC *, const char *, int);
00241 extern void queue_write(DESC *, const char *);
00242 extern void queue_string(DESC *, const char *);
00243 extern void freeqs(DESC *);
00244 extern void welcome_user(DESC *);
00245 extern void save_command(DESC *, CBLK *);
00246 extern void announce_disconnect(dbref, DESC *, const char *);
00247 extern int boot_by_port(SOCKET port, bool bGod, const char *message);
00248 extern void find_oldest(dbref target, DESC *dOldest[2]);
00249 extern void check_idle(void);
00250 void Task_ProcessCommand(void *arg_voidptr, int arg_iInteger);
00251 extern int site_check(struct in_addr, SITE *);
00252 extern dbref  find_connected_name(dbref, char *);
00253 extern void do_command(DESC *, char *);
00254 extern void desc_addhash(DESC *);
00255 
00256 // From predicates.cpp
00257 //
00258 #define alloc_desc(s) (DESC *)pool_alloc(POOL_DESC,s, __FILE__, __LINE__)
00259 #define free_desc(b) pool_free(POOL_DESC,(char *)(b), __FILE__, __LINE__)
00260 extern void handle_prog(DESC *d, char *message);
00261 
00262 // From player.cpp
00263 //
00264 extern void record_login(dbref, bool, char *, char *, char *, char *);
00265 extern dbref connect_player(char *, char *, char *, char *, char *);
00266 
00267 #define DESC_ITER_PLAYER(p,d) \
00268     for (d=(DESC *)hashfindLEN(&(p), sizeof(p), &mudstate.desc_htab); d; d = d->hashnext)
00269 #define DESC_ITER_CONN(d) \
00270     for (d=descriptor_list;(d);d=(d)->next) \
00271         if ((d)->flags & DS_CONNECTED)
00272 #define DESC_ITER_ALL(d) \
00273     for (d=descriptor_list;(d);d=(d)->next)
00274 
00275 #define DESC_SAFEITER_PLAYER(p,d,n) \
00276     for (d=(DESC *)hashfindLEN(&(p), sizeof(p), &mudstate.desc_htab), \
00277             n=((d!=NULL) ? d->hashnext : NULL); \
00278          d; \
00279          d=n,n=((n!=NULL) ? n->hashnext : NULL))
00280 #define DESC_SAFEITER_ALL(d,n) \
00281     for (d=descriptor_list,n=((d!=NULL) ? d->next : NULL); \
00282          d; \
00283          d=n,n=((n!=NULL) ? n->next : NULL))
00284 
00285 #endif // !__INTERFACE__H

Generated on Mon May 28 04:40:10 2007 for MUX by  doxygen 1.4.7