dcc.h 9.5 KB

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