dcc.h 9.4 KB

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