Commit 83bb8d9a authored by Youness Alaoui's avatar Youness Alaoui

Replace all sockaddr instances with sockaddr_storage to be ipv6 safe

parent 35b4e5be
......@@ -568,10 +568,11 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
Component *component = j->data;
if (component->selected_pair.local != NULL) {
CandidatePair *p = &component->selected_pair;
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
memset (&sockaddr, 0, sizeof (sockaddr));
nice_address_copy_to_sockaddr (&p->remote->addr, &sockaddr);
nice_address_copy_to_sockaddr (&p->remote->addr,
(struct sockaddr *) &sockaddr);
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
guint32 priority = nice_candidate_ice_priority_full (
......@@ -1639,7 +1640,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
bool cand_use = controlling;
size_t buffer_len;
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
unsigned int timeout;
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
......@@ -1648,7 +1649,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
memset (&sockaddr, 0, sizeof (sockaddr));
nice_address_copy_to_sockaddr (&pair->remote->addr, &sockaddr);
nice_address_copy_to_sockaddr (&pair->remote->addr,
(struct sockaddr *) &sockaddr);
{
gchar tmpbuf[INET6_ADDRSTRLEN];
......@@ -2065,7 +2067,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
*/
static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *stream, Component *component, NiceSocket *sockptr, const NiceAddress *from, NiceCandidate *local_candidate, NiceCandidate *remote_candidate, StunMessage *resp)
{
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
socklen_t socklen = sizeof (sockaddr);
GSList *i;
StunUsageIceReturn res;
......@@ -2081,7 +2083,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
stun_message_id (&p->stun_message, discovery_id);
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 0) {
res = stun_usage_ice_conncheck_process (resp, &sockaddr, &socklen,
res = stun_usage_ice_conncheck_process (resp,
(struct sockaddr *) &sockaddr, &socklen,
agent_to_ice_compatibility (agent));
nice_debug ("Agent %p : stun_bind_process/conncheck for %p res %d "
"(controlling=%d).", agent, p, (int)res, agent->controlling_mode);
......@@ -2132,7 +2135,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
priv_conn_check_unfreeze_related (agent, stream, p);
} else {
ok_pair = priv_process_response_check_for_peer_reflexive(agent,
stream, component, p, sockptr, &sockaddr,
stream, component, p, sockptr, (struct sockaddr *) &sockaddr,
local_candidate, remote_candidate);
}
......@@ -2194,9 +2197,9 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
*/
static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessage *resp)
{
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
socklen_t socklen = sizeof (sockaddr);
struct sockaddr alternate;
struct sockaddr_storage alternate;
socklen_t alternatelen = sizeof (sockaddr);
GSList *i;
StunUsageBindReturn res;
......@@ -2213,22 +2216,24 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
stun_message_id (&d->stun_message, discovery_id);
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 0) {
res = stun_usage_bind_process (resp, &sockaddr, &socklen,
&alternate, &alternatelen);
res = stun_usage_bind_process (resp, (struct sockaddr *) &sockaddr,
&socklen, (struct sockaddr *) &alternate, &alternatelen);
nice_debug ("Agent %p : stun_bind_process/disc for %p res %d.",
agent, d, (int)res);
if (res == STUN_USAGE_BIND_RETURN_ALTERNATE_SERVER) {
/* handle alternate server */
NiceAddress niceaddr;
nice_address_set_from_sockaddr (&niceaddr, &alternate);
nice_address_set_from_sockaddr (&niceaddr,
(struct sockaddr *) &alternate);
d->server = niceaddr;
d->pending = FALSE;
} else if (res == STUN_USAGE_BIND_RETURN_SUCCESS) {
/* case: succesful binding discovery, create a new local candidate */
NiceAddress niceaddr;
nice_address_set_from_sockaddr (&niceaddr, &sockaddr);
nice_address_set_from_sockaddr (&niceaddr,
(struct sockaddr *) &sockaddr);
discovery_add_server_reflexive_candidate (
d->agent,
......@@ -2302,11 +2307,11 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
*/
static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *resp)
{
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
socklen_t socklen = sizeof (sockaddr);
struct sockaddr alternate;
struct sockaddr_storage alternate;
socklen_t alternatelen = sizeof (alternate);
struct sockaddr relayaddr;
struct sockaddr_storage relayaddr;
socklen_t relayaddrlen = sizeof (relayaddr);
uint32_t lifetime;
uint32_t bandwidth;
......@@ -2326,15 +2331,19 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 0) {
res = stun_usage_turn_process (resp,
&relayaddr, &relayaddrlen, &sockaddr, &socklen, &alternate, &alternatelen,
(struct sockaddr *) &relayaddr, &relayaddrlen,
(struct sockaddr *) &sockaddr, &socklen,
(struct sockaddr *) &alternate, &alternatelen,
&bandwidth, &lifetime, agent_to_turn_compatibility (agent));
nice_debug ("Agent %p : stun_turn_process/disc for %p res %d.",
agent, d, (int)res);
if (res == STUN_USAGE_TURN_RETURN_ALTERNATE_SERVER) {
/* handle alternate server */
nice_address_set_from_sockaddr (&d->server, &alternate);
nice_address_set_from_sockaddr (&d->turn->server, &alternate);
nice_address_set_from_sockaddr (&d->server,
(struct sockaddr *) &alternate);
nice_address_set_from_sockaddr (&d->turn->server,
(struct sockaddr *) &alternate);
d->pending = FALSE;
} else if (res == STUN_USAGE_TURN_RETURN_RELAY_SUCCESS ||
......@@ -2345,7 +2354,8 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
/* We also received our mapped address */
if (res == STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS) {
nice_address_set_from_sockaddr (&niceaddr, &sockaddr);
nice_address_set_from_sockaddr (&niceaddr,
(struct sockaddr *) &sockaddr);
discovery_add_server_reflexive_candidate (
d->agent,
......@@ -2355,7 +2365,8 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
d->nicesock);
}
nice_address_set_from_sockaddr (&niceaddr, &relayaddr);
nice_address_set_from_sockaddr (&niceaddr,
(struct sockaddr *) &relayaddr);
relay_cand = discovery_add_relay_candidate (
d->agent,
d->stream->id,
......@@ -2626,7 +2637,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
Component *component, NiceSocket *socket, const NiceAddress *from,
gchar *buf, guint len)
{
struct sockaddr sockaddr;
struct sockaddr_storage sockaddr;
uint8_t rbuf[MAX_STUN_DATAGRAM_PAYLOAD];
ssize_t res;
size_t rbuf_len = sizeof (rbuf);
......@@ -2645,7 +2656,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
NiceCandidate *local_candidate = NULL;
gboolean discovery_msg = FALSE;
nice_address_copy_to_sockaddr (from, &sockaddr);
nice_address_copy_to_sockaddr (from, (struct sockaddr *) &sockaddr);
/* note: contents of 'buf' already validated, so it is
* a valid and fully received STUN message */
......@@ -2843,7 +2854,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
rbuf_len = sizeof (rbuf);
res = stun_usage_ice_conncheck_create_reply (&agent->stun_agent, &req,
&msg, rbuf, &rbuf_len, &sockaddr, sizeof (sockaddr),
&msg, rbuf, &rbuf_len, (struct sockaddr *) &sockaddr, sizeof (sockaddr),
&control, agent->tie_breaker,
agent_to_ice_compatibility (agent));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment