Update documentation (doxygen).

This commit is contained in:
bossiel 2010-03-01 23:24:11 +00:00
parent 19567fcef5
commit e40fdce215
14 changed files with 238 additions and 159 deletions

View File

@ -43,9 +43,13 @@
// RFC 3319 Dynamic Host Configuration Protocol (DHCPv6) Options for Session Initiation Protocol (SIP) Servers
// RFC 3361 Dynamic Host Configuration Protocol (DHCP-for-IPv4) Option for Session Initiation Protocol (SIP) Servers
/**@defgroup tnet_dhcp_group DHCPv4/BOOTP (RFC 2131) implementation.
*/
/* FIXME: USE retransmission mech (*2*2...)
*/
/**@ingroup tnet_dhcp_group
*/
tnet_dhcp_reply_t* tnet_dhcp_send_request(tnet_dhcp_ctx_t* ctx, tnet_dhcp_request_t* request)
{
tsk_buffer_t *output;
@ -203,6 +207,8 @@ bail:
return reply;
}
/**@ingroup tnet_dhcp_group
*/
tnet_dhcp_reply_t* tnet_dhcp_query(tnet_dhcp_ctx_t* ctx, tnet_dhcp_message_type_t type, tnet_dhcp_params_t* params)
{
tnet_dhcp_reply_t* reply = 0;
@ -224,7 +230,8 @@ bail:
return reply;
}
/**@ingroup tnet_dhcp_group
*/
int tnet_dhcp_params_add_code(tnet_dhcp_params_t* params, tnet_dhcp_option_code_t code)
{
if(params){

View File

@ -40,25 +40,49 @@
#include "tsk_object.h"
#include "tsk_safeobj.h"
/**@ingroup tnet_dhcp_group
* @def TNET_DHCP_CTX_CREATE
* Creates new DHCPv4 context.
* @retval @ref tnet_dhcp_ctx_t object.
*/
/**@ingroup tnet_dhcp_group
* @def TNET_DHCP_PARAMS_CREATE
* Creates new DHCPv4 parameters.
* @retval @ref tnet_dhcp_params_t object.
*/
TNET_BEGIN_DECLS
#define TNET_DHCP_CTX_CREATE() tsk_object_new(tnet_dhcp_ctx_def_t)
#define TNET_DHCP_PARAMS_CREATE() tsk_object_new(tnet_dhcp_params_def_t)
/** Default timeout (in milliseconds) value for DHCP requests.
/**@ingroup tnet_dhcp_group
* Default timeout (in milliseconds) value for DHCP requests.
*/
#define TNET_DHCP_TIMEOUT_DEFAULT 2000
/**< Local port(client) to bind to for incoming DHCP messages as per RFC 2131 subclause 4.1. */
/**@ingroup tnet_dhcp_group
* Local port(client) to bind to for incoming DHCP messages as per RFC 2131 subclause 4.1. */
#define TNET_DHCP_CLIENT_PORT 68
/**< Destination port(Server) for outgoing DHCP messages as per RFC 2131 subclause 4.1. */
/**@ingroup tnet_dhcp_group
* Destination port(Server) for outgoing DHCP messages as per RFC 2131 subclause 4.1. */
#define TNET_DHCP_SERVER_PORT 67
/**@ingroup tnet_dhcp_group
* @def TNET_DHCP_VENDOR_ID_DEFAULT
*/
/**@ingroup tnet_dhcp_group
* @def TNET_DHCP_MAX_CODES
*/
/**@ingroup tnet_dhcp_group
* @def TNET_DHCP_MAX_MSG_SIZE
*/
#define TNET_DHCP_VENDOR_ID_DEFAULT "doubango/v0.0.0"
#define TNET_DHCP_MAX_CODES 20
#define TNET_DHCP_MAX_MSG_SIZE 1500
/** Parameter Request List (55)
/**@ingroup tnet_dhcp_group
* Parameter Request List (55)
*/
typedef struct tnet_dhcp_params_s
{
@ -69,6 +93,8 @@ typedef struct tnet_dhcp_params_s
}
tnet_dhcp_params_t;
/**@ingroup tnet_dhcp_group
*/
typedef struct tnet_dhcp_ctx_s
{
TSK_DECLARE_OBJECT;

View File

@ -36,12 +36,12 @@
#include "tsk_thread.h"
/**@defgroup tnet_dhcp6_group DHCPv6 implementation.
/**@defgroup tnet_dhcp6_group DHCPv6 (RFC 3315) implementation.
* Dynamic Host Configuration Protocol for IPv6 (DHCPv6) as per RFC 3315.
* Also implement: RFC 3319, 3633, 3646, 3736, 4242, 5007 ...
*/
/**@ingroup tnet_dhcpv_group
/**@ingroup tnet_dhcp6_group
*/
tnet_dhcp6_reply_t* tnet_dhcp6_send_request(const tnet_dhcp6_ctx_t* ctx, tnet_dhcp6_request_t* request)
{
@ -192,7 +192,8 @@ bail:
/**@ingroup tnet_dhcp6_group
*/
tnet_dhcp6_reply_t* tnet_dhcp6_requestinfo(const tnet_dhcp6_ctx_t* ctx, const tnet_dhcp6_option_orequest_t *orequest)
{
tnet_dhcp6_reply_t* reply = 0;

View File

@ -21,7 +21,7 @@
*/
/**@file tnet.c
* @brief Network utilities.
* @brief Network stack.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
@ -44,10 +44,10 @@
* @par Highlights
*
* - <b>STUN2</b>: Session Traversal Utilities for NAT (STUN) is a protocol that serves
* as a tool for other protocols in dealing with Network Address Translator (NAT) traversal.
* It can be used by an endpoint to determine the IP address and port allocated to it by a NAT.
* as a tool for other protocols in dealing with Network Address Translator (NAT) traversal. <br>
* It can be used by an endpoint to determine the IP address and port allocated to it by a NAT. <br>
* It can also be used to check connectivity between two endpoints, and as a
* keep-alive protocol to maintain NAT bindings. STUN works with many existing NATs, and does not require any special behavior from them.
* keep-alive protocol to maintain NAT bindings. STUN works with many existing NATs, and does not require any special behavior from them.<br>
* <b>tinyNET</b> fully support STUN2(RFC 5389) and partialy implement STUN1 (RFC 3489) which is obsolete.
*
* - <b>TURN</b>:
@ -60,8 +60,10 @@
*
* - @ref tnet_socket_group
* - @ref tnet_utils_group
*
* - @ref tnet_stun_group
* - @ref tnet_dns_group
* - @ref tnet_dhcp_group
* - @ref tnet_dhcp6_group
* - @ref tnet_nat_group (@ref tnet_stun_group, @ref tnet_turn_group and ICE)
*
* @par IMPORTANT
*
@ -71,9 +73,7 @@
static int __tnet_started = 0;
/**
* @fn int tnet_startup()
*
* This is probably the most important function. You MUST call this function to initialize the network stack before calling any tnet_* function.
* This is probably the most important function. You MUST call this function to initialize the network stack before calling any <b>tnet_*</b> function.
* You MUST call @ref tnet_cleanup to cleanup the network stack.
*
* @sa @ref tnet_cleanup.
@ -120,9 +120,7 @@ bail:
/**
* @fn int tnet_cleanup()
*
* @brief Cleanup the network stack.
* Cleanup the network stack.
*
* @sa @ref tnet_startup.
* @retval Zero if succeed and non-zero error code otherwise.

View File

@ -21,7 +21,7 @@
*/
/**@file tnet.h
* @brief Network utilities.
* @brief Network stack.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*

View File

@ -34,13 +34,11 @@
#include "tsk_debug.h"
/**@defgroup tnet_nat_group NAT Traversal API (STUN, TURN and ICE).
*/
/**
* @fn int __pred_find_turn_allocation(const tsk_list_item_t* item, const void* id)
*
* @brief Predicate function to find turn allocation by id.
*
* @author Mamadou
* @date 1/23/2010
* Predicate function to find turn allocation by id.
*
* @param [in,out] item The current list item.
* @param [in,out] id A pointer to the allocation identifier.
@ -116,11 +114,7 @@ int __pred_find_turn_channel_binding(const tsk_list_item_t* item, const void* id
}
/**
*
* @brief Formats binary IP address as string.
*
* @author Mamadou
* @date 1/23/2010
* Formats binary IP address as string.
*
* @param in_ip The binary IP address to format.
* @param family The address family.
@ -153,14 +147,9 @@ int tnet_stun_address_tostring(const uint8_t in_ip[16], tnet_stun_addr_family_t
}
/**
* @fn int tnet_nat_set_server_address(tnet_nat_context_handle_t* self,
* const char* server_address)
/**@ingroup tnet_nat_group
*
* @brief Sets the address of the STUN/TURN server.
*
* @author Mamadou
* @date 1/23/2010
* Sets the address of the STUN/TURN server.
*
* @param [in,out] self The NAT context.
* @param [in,out] server_address The address of server.
@ -179,14 +168,9 @@ int tnet_nat_set_server_address(tnet_nat_context_handle_t* self, const char* ser
return -1;
}
/**
* @fn int tnet_nat_set_server(tnet_nat_context_handle_t* self, const char* server_address,
* tnet_port_t server_port)
/**@ingroup tnet_nat_group
*
* @brief Sets the address and port of the STUN/TURN server.
*
* @author Mamadou
* @date 1/23/2010
* Sets the address and port of the STUN/TURN server.
*
* @param [in,out] self The NAT context.
* @param [in,out] server_address The address of server.
@ -208,16 +192,11 @@ int tnet_nat_set_server(tnet_nat_context_handle_t* self, const char* server_addr
return -1;
}
/**
* @fn tnet_stun_binding_id_t tnet_nat_stun_bind(const tnet_nat_context_handle_t* self,
* const tnet_fd_t localFD)
/**@ingroup tnet_nat_group
*
* @brief Creates and sends a STUN2 binding request to the STUN/TURN server in order to get the server reflexive
* Creates and sends a STUN2 binding request to the STUN/TURN server in order to get the server reflexive
* address associated to this file descriptor (or socket). The caller should call @ref tnet_nat_stun_unbind to destroy the binding.
*
* @author Mamadou
* @date 1/23/2010
*
* @param [in,out] self The NAT context.
* @param localFD The local file descriptor (or socket) for which to get the reflexive server address.
*
@ -236,14 +215,9 @@ tnet_stun_binding_id_t tnet_nat_stun_bind(const tnet_nat_context_handle_t* self,
return TNET_STUN_INVALID_BINDING_ID;
}
/**
* @fn int tnet_nat_stun_get_reflexive_address(const tnet_nat_context_handle_t* self,
* tnet_stun_binding_id_t id, char** ipaddress, tnet_port_t *port)
/**@ingroup tnet_nat_group
* Gets the server reflexive address associated to this STUN2 binding.
*
* @brief Gets the server reflexive address associated to this STUN2 binding.
*
* @author Mamadou
* @date 1/23/2010
*
* @param [in,out] self The NAT context.
* @param id The id of the STUN2 binding conetxt (obtained using @ref tnet_nat_stun_bind) holding the server-reflexive address.
@ -281,13 +255,10 @@ int tnet_nat_stun_get_reflexive_address(const tnet_nat_context_handle_t* self, t
return -1;
}
/**
* @fn int tnet_nat_stun_unbind(const tnet_nat_context_handle_t* self, tnet_stun_binding_id_t id)
/**@ingroup tnet_nat_group
*
* @brief Removes a STUN2 binding from the NAT context.
* Removes a STUN2 binding from the NAT context.
*
* @author Mamadou
* @date 1/23/2010
*
* @param [in,out] self The NAT context from which to remove the STUN2 binding.
* @param id The id of the STUN2 binding to remove.
@ -325,16 +296,11 @@ int tnet_nat_stun_unbind(const tnet_nat_context_handle_t* self, tnet_stun_bindin
/**
* @fn tnet_turn_allocation_id_t tnet_nat_turn_allocate(const tnet_nat_context_handle_t* self,
* const tnet_fd_t localFD)
/**@ingroup tnet_nat_group
*
* @brief Creates TURN allocation as per draft-ietf-behave-turn-16 subclause 6. This function will also
* Creates TURN allocation as per draft-ietf-behave-turn-16 subclause 6. This function will also
* send an allocation request to the server (subclause 6.1).
*
* @author Mamadou
* @date 1/24/2010
*
* @param [in,out] self The NAT context.
* @param localFD The local file descriptor.
*
@ -354,14 +320,8 @@ tnet_turn_allocation_id_t tnet_nat_turn_allocate(const tnet_nat_context_handle_t
return TNET_TURN_INVALID_ALLOCATION_ID;
}
/**
* @fn int tnet_nat_turn_get_reflexive_address(const tnet_nat_context_handle_t* self,
* tnet_turn_allocation_id_t id, char** ipaddress, tnet_port_t *port)
*
* @brief Gets the STUN server-refelexive IP address and port associated to this TURN allocation.
*
* @author Mamadou
* @date 1/24/2010
/**@ingroup tnet_nat_group
* Gets the STUN server-refelexive IP address and port associated to this TURN allocation.
*
* @param [in,out] self The NAT context.
* @param id The id of the TURN allocation for which to to get server-reflexive IP address and port.
@ -399,14 +359,9 @@ int tnet_nat_turn_get_reflexive_address(const tnet_nat_context_handle_t* self, t
return -1;
}
/**
* @fn int tnet_nat_turn_allocation_refresh(const tnet_nat_context_handle_t* self,
* tnet_turn_allocation_id_t id)
/**@ingroup tnet_nat_group
*
* @brief Refresh a TURN allocation previously created using @ref tnet_nat_turn_allocate.
*
* @author Mamadou
* @date 1/24/2010
* Refresh a TURN allocation previously created using @ref tnet_nat_turn_allocate.
*
* @param [in,out] self The NAT context.
* @param id The id of the TURN allocation to refresh.
@ -429,14 +384,9 @@ int tnet_nat_turn_allocation_refresh(const tnet_nat_context_handle_t* self, tnet
return -1;
}
/**
* @fn int tnet_nat_turn_unallocate(const tnet_nat_context_handle_t* self,
* tnet_turn_allocation_id_t id)
/**@ingroup tnet_nat_group
*
* @brief Unallocate/remove a TURN allocation from the server.
*
* @author Mamadou
* @date 1/24/2010
* Unallocate/remove a TURN allocation from the server.
*
* @param [in,out] self The NAT context from which to remove the allocation.
* @param id The id of the TURN allocation to remove.
@ -461,15 +411,10 @@ int tnet_nat_turn_unallocate(const tnet_nat_context_handle_t* self, tnet_turn_al
return -1;
}
/**
* @fn tnet_turn_channel_binding_id_t tnet_nat_turn_channel_bind(const tnet_nat_context_handle_t* self,
* tnet_turn_allocation_id_t id, struct sockaddr_storage *peer)
*
* @brief Creates TURN channel binding as per draft-ietf-behave-turn-16 sublause 11 and send it to the
/**@ingroup tnet_nat_group
* Creates TURN channel binding as per draft-ietf-behave-turn-16 sublause 11 and send it to the
* server as per subclause 11.1.
*
* @author Mamadou
* @date 1/24/2010
*
* @param [in,out] self The NAT context.
* @param id The id of the TURN allocation associated to this binding.
@ -493,6 +438,8 @@ tnet_turn_channel_binding_id_t tnet_nat_turn_channel_bind(const tnet_nat_context
return TNET_TURN_INVALID_CHANNEL_BINDING_ID;
}
/**@ingroup tnet_nat_group
*/
int tnet_nat_turn_channel_refresh(const tnet_nat_context_handle_t* self, tnet_turn_channel_binding_id_t id)
{
const tnet_nat_context_t* context = self;
@ -512,6 +459,8 @@ int tnet_nat_turn_channel_refresh(const tnet_nat_context_handle_t* self, tnet_tu
return -1;
}
/**@ingroup tnet_nat_group
*/
int tnet_nat_turn_channel_send(const tnet_nat_context_handle_t* self, tnet_turn_channel_binding_id_t id, const void* data, size_t size, int indication)
{
const tnet_nat_context_t* context = self;
@ -531,6 +480,8 @@ int tnet_nat_turn_channel_send(const tnet_nat_context_handle_t* self, tnet_turn_
return -1;
}
/**@ingroup tnet_nat_group
*/
int tnet_nat_turn_add_permission(const tnet_nat_context_handle_t* self, tnet_turn_allocation_id_t id, const char* ipaddress, uint32_t timeout)
{
const tnet_nat_context_t* context = self;

View File

@ -40,21 +40,29 @@
#include "tsk_object.h"
/**@ingroup tnet_nat_group
* @def TNET_NAT_CONTEXT_CREATE
* Creates new NAT context.
* @retval tnet_nat_context_t context.
*/
TNET_BEGIN_DECLS
#define TNET_NAT_CONTEXT_CREATE(socket_type, username, password) tsk_object_new(tnet_nat_context_def_t, (tnet_socket_type_t) socket_type, (const char*)username, (const char*)password)
#define TNET_NAT_DEFAULT_RTO 500 /**< Estimate of the round-trip time (RTT) in millisecond. */
#define TNET_NAT_DEFAULT_RC 7 /**< Number of retransmission for UDP retransmission in millisecond. */
/**@ingroup tnet_nat_group
* Estimate of the round-trip time (RTT) in millisecond.
*/
#define TNET_NAT_DEFAULT_RTO 500
/**@ingroup tnet_nat_group
* Number of retransmission for UDP retransmission in millisecond.
*/
#define TNET_NAT_DEFAULT_RC 7
/**@ingroup tnet_nat_group
*/
#define TNET_NAT_TCP_UDP_DEFAULT_PORT 3478
/**
* @struct tnet_nat_context_s
*
* @brief NAT context.
*
* @author Mamadou
* @date 1/23/2010
/**@ingroup tnet_nat_group
* NAT context.
**/
typedef struct tnet_nat_context_s
{
@ -84,10 +92,8 @@ typedef struct tnet_nat_context_s
}
tnet_nat_context_t;
/**
* @typedef void tnet_nat_context_handle_t
*
* @brief Handle to the NAT context(@ref tnet_nat_context_t).
/**@ingroup tnet_nat_group
* Handle to the NAT context(@ref tnet_nat_context_t).
**/
typedef void tnet_nat_context_handle_t;

View File

@ -24,7 +24,6 @@
#if TNET_USE_POLL && !TNET_HAVE_POLL
/**
* @fn int tnet_poll(tnet_pollfd_t fds[ ], nfds_t nfds, int timeout)
*
* @brief poll() method implementation for multiplexing network sockets.
*

View File

@ -46,6 +46,9 @@
#include <string.h>
/**@defgroup tnet_turn_group TURN(draft-ietf-behave-turn-16) implementation.
*/
/*
- IMPORTANT: 16. Detailed Example
- It is suggested that the client refresh the allocation roughly 1 minute before it expires.
@ -54,6 +57,8 @@
typedef tnet_stun_request_t* (*tnet_turn_create_request_func)(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app);
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, tnet_stun_message_type_t type)
{
tnet_stun_attribute_t* attribute;
@ -91,6 +96,8 @@ tnet_stun_request_t* tnet_turn_create_request(const tnet_nat_context_t* context,
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_allocate(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t* request = tnet_turn_create_request(context, allocation, stun_allocate_request);
@ -120,6 +127,8 @@ tnet_stun_request_t* tnet_turn_create_request_allocate(const tnet_nat_context_t*
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_refresh(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t *request = tnet_turn_create_request_allocate(context, allocation, app);
@ -130,6 +139,8 @@ tnet_stun_request_t* tnet_turn_create_request_refresh(const tnet_nat_context_t*
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_unallocate(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t *request = tnet_turn_create_request_refresh(context, allocation, app);
@ -140,7 +151,8 @@ tnet_stun_request_t* tnet_turn_create_request_unallocate(const tnet_nat_context_
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_channel_bind(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t* request = tnet_turn_create_request(context, allocation, stun_channelbind_request);
@ -175,11 +187,15 @@ tnet_stun_request_t* tnet_turn_create_request_channel_bind(const tnet_nat_contex
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_channel_refresh(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
return tnet_turn_create_request_channel_bind(context, allocation, app);
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_sendindication(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t* request = tnet_turn_create_request(context, allocation, stun_send_indication);
@ -212,6 +228,8 @@ tnet_stun_request_t* tnet_turn_create_request_sendindication(const tnet_nat_cont
return request;
}
/**@ingroup tnet_turn_group
*/
tnet_stun_request_t* tnet_turn_create_request_permission(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, va_list *app)
{
tnet_stun_request_t* request = tnet_turn_create_request(context, allocation, stun_createpermission_request);
@ -239,6 +257,8 @@ tnet_stun_request_t* tnet_turn_create_request_permission(const tnet_nat_context_
return request;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_send_request(const tnet_nat_context_t* context, tnet_turn_allocation_t* allocation, tnet_turn_create_request_func funcptr, ...)
{
tnet_stun_request_t *request;
@ -329,6 +349,8 @@ int tnet_turn_send_request(const tnet_nat_context_t* context, tnet_turn_allocati
return ret;
}
/**@ingroup tnet_turn_group
*/
tnet_turn_allocation_id_t tnet_turn_allocate(const tnet_nat_context_t* nat_context, const tnet_fd_t localFD, tnet_socket_type_t socket_type)
{
tnet_turn_allocation_id_t id = TNET_TURN_INVALID_ALLOCATION_ID;
@ -354,6 +376,8 @@ tnet_turn_allocation_id_t tnet_turn_allocate(const tnet_nat_context_t* nat_conte
return id;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_allocation_refresh(const struct tnet_nat_context_s* nat_context, tnet_turn_allocation_t *allocation)
{
if(nat_context && allocation)
@ -370,6 +394,8 @@ int tnet_turn_allocation_refresh(const struct tnet_nat_context_s* nat_context, t
return -1;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_unallocate(const tnet_nat_context_t* nat_context, tnet_turn_allocation_t *allocation)
{
if(nat_context && allocation)
@ -390,6 +416,8 @@ int tnet_turn_unallocate(const tnet_nat_context_t* nat_context, tnet_turn_alloca
return -1;
}
/**@ingroup tnet_turn_group
*/
tnet_turn_channel_binding_id_t tnet_turn_channel_bind(const tnet_nat_context_t* nat_context, tnet_turn_allocation_t *allocation, struct sockaddr_storage *peer)
{
tnet_turn_channel_binding_id_t id = TNET_TURN_INVALID_CHANNEL_BINDING_ID;
@ -448,6 +476,8 @@ bail:
return id;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_channel_refresh(const struct tnet_nat_context_s* nat_context, const tnet_turn_channel_binding_t * channel_bind)
{
if(nat_context && channel_bind)
@ -464,6 +494,8 @@ int tnet_turn_channel_refresh(const struct tnet_nat_context_s* nat_context, cons
return -1;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_channel_senddata(const struct tnet_nat_context_s* nat_context, const tnet_turn_channel_binding_t * channel_bind, const void* data, size_t size, int indication)
{
tnet_turn_channel_data_t *channel_data = 0;
@ -515,6 +547,8 @@ bail:
return ret;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_add_permission(const tnet_nat_context_t* nat_context, tnet_turn_allocation_t *allocation, const char* ipaddress, uint32_t timeout)
{
if(nat_context && allocation)

View File

@ -44,28 +44,60 @@
#include "tsk_object.h"
/**@ingroup tnet_turn_group
* @def TNET_TURN_PERMISSION_TIMEOUT_DEFAULT
*/
/**@ingroup tnet_turn_group
* @def TNET_TURN_CHANBIND_TIMEOUT_DEFAULT
*/
TNET_BEGIN_DECLS
#define TNET_TURN_PERMISSION_TIMEOUT_DEFAULT 300 /* draft-ietf-behave-turn-16 subclause 8 */
#define TNET_TURN_CHANBIND_TIMEOUT_DEFAULT 600 /* draft-ietf-behave-turn-16 subclause 11 */
/**@ingroup tnet_turn_group
*/
#define TNET_TURN_CHANNEL_BINDING_CREATE(allocation) \
tsk_object_new(tnet_turn_channel_binding_def_t, (const tnet_turn_allocation_t *)allocation)
/**@ingroup tnet_turn_group
*/
#define TNET_TURN_PERMISSION_CREATE(timeout) \
tsk_object_new(tnet_turn_permission_def_t, (uint32_t)timeout)
/**@ingroup tnet_turn_group
*/
#define TNET_TURN_ALLOCATION_CREATE(fd, socket_type, server_address, server_port, username, password) \
tsk_object_new(tnet_turn_allocation_def_t, (tnet_fd_t)fd, (tnet_socket_type_t)socket_type, (const char*)server_address, (tnet_port_t)server_port, (const char*)username, (const char*)password)
/**@ingroup tnet_turn_group
* @def tnet_turn_allocation_id_t.
*/
/**@ingroup tnet_turn_group
* @def TNET_TURN_INVALID_ALLOCATION_ID.
*/
/**@ingroup tnet_turn_group
* @def TNET_TURN_IS_VALID_ALLOCATION_ID.
*/
typedef uint64_t tnet_turn_allocation_id_t;
#define TNET_TURN_INVALID_ALLOCATION_ID 0
#define TNET_TURN_IS_VALID_ALLOCATION_ID(id) (id != TNET_TURN_INVALID_ALLOCATION_ID)
/**@ingroup tnet_turn_group
* @def tnet_turn_channel_binding_id_t.
*/
/**@ingroup tnet_turn_group
* @def TNET_TURN_INVALID_CHANNEL_BINDING_ID.
*/
/**@ingroup tnet_turn_group
* @def TNET_TURN_IS_VALID_CHANNEL_BINDING_ID.
*/
typedef uint16_t tnet_turn_channel_binding_id_t;
#define TNET_TURN_INVALID_CHANNEL_BINDING_ID 0x00
#define TNET_TURN_IS_VALID_CHANNEL_BINDING_ID(id) ( (0x4000 <= id) && (id <= 0x7FFF) ) /* see draft-ietf-behave-turn-16 subcaluse 11. */
/**@ingroup tnet_turn_group
*/
typedef struct tnet_turn_permission_s
{
TSK_DECLARE_OBJECT;
@ -74,8 +106,10 @@ typedef struct tnet_turn_permission_s
uint32_t timeout; /**< Timeout value in seconds. Default is 300s(5 minutes). */
}
tnet_turn_permission_t;
typedef tsk_list_t tnet_turn_permissions_L_t;
typedef tsk_list_t tnet_turn_permissions_L_t; /**< List of @ref tnet_turn_permission_t elements. */
/**@ingroup tnet_turn_group
*/
typedef struct tnet_turn_channel_binding_s
{
TSK_DECLARE_OBJECT;
@ -86,8 +120,10 @@ typedef struct tnet_turn_channel_binding_s
uint32_t timeout; /**< Timeout value in seconds. Default is 600s(10 minutes). */
}
tnet_turn_channel_binding_t;
typedef tsk_list_t tnet_turn_channel_bindings_L_t;
typedef tsk_list_t tnet_turn_channel_bindings_L_t; /**< List of @ref tnet_turn_channel_binding_t elements. */
/**@ingroup tnet_turn_group
*/
typedef struct tnet_turn_allocation_s
{
TSK_DECLARE_OBJECT;
@ -128,7 +164,7 @@ typedef struct tnet_turn_allocation_s
tnet_turn_permissions_L_t *permissions;
}
tnet_turn_allocation_t;
typedef tsk_list_t tnet_turn_allocations_L_t;
typedef tsk_list_t tnet_turn_allocations_L_t; /**< List of @ref tnet_turn_allocation_t elements. */
TINYNET_GEXTERN const void *tnet_turn_permission_def_t;
TINYNET_GEXTERN const void *tnet_turn_channel_binding_def_t;

View File

@ -35,7 +35,8 @@
#include <string.h>
/**@ingroup tnet_turn_group
*/
tnet_stun_attribute_t* tnet_turn_attribute_deserialize(tnet_stun_attribute_type_t type, uint16_t length, const void* payload, size_t payload_size)
{
tnet_stun_attribute_t *attribute = 0;
@ -127,7 +128,8 @@ tnet_stun_attribute_t* tnet_turn_attribute_deserialize(tnet_stun_attribute_type_
return attribute;
}
/**@ingroup tnet_turn_group
*/
int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_buffer_t *output)
{
if(!attribute || !output)

View File

@ -36,32 +36,42 @@
TNET_BEGIN_DECLS
/* draft-ietf-behave-turn-16 - 14.1. CHANNEL-NUMBER */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.1. CHANNEL-NUMBER */
#define TNET_TURN_ATTRIBUTE_CHANNELNUM_CREATE(number) tsk_object_new(tnet_turn_attribute_channelnum_def_t, (uint16_t)number)
/* draft-ietf-behave-turn-16 - 14.2. LIFETIME */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.2. LIFETIME */
#define TNET_TURN_ATTRIBUTE_LIFETIME_CREATE(lifetime) tsk_object_new(tnet_turn_attribute_lifetime_def_t, (uint32_t)lifetime)
/* draft-ietf-behave-turn-16 - 14.3. XOR-PEER-ADDRESS */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.3. XOR-PEER-ADDRESS */
#define TNET_TURN_ATTRIBUTE_XPEER_ADDR_CREATE(payload, payload_size) tsk_object_new(tnet_turn_attribute_xpeer_addr_def_t, (const void*)payload, (size_t)payload_size)
#define TNET_TURN_ATTRIBUTE_XPEER_ADDR_CREATE_NULL() TNET_TURN_ATTRIBUTE_XPEER_ADDR_CREATE(0,0)
/* draft-ietf-behave-turn-16 - 14.4. DATA */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.4. DATA */
#define TNET_TURN_ATTRIBUTE_DATA_CREATE(payload, payload_size) tsk_object_new(tnet_turn_attribute_data_def_t, (const void*)payload, (size_t)payload_size)
/* draft-ietf-behave-turn-16 - 14.5. XOR-RELAYED-ADDRESS */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.5. XOR-RELAYED-ADDRESS */
#define TNET_TURN_ATTRIBUTE_XRELAYED_ADDR_CREATE(payload, payload_size) tsk_object_new(tnet_turn_attribute_xrelayed_addr_def_t, (const void*)payload, (size_t)payload_size)
/* draft-ietf-behave-turn-16 - 14.6. EVEN-PORT */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.6. EVEN-PORT */
#define TNET_TURN_ATTRIBUTE_EVEN_PORT_CREATE(R) tsk_object_new(tnet_turn_attribute_even_port_def_t, (unsigned)R)
/* draft-ietf-behave-turn-16 - 14.7. REQUESTED-TRANSPORT */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.7. REQUESTED-TRANSPORT */
#define TNET_TURN_ATTRIBUTE_REQTRANS_CREATE(protocol) tsk_object_new(tnet_turn_attribute_reqtrans_def_t, (tnet_proto_t)protocol)
/* draft-ietf-behave-turn-16 - 14.8. DONT-FRAGMENT */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.8. DONT-FRAGMENT */
#define TNET_TURN_ATTRIBUTE_DONTFRAG_CREATE() tsk_object_new(tnet_turn_attribute_dontfrag_def_t)
/* draft-ietf-behave-turn-16 - 14.9. RESERVATION-TOKEN */
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.9. RESERVATION-TOKEN */
#define TNET_TURN_ATTRIBUTE_RESTOKEN_CREATE(payload, payload_size) tsk_object_new(tnet_turn_attribute_restoken_def_t, (const void*)payload, (size_t)payload_size)
typedef tnet_stun_attribute_t tnet_turn_attribute_t;
@ -73,6 +83,8 @@ typedef tnet_stun_attribute_t tnet_turn_attribute_t;
| Channel Number | RFFU = 0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
/**@ingroup tnet_turn_group
*/
typedef struct tnet_turn_attribute_channelnum_s
{
TNET_STUN_DECLARE_ATTRIBUTE;
@ -84,7 +96,8 @@ tnet_turn_attribute_channelnum_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_channelnum_def_t;
/* draft-ietf-behave-turn-16 - 14.2. LIFETIME
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.2. LIFETIME
*/
typedef struct tnet_turn_attribute_lifetime_s
{
@ -96,7 +109,8 @@ tnet_turn_attribute_lifetime_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_lifetime_def_t;
/* draft-ietf-behave-turn-16 - 14.3. XOR-PEER-ADDRESS
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.3. XOR-PEER-ADDRESS
*/
typedef struct tnet_turn_attribute_xpeer_addr_s
{
@ -109,7 +123,8 @@ typedef struct tnet_turn_attribute_xpeer_addr_s
tnet_turn_attribute_xpeer_addr_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_xpeer_addr_def_t;
/* draft-ietf-behave-turn-16 - 14.4. DATA
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.4. DATA
*/
typedef struct tnet_turn_attribute_data_s
{
@ -120,7 +135,8 @@ typedef struct tnet_turn_attribute_data_s
tnet_turn_attribute_data_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_data_def_t;
/* draft-ietf-behave-turn-16 - 14.5. XOR-RELAYED-ADDRESS
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.5. XOR-RELAYED-ADDRESS
*/
typedef struct tnet_turn_attribute_xrelayed_addr_s
{
@ -133,34 +149,39 @@ typedef struct tnet_turn_attribute_xrelayed_addr_s
tnet_turn_attribute_xrelayed_addr_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_xrelayed_addr_def_t;
/* draft-ietf-behave-turn-16 - 14.6. EVEN-PORT
0
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|R| RFFU |
+-+-+-+-+-+-+-+-+
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.6. EVEN-PORT
*/
typedef struct tnet_turn_attribute_even_port_s
{
TNET_STUN_DECLARE_ATTRIBUTE;
/*
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|R| RFFU |
+-+-+-+-+-+-+-+-+
*/
unsigned R:1;
unsigned rffu:7;
}
tnet_turn_attribute_even_port_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_even_port_def_t;
/* draft-ietf-behave-turn-16 - 14.7. REQUESTED-TRANSPORT
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Protocol | RFFU |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/**@ingroup tnet_turn_group
*/
typedef struct tnet_turn_attribute_reqtrans_s
{
TNET_STUN_DECLARE_ATTRIBUTE;
/*
draft-ietf-behave-turn-16 - 14.7. REQUESTED-TRANSPORT
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Protocol | RFFU |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
tnet_proto_t protocol;
uint8_t rffu[3];
}
@ -169,7 +190,8 @@ TINYNET_GEXTERN const void *tnet_turn_attribute_reqtrans_def_t;
/* draft-ietf-behave-turn-16 - 14.8. DONT-FRAGMENT
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.8. DONT-FRAGMENT
*/
typedef struct tnet_turn_attribute_dontfrag_s
{
@ -179,7 +201,8 @@ tnet_turn_attribute_dontfrag_t;
TINYNET_GEXTERN const void *tnet_turn_attribute_dontfrag_def_t;
/* draft-ietf-behave-turn-16 - 14.9. RESERVATION-TOKEN
/**@ingroup tnet_turn_group
* draft-ietf-behave-turn-16 - 14.9. RESERVATION-TOKEN
*/
typedef struct tnet_turn_attribute_restoken_s
{

View File

@ -36,7 +36,8 @@
/**@ingroup tnet_turn_group
*/
tsk_buffer_t* tnet_turn_channel_data_serialize(const tnet_turn_channel_data_t *message)
{
tsk_buffer_t *output = 0;

View File

@ -39,14 +39,9 @@ TNET_BEGIN_DECLS
#define TNET_TURN_CHANNEL_DATA_CREATE(number, length, data) tsk_object_new(tnet_turn_channel_data_def_t, (uint16_t)number, (uint16_t)length, (const void*)data)
#define TNET_TURN_CHANNEL_DATA_CREATE_NULL() TNET_TURN_CHANNEL_DATA_CREATE(0,0,0)
/**
* @struct tnet_turn_channel_data_s
*
* @brief TURN channel data message as per draft-ietf-behave-turn-16 subclause 11.4.
*
* @author Mamadou
* @date 1/24/2010
**/
/**@ingroup tnet_turn_group
* TURN channel data message as per draft-ietf-behave-turn-16 subclause 11.4.
*/
typedef struct tnet_turn_channel_data_s
{
TSK_DECLARE_OBJECT;