ds.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <sys/types.h>
  2. #include <netinet/in.h>
  3. #include <openssl/ssl.h>
  4. typedef struct {
  5. int s;
  6. int ipv6;
  7. int server;
  8. struct sockaddr_storage peer;
  9. } *sockDs, s_sockDs;
  10. typedef struct {
  11. int f;
  12. } *fileDs, s_fileDs;
  13. #define DEFAULT_LISTENNING_QUEUE 5
  14. typedef struct{
  15. int s;
  16. int ipv6;
  17. } *nethandler, s_nethandler;
  18. typedef enum {
  19. file, sock
  20. } dstype;
  21. typedef struct {
  22. dstype tp;
  23. void *original;
  24. SSL *s;
  25. } *tlsDs, s_tlsDs;
  26. nethandler getIPv4Port(const int port);
  27. nethandler getPort(const int port);
  28. fileDs createFromFile(int);
  29. fileDs createFromFileName(const char*);
  30. sockDs createFromHandler(nethandler);
  31. sockDs createToIPv4Host(const unsigned long, const int);
  32. sockDs createToIPv6Host(const unsigned char[16], const int);
  33. tlsDs startSockTls(sockDs, const char*, const char*);
  34. int getPeer(sockDs, unsigned long*, unsigned char[16], int*);
  35. void closeSockDs(sockDs);
  36. void closeFileDs(fileDs);
  37. void closeHandler(nethandler);
  38. void closeTlsDs(tlsDs);
  39. int fileDsSend(fileDs, const char[const], const int);
  40. int fileDsRecv(fileDs, char[], const int);
  41. int sockDsSend(sockDs, const char[const], const int);
  42. int sockDsRecv(sockDs, char[], const int);
  43. int tlsDsSend(tlsDs, const char[const], const int);
  44. int tlsDsRecv(tlsDs, char[], const int);
  45. int stdDsSend(const char[const], const int);
  46. int stdDsRecv(char[], const int);