typedef struct {
char *ice_user;
char *user_ice;
+ char *luser_ice;
char *pass;
char *rpass;
switch_sockaddr_t *addr;
uint8_t ready;
uint8_t rready;
int missed_count;
- char last_sent_id[12];
+ char last_sent_id[13];
} switch_rtp_ice_t;
struct switch_rtp;
return status;
}
+int icecmp(const char *them, switch_rtp_ice_t *ice)
+{
+ if (strchr(them, ':')) {
+ return strcmp(them, ice->user_ice);
+ }
+
+ return strcmp(them, ice->luser_ice);
+}
static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *data, switch_size_t len)
{
rtp_session->last_stun = switch_micro_time_now();
switch_stun_packet_first_attribute(packet, attr);
-
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "STUN PACKET TYPE: %s\n",
+ switch_stun_value_to_name(SWITCH_STUN_TYPE_PACKET_TYPE, packet->header.type));
do {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "|---: STUN ATTR %s\n",
+ switch_stun_value_to_name(SWITCH_STUN_TYPE_ATTRIBUTE, attr->type));
+
switch (attr->type) {
+ case SWITCH_STUN_ATTR_USE_CAND:
+ {
+ ice->rready = 1;
+ }
+ break;
case SWITCH_STUN_ATTR_ERROR_CODE:
{
switch_stun_error_code_t *err = (switch_stun_error_code_t *) attr->value;
char ip[16];
uint16_t port;
switch_stun_packet_attribute_get_mapped_address(attr, ip, &port);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "|------: %s:%d\n", ip, port);
}
break;
case SWITCH_STUN_ATTR_USERNAME:
if (attr->type) {
switch_stun_packet_attribute_get_username(attr, username, sizeof(username));
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "|------: %s\n", username);
}
break;
case SWITCH_STUN_ATTR_PRIORITY:
{
+ uint32_t priority = 0;
pri = (uint32_t *) attr->value;
- ok = *pri == ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].priority;
+ priority = ntohl(*pri);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "|------: %u\n", priority);
+ ok = priority == ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].priority;
}
break;
}
if (!switch_stun_packet_next_attribute(attr, end_buf)) {
break;
}
+
xlen += 4 + switch_stun_attribute_padded_length(attr);
} while (xlen <= packet->header.length);
if ((ice->type & ICE_GOOGLE_JINGLE) && ok) {
ok = !strcmp(ice->user_ice, username);
}
+
+ if (packet->header.type != SWITCH_STUN_BINDING_REQUEST && packet->header.type != SWITCH_STUN_BINDING_RESPONSE) {
+ goto end;
+ }
if ((ice->type & ICE_VANILLA)) {
char foo1[13] = "", foo2[13] = "";
- if (!ok) ok = !strncmp(packet->header.id, ice->last_sent_id, 12);
-
-
+ if (!ok) ok = !memcmp(packet->header.id, ice->last_sent_id, 12);
if (packet->header.type == SWITCH_STUN_BINDING_RESPONSE) {
ok = 1;
}
}
- strncpy(foo1, packet->header.id, 12);
- strncpy(foo2, ice->last_sent_id, 12);
+ memcpy(foo1, packet->header.id, 12);
+ memcpy(foo2, ice->last_sent_id, 12);
if (!ok && ice == &rtp_session->ice && rtp_session->rtcp_ice.ice_params && pri &&
*pri == rtp_session->rtcp_ice.ice_params->cands[rtp_session->rtcp_ice.ice_params->chosen[1]][1].priority) {
}
if (!zstr(username)) {
- if (!strcmp(username, ice->user_ice)) {
+ if (!icecmp(username, ice)) {
ok = 1;
- } else if(!zstr(rtp_session->rtcp_ice.user_ice) && !strcmp(username, rtp_session->rtcp_ice.user_ice)) {
+ } else if(!zstr(rtp_session->rtcp_ice.user_ice) && !icecmp(username, &rtp_session->rtcp_ice)) {
ice = &rtp_session->rtcp_ice;
ok = 1;
}
{
char ice_user[80];
char user_ice[80];
+ char luser_ice[80];
switch_rtp_ice_t *ice;
char *host = NULL;
switch_port_t port = 0;
if ((type & ICE_VANILLA)) {
switch_snprintf(ice_user, sizeof(ice_user), "%s:%s", login, rlogin);
switch_snprintf(user_ice, sizeof(user_ice), "%s:%s", rlogin, login);
+ switch_snprintf(luser_ice, sizeof(user_ice), "%s%s", rlogin, login);
ice->ready = ice->rready = 0;
} else {
switch_snprintf(ice_user, sizeof(ice_user), "%s%s", login, rlogin);
ice->ice_user = switch_core_strdup(rtp_session->pool, ice_user);
ice->user_ice = switch_core_strdup(rtp_session->pool, user_ice);
+ ice->luser_ice = switch_core_strdup(rtp_session->pool, luser_ice);
ice->type = type;
ice->ice_params = ice_params;
ice->pass = "";
{SWITCH_STUN_ATTR_SOURCE_ADDRESS2, "SOURCE_ADDRESS2"},
{SWITCH_STUN_ATTR_DATA, "DATA"},
{SWITCH_STUN_ATTR_OPTIONS, "OPTIONS"},
+ {SWITCH_STUN_ATTR_PRIORITY, "PRIORITY"},
+ {SWITCH_STUN_ATTR_USE_CAND, "USE_CAND"},
+ {SWITCH_STUN_ATTR_PADDING, "PADDING"},
+ {SWITCH_STUN_ATTR_RESP_PORT, "RESP_PORT"},
+ {SWITCH_STUN_ATTR_SOFTWARE, "SOFTWARE"},
+ {SWITCH_STUN_ATTR_ALT_SERVER, "ALT_SERVER"},
+ {SWITCH_STUN_ATTR_FINGERPRINT, "FINGERPRINT"},
+ {SWITCH_STUN_ATTR_CONTROLLED, "CONTROLLED"},
+ {SWITCH_STUN_ATTR_CONTROLLING, "CONTROLLING"},
+ {SWITCH_STUN_ATTR_RESP_ORIGIN, "RESP_ORIGIN"},
+ {SWITCH_STUN_ATTR_OTHER_ADDR, "OTHER_ADDR"},
{0, 0}
};
}
break;
+ case SWITCH_STUN_ATTR_SOFTWARE:
case SWITCH_STUN_ATTR_USERNAME: /* ByteString, multiple of 4 bytes */
case SWITCH_STUN_ATTR_PASSWORD: /* ByteString, multiple of 4 bytes */
case SWITCH_STUN_ATTR_DATA: /* ByteString */