sslconnection.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. ** JNetLib
  3. ** Copyright (C) 2000-2006 CockOS, Inc.
  4. ** Author: Justin Frankel, Joshua Teitelbaum
  5. ** File: sslconnection.h - JNL SSL TCP connection interface
  6. ** License: see jnetlib.h
  7. */
  8. #ifndef _JNETLIB_SSL_H_
  9. #define _JNETLIB_SSL_H_
  10. #include "netinc.h"
  11. #include "util.h"
  12. #include "connection.h"
  13. /*
  14. ** AUTOLINK WITH THESE GUYS NOT IN PROJECT HEH HEH :)
  15. ** Build and go, for you :)
  16. */
  17. #include <openssl/ssl.h>
  18. class JNL_SSL_Connection : public JNL_Connection
  19. {
  20. protected:
  21. SSL *m_ssl;
  22. bool m_bcontextowned;
  23. bool m_bsslinit;
  24. public:
  25. JNL_SSL_Connection();
  26. JNL_SSL_Connection( SSL *pssl, JNL_AsyncDNS *dns, size_t sendbufsize, size_t recvbufsize );
  27. virtual ~JNL_SSL_Connection();
  28. virtual void connect( SOCKET sock, sockaddr *addr, socklen_t length /* of addr */ ); // used by the listen object, usually not needed by users.
  29. virtual void run( size_t max_send_bytes = -1, size_t max_recv_bytes = -1, size_t *bytes_sent = NULL, size_t *bytes_rcvd = NULL );
  30. /*
  31. ** Joshua Teitelbaum 1/27/2006 Adding new BSD socket analogues for SSL compatibility
  32. */
  33. protected:
  34. virtual void socket_shutdown();
  35. virtual ssize_t socket_recv( char *buf, size_t len, int options );
  36. virtual ssize_t socket_send( const char *buf, size_t len, int options );
  37. virtual int socket_connect();
  38. virtual void on_socket_connected();
  39. /*
  40. ** init_ssl_connection:
  41. ** returns true if can continue onwards (could be error, in which case
  42. ** we want the error to cascade through).
  43. ** Else, false if connection was not made, and we have to call this
  44. ** again.
  45. */
  46. bool init_ssl_connection();
  47. bool forceConnect;
  48. };
  49. extern SSL_CTX *sslContext;
  50. #endif