dcc.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #ifndef _DCC_H
  2. #define _DCC_H
  3. #ifdef HAVE_CONFIG_H
  4. # include "config.h"
  5. #endif
  6. #include "types.h"
  7. #include "crypt.h"
  8. #include "eggdrop.h"
  9. #include "dns.h"
  10. /* Public structure of all the dcc connections */
  11. struct dcc_table {
  12. char *name;
  13. int flags;
  14. void (*eof) (int);
  15. void (*activity) (int, char *, int);
  16. int *timeout_val;
  17. void (*timeout) ();
  18. void (*display) (int, char *);
  19. void (*kill) (int, void *);
  20. void (*output) (int, char *, void *);
  21. void (*outdone) (int);
  22. };
  23. struct dcc_t {
  24. long sock; /* This should be a long to keep 64-bit
  25. machines sane */
  26. IP addr; /* IP address in host byte order */
  27. #ifdef USE_IPV6
  28. char addr6[121]; /* easier.. ipv6 address in regular notation (3ffe:80c0:225::) */
  29. #endif /* USE_IPV6 */
  30. unsigned int port;
  31. int ssl; /* use ssl on this dcc? */
  32. struct userrec *user;
  33. char simulbot[NICKLEN]; /* used for hub->leaf cmd simulation, holds bot that results should be sent to */
  34. time_t simultime; /* the time when the simul dcc is initiated, expires after a number of seconds */
  35. int simul; /* this will hold the idx on the remote bot to return result. */
  36. char hash[MD5_HASH_LENGTH + 1]; /* used for dcc authing */
  37. char nick[NICKLEN];
  38. char host[UHOSTLEN];
  39. struct dcc_table *type;
  40. time_t timeval; /* Use for any timing stuff
  41. - this is used for timeout checking */
  42. time_t pingtime;
  43. unsigned long status; /* A LOT of dcc types have status
  44. thingos, this makes it more avaliabe */
  45. union {
  46. struct chat_info *chat;
  47. struct file_info *file;
  48. struct edit_info *edit;
  49. struct xfer_info *xfer;
  50. struct bot_info *bot;
  51. struct relay_info *relay;
  52. struct dns_info *dns;
  53. struct dupwait_info *dupwait;
  54. int ident_sock;
  55. void *other;
  56. } u; /* Special use depending on type */
  57. };
  58. struct chat_info {
  59. char *away; /* non-NULL if user is away */
  60. int msgs_per_sec; /* used to stop flooding */
  61. int con_flags; /* with console: what to show */
  62. int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
  63. char con_chan[81]; /* with console: what channel to view */
  64. int channel; /* 0=party line, -1=off */
  65. struct msgq *buffer; /* a buffer of outgoing lines
  66. (for .page cmd) */
  67. int max_line; /* maximum lines at once */
  68. int line_count; /* number of lines sent since last page */
  69. int current_lines; /* number of lines total stored */
  70. char *su_nick;
  71. };
  72. struct file_info {
  73. struct chat_info *chat;
  74. char dir[161];
  75. };
  76. struct xfer_info {
  77. char *filename;
  78. char *origname;
  79. char dir[DIRLEN]; /* used when uploads go to the current dir */
  80. unsigned long length;
  81. unsigned long acked;
  82. char buf[4]; /* you only need 5 bytes! */
  83. unsigned char sofar; /* how much of the byte count received */
  84. char from[NICKLEN]; /* [GET] user who offered the file */
  85. FILE *f; /* pointer to file being sent/received */
  86. unsigned int type; /* xfer connection type, see enum below */
  87. unsigned short ack_type; /* type of ack */
  88. unsigned long offset; /* offset from beginning of file, during
  89. resend. */
  90. unsigned long block_pending; /* bytes of this DCC block which weren't
  91. sent yet. */
  92. time_t start_time; /* Time when a xfer was started. */
  93. };
  94. struct bot_info {
  95. char version[121]; /* channel/version info */
  96. time_t bts; /* build timestamp */
  97. char linker[NOTENAMELEN + 1]; /* who requested this link */
  98. int numver;
  99. char sysname[121];
  100. int port; /* base port */
  101. int uff_flags; /* user file feature flags */
  102. };
  103. struct relay_info {
  104. struct chat_info *chat;
  105. int sock;
  106. int port;
  107. int old_status;
  108. };
  109. struct dupwait_info {
  110. int atr; /* the bots attributes */
  111. struct chat_info *chat; /* holds current chat data */
  112. };
  113. /* Flags about dcc types
  114. */
  115. #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
  116. chatter */
  117. #define DCT_MASTER 0x00000002 /* received master chatter */
  118. #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
  119. #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
  120. #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
  121. in tcl */
  122. #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
  123. #define DCT_CANBOOT 0x00000040 /* can be booted */
  124. #define DCT_GETNOTES DCT_CHAT /* can receive notes */
  125. #define DCT_ 0x00000080 /* unused */
  126. #define DCT_FORKTYPE 0x00000100 /* a forking type */
  127. #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
  128. #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
  129. #define DCT_FILESEND 0x00000800 /* a sending file transfer,
  130. getting = !this */
  131. #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
  132. /* For dcc chat & files:
  133. */
  134. #define STAT_ECHO 0x00001 /* echo commands back? */
  135. #define STAT_DENY 0x00002 /* bad username (ignore password & deny
  136. access) */
  137. #define STAT_CHAT 0x00004 /* in file-system but may return */
  138. #define STAT_TELNET 0x00008 /* connected via telnet */
  139. #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
  140. #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
  141. #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
  142. #define STAT_PAGE 0x00080 /* page output to the user */
  143. #define STAT_COLOR 0x00100 /* Color enabled for user */
  144. /* For stripping out mIRC codes
  145. */
  146. #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
  147. #define STRIP_BOLD 0x00002 /* remove bold codes */
  148. #define STRIP_REV 0x00004 /* remove reverse video codes */
  149. #define STRIP_UNDER 0x00008 /* remove underline codes */
  150. #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
  151. #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
  152. #define STRIP_ALL 0x00040 /* remove every damn thing! */
  153. /* for dcc bot links: */
  154. #define STAT_PINGED 0x00001 /* waiting for ping to return */
  155. #define STAT_SHARE 0x00002 /* sharing user data with the bot */
  156. #define STAT_CALLED 0x00004 /* this bot called me */
  157. #define STAT_OFFERED 0x00008 /* offered her the user file */
  158. #define STAT_SENDING 0x00010 /* in the process of sending a user list */
  159. #define STAT_GETTING 0x00020 /* in the process of getting a user list */
  160. #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
  161. #define STAT_LEAF 0x00080 /* this bot is a leaf only */
  162. #define STAT_LINKING 0x00100 /* the bot is currently going through
  163. the linking stage */
  164. #define STAT_AGGRESSIVE 0x00200 /* aggressively sharing with this bot */
  165. #define STAT_OFFEREDU 0x00400
  166. #define STAT_SENDINGU 0x00800
  167. #define STAT_GETTINGU 0x01000
  168. #define STAT_UPDATED 0x02000
  169. /* Flags for listening sockets
  170. */
  171. #define LSTN_PUBLIC 0x000001 /* No access restrictions */
  172. /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
  173. * "TELNET Echo Option" (RFC 875) for details.
  174. */
  175. #define TLN_AYT 246 /* Are You There */
  176. #define TLN_WILL 251 /* Will */
  177. #define TLN_WILL_C "\373"
  178. #define TLN_WONT 252 /* Won't */
  179. #define TLN_WONT_C "\374"
  180. #define TLN_DO 253 /* Do */
  181. #define TLN_DO_C "\375"
  182. #define TLN_DONT 254 /* Don't */
  183. #define TLN_DONT_C "\376"
  184. #define TLN_IAC 255 /* Interpret As Command */
  185. #define TLN_IAC_C "\377"
  186. #define TLN_ECHO 1 /* Echo */
  187. #define TLN_ECHO_C "\001"
  188. extern struct dcc_t *dcc;
  189. extern int dcc_total, timesync;
  190. extern char network[];
  191. extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_LOST, DCC_BOT_NEW,
  192. DCC_RELAY, DCC_RELAYING, DCC_FORK_RELAY, DCC_PRE_RELAY, DCC_CHAT_PASS,
  193. DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
  194. DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_DNSWAIT;
  195. void send_timesync(int);
  196. void failed_link(int);
  197. void dupwait_notify(char *);
  198. char *rand_dccresp();
  199. #endif /* !_DCC_H */