ds.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <sys/types.h>
  2. #include <netinet/in.h>
  3. #include <openssl/ssl.h>
  4. typedef enum {
  5. file, std, sock
  6. } dstype;
  7. typedef struct {
  8. int fd;
  9. int eof;
  10. dstype tp;
  11. int ipv6;
  12. int server;
  13. struct sockaddr_storage peer;
  14. } *ds, s_ds;
  15. #define DEFAULT_LISTENNING_QUEUE 5
  16. typedef struct{
  17. int fd;
  18. int ipv6;
  19. } *nethandler, s_nethandler;
  20. typedef struct {
  21. dstype tp;
  22. void *original;
  23. SSL *s;
  24. int eof;
  25. } *tlsDs, s_tlsDs;
  26. nethandler getIPv4Port(const int port);
  27. nethandler getPort(const int port);
  28. ds createFromFile(int);
  29. ds createFromFileName(const char*);
  30. ds createFromHandler(nethandler);
  31. ds createToIPv4Host(const unsigned long, const int);
  32. ds createToIPv6Host(const unsigned char[16], const int);
  33. tlsDs startSockTls(ds, const char*, const char*, const char*);
  34. int getPeer(ds, unsigned long*, unsigned char[16], int*);
  35. int closeDs(ds);
  36. void closeHandler(nethandler);
  37. ds closeTls(tlsDs);
  38. int sendDs(ds, const char[const], const int);
  39. int recvDs(ds, char[], const int);
  40. int tlsDsSend(tlsDs, const char[const], const int);
  41. int tlsDsRecv(tlsDs, char[], const int);
  42. int *getStd();
  43. int stdDsSend(const char[const], const int);
  44. int stdDsRecv(int*, char[], const int);
  45. void closeStd(int*);
  46. int getFd(ds);
  47. int getTlsFd(tlsDs);
  48. int isStdEOF(int*);
  49. int isDsEOF(ds);
  50. int isTlsEOF(tlsDs);
  51. void closeFd(int);