Commit 32359633 authored by Youness Alaoui's avatar Youness Alaoui

Renamed stun-ice.[ch] usages into ice.[ch]

Added a stun_usage_ice_conncheck_process in order to correctly process a connectivity check (same as bind process but adds role conflict checking)
parent 53d18e51
...@@ -22,7 +22,7 @@ libstun_la_SOURCES = stun.h constants.h \ ...@@ -22,7 +22,7 @@ libstun_la_SOURCES = stun.h constants.h \
stuncrc32.c stuncrc32.h \ stuncrc32.c stuncrc32.h \
stunhmac.c stunhmac.h \ stunhmac.c stunhmac.h \
utils.c utils.h \ utils.c utils.h \
usages/stun-ice.c usages/stun-ice.h \ usages/ice.c usages/ice.h \
usages/bind.c usages/bind.h \ usages/bind.c usages/bind.h \
usages/timer.c usages/timer.h \ usages/timer.c usages/timer.h \
usages/trans.c usages/trans.h usages/trans.c usages/trans.h
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "stun/stunagent.h" #include "stun/stunagent.h"
#include "stun/usages/stun-ice.h" #include "stun/usages/ice.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include <errno.h> #include <errno.h>
/** ICE connectivity checks **/ /** ICE connectivity checks **/
#include "stun-ice.h" #include "ice.h"
size_t size_t
...@@ -93,6 +93,35 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, ...@@ -93,6 +93,35 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
} }
StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
struct sockaddr *addr, socklen_t *addrlen,
struct sockaddr *alternate_server, socklen_t *alternate_server_len)
{
int code = -1;
StunUsageBindReturn res;
res = stun_usage_bind_process (msg, addr, addrlen,
alternate_server, alternate_server_len);
switch (res) {
case STUN_USAGE_BIND_RETURN_ERROR:
if (stun_message_get_class (msg) == STUN_ERROR) {
if (stun_message_find_error (msg, &code) == 0 &&
code == STUN_ERROR_ROLE_CONFLICT)
return STUN_USAGE_ICE_RETURN_ROLE_CONFLICT;
}
return STUN_USAGE_ICE_RETURN_ERROR;
case STUN_USAGE_BIND_RETURN_RETRY:
return STUN_USAGE_ICE_RETURN_RETRY;
case STUN_USAGE_BIND_RETURN_ALTERNATE_SERVER:
return STUN_USAGE_ICE_RETURN_ALTERNATE_SERVER;
default:
return STUN_USAGE_ICE_RETURN_SUCCESS;
}
}
static int static int
stun_bind_error (StunAgent *agent, StunMessage *msg, stun_bind_error (StunAgent *agent, StunMessage *msg,
uint8_t *buf, size_t *plen, const StunMessage *req, uint8_t *buf, size_t *plen, const StunMessage *req,
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
# define STUN_CONNCHECK_H 1 # define STUN_CONNCHECK_H 1
/** /**
* @file stun-ice.h * @file ice.h
* @brief STUN/ICE connectivity checks * @brief STUN/ICE connectivity checks
*/ */
...@@ -53,6 +53,16 @@ typedef enum { ...@@ -53,6 +53,16 @@ typedef enum {
STUN_USAGE_ICE_COMPATIBILITY_MSN, STUN_USAGE_ICE_COMPATIBILITY_MSN,
} StunUsageIceCompatibility; } StunUsageIceCompatibility;
typedef enum {
STUN_USAGE_ICE_RETURN_SUCCESS,
STUN_USAGE_ICE_RETURN_ERROR,
STUN_USAGE_ICE_RETURN_RETRY,
STUN_USAGE_ICE_RETURN_ALTERNATE_SERVER,
STUN_USAGE_ICE_RETURN_ROLE_CONFLICT,
} StunUsageIceReturn;
size_t size_t
stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, uint8_t *buffer, size_t buffer_len,
...@@ -62,6 +72,10 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, ...@@ -62,6 +72,10 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
uint64_t tie, StunUsageIceCompatibility compatibility); uint64_t tie, StunUsageIceCompatibility compatibility);
StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
struct sockaddr *addr, socklen_t *addrlen,
struct sockaddr *alternate_server, socklen_t *alternate_server_len);
/** /**
* Tries to parse a STUN connectivity check (Binding request) and format a * Tries to parse a STUN connectivity check (Binding request) and format a
* response accordingly. * response accordingly.
......
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