ds.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. dstype tp;
  10. int ipv6;
  11. int server;
  12. struct sockaddr_storage peer;
  13. } *ds, s_ds;
  14. #define DEFAULT_LISTENNING_QUEUE 5
  15. typedef struct{
  16. int fd;
  17. int ipv6;
  18. } *nethandler, s_nethandler;
  19. typedef struct {
  20. dstype tp;
  21. void *original;
  22. SSL *s;
  23. } *tlsDs, s_tlsDs;
  24. nethandler getIPv4Port(const int port);
  25. nethandler getPort(const int port);
  26. ds createFromFile(int);
  27. ds createFromFileName(const char*);
  28. ds createFromHandler(nethandler);
  29. ds createToIPv4Host(const unsigned long, const int);
  30. ds createToIPv6Host(const unsigned char[16], const int);
  31. tlsDs startSockTls(ds, const char*, const char*, const char*);
  32. int getPeer(ds, unsigned long*, unsigned char[16], int*);
  33. int closeDs(ds);
  34. void closeHandler(nethandler);
  35. ds closeTls(tlsDs);
  36. int sendDs(ds, const char[const], const int);
  37. int recvDs(ds, char[], const int);
  38. int tlsDsSend(tlsDs, const char[const], const int);
  39. int tlsDsRecv(tlsDs, char[], const int);
  40. int stdDsSend(const char[const], const int);
  41. int stdDsRecv(char[], const int);
  42. int getFd(ds);
  43. int getTlsFd(tlsDs);
  44. void closeFd(int);