MsnSlpCall * msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) { MsnSlpCall *slpcall; const guchar *body; gsize body_len; slpcall = NULL; body = slpmsg->buffer; body_len = slpmsg->size; if (slpmsg->flags == 0x0) { char *body_str; body_str = g_strndup((const char *)body, body_len); slpcall = msn_slp_sip_recv(slplink, body_str); g_free(body_str); } else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) { slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id); if (slpcall != NULL) { if (slpcall->timer) purple_timeout_remove(slpcall->timer); slpcall->cb(slpcall, body, body_len); slpcall->wasted = TRUE; } } #if 0 else if (slpmsg->flags == 0x100) { slpcall = slplink->directconn->initial_call; if (slpcall != NULL) msn_slp_call_session_init(slpcall); } #endif return slpcall; }
static void send_ok(MsnSlpCall *slpcall, const char *branch, const char *type, const char *content) { MsnSlpLink *slplink; MsnSlpMessage *slpmsg; slplink = slpcall->slplink; /* 200 OK */ slpmsg = msn_slpmsg_sip_new(slpcall, 1, "MSNSLP/1.0 200 OK", branch, type, content); #ifdef PECAN_DEBUG_SLP slpmsg->info = "SLP 200 OK"; slpmsg->text_body = TRUE; #endif msn_slplink_queue_slpmsg(slplink, slpmsg); msn_slp_call_session_init(slpcall); }
static void got_ok(MsnSlpCall *slpcall, const char *type, const char *content) { g_return_if_fail(slpcall != NULL); g_return_if_fail(type != NULL); pecan_log ("type=%s", type); if (!strcmp(type, "application/x-msnmsgr-sessionreqbody")) { #ifdef MSN_DIRECTCONN if (slpcall->slplink->session->use_directconn && slpcall->type == MSN_SLPCALL_DC) { /* First let's try a DirectConnection. */ MsnSlpLink *slplink; MsnSlpMessage *slpmsg; char *header; gchar *new_content; char *branch; slplink = slpcall->slplink; branch = msn_rand_guid(); new_content = pecan_strdup_printf( "Bridges: TRUDPv1 TCPv1\r\n" "NetID: 0\r\n" "Conn-Type: Direct-Connect\r\n" "UPnPNat: false\r\n" "ICF: false\r\n" ); header = pecan_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", slplink->remote_user); slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, branch, "application/x-msnmsgr-transreqbody", new_content); #ifdef PECAN_DEBUG_SLP slpmsg->info = "SLP INVITE"; slpmsg->text_body = TRUE; #endif msn_slplink_send_slpmsg(slplink, slpmsg); g_free(header); g_free(new_content); g_free(branch); } else { msn_slp_call_session_init(slpcall); } #else msn_slp_call_session_init(slpcall); #endif /* MSN_DIRECTCONN */ } else if (!strcmp(type, "application/x-msnmsgr-transreqbody")) { /* Do we get this? */ pecan_info ("OK with transreqbody"); } #ifdef MSN_DIRECTCONN else if (!strcmp(type, "application/x-msnmsgr-transrespbody")) { char *ip_addrs; char *temp; char *nonce; int port; { char *listening; listening = get_token(content, "Listening: ", "\r\n"); if (strcmp (listening, "false") == 0) { /** @todo I'm not sure if this is OK. */ msn_slp_call_session_init(slpcall); g_free (listening); return; } g_free (listening); } nonce = get_token(content, "Nonce: {", "}\r\n"); ip_addrs = get_token(content, "IPv4Internal-Addrs: ", "\r\n"); temp = get_token(content, "IPv4Internal-Port: ", "\r\n"); if (temp != NULL) port = atoi(temp); else port = -1; g_free(temp); if (ip_addrs == NULL) return; if (port > 0) got_transresp(slpcall, nonce, ip_addrs, port); g_free(nonce); g_free(ip_addrs); } #endif /* MSN_DIRECTCONN */ }