Commit 8febb558 authored by Youness Alaoui's avatar Youness Alaoui

Move bind and stun-ice back into a usages/ directory and update the includes...

Move bind and stun-ice back into a usages/ directory and update the includes and makefiles everywhere
parent 3ba6f77e
...@@ -22,7 +22,10 @@ libstun_la_SOURCES = stun.h constants.h \ ...@@ -22,7 +22,10 @@ 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 \
stun-ice.c stun-ice.h usages/stun-ice.c usages/stun-ice.h \
usages/bind.c usages/bind.h \
usages/timer.c usages/timer.h \
usages/trans.c usages/trans.h
libstun_la_LIBADD = $(OPENSSL_LIBS) $(LIBRT) libstun_la_LIBADD = $(OPENSSL_LIBS) $(LIBRT)
...@@ -16,11 +16,6 @@ check_PROGRAMS = \ ...@@ -16,11 +16,6 @@ check_PROGRAMS = \
test-bind \ test-bind \
test-conncheck test-conncheck
test_bind_SOURCES = test-bind.c \
../tools/bind.c \
../tools/trans.c \
../tools/timer.c
dist_check_SCRIPTS = check-bind.sh dist_check_SCRIPTS = check-bind.sh
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)
......
...@@ -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/tools/bind.h" #include "stun/usages/bind.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.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/stun-ice.h" #include "stun/usages/stun-ice.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -18,10 +18,7 @@ check_PROGRAMS = stund ...@@ -18,10 +18,7 @@ check_PROGRAMS = stund
stund_SOURCES = stund.c stund.h stund_SOURCES = stund.c stund.h
stund_LDADD = ../libstun.la -lpthread stund_LDADD = ../libstun.la -lpthread
stunbdc_SOURCES = stunbdc.c \ stunbdc_SOURCES = stunbdc.c
bind.c bind.h \
trans.c trans.h \
timer.c timer.h
stunbdc_LDADD = ../libstun.la stunbdc_LDADD = ../libstun.la
......
...@@ -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 "bind.h" #include "stun/usages/bind.h"
#include <unistd.h> #include <unistd.h>
#include <getopt.h> #include <getopt.h>
......
...@@ -161,6 +161,32 @@ int stun_bind_process (stun_bind_t *restrict context, ...@@ -161,6 +161,32 @@ int stun_bind_process (stun_bind_t *restrict context,
*/ */
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, int compat); socklen_t srvlen, int compat);
/**
* Starts a connectivity check using STUN Binding discovery.
*
* @param context pointer to an opaque pointer that will be passed to
* stun_bind_resume() afterward
* @param fd socket to use for discovery, or -1 to create one
* @param srv STUN server socket address
* @param srvlen STUN server socket address length
* @param username nul-terminated username for authentication
* (need not be kept valid after return)
* @param password nul-terminated shared secret (ICE password)
* (need not be kept valid after return)
* @param cand_use whether to include a USE-CANDIDATE flag
* @param priority host-byte order PRIORITY value
* @param controlling whether we are in controlling (true) or
* controlled (false) state
* @param tie control tie breaker value (host-byte order)
*
* @return 0 on success, a standard error value otherwise.
*/
int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority,
uint64_t tie, uint32_t compat);
/** /**
...@@ -179,27 +205,7 @@ int stun_nested_process (stun_nested_t *restrict ctx, ...@@ -179,27 +205,7 @@ int stun_nested_process (stun_nested_t *restrict ctx,
struct sockaddr *restrict intad, socklen_t *adlen); struct sockaddr *restrict intad, socklen_t *adlen);
# ifndef STUN_VALIDATE_DECLARATION
# define STUN_VALIDATE_DECLARATION 2
/**
* Verifies that a packet is a valid STUN message.
*
* @return actual byte length of the message if valid (>0),
* 0 if it the packet is incomplete or -1 in case of other error.
*/
ssize_t stun_validate (const uint8_t *msg, size_t len);
/**
* Checks whether a packet on a mutiplexed STUN/non-STUN channel looks like a
* STUN message. It is assumed that stun_validate succeeded first (i.e.
* returned a stricly positive value).
*
* @return true if STUN message with cookie and fingerprint, 0 otherwise.
*/
bool stun_demux (const uint8_t *msg);
# endif
# ifdef __cplusplus # ifdef __cplusplus
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "tools/bind.h" #include "stun/usages/bind.h"
#include "stunagent.h" #include "stunagent.h"
#include <errno.h> #include <errno.h>
......
...@@ -41,39 +41,12 @@ ...@@ -41,39 +41,12 @@
* @brief STUN/ICE connectivity checks * @brief STUN/ICE connectivity checks
*/ */
# include "stun/tools/bind.h"
# include "stun/stunagent.h" # include "stun/stunagent.h"
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
# endif # endif
/**
* Starts a connectivity check using STUN Binding discovery.
*
* @param context pointer to an opaque pointer that will be passed to
* stun_bind_resume() afterward
* @param fd socket to use for discovery, or -1 to create one
* @param srv STUN server socket address
* @param srvlen STUN server socket address length
* @param username nul-terminated username for authentication
* (need not be kept valid after return)
* @param password nul-terminated shared secret (ICE password)
* (need not be kept valid after return)
* @param cand_use whether to include a USE-CANDIDATE flag
* @param priority host-byte order PRIORITY value
* @param controlling whether we are in controlling (true) or
* controlled (false) state
* @param tie control tie breaker value (host-byte order)
*
* @return 0 on success, a standard error value otherwise.
*/
int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority,
uint64_t tie, uint32_t compat);
/** /**
* 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.
......
...@@ -425,6 +425,9 @@ int stun_trans_preprocess (StunAgent *agent, ...@@ -425,6 +425,9 @@ int stun_trans_preprocess (StunAgent *agent,
return EAGAIN; return EAGAIN;
break; break;
case STUN_RESPONSE:
break;
case STUN_ERROR: case STUN_ERROR:
if (stun_message_find_error (&tr->message, pcode) != 0) if (stun_message_find_error (&tr->message, pcode) != 0)
return EAGAIN; // missing ERROR-CODE: ignore message return EAGAIN; // missing ERROR-CODE: ignore message
......
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