client.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef WOE_CLIENT_H
  2. #define WOE_CLIENT_H
  3. #if !defined(_POSIX_SOURCE)
  4. #define _POSIX_SOURCE
  5. #endif
  6. #if !defined(_BSD_SOURCE)
  7. #define _BSD_SOURCE
  8. #endif
  9. #define _XOPEN_SOURCE
  10. #include <sys/socket.h>
  11. #include <netinet/in.h>
  12. #include <arpa/inet.h>
  13. #include <netdb.h>
  14. #include <poll.h>
  15. #include <unistd.h>
  16. #include <errno.h>
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <ctype.h>
  21. #include "libtelnet.h"
  22. #ifndef WOE_CLIENTS_MAX
  23. /* Must beless than ulimit -nor */
  24. #define WOE_CLIENTS_MAX 1000
  25. #endif
  26. #ifndef WOE_CLIENT_BUFFER_SIZE
  27. #define WOE_CLIENT_BUFFER_SIZE 256
  28. #endif
  29. struct woe_server;
  30. struct woe_client {
  31. struct woe_server * server;
  32. int index;
  33. int sock;
  34. telnet_t * telnet;
  35. char linebuf[256];
  36. int linepos;
  37. int busy;
  38. struct sockaddr_in addr;
  39. socklen_t addrlen;
  40. };
  41. int woe_clients_max(void);
  42. int woe_client_iac(struct woe_client * cli, int cmd);
  43. int woe_client_input(struct woe_client * cli, const char * buffer, size_t size);
  44. int woe_client_zmp(struct woe_client * cli, int argc, const char *argv[]);
  45. int woe_client_negotiate(struct woe_client * cli, int how, int option);
  46. int woe_client_subnegotiate(struct woe_client * cli, const char * buf, int len, int telopt);
  47. int woe_client_ttype(struct woe_client * cli, int cmd, const char * name);
  48. int woe_client_error(struct woe_client * cli, int code, const char * msg);
  49. int woe_client_warning(struct woe_client * cli, int code, const char * msg);
  50. int woe_client_compress(struct woe_client * cli, int state);
  51. int woe_client_environ(struct woe_client * cli, int cmd, const struct telnet_environ_t *values, size_t size);
  52. int woe_client_mssp(struct woe_client * cli, const struct telnet_environ_t *values, size_t size);
  53. struct woe_client *
  54. woe_client_new(struct woe_server * srv, int index, int socket,
  55. struct sockaddr_in *addr, socklen_t addrlen);
  56. struct woe_client * woe_client_free(struct woe_client * cli);
  57. #endif