tport_ws.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef TPORT_WS_H
  25. /** Defined when <tport_ws.h> has been included. */
  26. #define TPORT_WS_H
  27. /**@internal
  28. * @file tport_ws.h
  29. * @brief Internal WS interface
  30. *
  31. * @author Mike Jerris <mike@jerris.com>
  32. *
  33. * Copyright 2013 Michael Jerris. All rights reserved.
  34. *
  35. */
  36. #ifndef SU_TYPES_H
  37. #include <sofia-sip/su_types.h>
  38. #endif
  39. #include "tport_internal.h"
  40. #include "ws.h"
  41. SOFIA_BEGIN_DECLS
  42. typedef enum {
  43. TPORT_WS_OPCODE_CONTINUATION = 0x0,
  44. TPORT_WS_OPCODE_TEXT = 0x1,
  45. TPORT_WS_OPCODE_BINARY = 0x2,
  46. TPORT_WS_OPCODE_CLOSE = 0x8,
  47. TPORT_WS_OPCODE_PING = 0x9,
  48. TPORT_WS_OPCODE_PONG = 0xA
  49. } tport_ws_opcode_t;
  50. typedef struct tport_ws_s {
  51. tport_t wstp_tp[1];
  52. wsh_t ws;
  53. char wstp_buffer[65536];
  54. size_t wstp_buflen;
  55. SU_S8_T ws_initialized;
  56. time_t connected;
  57. unsigned ws_secure:1;
  58. unsigned:0;
  59. } tport_ws_t;
  60. typedef struct tport_ws_primary_s {
  61. tport_primary_t wspri_pri[1];
  62. SSL_CTX *ssl_ctx;
  63. const SSL_METHOD *ssl_method;
  64. unsigned ws_secure:1;
  65. unsigned :0;
  66. } tport_ws_primary_t;
  67. int tport_recv_stream_ws(tport_t *self);
  68. ssize_t tport_send_stream_ws(tport_t const *self, msg_t *msg,
  69. msg_iovec_t iov[], size_t iovused);
  70. int tport_ws_ping(tport_t *self, su_time_t now);
  71. int tport_ws_pong(tport_t *self);
  72. int tport_ws_init_primary(tport_primary_t *,
  73. tp_name_t tpn[1],
  74. su_addrinfo_t *, tagi_t const *,
  75. char const **return_culprit);
  76. int tport_ws_init_client(tport_primary_t *,
  77. tp_name_t tpn[1],
  78. su_addrinfo_t *, tagi_t const *,
  79. char const **return_culprit);
  80. int tport_ws_init_secondary(tport_t *self, int socket, int accepted,
  81. char const **return_reason);
  82. int tport_ws_next_timer(tport_t *self, su_time_t *, char const **);
  83. void tport_ws_timer(tport_t *self, su_time_t);
  84. static void tport_ws_deinit_secondary(tport_t *self);
  85. SOFIA_END_DECLS
  86. #endif