dcc.h 9.5 KB

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