Commit 1aeb122c authored by Olivier Crête's avatar Olivier Crête

Put the fingerprint only when not in google compat mode

parent dfd0ec14
...@@ -430,7 +430,8 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer) ...@@ -430,7 +430,8 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer)
nice_address_copy_to_sockaddr (&p->remote->addr, &sockaddr); nice_address_copy_to_sockaddr (&p->remote->addr, &sockaddr);
res = stun_bind_keepalive (p->local->sockptr->fileno, res = stun_bind_keepalive (p->local->sockptr->fileno,
&sockaddr, sizeof (sockaddr)); &sockaddr, sizeof (sockaddr),
agent->compatibility);
g_debug ("Agent %p : stun_bind_keepalive for pair %p res %d (%s).", agent, p, res, strerror (res)); g_debug ("Agent %p : stun_bind_keepalive for pair %p res %d (%s).", agent, p, res, strerror (res));
if (res < 0) if (res < 0)
++errors; ++errors;
......
...@@ -502,8 +502,9 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer) ...@@ -502,8 +502,9 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
cand->component->id, cand->component->id,
NICE_COMPONENT_STATE_GATHERING); NICE_COMPONENT_STATE_GATHERING);
res = stun_bind_start (&cand->stun_ctx, cand->socket, res = stun_bind_start (&cand->stun_ctx, cand->socket,
&stun_server.s.addr, sizeof(stun_server.s)); &stun_server.s.addr, sizeof(stun_server.s),
agent->compatibility);
if (res == 0) { if (res == 0) {
/* case: success, start waiting for the result */ /* case: success, start waiting for the result */
g_get_current_time (&cand->next_tick); g_get_current_time (&cand->next_tick);
......
...@@ -108,7 +108,7 @@ stun_bind_alloc (stun_bind_t **restrict context, int fd, ...@@ -108,7 +108,7 @@ stun_bind_alloc (stun_bind_t **restrict context, int fd,
int stun_bind_start (stun_bind_t **restrict context, int fd, int stun_bind_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, const struct sockaddr *restrict srv,
socklen_t srvlen) socklen_t srvlen, int compat)
{ {
stun_bind_t *ctx; stun_bind_t *ctx;
...@@ -117,7 +117,7 @@ int stun_bind_start (stun_bind_t **restrict context, int fd, ...@@ -117,7 +117,7 @@ int stun_bind_start (stun_bind_t **restrict context, int fd,
return val; return val;
ctx = *context; ctx = *context;
val = stun_finish (ctx->trans.msg.buf, &ctx->trans.msg.length); val = stun_finish (ctx->trans.msg.buf, &ctx->trans.msg.length, compat);
if (val) if (val)
goto error; goto error;
...@@ -205,13 +205,13 @@ int stun_bind_process (stun_bind_t *restrict ctx, ...@@ -205,13 +205,13 @@ int stun_bind_process (stun_bind_t *restrict ctx,
int stun_bind_run (int fd, int stun_bind_run (int fd,
const struct sockaddr *restrict srv, socklen_t srvlen, const struct sockaddr *restrict srv, socklen_t srvlen,
struct sockaddr *restrict addr, socklen_t *addrlen) struct sockaddr *restrict addr, socklen_t *addrlen, int compat)
{ {
stun_bind_t *ctx; stun_bind_t *ctx;
uint8_t buf[STUN_MAXMSG]; uint8_t buf[STUN_MAXMSG];
ssize_t val; ssize_t val;
val = stun_bind_start (&ctx, fd, srv, srvlen); val = stun_bind_start (&ctx, fd, srv, srvlen, compat);
if (val) if (val)
return val; return val;
...@@ -236,14 +236,14 @@ int stun_bind_run (int fd, ...@@ -236,14 +236,14 @@ int stun_bind_run (int fd,
int int
stun_bind_keepalive (int fd, const struct sockaddr *restrict srv, stun_bind_keepalive (int fd, const struct sockaddr *restrict srv,
socklen_t srvlen) socklen_t srvlen, int compat)
{ {
uint8_t buf[28]; uint8_t buf[28];
size_t len = sizeof (buf); size_t len = sizeof (buf);
int val; int val;
stun_init_indication (buf, STUN_BINDING); stun_init_indication (buf, STUN_BINDING);
val = stun_finish (buf, &len); val = stun_finish (buf, &len, compat);
assert (val == 0); assert (val == 0);
(void)val; (void)val;
...@@ -310,7 +310,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -310,7 +310,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
} }
val = stun_finish_short (ctx->trans.msg.buf, &ctx->trans.msg.length, val = stun_finish_short (ctx->trans.msg.buf, &ctx->trans.msg.length,
username, compat == 1 ? NULL : password, NULL); username, compat == 1 ? NULL : password, NULL, compat);
if (val) if (val)
goto error; goto error;
...@@ -339,7 +339,7 @@ struct stun_nested_s ...@@ -339,7 +339,7 @@ struct stun_nested_s
int stun_nested_start (stun_nested_t **restrict context, int fd, int stun_nested_start (stun_nested_t **restrict context, int fd,
const struct sockaddr *restrict mapad, const struct sockaddr *restrict mapad,
const struct sockaddr *restrict natad, const struct sockaddr *restrict natad,
socklen_t adlen, uint32_t refresh) socklen_t adlen, uint32_t refresh, int compat)
{ {
stun_nested_t *ctx; stun_nested_t *ctx;
int val; int val;
...@@ -366,7 +366,8 @@ int stun_nested_start (stun_nested_t **restrict context, int fd, ...@@ -366,7 +366,8 @@ int stun_nested_start (stun_nested_t **restrict context, int fd,
goto error; goto error;
val = stun_finish (ctx->bind->trans.msg.buf, val = stun_finish (ctx->bind->trans.msg.buf,
&ctx->bind->trans.msg.length); &ctx->bind->trans.msg.length,
compat);
if (val) if (val)
goto error; goto error;
......
...@@ -71,7 +71,7 @@ extern "C" { ...@@ -71,7 +71,7 @@ extern "C" {
*/ */
int stun_bind_run (int fd, int stun_bind_run (int fd,
const struct sockaddr *restrict srv, socklen_t srvlen, const struct sockaddr *restrict srv, socklen_t srvlen,
struct sockaddr *restrict addr, socklen_t *addrlen); struct sockaddr *restrict addr, socklen_t *addrlen, int compat);
/** /**
* Starts STUN Binding discovery in non-blocking mode. * Starts STUN Binding discovery in non-blocking mode.
...@@ -85,7 +85,8 @@ int stun_bind_run (int fd, ...@@ -85,7 +85,8 @@ int stun_bind_run (int fd,
* @return 0 on success, a standard error value otherwise. * @return 0 on success, a standard error value otherwise.
*/ */
int stun_bind_start (stun_bind_t **restrict context, int fd, int stun_bind_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen); const struct sockaddr *restrict srv, socklen_t srvlen,
int compat);
/** /**
* Aborts a running STUN Binding discovery. * Aborts a running STUN Binding discovery.
...@@ -157,7 +158,7 @@ int stun_bind_process (stun_bind_t *restrict context, ...@@ -157,7 +158,7 @@ int stun_bind_process (stun_bind_t *restrict context,
* @return 0 on success, an error code from sendto() otherwise. * @return 0 on success, an error code from sendto() otherwise.
*/ */
int stun_bind_keepalive (int fd, const struct sockaddr *restrict srv, int stun_bind_keepalive (int fd, const struct sockaddr *restrict srv,
socklen_t srvlen); socklen_t srvlen, int compat);
/** /**
...@@ -169,7 +170,7 @@ typedef struct stun_nested_s stun_nested_t; ...@@ -169,7 +170,7 @@ typedef struct stun_nested_s stun_nested_t;
int stun_nested_start (stun_nested_t **restrict context, int fd, int stun_nested_start (stun_nested_t **restrict context, int fd,
const struct sockaddr *restrict mapad, const struct sockaddr *restrict mapad,
const struct sockaddr *restrict natad, const struct sockaddr *restrict natad,
socklen_t adlen, uint32_t refresh); socklen_t adlen, uint32_t refresh, int compat);
int stun_nested_process (stun_nested_t *restrict ctx, int stun_nested_process (stun_nested_t *restrict ctx,
const void *restrict buf, size_t len, const void *restrict buf, size_t len,
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
static int static int
stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req, stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req,
stun_error_t code, const char *pass) stun_error_t code, const char *pass, int compat)
{ {
size_t len = *plen; size_t len = *plen;
int val; int val;
...@@ -64,7 +64,7 @@ stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req, ...@@ -64,7 +64,7 @@ stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req,
if (val) if (val)
return val; return val;
val = stun_finish_short (buf, &len, NULL, pass, NULL); val = stun_finish_short (buf, &len, NULL, pass, NULL, compat);
if (val) if (val)
return val; return val;
...@@ -89,7 +89,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen, ...@@ -89,7 +89,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
int val, ret = 0; int val, ret = 0;
#define err( code ) \ #define err( code ) \
stun_bind_error (buf, &len, msg, code, pass); \ stun_bind_error (buf, &len, msg, code, pass, compat); \
*plen = len *plen = len
*plen = 0; *plen = 0;
...@@ -113,7 +113,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen, ...@@ -113,7 +113,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
DBG (" Unknown mandatory attributes in message.\n"); DBG (" Unknown mandatory attributes in message.\n");
val = stun_init_error_unknown (buf, len, msg); val = stun_init_error_unknown (buf, len, msg);
if (!val) if (!val)
val = stun_finish_short (buf, &len, NULL, pass, NULL); val = stun_finish_short (buf, &len, NULL, pass, NULL, compat);
if (val) if (val)
goto failure; goto failure;
...@@ -143,7 +143,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen, ...@@ -143,7 +143,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
if (val) if (val)
{ {
stun_bind_error (buf, &len, msg, val, NULL); stun_bind_error (buf, &len, msg, val, NULL, compat);
*plen = len; *plen = len;
return EPERM; return EPERM;
} }
...@@ -201,7 +201,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen, ...@@ -201,7 +201,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
} }
val = stun_finish_short (buf, &len, compat == 1 ? username : NULL, val = stun_finish_short (buf, &len, compat == 1 ? username : NULL,
compat == 1 ? NULL : pass, NULL); compat == 1 ? NULL : pass, NULL, compat);
if (val) if (val)
goto failure; goto failure;
......
...@@ -583,7 +583,7 @@ int stun_init_error_unknown (uint8_t *ans, size_t msize, const uint8_t *req); ...@@ -583,7 +583,7 @@ int stun_init_error_unknown (uint8_t *ans, size_t msize, const uint8_t *req);
size_t size_t
stun_finish_long (uint8_t *msg, size_t *restrict plen, stun_finish_long (uint8_t *msg, size_t *restrict plen,
const char *realm, const char *username, const char *nonce, const char *realm, const char *username, const char *nonce,
const void *restrict key, size_t keylen); const void *restrict key, size_t keylen, int compat);
/** /**
* Completes a STUN message structure before sending it, and * Completes a STUN message structure before sending it, and
...@@ -600,7 +600,7 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen, ...@@ -600,7 +600,7 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen,
*/ */
size_t stun_finish_short (uint8_t *msg, size_t *restrict plen, size_t stun_finish_short (uint8_t *msg, size_t *restrict plen,
const char *username, const char *password, const char *username, const char *password,
const char *nonce); const char *nonce, int compat);
/** /**
* Completes a STUN message structure before sending it. * Completes a STUN message structure before sending it.
...@@ -611,7 +611,7 @@ size_t stun_finish_short (uint8_t *msg, size_t *restrict plen, ...@@ -611,7 +611,7 @@ size_t stun_finish_short (uint8_t *msg, size_t *restrict plen,
* *
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
size_t stun_finish (uint8_t *restrict msg, size_t *restrict plen); size_t stun_finish (uint8_t *restrict msg, size_t *restrict plen, int compat);
void *stun_append (uint8_t *msg, size_t msize, stun_attr_type_t type, void *stun_append (uint8_t *msg, size_t msize, stun_attr_type_t type,
......
...@@ -98,7 +98,7 @@ static int run (int family, const char *hostname, const char *service) ...@@ -98,7 +98,7 @@ static int run (int family, const char *hostname, const char *service)
printaddr ("Server address", ptr->ai_addr, ptr->ai_addrlen); printaddr ("Server address", ptr->ai_addr, ptr->ai_addrlen);
val = stun_bind_run (-1, ptr->ai_addr, ptr->ai_addrlen, val = stun_bind_run (-1, ptr->ai_addr, ptr->ai_addrlen,
(struct sockaddr *)&addr, &addrlen); (struct sockaddr *)&addr, &addrlen, 0);
if (val) if (val)
fprintf (stderr, "%s\n", strerror (val)); fprintf (stderr, "%s\n", strerror (val));
else else
......
...@@ -235,7 +235,7 @@ static int dgram_process (int sock) ...@@ -235,7 +235,7 @@ static int dgram_process (int sock)
} }
finish: finish:
stun_finish (buf, &iov.iov_len); stun_finish (buf, &iov.iov_len, 0);
len = send_safe (sock, &mh); len = send_safe (sock, &mh);
return (len < iov.iov_len) ? -1 : 0; return (len < iov.iov_len) ? -1 : 0;
......
...@@ -441,7 +441,7 @@ int stun_append_xor_addr (uint8_t *restrict msg, size_t msize, ...@@ -441,7 +441,7 @@ int stun_append_xor_addr (uint8_t *restrict msg, size_t msize,
size_t size_t
stun_finish_long (uint8_t *msg, size_t *restrict plen, stun_finish_long (uint8_t *msg, size_t *restrict plen,
const char *realm, const char *username, const char *nonce, const char *realm, const char *username, const char *nonce,
const void *restrict key, size_t keylen) const void *restrict key, size_t keylen, int compat)
{ {
size_t len = *plen; size_t len = *plen;
uint8_t *ptr; uint8_t *ptr;
...@@ -494,7 +494,7 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen, ...@@ -494,7 +494,7 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen,
} }
if (0) { if (compat != 1) {
/* /*
* NOTE: we always add a FINGERPRINT, even when it's not needed. * NOTE: we always add a FINGERPRINT, even when it's not needed.
* This is OK, as it is an optional attribute. It also makes my * This is OK, as it is an optional attribute. It also makes my
...@@ -515,14 +515,14 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen, ...@@ -515,14 +515,14 @@ stun_finish_long (uint8_t *msg, size_t *restrict plen,
size_t stun_finish_short (uint8_t *msg, size_t *restrict plen, size_t stun_finish_short (uint8_t *msg, size_t *restrict plen,
const char *username, const char *restrict password, const char *username, const char *restrict password,
const char *nonce) const char *nonce, int compat)
{ {
return stun_finish_long (msg, plen, NULL, username, nonce, return stun_finish_long (msg, plen, NULL, username, nonce,
password, password ? strlen (password) : 0); password, password ? strlen (password) : 0, compat);
} }
size_t stun_finish (uint8_t *msg, size_t *restrict plen) size_t stun_finish (uint8_t *msg, size_t *restrict plen, int compat)
{ {
return stun_finish_short (msg, plen, NULL, NULL, NULL); return stun_finish_short (msg, plen, NULL, NULL, NULL, compat);
} }
...@@ -98,7 +98,7 @@ static void bad_family (void) ...@@ -98,7 +98,7 @@ static void bad_family (void)
#endif #endif
val = stun_bind_run (-1, &addr, sizeof (addr), val = stun_bind_run (-1, &addr, sizeof (addr),
&dummy, &(socklen_t){ sizeof (dummy) }); &dummy, &(socklen_t){ sizeof (dummy) }, 0);
assert (val != 0); assert (val != 0);
} }
...@@ -116,7 +116,7 @@ static void small_srv_addr (void) ...@@ -116,7 +116,7 @@ static void small_srv_addr (void)
#endif #endif
val = stun_bind_run (-1, &addr, 1, val = stun_bind_run (-1, &addr, 1,
&dummy, &(socklen_t){ sizeof (dummy) }); &dummy, &(socklen_t){ sizeof (dummy) }, 0);
assert (val == EINVAL); assert (val == EINVAL);
} }
...@@ -133,7 +133,7 @@ static void big_srv_addr (void) ...@@ -133,7 +133,7 @@ static void big_srv_addr (void)
memset (buf, 0, sizeof (buf)); memset (buf, 0, sizeof (buf));
val = stun_bind_run (fd, (struct sockaddr *)buf, sizeof (buf), val = stun_bind_run (fd, (struct sockaddr *)buf, sizeof (buf),
&dummy, &(socklen_t){ sizeof (dummy) }); &dummy, &(socklen_t){ sizeof (dummy) }, 0);
assert (val == ENOBUFS); assert (val == ENOBUFS);
close (fd); close (fd);
} }
...@@ -155,7 +155,7 @@ static void timeout (void) ...@@ -155,7 +155,7 @@ static void timeout (void)
assert (val == 0); assert (val == 0);
val = stun_bind_run (-1, (struct sockaddr *)&srv, srvlen, val = stun_bind_run (-1, (struct sockaddr *)&srv, srvlen,
&dummy, &(socklen_t){ sizeof (dummy) }); &dummy, &(socklen_t){ sizeof (dummy) }, 0);
assert (val == ETIMEDOUT); assert (val == ETIMEDOUT);
close (servfd); close (servfd);
...@@ -181,7 +181,7 @@ static void bad_responses (void) ...@@ -181,7 +181,7 @@ static void bad_responses (void)
fd = socket (addr.ss_family, SOCK_DGRAM, 0); fd = socket (addr.ss_family, SOCK_DGRAM, 0);
assert (fd != -1); assert (fd != -1);
val = stun_bind_start (&ctx, fd, (struct sockaddr *)&addr, addrlen); val = stun_bind_start (&ctx, fd, (struct sockaddr *)&addr, addrlen, 0);
assert (val == 0); assert (val == 0);
/* Send to/receive from our client instance only */ /* Send to/receive from our client instance only */
...@@ -260,7 +260,7 @@ static void responses (void) ...@@ -260,7 +260,7 @@ static void responses (void)
assert (val == 0); assert (val == 0);
/* Send error response */ /* Send error response */
val = stun_bind_start (&ctx, fd, NULL, 0); val = stun_bind_start (&ctx, fd, NULL, 0, 0);
assert (val == 0); assert (val == 0);
val = recv (servfd, buf, 1000, MSG_DONTWAIT); val = recv (servfd, buf, 1000, MSG_DONTWAIT);
...@@ -268,7 +268,7 @@ static void responses (void) ...@@ -268,7 +268,7 @@ static void responses (void)
stun_init_error (buf, sizeof (buf), buf, STUN_SERVER_ERROR); stun_init_error (buf, sizeof (buf), buf, STUN_SERVER_ERROR);
len = sizeof (buf); len = sizeof (buf);
val = stun_finish (buf, &len); val = stun_finish (buf, &len, 0);
assert (val == 0); assert (val == 0);
val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen); val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen);
...@@ -278,7 +278,7 @@ static void responses (void) ...@@ -278,7 +278,7 @@ static void responses (void)
assert (val == ECONNREFUSED); assert (val == ECONNREFUSED);
/* Send response with an unknown attribute */ /* Send response with an unknown attribute */
val = stun_bind_start (&ctx, fd, NULL, 0); val = stun_bind_start (&ctx, fd, NULL, 0, 0);
assert (val == 0); assert (val == 0);
val = recv (servfd, buf, 1000, MSG_DONTWAIT); val = recv (servfd, buf, 1000, MSG_DONTWAIT);
...@@ -289,7 +289,7 @@ static void responses (void) ...@@ -289,7 +289,7 @@ static void responses (void)
"This is an unknown attribute!"); "This is an unknown attribute!");
assert (val == 0); assert (val == 0);
len = sizeof (buf); len = sizeof (buf);
val = stun_finish (buf, &len); val = stun_finish (buf, &len, 0);
assert (val == 0); assert (val == 0);
val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen); val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen);
...@@ -300,7 +300,7 @@ static void responses (void) ...@@ -300,7 +300,7 @@ static void responses (void)
assert (val == EPROTO); assert (val == EPROTO);
/* Send response with a no mapped address at all */ /* Send response with a no mapped address at all */
val = stun_bind_start (&ctx, fd, NULL, 0); val = stun_bind_start (&ctx, fd, NULL, 0, 0);
assert (val == 0); assert (val == 0);
val = recv (servfd, buf, 1000, MSG_DONTWAIT); val = recv (servfd, buf, 1000, MSG_DONTWAIT);
...@@ -308,7 +308,7 @@ static void responses (void) ...@@ -308,7 +308,7 @@ static void responses (void)
stun_init_response (buf, sizeof (buf), buf); stun_init_response (buf, sizeof (buf), buf);
len = sizeof (buf); len = sizeof (buf);
val = stun_finish (buf, &len); val = stun_finish (buf, &len, 0);
assert (val == 0); assert (val == 0);
val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen); val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen);
...@@ -319,7 +319,7 @@ static void responses (void) ...@@ -319,7 +319,7 @@ static void responses (void)
assert (val == ENOENT); assert (val == ENOENT);
/* Send old-style response */ /* Send old-style response */
val = stun_bind_start (&ctx, fd, NULL, 0); val = stun_bind_start (&ctx, fd, NULL, 0, 0);
assert (val == 0); assert (val == 0);
val = recv (servfd, buf, 1000, MSG_DONTWAIT); val = recv (servfd, buf, 1000, MSG_DONTWAIT);
...@@ -330,7 +330,7 @@ static void responses (void) ...@@ -330,7 +330,7 @@ static void responses (void)
(struct sockaddr *)&addr, addrlen); (struct sockaddr *)&addr, addrlen);
assert (val == 0); assert (val == 0);
len = sizeof (buf); len = sizeof (buf);
val = stun_finish (buf, &len); val = stun_finish (buf, &len, 0);
assert (val == 0); assert (val == 0);
val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen); val = getsockname (servfd, (struct sockaddr *)&addr, &addrlen);
...@@ -366,12 +366,12 @@ static void keepalive (void) ...@@ -366,12 +366,12 @@ static void keepalive (void)
assert (fd != -1); assert (fd != -1);
/* Keep alive sending smoke test */ /* Keep alive sending smoke test */
val = stun_bind_keepalive (fd, (struct sockaddr *)&addr, addrlen); val = stun_bind_keepalive (fd, (struct sockaddr *)&addr, addrlen, 0);
assert (val == 0); assert (val == 0);
/* Wrong address family test */ /* Wrong address family test */
addr.ss_family = addr.ss_family == AF_INET ? AF_INET6 : AF_INET; addr.ss_family = addr.ss_family == AF_INET ? AF_INET6 : AF_INET;
val = stun_bind_keepalive (fd, (struct sockaddr *)&addr, addrlen); val = stun_bind_keepalive (fd, (struct sockaddr *)&addr, addrlen, 0);
assert (val != 0); assert (val != 0);
/* End */ /* End */
......
...@@ -77,7 +77,7 @@ int main (void) ...@@ -77,7 +77,7 @@ int main (void)
stun_init_request (req, STUN_BINDING); stun_init_request (req, STUN_BINDING);
stun_init_response (req, sizeof (req), req); stun_init_response (req, sizeof (req), req);
len = sizeof (req); len = sizeof (req);
val = stun_finish (req, &len); val = stun_finish (req, &len, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -89,7 +89,7 @@ int main (void) ...@@ -89,7 +89,7 @@ int main (void)
/* Incorrect message method */ /* Incorrect message method */
stun_init_request (req, 0x666); stun_init_request (req, 0x666);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, username, pass, NULL); val = stun_finish_short (req, &len, username, pass, NULL, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -104,7 +104,7 @@ int main (void) ...@@ -104,7 +104,7 @@ int main (void)
"The evil unknown attribute!"); "The evil unknown attribute!");
assert (val == 0); assert (val == 0);
len = sizeof (req); len = sizeof (req);
val = stun_finish (req, &len); val = stun_finish (req, &len, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -116,7 +116,7 @@ int main (void) ...@@ -116,7 +116,7 @@ int main (void)
/* Unauthenticated message */ /* Unauthenticated message */
stun_init_request (req, STUN_BINDING); stun_init_request (req, STUN_BINDING);
len = sizeof (req); len = sizeof (req);
val = stun_finish (req, &len); val = stun_finish (req, &len, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -130,7 +130,7 @@ int main (void) ...@@ -130,7 +130,7 @@ int main (void)
/* No username */ /* No username */
stun_init_request (req, STUN_BINDING); stun_init_request (req, STUN_BINDING);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, NULL, pass, NULL); val = stun_finish_short (req, &len, NULL, pass, NULL, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -150,7 +150,7 @@ int main (void) ...@@ -150,7 +150,7 @@ int main (void)
val = stun_append_flag (req, sizeof (req), STUN_USE_CANDIDATE); val = stun_append_flag (req, sizeof (req), STUN_USE_CANDIDATE);
assert (val == 0); assert (val == 0);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, username, pass, NULL); val = stun_finish_short (req, &len, username, pass, NULL, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -195,7 +195,7 @@ int main (void) ...@@ -195,7 +195,7 @@ int main (void)
/* Bad CRC32 */ /* Bad CRC32 */
stun_init_request (req, STUN_BINDING); stun_init_request (req, STUN_BINDING);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, ufrag, pass, NULL); val = stun_finish_short (req, &len, ufrag, pass, NULL, 0);
assert (val == 0); assert (val == 0);
((uint8_t *)stun_find (req, STUN_FINGERPRINT, &alen))[0] ^= 1; ((uint8_t *)stun_find (req, STUN_FINGERPRINT, &alen))[0] ^= 1;
...@@ -210,7 +210,7 @@ int main (void) ...@@ -210,7 +210,7 @@ int main (void)
val = stun_append64 (req, sizeof (req), STUN_ICE_CONTROLLING, tie + 1); val = stun_append64 (req, sizeof (req), STUN_ICE_CONTROLLING, tie + 1);
assert (val == 0); assert (val == 0);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, username, pass, NULL); val = stun_finish_short (req, &len, username, pass, NULL, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
...@@ -229,7 +229,7 @@ int main (void) ...@@ -229,7 +229,7 @@ int main (void)
val = stun_append64 (req, sizeof (req), STUN_ICE_CONTROLLED, tie - 1); val = stun_append64 (req, sizeof (req), STUN_ICE_CONTROLLED, tie - 1);
assert (val == 0); assert (val == 0);
len = sizeof (req); len = sizeof (req);
val = stun_finish_short (req, &len, username, pass, NULL); val = stun_finish_short (req, &len, username, pass, NULL, 0);
assert (val == 0); assert (val == 0);
len = sizeof (resp); len = sizeof (resp);
......
...@@ -82,14 +82,14 @@ finish_check (uint8_t *msg) ...@@ -82,14 +82,14 @@ finish_check (uint8_t *msg)
size_t len = sizeof (stun_msg_t); size_t len = sizeof (stun_msg_t);
memcpy (mshort, msg, sizeof (mshort)); memcpy (mshort, msg, sizeof (mshort));
if (stun_finish (msg, &len)) if (stun_finish (msg, &len, 0))
fatal ("Cannot finish message"); fatal ("Cannot finish message");
dynamic_check (msg, len); dynamic_check (msg, len);
len = sizeof (mshort); len = sizeof (mshort);
if (stun_verify_password (mshort, "toto") != ENOENT) if (stun_verify_password (mshort, "toto") != ENOENT)
fatal ("Missing HMAC test failed"); fatal ("Missing HMAC test failed");
if (stun_finish_short (mshort, &len, "ABCDE", "admin", "ABC")) if (stun_finish_short (mshort, &len, "ABCDE", "admin", "ABC", 0))
fatal ("Cannot finish message with short-term creds"); fatal ("Cannot finish message with short-term creds");
dynamic_check (mshort, len); dynamic_check (mshort, len);
if (stun_verify_password (mshort, "admin") != 0) if (stun_verify_password (mshort, "admin") != 0)
...@@ -197,16 +197,16 @@ int main (void) ...@@ -197,16 +197,16 @@ int main (void)
sizeof (addr)) != ENOBUFS) sizeof (addr)) != ENOBUFS)
fatal ("Address overflow test failed"); fatal ("Address overflow test failed");
len = sizeof (msg); len = sizeof (msg);
if (stun_finish (msg, &len) != ENOBUFS) if (stun_finish (msg, &len, 0) != ENOBUFS)
fatal ("Fingerprint overflow test failed"); fatal ("Fingerprint overflow test failed");
len = sizeof (msg); len = sizeof (msg);
if (stun_finish_short (msg, &len, NULL, "secret", NULL) != ENOBUFS) if (stun_finish_short (msg, &len, NULL, "secret", NULL, 0) != ENOBUFS)
fatal ("Message integrity overflow test failed"); fatal ("Message integrity overflow test failed");
len = sizeof (msg); len = sizeof (msg);
if (stun_finish_short (msg, &len, "login", "secret", NULL) != ENOBUFS) if (stun_finish_short (msg, &len, "login", "secret", NULL, 0) != ENOBUFS)
fatal ("Username overflow test failed"); fatal ("Username overflow test failed");
len = sizeof (msg); len = sizeof (msg);
if (stun_finish_short (msg, &len, NULL, "secret", "foobar") != ENOBUFS) if (stun_finish_short (msg, &len, NULL, "secret", "foobar", 0) != ENOBUFS)
fatal ("Nonce overflow test failed"); fatal ("Nonce overflow test failed");
/* Address attributes tests */ /* Address attributes tests */
......
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