#define _MSRP_H
#include <switch.h>
-#include <switch_ssl.h>
-
#define MSRP_LISTEN_PORT 2855
#define MSRP_SSL_LISTEN_PORT 2856
MSRP_H_UNKNOWN
};
+typedef struct switch_msrp_session_s switch_msrp_session_t;
+typedef struct msrp_client_socket_s switch_msrp_client_socket_t;
+typedef struct msrp_socket_s switch_msrp_socket_t;
+
typedef struct msrp_msg_s {
int state;
int method;
char *last_p;
char *payload;
struct msrp_msg_s *next;
-} msrp_msg_t;
-
-typedef struct msrp_msg_s switch_msrp_msg_t;
-
-typedef struct msrp_socket_s {
- switch_port_t port;
- switch_socket_t *sock;
- switch_thread_t *thread;
- int secure;
-} msrp_socket_t;
-
-struct msrp_client_socket_s {
- switch_socket_t *sock;
- SSL *ssl;
- int secure;
- int client_mode;
- struct switch_msrp_session_s *msrp_session;
-};
+} switch_msrp_msg_t;
struct switch_msrp_session_s{
switch_memory_pool_t *pool;
char *local_file_selector;
int local_port;
char *call_id;
- msrp_msg_t *msrp_msg;
- msrp_msg_t *last_msg;
+ switch_msrp_msg_t *msrp_msg;
+ switch_msrp_msg_t *last_msg;
switch_mutex_t *mutex;
switch_size_t msrp_msg_buffer_size;
switch_size_t msrp_msg_count;
- msrp_socket_t *msock;
- struct msrp_client_socket_s *csock;
+ switch_msrp_socket_t *msock;
+ switch_msrp_client_socket_t *csock;
switch_frame_t frame;
uint8_t frame_data[SWITCH_RTP_MAX_BUF_LEN];
int running;
void *user_data;
};
-typedef struct msrp_client_socket_s msrp_client_socket_t;
-typedef struct switch_msrp_session_s switch_msrp_session_t;
-
SWITCH_DECLARE(switch_status_t) switch_msrp_init(void);
SWITCH_DECLARE(switch_status_t) switch_msrp_destroy(void);
SWITCH_DECLARE(switch_msrp_session_t *)switch_msrp_session_new(switch_memory_pool_t *pool, const char *call_id, switch_bool_t secure);
SWITCH_DECLARE(switch_status_t) switch_msrp_session_destroy(switch_msrp_session_t **ms);
-// switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, msrp_msg_t *msg);
+// switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, switch_msrp_msg_t *msg);
SWITCH_DECLARE(switch_msrp_msg_t *)switch_msrp_session_pop_msg(switch_msrp_session_t *ms);
-SWITCH_DECLARE(switch_status_t) switch_msrp_perform_send(switch_msrp_session_t *ms, msrp_msg_t *msg, const char *file, const char *func, int line);
+SWITCH_DECLARE(switch_status_t) switch_msrp_perform_send(switch_msrp_session_t *ms, switch_msrp_msg_t *msg, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_msrp_start_client(switch_msrp_session_t *msrp_session);
SWITCH_DECLARE(const char *) switch_msrp_listen_ip(void);
*/
#include <switch.h>
+#include <switch_ssl.h>
#include <switch_msrp.h>
#include <switch_stun.h>
#define MSRP_BUFF_SIZE SWITCH_RTP_MAX_BUF_LEN
#define DEBUG_MSRP 0
+#define MSRP_LISTEN_PORT 2855
+#define MSRP_SSL_LISTEN_PORT 2856
+
+struct msrp_socket_s {
+ switch_port_t port;
+ switch_socket_t *sock;
+ switch_thread_t *thread;
+ int secure;
+};
+
+struct msrp_client_socket_s {
+ switch_socket_t *sock;
+ SSL *ssl;
+ int secure;
+ int client_mode;
+ struct switch_msrp_session_s *msrp_session;
+};
static struct {
int running;
const SSL_METHOD *ssl_client_method;
SSL_CTX *ssl_client_ctx;
- msrp_socket_t msock;
- msrp_socket_t msock_ssl;
+ switch_msrp_socket_t msock;
+ switch_msrp_socket_t msock_ssl;
} globals;
typedef struct worker_helper{
int debug;
switch_memory_pool_t *pool;
- msrp_client_socket_t csock;
+ switch_msrp_client_socket_t csock;
switch_msrp_session_t *msrp_session;
} worker_helper_t;
return SWITCH_STATUS_SUCCESS;
}
-switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, msrp_msg_t *msg)
+switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, switch_msrp_msg_t *msg)
{
switch_mutex_lock(ms->mutex);
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(msrp_msg_t *)switch_msrp_session_pop_msg(switch_msrp_session_t *ms)
+SWITCH_DECLARE(switch_msrp_msg_t *)switch_msrp_session_pop_msg(switch_msrp_session_t *ms)
{
- msrp_msg_t *m = ms->msrp_msg;
+ switch_msrp_msg_t *m = ms->msrp_msg;
if (m == NULL) {
switch_yield(20000);
return NULL;
return m;
}
-switch_status_t msrp_msg_serialize(msrp_msg_t *msrp_msg, char *buf)
+switch_status_t msrp_msg_serialize(switch_msrp_msg_t *msrp_msg, char *buf)
{
char *code_number_str = switch_mprintf("%d", msrp_msg->code_number);
char method[10];
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t msrp_socket_recv(msrp_client_socket_t *csock, char *buf, switch_size_t *len)
+static switch_status_t msrp_socket_recv(switch_msrp_client_socket_t *csock, char *buf, switch_size_t *len)
{
switch_status_t status = SWITCH_STATUS_FALSE;
return status;
}
-static switch_status_t msrp_socket_send(msrp_client_socket_t *csock, char *buf, switch_size_t *len)
+static switch_status_t msrp_socket_send(switch_msrp_client_socket_t *csock, char *buf, switch_size_t *len)
{
if (csock->secure) {
*len = SSL_write(csock->ssl, buf, *len);
-------d4c667b2351e958f$
*/
-char *msrp_parse_header(char *start, int skip, const char *end, msrp_msg_t *msrp_msg, int index, switch_memory_pool_t *pool)
+char *msrp_parse_header(char *start, int skip, const char *end, switch_msrp_msg_t *msrp_msg, int index, switch_memory_pool_t *pool)
{
char *p = start + skip;
char *q;
return start;
}
-msrp_msg_t *msrp_parse_headers(const char *start, int len, msrp_msg_t *msrp_msg, switch_memory_pool_t *pool)
+switch_msrp_msg_t *msrp_parse_headers(const char *start, int len, switch_msrp_msg_t *msrp_msg, switch_memory_pool_t *pool)
{
char *p = (char *)start;
char *q = p;
return msrp_msg;
}
-msrp_msg_t *msrp_parse_buffer(char *buf, int len, msrp_msg_t *msrp_msg, switch_memory_pool_t *pool)
+switch_msrp_msg_t *msrp_parse_buffer(char *buf, int len, switch_msrp_msg_t *msrp_msg, switch_memory_pool_t *pool)
{
const char *start;
if (!msrp_msg) {
- switch_zmalloc(msrp_msg, sizeof(msrp_msg_t));
+ switch_zmalloc(msrp_msg, sizeof(switch_msrp_msg_t));
switch_assert(msrp_msg);
msrp_msg->state = MSRP_ST_WAIT_HEADER;
}
}
-switch_status_t msrp_reply(msrp_client_socket_t *csock, msrp_msg_t *msrp_msg)
+switch_status_t msrp_reply(switch_msrp_client_socket_t *csock, switch_msrp_msg_t *msrp_msg)
{
char buf[2048];
switch_size_t len;
return msrp_socket_send(csock, buf, &len);
}
-switch_status_t msrp_report(msrp_client_socket_t *csock, msrp_msg_t *msrp_msg, char *status_code)
+switch_status_t msrp_report(switch_msrp_client_socket_t *csock, switch_msrp_msg_t *msrp_msg, char *status_code)
{
char buf[2048];
switch_size_t len;
static void *SWITCH_THREAD_FUNC msrp_worker(switch_thread_t *thread, void *obj)
{
worker_helper_t *helper = (worker_helper_t *) obj;
- msrp_client_socket_t *csock = &helper->csock;
+ switch_msrp_client_socket_t *csock = &helper->csock;
switch_memory_pool_t *pool = helper->pool;
char buf[MSRP_BUFF_SIZE];
char *p;
char *last_p;
switch_size_t len = MSRP_BUFF_SIZE;
switch_status_t status;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
char uuid[128] = { 0 };
switch_msrp_session_t *msrp_session = NULL;
int sanity = 10;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "state:%d, len:%" SWITCH_SIZE_T_FMT " payload_bytes:%" SWITCH_SIZE_T_FMT "\n", msrp_msg->state, len, msrp_msg->payload_bytes);
// {
// char bbb[MSRP_BUFF_SIZE * 2];
- // msrp_msg_serialize(msrp_msg_tmp, bbb),
+ // msrp_msg_serialize(switch_msrp_msg_tmp, bbb),
// }
}
{
int i;
- msrp_msg_t *msrp_msg_old = msrp_msg;
+ switch_msrp_msg_t *msrp_msg_old = msrp_msg;
msrp_msg = NULL;
/*dup msrp_msg*/
- switch_zmalloc(msrp_msg, sizeof(msrp_msg_t));
+ switch_zmalloc(msrp_msg, sizeof(switch_msrp_msg_t));
switch_assert(msrp_msg);
msrp_msg->state = msrp_msg_old->state;
msrp_msg->byte_start = msrp_msg_old->byte_end + 1;
static void *SWITCH_THREAD_FUNC msrp_listener(switch_thread_t *thread, void *obj)
{
- msrp_socket_t *msock = (msrp_socket_t *)obj;
+ switch_msrp_socket_t *msock = (switch_msrp_socket_t *)obj;
switch_status_t rv;
switch_memory_pool_t *pool = NULL;
switch_threadattr_t *thd_attr = NULL;
}
#define MSRP_TRANS_ID_LEN 16
-SWITCH_DECLARE(switch_status_t) switch_msrp_perform_send(switch_msrp_session_t *ms, msrp_msg_t *msrp_msg, const char *file, const char *func, int line)
+SWITCH_DECLARE(switch_status_t) switch_msrp_perform_send(switch_msrp_session_t *ms, switch_msrp_msg_t *msrp_msg, const char *file, const char *func, int line)
{
char transaction_id[MSRP_TRANS_ID_LEN + 1] = { 0 };
char buf[MSRP_BUFF_SIZE];
SWITCH_STANDARD_APP(msrp_echo_function)
{
msrp_session_t *msrp_session = NULL;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
// private_object_t *tech_pvt = switch_core_session_get_private(session);
SWITCH_STANDARD_APP(msrp_recv_function)
{
msrp_session_t *msrp_session = NULL;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
SWITCH_STANDARD_APP(msrp_send_function)
{
msrp_session_t *msrp_session = NULL;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
switch_assert(pool);
- switch_zmalloc(msrp_msg, sizeof(msrp_msg_t));
+ switch_zmalloc(msrp_msg, sizeof(switch_msrp_msg_t));
switch_assert(msrp_msg);
msrp_msg->headers[MSRP_H_FROM_PATH] = switch_mprintf("msrp://%s:%d/%s;tcp",
msrp_session_t *peer_msrp_session = NULL;
private_object_t *tech_pvt = NULL;
private_object_t *ptech_pvt = NULL;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
switch_status_t status;
int argc;
switch_core_session_t *msession = NULL;
// msrp_session_t *msrp_session = NULL;
- msrp_msg_t *msrp_msg = NULL;
+ switch_msrp_msg_t *msrp_msg = NULL;
private_object_t *tech_pvt = NULL;
switch_memory_pool_t *pool = NULL;
return SWITCH_STATUS_SUCCESS;
}
- switch_zmalloc(msrp_msg, sizeof(msrp_msg_t));
+ switch_zmalloc(msrp_msg, sizeof(switch_msrp_msg_t));
switch_assert(msrp_msg);
msrp_msg->headers[MSRP_H_FROM_PATH] = switch_mprintf("msrp://%s:%d/%s;tcp",