agent.h | agent.h | |||
---|---|---|---|---|
skipping to change at line 210 | skipping to change at line 210 | |||
NICE_COMPONENT_TYPE_RTCP = 2 | NICE_COMPONENT_TYPE_RTCP = 2 | |||
} NiceComponentType; | } NiceComponentType; | |||
/** | /** | |||
* NiceCompatibility: | * NiceCompatibility: | |||
* @NICE_COMPATIBILITY_RFC5245: Use compatibility with the RFC5245 ICE spec s | * @NICE_COMPATIBILITY_RFC5245: Use compatibility with the RFC5245 ICE spec s | |||
* @NICE_COMPATIBILITY_GOOGLE: Use compatibility for Google Talk specs | * @NICE_COMPATIBILITY_GOOGLE: Use compatibility for Google Talk specs | |||
* @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs | * @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs | |||
* @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messeng er | * @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messeng er | |||
* 2009 | * 2009 | |||
* @NICE_COMPATIBILITY_OC2007: Use compatibility with Microsoft Office Comm | ||||
unicator 2007 | ||||
* @NICE_COMPATIBILITY_OC2007R2: Use compatibility with Microsoft Office Co | ||||
mmunicator 2007 R2 | ||||
* @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs | * @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs | |||
* @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode | * @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode | |||
* | * | |||
* An enum to specify which compatible specifications the #NiceAgent should use. | * An enum to specify which compatible specifications the #NiceAgent should use. | |||
* Use with nice_agent_new() | * Use with nice_agent_new() | |||
* | * | |||
* <warning>@NICE_COMPATIBILITY_DRAFT19 is deprecated and should not be use d | * <warning>@NICE_COMPATIBILITY_DRAFT19 is deprecated and should not be use d | |||
* in newly-written code. It is kept for compatibility reasons and | * in newly-written code. It is kept for compatibility reasons and | |||
* represents the same compatibility as @NICE_COMPATIBILITY_RFC5245 </warni ng> | * represents the same compatibility as @NICE_COMPATIBILITY_RFC5245 </warni ng> | |||
*/ | */ | |||
typedef enum | typedef enum | |||
{ | { | |||
NICE_COMPATIBILITY_RFC5245 = 0, | NICE_COMPATIBILITY_RFC5245 = 0, | |||
NICE_COMPATIBILITY_GOOGLE, | NICE_COMPATIBILITY_GOOGLE, | |||
NICE_COMPATIBILITY_MSN, | NICE_COMPATIBILITY_MSN, | |||
NICE_COMPATIBILITY_WLM2009, | NICE_COMPATIBILITY_WLM2009, | |||
NICE_COMPATIBILITY_OC2007, | ||||
NICE_COMPATIBILITY_OC2007R2, | ||||
NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245, | NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245, | |||
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009, | NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2, | |||
} NiceCompatibility; | } NiceCompatibility; | |||
/** | /** | |||
* NiceProxyType: | * NiceProxyType: | |||
* @NICE_PROXY_TYPE_NONE: Do not use a proxy | * @NICE_PROXY_TYPE_NONE: Do not use a proxy | |||
* @NICE_PROXY_TYPE_SOCKS5: Use a SOCKS5 proxy | * @NICE_PROXY_TYPE_SOCKS5: Use a SOCKS5 proxy | |||
* @NICE_PROXY_TYPE_HTTP: Use an HTTP proxy | * @NICE_PROXY_TYPE_HTTP: Use an HTTP proxy | |||
* @NICE_PROXY_TYPE_LAST: Dummy last proxy type | * @NICE_PROXY_TYPE_LAST: Dummy last proxy type | |||
* | * | |||
* An enum to specify which proxy type to use for relaying. | * An enum to specify which proxy type to use for relaying. | |||
skipping to change at line 345 | skipping to change at line 349 | |||
* | * | |||
* Remove and free a previously created data stream from @agent | * Remove and free a previously created data stream from @agent | |||
* | * | |||
**/ | **/ | |||
void | void | |||
nice_agent_remove_stream ( | nice_agent_remove_stream ( | |||
NiceAgent *agent, | NiceAgent *agent, | |||
guint stream_id); | guint stream_id); | |||
/** | /** | |||
* nice_agent_set_port_range: | ||||
* @agent: The #NiceAgent Object | ||||
* @stream_id: The ID of the stream | ||||
* @component_id: The ID of the component | ||||
* @min_port: The minimum port to use | ||||
* @max_port: The maximum port to use | ||||
* | ||||
* Sets a preferred port range for allocating host candidates. | ||||
* <para> | ||||
* If a local host candidate cannot be created on that port | ||||
* range, then the nice_agent_gather_candidates() call will fail. | ||||
* </para> | ||||
* <para> | ||||
* This MUST be called before nice_agent_gather_candidates() | ||||
* </para> | ||||
* | ||||
*/ | ||||
void | ||||
nice_agent_set_port_range ( | ||||
NiceAgent *agent, | ||||
guint stream_id, | ||||
guint component_id, | ||||
guint min_port, | ||||
guint max_port); | ||||
/** | ||||
* nice_agent_set_relay_info: | * nice_agent_set_relay_info: | |||
* @agent: The #NiceAgent Object | * @agent: The #NiceAgent Object | |||
* @stream_id: The ID of the stream | * @stream_id: The ID of the stream | |||
* @component_id: The ID of the component | * @component_id: The ID of the component | |||
* @server_ip: The IP address of the TURN server | * @server_ip: The IP address of the TURN server | |||
* @server_port: The port of the TURN server | * @server_port: The port of the TURN server | |||
* @username: The TURN username to use for the allocate | * @username: The TURN username to use for the allocate | |||
* @password: The TURN password to use for the allocate | * @password: The TURN password to use for the allocate | |||
* @type: The type of relay to use | * @type: The type of relay to use | |||
* | * | |||
skipping to change at line 378 | skipping to change at line 408 | |||
NiceRelayType type); | NiceRelayType type); | |||
/** | /** | |||
* nice_agent_gather_candidates: | * nice_agent_gather_candidates: | |||
* @agent: The #NiceAgent Object | * @agent: The #NiceAgent Object | |||
* @stream_id: The id of the stream to start | * @stream_id: The id of the stream to start | |||
* | * | |||
* Start the candidate gathering process. | * Start the candidate gathering process. | |||
* Once done, #NiceAgent::candidate-gathering-done is called for the stream | * Once done, #NiceAgent::candidate-gathering-done is called for the stream | |||
* | * | |||
* Returns: %FALSE if there were no local addresses and they couldn't be di | * <para>See also: nice_agent_add_local_address()</para> | |||
scovered. In this case, call nice_agent_add_local_address() first. | * <para>See also: nice_agent_set_port_range()</para> | |||
* | ||||
* Returns: %FALSE if the stream id is invalid or if a host candidate could | ||||
n't be allocated | ||||
* on the requested interfaces/ports. | ||||
* | * | |||
* See also: nice_agent_add_local_address() | ||||
<note> | <note> | |||
<para> | <para> | |||
Local addresses can be previously set with nice_agent_add_local_address () | Local addresses can be previously set with nice_agent_add_local_address () | |||
</para> | </para> | |||
<para> | <para> | |||
Since 0.0.5, If no local address was previously added, then the nice ag ent | Since 0.0.5, If no local address was previously added, then the nice ag ent | |||
will automatically detect the local address using | will automatically detect the local address using | |||
nice_interfaces_get_local_ips() | nice_interfaces_get_local_ips() | |||
</para> | </para> | |||
</note> | </note> | |||
skipping to change at line 448 | skipping to change at line 481 | |||
nice_agent_get_local_credentials ( | nice_agent_get_local_credentials ( | |||
NiceAgent *agent, | NiceAgent *agent, | |||
guint stream_id, | guint stream_id, | |||
gchar **ufrag, gchar **pwd); | gchar **ufrag, gchar **pwd); | |||
/** | /** | |||
* nice_agent_set_remote_candidates: | * nice_agent_set_remote_candidates: | |||
* @agent: The #NiceAgent Object | * @agent: The #NiceAgent Object | |||
* @stream_id: The ID of the stream the candidates are for | * @stream_id: The ID of the stream the candidates are for | |||
* @component_id: The ID of the component the candidates are for | * @component_id: The ID of the component the candidates are for | |||
* @candidates: a #GList of #NiceCandidate items describing each candidate to add | * @candidates: a #GSList of #NiceCandidate items describing each candidate to add | |||
* | * | |||
* Sets, adds or updates the remote candidates for a component of a stream. | * Sets, adds or updates the remote candidates for a component of a stream. | |||
* | * | |||
<note> | <note> | |||
<para> | <para> | |||
NICE_AGENT_MAX_REMOTE_CANDIDATES is the absolute maximum limit | NICE_AGENT_MAX_REMOTE_CANDIDATES is the absolute maximum limit | |||
for remote candidates. | for remote candidates. | |||
</para> | </para> | |||
<para> | <para> | |||
You must first call nice_agent_gather_candidates() and wait for the | You must first call nice_agent_gather_candidates() and wait for the | |||
skipping to change at line 489 | skipping to change at line 522 | |||
* @len: The length of the buffer to send | * @len: The length of the buffer to send | |||
* @buf: The buffer of data to send | * @buf: The buffer of data to send | |||
* | * | |||
* Sends a data payload over a stream's component. | * Sends a data payload over a stream's component. | |||
* | * | |||
<note> | <note> | |||
<para> | <para> | |||
Component state MUST be NICE_COMPONENT_STATE_READY, or as a special ca se, | Component state MUST be NICE_COMPONENT_STATE_READY, or as a special ca se, | |||
in any state if component was in READY state before and was then resta rted | in any state if component was in READY state before and was then resta rted | |||
</para> | </para> | |||
</note> | <para> | |||
In reliable mode, the -1 error value means either that you are not yet | ||||
connected or that the send buffer is full (equivalent to EWOULDBLOCK). | ||||
In both cases, you simply need to wait for the | ||||
#NiceAgent::reliable-transport-writable signal to be fired before resend | ||||
ing | ||||
the data. | ||||
</para> | ||||
<para> | ||||
In non-reliable mode, it will virtually never happen with UDP sockets, b | ||||
ut | ||||
it might happen if the active candidate is a TURN-TCP connection that go | ||||
t | ||||
disconnected. | ||||
</para> | ||||
<para> | ||||
In both reliable and non-reliable mode, a -1 error code could also mean | ||||
that | ||||
the stream_id and/or component_id are invalid. | ||||
</para> | ||||
</note> | ||||
* | * | |||
* Returns: The number of bytes sent, or negative error code | * Returns: The number of bytes sent, or negative error code | |||
*/ | */ | |||
gint | gint | |||
nice_agent_send ( | nice_agent_send ( | |||
NiceAgent *agent, | NiceAgent *agent, | |||
guint stream_id, | guint stream_id, | |||
guint component_id, | guint component_id, | |||
guint len, | guint len, | |||
const gchar *buf); | const gchar *buf); | |||
End of changes. 8 change blocks. | ||||
6 lines changed or deleted | 61 lines changed or added | |||
ice.h | ice.h | |||
---|---|---|---|---|
skipping to change at line 68 | skipping to change at line 68 | |||
extern "C" { | extern "C" { | |||
# endif | # endif | |||
/** | /** | |||
* StunUsageIceCompatibility: | * StunUsageIceCompatibility: | |||
* @STUN_USAGE_ICE_COMPATIBILITY_RFC5245: The ICE compatibility with RFC 52 45 | * @STUN_USAGE_ICE_COMPATIBILITY_RFC5245: The ICE compatibility with RFC 52 45 | |||
* @STUN_USAGE_ICE_COMPATIBILITY_GOOGLE: The ICE compatibility with Google' s | * @STUN_USAGE_ICE_COMPATIBILITY_GOOGLE: The ICE compatibility with Google' s | |||
* implementation of ICE | * implementation of ICE | |||
* @STUN_USAGE_ICE_COMPATIBILITY_MSN: The ICE compatibility with MSN's | * @STUN_USAGE_ICE_COMPATIBILITY_MSN: The ICE compatibility with MSN's | |||
* implementation of ICE | * implementation of ICE | |||
* @STUN_USAGE_ICE_COMPATIBILITY_WLM2009: The ICE compatibility with Window | ||||
s | ||||
* Live Messenger and Microsoft Office Communicator 2007 R2 implementation | ||||
of ICE | ||||
* @STUN_USAGE_ICE_COMPATIBILITY_DRAFT19: The ICE compatibility with draft 19 | * @STUN_USAGE_ICE_COMPATIBILITY_DRAFT19: The ICE compatibility with draft 19 | |||
* | * | |||
* This enum defines which compatibility modes this ICE usage can use | * This enum defines which compatibility modes this ICE usage can use | |||
* | * | |||
* <warning>@STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 is deprecated and should not | * <warning>@STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 is deprecated and should not | |||
* be used in newly-written code. It is kept for compatibility reasons and | * be used in newly-written code. It is kept for compatibility reasons and | |||
* represents the same compatibility as @STUN_USAGE_ICE_COMPATIBILITY_RFC52 45 | * represents the same compatibility as @STUN_USAGE_ICE_COMPATIBILITY_RFC52 45 | |||
* </warning> | * </warning> | |||
*/ | */ | |||
typedef enum { | typedef enum { | |||
STUN_USAGE_ICE_COMPATIBILITY_RFC5245, | STUN_USAGE_ICE_COMPATIBILITY_RFC5245, | |||
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE, | STUN_USAGE_ICE_COMPATIBILITY_GOOGLE, | |||
STUN_USAGE_ICE_COMPATIBILITY_MSN, | STUN_USAGE_ICE_COMPATIBILITY_MSN, | |||
STUN_USAGE_ICE_COMPATIBILITY_WLM2009, | ||||
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC52 45, | STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC52 45, | |||
} StunUsageIceCompatibility; | } StunUsageIceCompatibility; | |||
/** | /** | |||
* StunUsageIceReturn: | * StunUsageIceReturn: | |||
* @STUN_USAGE_ICE_RETURN_SUCCESS: The function succeeded | * @STUN_USAGE_ICE_RETURN_SUCCESS: The function succeeded | |||
* @STUN_USAGE_ICE_RETURN_ERROR: There was an unspecified error | * @STUN_USAGE_ICE_RETURN_ERROR: There was an unspecified error | |||
* @STUN_USAGE_ICE_RETURN_INVALID: The message is invalid for processing | * @STUN_USAGE_ICE_RETURN_INVALID: The message is invalid for processing | |||
* @STUN_USAGE_ICE_RETURN_ROLE_CONFLICT: A role conflict was detected | * @STUN_USAGE_ICE_RETURN_ROLE_CONFLICT: A role conflict was detected | |||
* @STUN_USAGE_ICE_RETURN_INVALID_REQUEST: The message is an not a request | * @STUN_USAGE_ICE_RETURN_INVALID_REQUEST: The message is an not a request | |||
skipping to change at line 131 | skipping to change at line 134 | |||
* @username: The username to use in the request | * @username: The username to use in the request | |||
* @username_len: The length of @username | * @username_len: The length of @username | |||
* @password: The key to use for building the MESSAGE-INTEGRITY | * @password: The key to use for building the MESSAGE-INTEGRITY | |||
* @password_len: The length of @password | * @password_len: The length of @password | |||
* @cand_use: Set to %TRUE to append the USE-CANDIDATE flag to the request | * @cand_use: Set to %TRUE to append the USE-CANDIDATE flag to the request | |||
* @controlling: Set to %TRUE if you are the controlling agent or set to | * @controlling: Set to %TRUE if you are the controlling agent or set to | |||
* %FALSE if you are the controlled agent. | * %FALSE if you are the controlled agent. | |||
* @priority: The value of the PRIORITY attribute | * @priority: The value of the PRIORITY attribute | |||
* @tie: The value of the tie-breaker to put in the ICE-CONTROLLED or | * @tie: The value of the tie-breaker to put in the ICE-CONTROLLED or | |||
* ICE-CONTROLLING attribute | * ICE-CONTROLLING attribute | |||
* @candidate_identifier: The foundation value to put in the | ||||
* CANDIDATE-IDENTIFIER attribute | ||||
* @compatibility: The compatibility mode to use for building the conncheck | * @compatibility: The compatibility mode to use for building the conncheck | |||
* request | * request | |||
* | * | |||
* Builds an ICE connectivity check STUN message. | * Builds an ICE connectivity check STUN message. | |||
* If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_RFC5245, the | * If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_RFC5245, the | |||
* @cand_use, @controlling, @priority and @tie arguments are not used. | * @cand_use, @controlling, @priority and @tie arguments are not used. | |||
* If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_WLM2009, the | ||||
* @candidate_identifier argument is not used. | ||||
* Returns: The length of the message built. | * Returns: The length of the message built. | |||
*/ | */ | |||
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, | |||
const uint8_t *username, const size_t username_len, | const uint8_t *username, const size_t username_len, | |||
const uint8_t *password, const size_t password_len, | const uint8_t *password, const size_t password_len, | |||
bool cand_use, bool controlling, uint32_t priority, | bool cand_use, bool controlling, uint32_t priority, | |||
uint64_t tie, StunUsageIceCompatibility compatibility); | uint64_t tie, const char *candidate_identifier, | |||
StunUsageIceCompatibility compatibility); | ||||
/** | /** | |||
* stun_usage_ice_conncheck_process: | * stun_usage_ice_conncheck_process: | |||
* @msg: The #StunMessage to process | * @msg: The #StunMessage to process | |||
* @addr: A pointer to a #sockaddr structure to fill with the mapped addres s | * @addr: A pointer to a #sockaddr structure to fill with the mapped addres s | |||
* that the STUN connectivity check response contains | * that the STUN connectivity check response contains | |||
* @addrlen: The length of @addr | * @addrlen: The length of @addr | |||
* @compatibility: The compatibility mode to use for processing the connche ck | * @compatibility: The compatibility mode to use for processing the connche ck | |||
* response | * response | |||
* | * | |||
End of changes. 5 change blocks. | ||||
1 lines changed or deleted | 11 lines changed or added | |||
stunagent.h | stunagent.h | |||
---|---|---|---|---|
skipping to change at line 83 | skipping to change at line 83 | |||
/** | /** | |||
* StunCompatibility: | * StunCompatibility: | |||
* @STUN_COMPATIBILITY_RFC3489: Use the STUN specifications compatible with | * @STUN_COMPATIBILITY_RFC3489: Use the STUN specifications compatible with | |||
* RFC 3489 | * RFC 3489 | |||
* @STUN_COMPATIBILITY_RFC5389: Use the STUN specifications compatible with | * @STUN_COMPATIBILITY_RFC5389: Use the STUN specifications compatible with | |||
* RFC 5389 | * RFC 5389 | |||
* @STUN_COMPATIBILITY_WLM2009: Use the STUN specifications compatible with | * @STUN_COMPATIBILITY_WLM2009: Use the STUN specifications compatible with | |||
* Windows Live Messenger 2009 (a mix between RFC3489 and RFC5389, as well as | * Windows Live Messenger 2009 (a mix between RFC3489 and RFC5389, as well as | |||
* a special usecase against a typo in their code) | * a special usecase against a typo in their code) | |||
* @STUN_COMPATIBILITY_OC2007: Use the STUN specifications compatible with | ||||
* Microsoft Office Communicator 2007 (basically RFC3489 with swapped | ||||
* REALM and NONCE attribute hex IDs, attributes are not aligned) | ||||
* @STUN_COMPATIBILITY_LAST: Dummy last compatibility mode | * @STUN_COMPATIBILITY_LAST: Dummy last compatibility mode | |||
* | * | |||
* Enum that specifies the STUN compatibility mode of the #StunAgent | * Enum that specifies the STUN compatibility mode of the #StunAgent | |||
*/ | */ | |||
typedef enum { | typedef enum { | |||
STUN_COMPATIBILITY_RFC3489, | STUN_COMPATIBILITY_RFC3489, | |||
STUN_COMPATIBILITY_RFC5389, | STUN_COMPATIBILITY_RFC5389, | |||
STUN_COMPATIBILITY_WLM2009, | STUN_COMPATIBILITY_WLM2009, | |||
STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_WLM2009 | STUN_COMPATIBILITY_OC2007, | |||
STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_OC2007 | ||||
} StunCompatibility; | } StunCompatibility; | |||
/** | /** | |||
* StunValidationStatus: | * StunValidationStatus: | |||
* @STUN_VALIDATION_SUCCESS: The message is validated | * @STUN_VALIDATION_SUCCESS: The message is validated | |||
* @STUN_VALIDATION_NOT_STUN: This is not a valid STUN message | * @STUN_VALIDATION_NOT_STUN: This is not a valid STUN message | |||
* @STUN_VALIDATION_INCOMPLETE_STUN: The message seems to be valid but inco mplete | * @STUN_VALIDATION_INCOMPLETE_STUN: The message seems to be valid but inco mplete | |||
* @STUN_VALIDATION_BAD_REQUEST: The message does not have the cookie or th e | * @STUN_VALIDATION_BAD_REQUEST: The message does not have the cookie or th e | |||
* fingerprint while the agent needs it with its usage | * fingerprint while the agent needs it with its usage | |||
* @STUN_VALIDATION_UNAUTHORIZED_BAD_REQUEST: The message is valid but | * @STUN_VALIDATION_UNAUTHORIZED_BAD_REQUEST: The message is valid but | |||
skipping to change at line 157 | skipping to change at line 161 | |||
* @STUN_AGENT_USAGE_NO_INDICATION_AUTH: The agent should ignore credential s | * @STUN_AGENT_USAGE_NO_INDICATION_AUTH: The agent should ignore credential s | |||
* in the STUN messages it receives if the #StunClass of the message is | * in the STUN messages it receives if the #StunClass of the message is | |||
* #STUN_INDICATION (some implementation require #STUN_INDICATION messages to | * #STUN_INDICATION (some implementation require #STUN_INDICATION messages to | |||
* be authenticated, while others never add a MESSAGE-INTEGRITY attribute t o a | * be authenticated, while others never add a MESSAGE-INTEGRITY attribute t o a | |||
* #STUN_INDICATION message) | * #STUN_INDICATION message) | |||
* @STUN_AGENT_USAGE_FORCE_VALIDATER: The agent should always try to valida te | * @STUN_AGENT_USAGE_FORCE_VALIDATER: The agent should always try to valida te | |||
* the password of a STUN message, even if it already knows what the passwo rd | * the password of a STUN message, even if it already knows what the passwo rd | |||
* should be (a response to a previously created request). This means that the | * should be (a response to a previously created request). This means that the | |||
* #StunMessageIntegrityValidate callback will always be called when there is | * #StunMessageIntegrityValidate callback will always be called when there is | |||
* a MESSAGE-INTEGRITY attribute. | * a MESSAGE-INTEGRITY attribute. | |||
* @STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES: The agent should not assume STU | ||||
N | ||||
* attributes are aligned on 32-bit boundaries when parsing messages and al | ||||
so | ||||
* do not add padding when creating messages. | ||||
* | * | |||
* This enum defines a bitflag usages for a #StunAgent and they will define how | * This enum defines a bitflag usages for a #StunAgent and they will define how | |||
* the agent should behave, independently of the compatibility mode it uses . | * the agent should behave, independently of the compatibility mode it uses . | |||
* <para> See also: stun_agent_init() </para> | * <para> See also: stun_agent_init() </para> | |||
* <para> See also: stun_agent_validate() </para> | * <para> See also: stun_agent_validate() </para> | |||
*/ | */ | |||
typedef enum { | typedef enum { | |||
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS = (1 << 0), | STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS = (1 << 0), | |||
STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS = (1 << 1), | STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS = (1 << 1), | |||
STUN_AGENT_USAGE_USE_FINGERPRINT = (1 << 2), | STUN_AGENT_USAGE_USE_FINGERPRINT = (1 << 2), | |||
STUN_AGENT_USAGE_ADD_SOFTWARE = (1 << 3), | STUN_AGENT_USAGE_ADD_SOFTWARE = (1 << 3), | |||
STUN_AGENT_USAGE_IGNORE_CREDENTIALS = (1 << 4), | STUN_AGENT_USAGE_IGNORE_CREDENTIALS = (1 << 4), | |||
STUN_AGENT_USAGE_NO_INDICATION_AUTH = (1 << 5), | STUN_AGENT_USAGE_NO_INDICATION_AUTH = (1 << 5), | |||
STUN_AGENT_USAGE_FORCE_VALIDATER = (1 << 6), | STUN_AGENT_USAGE_FORCE_VALIDATER = (1 << 6), | |||
STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES = (1 << 7), | ||||
} StunAgentUsageFlags; | } StunAgentUsageFlags; | |||
typedef struct { | typedef struct { | |||
StunTransactionId id; | StunTransactionId id; | |||
StunMethod method; | StunMethod method; | |||
uint8_t *key; | uint8_t *key; | |||
size_t key_len; | size_t key_len; | |||
uint8_t long_term_key[16]; | uint8_t long_term_key[16]; | |||
bool long_term_valid; | bool long_term_valid; | |||
bool valid; | bool valid; | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 11 lines changed or added | |||
stunmessage.h | stunmessage.h | |||
---|---|---|---|---|
skipping to change at line 209 | skipping to change at line 209 | |||
* TURN draft 04 | * TURN draft 04 | |||
* @STUN_ATTRIBUTE_RESERVATION_TOKEN: The RESERVATION-TOKEN attribute as de fined | * @STUN_ATTRIBUTE_RESERVATION_TOKEN: The RESERVATION-TOKEN attribute as de fined | |||
* by TURN draft 09 and 12 | * by TURN draft 09 and 12 | |||
* @STUN_ATTRIBUTE_CONNECT_STAT: The CONNECT-STAT attribute as defined by T URN | * @STUN_ATTRIBUTE_CONNECT_STAT: The CONNECT-STAT attribute as defined by T URN | |||
* draft 04 | * draft 04 | |||
* @STUN_ATTRIBUTE_PRIORITY: The PRIORITY attribute as defined by ICE draft 19 | * @STUN_ATTRIBUTE_PRIORITY: The PRIORITY attribute as defined by ICE draft 19 | |||
* @STUN_ATTRIBUTE_USE_CANDIDATE: The USE-CANDIDATE attribute as defined by | * @STUN_ATTRIBUTE_USE_CANDIDATE: The USE-CANDIDATE attribute as defined by | |||
* ICE draft 19 | * ICE draft 19 | |||
* @STUN_ATTRIBUTE_OPTIONS: The OPTIONS optional attribute as defined by | * @STUN_ATTRIBUTE_OPTIONS: The OPTIONS optional attribute as defined by | |||
* libjingle | * libjingle | |||
* @STUN_ATTRIBUTE_MS_VERSION: The MS-VERSION optional attribute as defined | ||||
* by [MS-TURN] | ||||
* @STUN_ATTRIBUTE_SOFTWARE: The SOFTWARE optional attribute as defined by RFC5389 | * @STUN_ATTRIBUTE_SOFTWARE: The SOFTWARE optional attribute as defined by RFC5389 | |||
* @STUN_ATTRIBUTE_ALTERNATE_SERVER: The ALTERNATE-SERVER optional attribut e as | * @STUN_ATTRIBUTE_ALTERNATE_SERVER: The ALTERNATE-SERVER optional attribut e as | |||
* defined by RFC5389 | * defined by RFC5389 | |||
* @STUN_ATTRIBUTE_FINGERPRINT: The FINGERPRINT optional attribute as defin ed | * @STUN_ATTRIBUTE_FINGERPRINT: The FINGERPRINT optional attribute as defin ed | |||
* by RFC5389 | * by RFC5389 | |||
* @STUN_ATTRIBUTE_ICE_CONTROLLED: The ICE-CONTROLLED optional attribute as | * @STUN_ATTRIBUTE_ICE_CONTROLLED: The ICE-CONTROLLED optional attribute as | |||
* defined by ICE draft 19 | * defined by ICE draft 19 | |||
* @STUN_ATTRIBUTE_ICE_CONTROLLING: The ICE-CONTROLLING optional attribute as | * @STUN_ATTRIBUTE_ICE_CONTROLLING: The ICE-CONTROLLING optional attribute as | |||
* defined by ICE draft 19 | * defined by ICE draft 19 | |||
* @STUN_ATTRIBUTE_MS_SEQUENCE_NUMBER: The MS-SEQUENCE NUMBER optional attr | ||||
ibute | ||||
* as defined by [MS-TURN] | ||||
* @STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER: The CANDIDATE-IDENTIFIER optional | ||||
* attribute as defined by [MS-ICE2] | ||||
* | * | |||
* Known STUN attribute types as defined by various RFCs and drafts | * Known STUN attribute types as defined by various RFCs and drafts | |||
*/ | */ | |||
/* Should be in sync with stun_is_unknown() */ | /* Should be in sync with stun_is_unknown() */ | |||
typedef enum | typedef enum | |||
{ | { | |||
/* Mandatory attributes */ | /* Mandatory attributes */ | |||
/* 0x0000 */ /* reserved */ | /* 0x0000 */ /* reserved */ | |||
STUN_ATTRIBUTE_MAPPED_ADDRESS=0x0001, /* RFC5389 */ | STUN_ATTRIBUTE_MAPPED_ADDRESS=0x0001, /* RFC5389 */ | |||
STUN_ATTRIBUTE_RESPONSE_ADDRESS=0x0002, /* old RFC3489 */ | STUN_ATTRIBUTE_RESPONSE_ADDRESS=0x0002, /* old RFC3489 */ | |||
skipping to change at line 239 | skipping to change at line 245 | |||
STUN_ATTRIBUTE_SOURCE_ADDRESS=0x0004, /* old RFC3489 */ | STUN_ATTRIBUTE_SOURCE_ADDRESS=0x0004, /* old RFC3489 */ | |||
STUN_ATTRIBUTE_CHANGED_ADDRESS=0x0005, /* old RFC3489 */ | STUN_ATTRIBUTE_CHANGED_ADDRESS=0x0005, /* old RFC3489 */ | |||
STUN_ATTRIBUTE_USERNAME=0x0006, /* RFC5389 */ | STUN_ATTRIBUTE_USERNAME=0x0006, /* RFC5389 */ | |||
STUN_ATTRIBUTE_PASSWORD=0x0007, /* old RFC3489 */ | STUN_ATTRIBUTE_PASSWORD=0x0007, /* old RFC3489 */ | |||
STUN_ATTRIBUTE_MESSAGE_INTEGRITY=0x0008, /* RFC5389 */ | STUN_ATTRIBUTE_MESSAGE_INTEGRITY=0x0008, /* RFC5389 */ | |||
STUN_ATTRIBUTE_ERROR_CODE=0x0009, /* RFC5389 */ | STUN_ATTRIBUTE_ERROR_CODE=0x0009, /* RFC5389 */ | |||
STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES=0x000A, /* RFC5389 */ | STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES=0x000A, /* RFC5389 */ | |||
STUN_ATTRIBUTE_REFLECTED_FROM=0x000B, /* old RFC3489 */ | STUN_ATTRIBUTE_REFLECTED_FROM=0x000B, /* old RFC3489 */ | |||
STUN_ATTRIBUTE_CHANNEL_NUMBER=0x000C, /* TURN-12 */ | STUN_ATTRIBUTE_CHANNEL_NUMBER=0x000C, /* TURN-12 */ | |||
STUN_ATTRIBUTE_LIFETIME=0x000D, /* TURN-12 */ | STUN_ATTRIBUTE_LIFETIME=0x000D, /* TURN-12 */ | |||
/* 0x000E */ /* reserved (was ALTERNATE-SERVER from midcom-TURN 08 | /* MS_ALTERNATE_SERVER is only used by Microsoft's dialect, probably shou | |||
*/ | ld | |||
* not to be placed in STUN_ALL_KNOWN_ATTRIBUTES */ | ||||
STUN_ATTRIBUTE_MS_ALTERNATE_SERVER=0x000E, /* MS-TURN */ | ||||
STUN_ATTRIBUTE_MAGIC_COOKIE=0x000F, /* midcom-TURN 08 */ | STUN_ATTRIBUTE_MAGIC_COOKIE=0x000F, /* midcom-TURN 08 */ | |||
STUN_ATTRIBUTE_BANDWIDTH=0x0010, /* TURN-04 */ | STUN_ATTRIBUTE_BANDWIDTH=0x0010, /* TURN-04 */ | |||
STUN_ATTRIBUTE_DESTINATION_ADDRESS=0x0011, /* midcom-TURN 08 */ | STUN_ATTRIBUTE_DESTINATION_ADDRESS=0x0011, /* midcom-TURN 08 */ | |||
STUN_ATTRIBUTE_REMOTE_ADDRESS=0x0012, /* TURN-04 */ | STUN_ATTRIBUTE_REMOTE_ADDRESS=0x0012, /* TURN-04 */ | |||
STUN_ATTRIBUTE_PEER_ADDRESS=0x0012, /* TURN-09 */ | STUN_ATTRIBUTE_PEER_ADDRESS=0x0012, /* TURN-09 */ | |||
STUN_ATTRIBUTE_XOR_PEER_ADDRESS=0x0012, /* TURN-12 */ | STUN_ATTRIBUTE_XOR_PEER_ADDRESS=0x0012, /* TURN-12 */ | |||
STUN_ATTRIBUTE_DATA=0x0013, /* TURN-12 */ | STUN_ATTRIBUTE_DATA=0x0013, /* TURN-12 */ | |||
STUN_ATTRIBUTE_REALM=0x0014, /* RFC5389 */ | STUN_ATTRIBUTE_REALM=0x0014, /* RFC5389 */ | |||
STUN_ATTRIBUTE_NONCE=0x0015, /* RFC5389 */ | STUN_ATTRIBUTE_NONCE=0x0015, /* RFC5389 */ | |||
STUN_ATTRIBUTE_RELAY_ADDRESS=0x0016, /* TURN-04 */ | STUN_ATTRIBUTE_RELAY_ADDRESS=0x0016, /* TURN-04 */ | |||
skipping to change at line 279 | skipping to change at line 287 | |||
STUN_ATTRIBUTE_USE_CANDIDATE=0x0025, /* ICE-19 */ | STUN_ATTRIBUTE_USE_CANDIDATE=0x0025, /* ICE-19 */ | |||
/* 0x0026 */ /* reserved */ | /* 0x0026 */ /* reserved */ | |||
/* 0x0027 */ /* reserved */ | /* 0x0027 */ /* reserved */ | |||
/* 0x0028 */ /* reserved */ | /* 0x0028 */ /* reserved */ | |||
/* 0x0029 */ /* reserved */ | /* 0x0029 */ /* reserved */ | |||
/* 0x002A-0x7fff */ /* reserved */ | /* 0x002A-0x7fff */ /* reserved */ | |||
/* Optional attributes */ | /* Optional attributes */ | |||
/* 0x8000-0x8021 */ /* reserved */ | /* 0x8000-0x8021 */ /* reserved */ | |||
STUN_ATTRIBUTE_OPTIONS=0x8001, /* libjingle */ | STUN_ATTRIBUTE_OPTIONS=0x8001, /* libjingle */ | |||
STUN_ATTRIBUTE_MS_VERSION=0x8008, /* MS-TURN */ | ||||
STUN_ATTRIBUTE_SOFTWARE=0x8022, /* RFC5389 */ | STUN_ATTRIBUTE_SOFTWARE=0x8022, /* RFC5389 */ | |||
STUN_ATTRIBUTE_ALTERNATE_SERVER=0x8023, /* RFC5389 */ | STUN_ATTRIBUTE_ALTERNATE_SERVER=0x8023, /* RFC5389 */ | |||
/* 0x8024 */ /* reserved */ | /* 0x8024 */ /* reserved */ | |||
/* 0x8025 */ /* reserved */ | /* 0x8025 */ /* reserved */ | |||
/* 0x8026 */ /* reserved */ | /* 0x8026 */ /* reserved */ | |||
/* 0x8027 */ /* reserved */ | /* 0x8027 */ /* reserved */ | |||
STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */ | STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */ | |||
STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */ | STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */ | |||
STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */ | STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */ | |||
/* 0x802B-0xFFFF */ /* reserved */ | /* 0x802B-0x804F */ /* reserved */ | |||
STUN_ATTRIBUTE_MS_SEQUENCE_NUMBER=0x8050, /* MS-TURN */ | ||||
/* 0x8051-0x8053 */ /* reserved */ | ||||
STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER=0x8054 /* MS-ICE2 */ | ||||
/* 0x8055-0xFFFF */ /* reserved */ | ||||
} StunAttribute; | } StunAttribute; | |||
/** | /** | |||
* STUN_ALL_KNOWN_ATTRIBUTES: | * STUN_ALL_KNOWN_ATTRIBUTES: | |||
* | * | |||
* An array containing all the currently known and defined mandatory attrib utes | * An array containing all the currently known and defined mandatory attrib utes | |||
* from StunAttribute | * from StunAttribute | |||
*/ | */ | |||
/* Should be in sync with StunAttribute */ | /* Should be in sync with StunAttribute */ | |||
static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] = | static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] = | |||
skipping to change at line 342 | skipping to change at line 355 | |||
STUN_ATTRIBUTE_TIMER_VAL, | STUN_ATTRIBUTE_TIMER_VAL, | |||
STUN_ATTRIBUTE_REQUESTED_IP, | STUN_ATTRIBUTE_REQUESTED_IP, | |||
STUN_ATTRIBUTE_RESERVATION_TOKEN, | STUN_ATTRIBUTE_RESERVATION_TOKEN, | |||
STUN_ATTRIBUTE_CONNECT_STAT, | STUN_ATTRIBUTE_CONNECT_STAT, | |||
STUN_ATTRIBUTE_PRIORITY, | STUN_ATTRIBUTE_PRIORITY, | |||
STUN_ATTRIBUTE_USE_CANDIDATE, | STUN_ATTRIBUTE_USE_CANDIDATE, | |||
0 | 0 | |||
}; | }; | |||
/** | /** | |||
* STUN_MSOC_KNOWN_ATTRIBUTES: | ||||
* | ||||
* An array containing all the currently known mandatory attributes used by | ||||
* Microsoft Office Communicator as defined in [MS-TURN] | ||||
*/ | ||||
static const uint16_t STUN_MSOC_KNOWN_ATTRIBUTES[] = | ||||
{ | ||||
STUN_ATTRIBUTE_MAPPED_ADDRESS, | ||||
STUN_ATTRIBUTE_USERNAME, | ||||
STUN_ATTRIBUTE_MESSAGE_INTEGRITY, | ||||
STUN_ATTRIBUTE_ERROR_CODE, | ||||
STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES, | ||||
STUN_ATTRIBUTE_LIFETIME, | ||||
STUN_ATTRIBUTE_MS_ALTERNATE_SERVER, | ||||
STUN_ATTRIBUTE_MAGIC_COOKIE, | ||||
STUN_ATTRIBUTE_BANDWIDTH, | ||||
STUN_ATTRIBUTE_DESTINATION_ADDRESS, | ||||
STUN_ATTRIBUTE_REMOTE_ADDRESS, | ||||
STUN_ATTRIBUTE_DATA, | ||||
/* REALM and NONCE have swapped hexadecimal IDs in [MS-TURN]. Libnice u | ||||
sers | ||||
* or developers can still use these enumeration values in their origin | ||||
al | ||||
* meanings from StunAttribute anywhere in the code, as stun_message_fi | ||||
nd() | ||||
* and stun_message_append() will choose correct ID in MSOC compatibili | ||||
ty | ||||
* modes. */ | ||||
STUN_ATTRIBUTE_NONCE, | ||||
STUN_ATTRIBUTE_REALM, | ||||
0 | ||||
}; | ||||
/** | ||||
* StunTransactionId: | * StunTransactionId: | |||
* | * | |||
* A type that holds a STUN transaction id. | * A type that holds a STUN transaction id. | |||
*/ | */ | |||
typedef uint8_t StunTransactionId[STUN_MESSAGE_TRANS_ID_LEN]; | typedef uint8_t StunTransactionId[STUN_MESSAGE_TRANS_ID_LEN]; | |||
/** | /** | |||
* StunError: | * StunError: | |||
* @STUN_ERROR_TRY_ALTERNATE: The ERROR-CODE value for the | * @STUN_ERROR_TRY_ALTERNATE: The ERROR-CODE value for the | |||
* "Try Alternate" error as defined in RFC5389 | * "Try Alternate" error as defined in RFC5389 | |||
skipping to change at line 815 | skipping to change at line 858 | |||
* | * | |||
* Convenience macro for stun_message_validate_buffer_length() meaning that the | * Convenience macro for stun_message_validate_buffer_length() meaning that the | |||
* data to validate is not a valid STUN message | * data to validate is not a valid STUN message | |||
*/ | */ | |||
#define STUN_MESSAGE_BUFFER_INVALID -1 | #define STUN_MESSAGE_BUFFER_INVALID -1 | |||
/** | /** | |||
* stun_message_validate_buffer_length: | * stun_message_validate_buffer_length: | |||
* @msg: The buffer to validate | * @msg: The buffer to validate | |||
* @length: The length of the buffer | * @length: The length of the buffer | |||
* @has_padding: Set TRUE if attributes should be padded to multiple of 4 b ytes | ||||
* | * | |||
* This function will take a data buffer and will try to validate whether i t is | * This function will take a data buffer and will try to validate whether i t is | |||
* a STUN message or if it's not or if it's an incomplete STUN message and will | * a STUN message or if it's not or if it's an incomplete STUN message and will | |||
* provide us with the length of the STUN message. | * provide us with the length of the STUN message. | |||
* | * | |||
* Returns: The length of the valid STUN message in the buffer. | * Returns: The length of the valid STUN message in the buffer. | |||
* <para> See also: #STUN_MESSAGE_BUFFER_INCOMPLETE </para> | * <para> See also: #STUN_MESSAGE_BUFFER_INCOMPLETE </para> | |||
* <para> See also: #STUN_MESSAGE_BUFFER_INVALID </para> | * <para> See also: #STUN_MESSAGE_BUFFER_INVALID </para> | |||
*/ | */ | |||
int stun_message_validate_buffer_length (const uint8_t *msg, size_t length) | int stun_message_validate_buffer_length (const uint8_t *msg, size_t length, | |||
; | bool has_padding); | |||
/** | /** | |||
* stun_message_id: | * stun_message_id: | |||
* @msg: The #StunMessage | * @msg: The #StunMessage | |||
* @id: The #StunTransactionId to fill | * @id: The #StunTransactionId to fill | |||
* | * | |||
* Retreive the STUN transaction id from a STUN message | * Retreive the STUN transaction id from a STUN message | |||
*/ | */ | |||
void stun_message_id (const StunMessage *msg, StunTransactionId id); | void stun_message_id (const StunMessage *msg, StunTransactionId id); | |||
End of changes. 8 change blocks. | ||||
5 lines changed or deleted | 54 lines changed or added | |||
timer.h | timer.h | |||
---|---|---|---|---|
skipping to change at line 65 | skipping to change at line 65 | |||
<programlisting> | <programlisting> | |||
StunTimer timer; | StunTimer timer; | |||
unsigned remainder; | unsigned remainder; | |||
StunUsageTimerReturn ret; | StunUsageTimerReturn ret; | |||
// Build the message, etc.. | // Build the message, etc.. | |||
... | ... | |||
// Send the message and start the timer | // Send the message and start the timer | |||
send(socket, request, sizeof(request)); | send(socket, request, sizeof(request)); | |||
stun_timer_start(&timer); | stun_timer_start(&timer, STUN_TIMER_DEFAULT_TIMEOUT, | |||
STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS); | ||||
// Loop until we get the response | // Loop until we get the response | |||
for (;;) { | for (;;) { | |||
remainder = stun_timer_remainder(&timer); | remainder = stun_timer_remainder(&timer); | |||
// Poll the socket until data is received or the timer expires | // Poll the socket until data is received or the timer expires | |||
if (poll (&pollfd, 1, delay) <= 0) { | if (poll (&pollfd, 1, delay) <= 0) { | |||
// Time out and no response was received | // Time out and no response was received | |||
ret = stun_timer_refresh (&timer); | ret = stun_timer_refresh (&timer); | |||
if (ret == STUN_USAGE_TIMER_RETURN_TIMEOUT) { | if (ret == STUN_USAGE_TIMER_RETURN_TIMEOUT) { | |||
skipping to change at line 122 | skipping to change at line 123 | |||
/** | /** | |||
* StunTimer: | * StunTimer: | |||
* | * | |||
* An opaque structure representing a STUN transaction retransmission timer | * An opaque structure representing a STUN transaction retransmission timer | |||
*/ | */ | |||
typedef struct stun_timer_s StunTimer; | typedef struct stun_timer_s StunTimer; | |||
struct stun_timer_s { | struct stun_timer_s { | |||
struct timeval deadline; | struct timeval deadline; | |||
unsigned delay; | unsigned delay; | |||
unsigned retransmissions; | ||||
unsigned max_retransmissions; | ||||
}; | }; | |||
/** | /** | |||
* STUN_TIMER_DEFAULT_TIMEOUT: | ||||
* | ||||
* The default intial timeout to use for the timer | ||||
*/ | ||||
#define STUN_TIMER_DEFAULT_TIMEOUT 600 | ||||
/** | ||||
* STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS: | ||||
* | ||||
* The default maximum retransmissions allowed before a timer decides to ti | ||||
meout | ||||
*/ | ||||
#define STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS 3 | ||||
/** | ||||
* STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT: | ||||
* | ||||
* The default intial timeout to use for a reliable timer | ||||
*/ | ||||
#define STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT 7900 | ||||
/** | ||||
* StunUsageTimerReturn: | * StunUsageTimerReturn: | |||
* @STUN_USAGE_TIMER_RETURN_SUCCESS: The timer was refreshed successfully | * @STUN_USAGE_TIMER_RETURN_SUCCESS: The timer was refreshed successfully | |||
* and there is nothing to be done | * and there is nothing to be done | |||
* @STUN_USAGE_TIMER_RETURN_RETRANSMIT: The timer expired and the message | * @STUN_USAGE_TIMER_RETURN_RETRANSMIT: The timer expired and the message | |||
* should be retransmitted now. | * should be retransmitted now. | |||
* @STUN_USAGE_TIMER_RETURN_TIMEOUT: The timer expired as well as all the | * @STUN_USAGE_TIMER_RETURN_TIMEOUT: The timer expired as well as all the | |||
* retransmissions, the transaction timed out | * retransmissions, the transaction timed out | |||
* | * | |||
* Return value of stun_usage_timer_refresh() which provides you with statu s | * Return value of stun_usage_timer_refresh() which provides you with statu s | |||
* information on the timer. | * information on the timer. | |||
skipping to change at line 149 | skipping to change at line 173 | |||
STUN_USAGE_TIMER_RETURN_TIMEOUT | STUN_USAGE_TIMER_RETURN_TIMEOUT | |||
} StunUsageTimerReturn; | } StunUsageTimerReturn; | |||
# ifdef __cplusplus | # ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
# endif | # endif | |||
/** | /** | |||
* stun_timer_start: | * stun_timer_start: | |||
* @timer: The #StunTimer to start | * @timer: The #StunTimer to start | |||
* @initial_timeout: The initial timeout to use before the first retransmis | ||||
sion | ||||
* @max_retransmissions: The maximum number of transmissions before the | ||||
* #StunTimer times out | ||||
* | * | |||
* Starts a STUN transaction retransmission timer. | * Starts a STUN transaction retransmission timer. | |||
* This should be called as soon as you send the message for the first time on | * This should be called as soon as you send the message for the first time on | |||
* a UDP socket | * a UDP socket. | |||
* The timeout before the next retransmission is set to @initial_timeout, t | ||||
hen | ||||
* each time a packet is retransmited, that timeout will be doubled, until | ||||
the | ||||
* @max_retransmissions retransmissions limit is reached. | ||||
* <para> | ||||
* To determine the total timeout value, one can use the following equation | ||||
: | ||||
<programlisting> | ||||
total_timeout = initial_timeout * (2^(max_retransmissions + 1) - 1); | ||||
</programlisting> | ||||
* </para> | ||||
* | ||||
* See also: #STUN_TIMER_DEFAULT_TIMEOUT | ||||
* | ||||
* See also: #STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS | ||||
*/ | */ | |||
void stun_timer_start (StunTimer *timer); | void stun_timer_start (StunTimer *timer, unsigned int initial_timeout, | |||
unsigned int max_retransmissions); | ||||
/** | /** | |||
* stun_timer_start_reliable: | * stun_timer_start_reliable: | |||
* @timer: The #StunTimer to start | * @timer: The #StunTimer to start | |||
* | * | |||
* Starts a STUN transaction retransmission timer for a reliable transport. | * Starts a STUN transaction retransmission timer for a reliable transport. | |||
* This should be called as soon as you send the message for the first time on | * This should be called as soon as you send the message for the first time on | |||
* a TCP socket | * a TCP socket | |||
*/ | */ | |||
void stun_timer_start_reliable (StunTimer *timer); | void stun_timer_start_reliable (StunTimer *timer, unsigned int initial_time out); | |||
/** | /** | |||
* stun_timer_refresh: | * stun_timer_refresh: | |||
* @timer: The #StunTimer to refresh | * @timer: The #StunTimer to refresh | |||
* | * | |||
* Updates a STUN transaction retransmission timer. | * Updates a STUN transaction retransmission timer. | |||
* Returns: A #StunUsageTimerReturn telling you what to do next | * Returns: A #StunUsageTimerReturn telling you what to do next | |||
*/ | */ | |||
StunUsageTimerReturn stun_timer_refresh (StunTimer *timer); | StunUsageTimerReturn stun_timer_refresh (StunTimer *timer); | |||
End of changes. 7 change blocks. | ||||
4 lines changed or deleted | 50 lines changed or added | |||
turn.h | turn.h | |||
---|---|---|---|---|
skipping to change at line 61 | skipping to change at line 61 | |||
* an allocate or refresh request. | * an allocate or refresh request. | |||
*/ | */ | |||
#ifdef _WIN32 | #ifdef _WIN32 | |||
#include "win32_common.h" | #include "win32_common.h" | |||
#else | #else | |||
# include <stdbool.h> | # include <stdbool.h> | |||
# include <stdint.h> | # include <stdint.h> | |||
#endif | #endif | |||
#ifdef _WIN32 | ||||
#include <winsock2.h> | ||||
#else | ||||
#include <sys/types.h> | ||||
#include <sys/socket.h> | ||||
#endif | ||||
# include "stun/stunagent.h" | # include "stun/stunagent.h" | |||
# ifdef __cplusplus | # ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
# endif | # endif | |||
/** | /** | |||
* StunUsageTurnRequestPorts: | * StunUsageTurnRequestPorts: | |||
* @STUN_USAGE_TURN_REQUEST_PORT_NORMAL: Request a normal port | * @STUN_USAGE_TURN_REQUEST_PORT_NORMAL: Request a normal port | |||
* @STUN_USAGE_TURN_REQUEST_PORT_EVEN: Request an even port | * @STUN_USAGE_TURN_REQUEST_PORT_EVEN: Request an even port | |||
skipping to change at line 98 | skipping to change at line 105 | |||
* Google Talk's relay server | * Google Talk's relay server | |||
* @STUN_USAGE_TURN_COMPATIBILITY_MSN: Use the specification compatible wit h | * @STUN_USAGE_TURN_COMPATIBILITY_MSN: Use the specification compatible wit h | |||
* MSN TURN servers | * MSN TURN servers | |||
* | * | |||
* Specifies which TURN specification compatibility to use | * Specifies which TURN specification compatibility to use | |||
*/ | */ | |||
typedef enum { | typedef enum { | |||
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9, | STUN_USAGE_TURN_COMPATIBILITY_DRAFT9, | |||
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE, | STUN_USAGE_TURN_COMPATIBILITY_GOOGLE, | |||
STUN_USAGE_TURN_COMPATIBILITY_MSN, | STUN_USAGE_TURN_COMPATIBILITY_MSN, | |||
STUN_USAGE_TURN_COMPATIBILITY_OC2007, | ||||
STUN_USAGE_TURN_COMPATIBILITY_RFC5766, | ||||
} StunUsageTurnCompatibility; | } StunUsageTurnCompatibility; | |||
/** | /** | |||
* StunUsageTurnReturn: | * StunUsageTurnReturn: | |||
* @STUN_USAGE_TURN_RETURN_RELAY_SUCCESS: The response was successful and a relay | * @STUN_USAGE_TURN_RETURN_RELAY_SUCCESS: The response was successful and a relay | |||
* address is provided | * address is provided | |||
* @STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS: The response was successful and a | * @STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS: The response was successful and a | |||
* relay address as well as a mapped address are provided | * relay address as well as a mapped address are provided | |||
* @STUN_USAGE_TURN_RETURN_ERROR: The response resulted in an error | * @STUN_USAGE_TURN_RETURN_ERROR: The response resulted in an error | |||
* @STUN_USAGE_TURN_RETURN_INVALID: The response is not a valid response | * @STUN_USAGE_TURN_RETURN_INVALID: The response is not a valid response | |||
skipping to change at line 197 | skipping to change at line 206 | |||
* Create a new TURN Refresh request | * Create a new TURN Refresh request | |||
* Returns: The length of the message to send | * Returns: The length of the message to send | |||
*/ | */ | |||
size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg, | size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg, | |||
uint8_t *buffer, size_t buffer_len, | uint8_t *buffer, size_t buffer_len, | |||
StunMessage *previous_response, int32_t lifetime, | StunMessage *previous_response, int32_t lifetime, | |||
uint8_t *username, size_t username_len, | uint8_t *username, size_t username_len, | |||
uint8_t *password, size_t password_len, | uint8_t *password, size_t password_len, | |||
StunUsageTurnCompatibility compatibility); | StunUsageTurnCompatibility compatibility); | |||
size_t stun_usage_turn_create_permission (StunAgent *agent, StunMessage *ms | ||||
g, | ||||
uint8_t *buffer, size_t buffer_len, | ||||
uint8_t *username, size_t username_len, | ||||
uint8_t *password, size_t password_len, | ||||
uint8_t *realm, size_t realm_len, | ||||
uint8_t *nonce, size_t nonce_len, | ||||
struct sockaddr *peer, | ||||
StunUsageTurnCompatibility compatibility); | ||||
/** | /** | |||
* stun_usage_turn_process: | * stun_usage_turn_process: | |||
* @msg: The message containing the response | * @msg: The message containing the response | |||
* @relay_addr: A pointer to a #sockaddr structure to fill with the relay a ddress | * @relay_addr: A pointer to a #sockaddr structure to fill with the relay a ddress | |||
* that the TURN server allocated for us | * that the TURN server allocated for us | |||
* @relay_addrlen: The length of @relay_addr | * @relay_addrlen: The length of @relay_addr | |||
* @addr: A pointer to a #sockaddr structure to fill with the mapped addres s | * @addr: A pointer to a #sockaddr structure to fill with the mapped addres s | |||
* that the STUN response contains. | * that the STUN response contains. | |||
* This argument will only be filled if the return value | * This argument will only be filled if the return value | |||
* of the function is #STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS | * of the function is #STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 19 lines changed or added | |||