Moved files to correct location
This commit is contained in:
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* This file is part of the Nice GLib ICE library.
|
||||
*
|
||||
* (C) 2006-2009 Collabora Ltd.
|
||||
* Contact: Youness Alaoui
|
||||
* (C) 2006-2009 Nokia Corporation. All rights reserved.
|
||||
* Contact: Kai Vehmanen
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Nice GLib ICE library.
|
||||
*
|
||||
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
|
||||
* Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Youness Alaoui, Collabora Ltd.
|
||||
* Dafydd Harries, Collabora Ltd.
|
||||
* Kai Vehmanen
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
||||
* case the provisions of LGPL are applicable instead of those above. If you
|
||||
* wish to allow use of your version of this file only under the terms of the
|
||||
* LGPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replace
|
||||
* them with the notice and other provisions required by the LGPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef __LIBNICE_ADDRESS_H__
|
||||
#define __LIBNICE_ADDRESS_H__
|
||||
|
||||
/**
|
||||
* SECTION:address
|
||||
* @short_description: IP address convenience library
|
||||
* @stability: Stable
|
||||
*
|
||||
* The #NiceAddress structure will allow you to easily set/get and modify an IPv4
|
||||
* or IPv6 address in order to communicate with the #NiceAgent.
|
||||
*/
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* NiceAddress:
|
||||
*
|
||||
* The #NiceAddress structure that represents an IPv4 or IPv6 address.
|
||||
*/
|
||||
struct _NiceAddress
|
||||
{
|
||||
union
|
||||
{
|
||||
struct sockaddr addr;
|
||||
struct sockaddr_in ip4;
|
||||
struct sockaddr_in6 ip6;
|
||||
} s;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* NICE_ADDRESS_STRING_LEN:
|
||||
*
|
||||
* The maximum string length representation of an address.
|
||||
* When using nice_address_to_string() make sure the string has a size of
|
||||
* at least %NICE_ADDRESS_STRING_LEN
|
||||
*/
|
||||
#define NICE_ADDRESS_STRING_LEN INET6_ADDRSTRLEN
|
||||
|
||||
typedef struct _NiceAddress NiceAddress;
|
||||
|
||||
|
||||
/**
|
||||
* nice_address_init:
|
||||
* @addr: The #NiceAddress to init
|
||||
*
|
||||
* Initialize a #NiceAddress into an undefined address
|
||||
*/
|
||||
void
|
||||
nice_address_init (NiceAddress *addr);
|
||||
|
||||
/**
|
||||
* nice_address_new:
|
||||
*
|
||||
* Create a new #NiceAddress with undefined address
|
||||
* You must free it with nice_address_free()
|
||||
*
|
||||
* Returns: The new #NiceAddress
|
||||
*/
|
||||
NiceAddress *
|
||||
nice_address_new (void);
|
||||
|
||||
/**
|
||||
* nice_address_free:
|
||||
* @addr: The #NiceAddress to free
|
||||
*
|
||||
* Frees a #NiceAddress created with nice_address_new() or nice_address_dup()
|
||||
*/
|
||||
void
|
||||
nice_address_free (NiceAddress *addr);
|
||||
|
||||
/**
|
||||
* nice_address_dup:
|
||||
* @addr: The #NiceAddress to dup
|
||||
*
|
||||
* Creates a new #NiceAddress with the same address as @addr
|
||||
*
|
||||
* Returns: The new #NiceAddress
|
||||
*/
|
||||
NiceAddress *
|
||||
nice_address_dup (const NiceAddress *addr);
|
||||
|
||||
|
||||
/**
|
||||
* nice_address_set_ipv4:
|
||||
* @addr: The #NiceAddress to modify
|
||||
* @addr_ipv4: The IPv4 address
|
||||
*
|
||||
* Set @addr to an IPv4 address using the data from @addr_ipv4
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
This function will reset the port to 0, so make sure you call it before
|
||||
nice_address_set_port()
|
||||
</para>
|
||||
</note>
|
||||
*/
|
||||
void
|
||||
nice_address_set_ipv4 (NiceAddress *addr, guint32 addr_ipv4);
|
||||
|
||||
|
||||
/**
|
||||
* nice_address_set_ipv6:
|
||||
* @addr: The #NiceAddress to modify
|
||||
* @addr_ipv6: The IPv6 address
|
||||
*
|
||||
* Set @addr to an IPv6 address using the data from @addr_ipv6
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
This function will reset the port to 0, so make sure you call it before
|
||||
nice_address_set_port()
|
||||
</para>
|
||||
</note>
|
||||
*/
|
||||
void
|
||||
nice_address_set_ipv6 (NiceAddress *addr, const guchar *addr_ipv6);
|
||||
|
||||
|
||||
/**
|
||||
* nice_address_set_port:
|
||||
* @addr: The #NiceAddress to modify
|
||||
* @port: The port to set
|
||||
*
|
||||
* Set the port of @addr to @port
|
||||
*/
|
||||
void
|
||||
nice_address_set_port (NiceAddress *addr, guint port);
|
||||
|
||||
/**
|
||||
* nice_address_get_port:
|
||||
* @addr: The #NiceAddress to query
|
||||
*
|
||||
* Retreive the port of @addr
|
||||
*
|
||||
* Returns: The port of @addr
|
||||
*/
|
||||
guint
|
||||
nice_address_get_port (const NiceAddress *addr);
|
||||
|
||||
/**
|
||||
* nice_address_set_from_string:
|
||||
* @addr: The #NiceAddress to modify
|
||||
* @str: The string to set
|
||||
*
|
||||
* Sets an IPv4 or IPv6 address from the string @str
|
||||
*
|
||||
* Returns: %TRUE if success, %FALSE on error
|
||||
*/
|
||||
gboolean
|
||||
nice_address_set_from_string (NiceAddress *addr, const gchar *str);
|
||||
|
||||
/**
|
||||
* nice_address_set_from_sockaddr:
|
||||
* @addr: The #NiceAddress to modify
|
||||
* @sin: The sockaddr to set
|
||||
*
|
||||
* Sets an IPv4 or IPv6 address from the sockaddr structure @sin
|
||||
*
|
||||
*/
|
||||
void
|
||||
nice_address_set_from_sockaddr (NiceAddress *addr, const struct sockaddr *sin);
|
||||
|
||||
|
||||
/**
|
||||
* nice_address_copy_to_sockaddr:
|
||||
* @addr: The #NiceAddress to query
|
||||
* @sin: The sockaddr to fill
|
||||
*
|
||||
* Fills the sockaddr structure @sin with the address contained in @addr
|
||||
*
|
||||
*/
|
||||
void
|
||||
nice_address_copy_to_sockaddr (const NiceAddress *addr, struct sockaddr *sin);
|
||||
|
||||
/**
|
||||
* nice_address_equal:
|
||||
* @a: First #NiceAddress to compare
|
||||
* @b: Second #NiceAddress to compare
|
||||
*
|
||||
* Compares two #NiceAddress structures to see if they contain the same address
|
||||
* and the same port.
|
||||
*
|
||||
* Returns: %TRUE if @a and @b are the same address, %FALSE if they are different
|
||||
*/
|
||||
gboolean
|
||||
nice_address_equal (const NiceAddress *a, const NiceAddress *b);
|
||||
|
||||
/**
|
||||
* nice_address_equal_no_port:
|
||||
* @a: First #NiceAddress to compare
|
||||
* @b: Second #NiceAddress to compare
|
||||
*
|
||||
* Compares two #NiceAddress structures to see if they contain the same address,
|
||||
* ignoring the port.
|
||||
*
|
||||
* Returns: %TRUE if @a and @b are the same address, %FALSE if they
|
||||
* are different
|
||||
*
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
gboolean
|
||||
nice_address_equal_no_port (const NiceAddress *a, const NiceAddress *b);
|
||||
|
||||
/**
|
||||
* nice_address_to_string:
|
||||
* @addr: The #NiceAddress to query
|
||||
* @dst: The string to fill
|
||||
*
|
||||
* Transforms the address @addr into a human readable string
|
||||
*
|
||||
*/
|
||||
void
|
||||
nice_address_to_string (const NiceAddress *addr, gchar *dst);
|
||||
|
||||
/**
|
||||
* nice_address_is_private:
|
||||
* @addr: The #NiceAddress to query
|
||||
*
|
||||
* Verifies if the address in @addr is a private address or not
|
||||
*
|
||||
* Returns: %TRUE if @addr is a private address, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
nice_address_is_private (const NiceAddress *addr);
|
||||
|
||||
/**
|
||||
* nice_address_is_valid:
|
||||
* @addr: The #NiceAddress to query
|
||||
*
|
||||
* Validate whether the #NiceAddress @addr is a valid IPv4 or IPv6 address
|
||||
*
|
||||
* Returns: %TRUE if @addr is valid, %FALSE otherwise
|
||||
*/
|
||||
G_GNUC_WARN_UNUSED_RESULT
|
||||
gboolean
|
||||
nice_address_is_valid (const NiceAddress *addr);
|
||||
|
||||
/**
|
||||
* nice_address_ip_version:
|
||||
* @addr: The #NiceAddress to query
|
||||
*
|
||||
* Returns the IP version of the address
|
||||
*
|
||||
* Returns: 4 for IPv4, 6 for IPv6 and 0 for undefined address
|
||||
*/
|
||||
G_GNUC_WARN_UNUSED_RESULT
|
||||
int
|
||||
nice_address_ip_version (const NiceAddress *addr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBNICE_ADDRESS_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* This file is part of the Nice GLib ICE library.
|
||||
*
|
||||
* (C) 2006-2009 Collabora Ltd.
|
||||
* Contact: Youness Alaoui
|
||||
* (C) 2006-2009 Nokia Corporation. All rights reserved.
|
||||
* Contact: Kai Vehmanen
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Nice GLib ICE library.
|
||||
*
|
||||
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
|
||||
* Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Dafydd Harries, Collabora Ltd.
|
||||
* Youness Alaoui, Collabora Ltd.
|
||||
* Kai Vehmanen, Nokia
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
||||
* case the provisions of LGPL are applicable instead of those above. If you
|
||||
* wish to allow use of your version of this file only under the terms of the
|
||||
* LGPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replace
|
||||
* them with the notice and other provisions required by the LGPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef __LIBNICE_CANDIDATE_H__
|
||||
#define __LIBNICE_CANDIDATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:candidate
|
||||
* @short_description: ICE candidate representation
|
||||
* @see_also: #NiceAddress
|
||||
* @stability: Stable
|
||||
*
|
||||
* A representation of an ICE candidate. Make sure you read the ICE drafts[1] to
|
||||
* understand correctly the concept of ICE candidates.
|
||||
*
|
||||
* [1] http://tools.ietf.org/wg/mmusic/draft-ietf-mmusic-ice/
|
||||
*/
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Constants for determining candidate priorities */
|
||||
#define NICE_CANDIDATE_TYPE_PREF_HOST 120
|
||||
#define NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE 110
|
||||
#define NICE_CANDIDATE_TYPE_PREF_NAT_ASSISTED 105
|
||||
#define NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE 100
|
||||
#define NICE_CANDIDATE_TYPE_PREF_RELAYED_UDP 30
|
||||
#define NICE_CANDIDATE_TYPE_PREF_RELAYED 20
|
||||
|
||||
/* Priority preference constants for MS-ICE compatibility */
|
||||
#define NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP 15
|
||||
#define NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP 6
|
||||
#define NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE 2
|
||||
#define NICE_CANDIDATE_DIRECTION_MS_PREF_ACTIVE 5
|
||||
|
||||
/* Max foundation size '1*32ice-char' plus terminating NULL, ICE ID-19 */
|
||||
/**
|
||||
* NICE_CANDIDATE_MAX_FOUNDATION:
|
||||
*
|
||||
* The maximum size a candidate foundation can have.
|
||||
*/
|
||||
#define NICE_CANDIDATE_MAX_FOUNDATION (32+1)
|
||||
|
||||
|
||||
/**
|
||||
* NiceCandidateType:
|
||||
* @NICE_CANDIDATE_TYPE_HOST: A host candidate
|
||||
* @NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: A server reflexive candidate
|
||||
* @NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: A peer reflexive candidate
|
||||
* @NICE_CANDIDATE_TYPE_RELAYED: A relay candidate
|
||||
*
|
||||
* An enum represneting the type of a candidate
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NICE_CANDIDATE_TYPE_HOST,
|
||||
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE,
|
||||
NICE_CANDIDATE_TYPE_PEER_REFLEXIVE,
|
||||
NICE_CANDIDATE_TYPE_RELAYED,
|
||||
} NiceCandidateType;
|
||||
|
||||
/**
|
||||
* NiceCandidateTransport:
|
||||
* @NICE_CANDIDATE_TRANSPORT_UDP: UDP transport
|
||||
* @NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE: TCP Active transport
|
||||
* @NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE: TCP Passive transport
|
||||
* @NICE_CANDIDATE_TRANSPORT_TCP_SO: TCP Simultaneous-Open transport
|
||||
*
|
||||
* An enum representing the type of transport to use
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NICE_CANDIDATE_TRANSPORT_UDP,
|
||||
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE,
|
||||
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE,
|
||||
NICE_CANDIDATE_TRANSPORT_TCP_SO,
|
||||
} NiceCandidateTransport;
|
||||
|
||||
/**
|
||||
* NiceRelayType:
|
||||
* @NICE_RELAY_TYPE_TURN_UDP: A TURN relay using UDP
|
||||
* @NICE_RELAY_TYPE_TURN_TCP: A TURN relay using TCP
|
||||
* @NICE_RELAY_TYPE_TURN_TLS: A TURN relay using TLS over TCP
|
||||
*
|
||||
* An enum representing the type of relay to use
|
||||
*/
|
||||
typedef enum {
|
||||
NICE_RELAY_TYPE_TURN_UDP,
|
||||
NICE_RELAY_TYPE_TURN_TCP,
|
||||
NICE_RELAY_TYPE_TURN_TLS
|
||||
} NiceRelayType;
|
||||
|
||||
|
||||
typedef struct _NiceCandidate NiceCandidate;
|
||||
|
||||
typedef struct _TurnServer TurnServer;
|
||||
|
||||
/**
|
||||
* TurnServer:
|
||||
* @ref_count: Reference count for the structure.
|
||||
* @server: The #NiceAddress of the TURN server
|
||||
* @username: The TURN username
|
||||
* @password: The TURN password
|
||||
* @decoded_username: The base64 decoded TURN username
|
||||
* @decoded_password: The base64 decoded TURN password
|
||||
* @decoded_username_len: The length of @decoded_username
|
||||
* @decoded_password_len: The length of @decoded_password
|
||||
* @type: The #NiceRelayType of the server
|
||||
*
|
||||
* A structure to store the TURN relay settings
|
||||
*/
|
||||
struct _TurnServer
|
||||
{
|
||||
gint ref_count;
|
||||
|
||||
NiceAddress server;
|
||||
gchar *username;
|
||||
gchar *password;
|
||||
guint8 *decoded_username;
|
||||
guint8 *decoded_password;
|
||||
gsize decoded_username_len;
|
||||
gsize decoded_password_len;
|
||||
NiceRelayType type;
|
||||
};
|
||||
|
||||
/**
|
||||
* NiceCandidate:
|
||||
* @type: The type of candidate
|
||||
* @transport: The transport being used for the candidate
|
||||
* @addr: The #NiceAddress of the candidate
|
||||
* @base_addr: The #NiceAddress of the base address used by the candidate
|
||||
* @priority: The priority of the candidate <emphasis> see note </emphasis>
|
||||
* @stream_id: The ID of the stream to which belongs the candidate
|
||||
* @component_id: The ID of the component to which belongs the candidate
|
||||
* @foundation: The foundation of the candidate
|
||||
* @username: The candidate-specific username to use (overrides the one set
|
||||
* by nice_agent_set_local_credentials() or nice_agent_set_remote_credentials())
|
||||
* @password: The candidate-specific password to use (overrides the one set
|
||||
* by nice_agent_set_local_credentials() or nice_agent_set_remote_credentials())
|
||||
* @turn: The #TurnServer settings if the candidate is
|
||||
* of type %NICE_CANDIDATE_TYPE_RELAYED
|
||||
* @sockptr: The underlying socket
|
||||
*
|
||||
* A structure to represent an ICE candidate
|
||||
<note>
|
||||
<para>
|
||||
The @priority is an integer as specified in the ICE draft 19. If you are
|
||||
using the MSN or the GOOGLE compatibility mode (which are based on ICE
|
||||
draft 6, which uses a floating point qvalue as priority), then the @priority
|
||||
value will represent the qvalue multiplied by 1000.
|
||||
</para>
|
||||
</note>
|
||||
*/
|
||||
struct _NiceCandidate
|
||||
{
|
||||
NiceCandidateType type;
|
||||
NiceCandidateTransport transport;
|
||||
NiceAddress addr;
|
||||
NiceAddress base_addr;
|
||||
guint32 priority;
|
||||
guint stream_id;
|
||||
guint component_id;
|
||||
gchar foundation[NICE_CANDIDATE_MAX_FOUNDATION];
|
||||
gchar *username; /* pointer to a nul-terminated username string */
|
||||
gchar *password; /* pointer to a nul-terminated password string */
|
||||
TurnServer *turn;
|
||||
gpointer sockptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* nice_candidate_new:
|
||||
* @type: The #NiceCandidateType of the candidate to create
|
||||
*
|
||||
* Creates a new candidate. Must be freed with nice_candidate_free()
|
||||
*
|
||||
* Returns: A new #NiceCandidate
|
||||
*/
|
||||
NiceCandidate *
|
||||
nice_candidate_new (NiceCandidateType type);
|
||||
|
||||
/**
|
||||
* nice_candidate_free:
|
||||
* @candidate: The candidate to free
|
||||
*
|
||||
* Frees a #NiceCandidate
|
||||
*/
|
||||
void
|
||||
nice_candidate_free (NiceCandidate *candidate);
|
||||
|
||||
/**
|
||||
* nice_candidate_copy:
|
||||
* @candidate: The candidate to copy
|
||||
*
|
||||
* Makes a copy of a #NiceCandidate
|
||||
*
|
||||
* Returns: A new #NiceCandidate, a copy of @candidate
|
||||
*/
|
||||
NiceCandidate *
|
||||
nice_candidate_copy (const NiceCandidate *candidate);
|
||||
|
||||
/**
|
||||
* nice_candidate_equal_target:
|
||||
* @candidate1: A candidate
|
||||
* @candidate2: A candidate
|
||||
*
|
||||
* Verifies that the candidates point to the same place, meaning they have
|
||||
* the same transport and the same address. It ignores all other aspects.
|
||||
*
|
||||
* Returns: %TRUE if the candidates point to the same place
|
||||
*
|
||||
* Since: 0.1.15
|
||||
*/
|
||||
gboolean
|
||||
nice_candidate_equal_target (const NiceCandidate *candidate1,
|
||||
const NiceCandidate *candidate2);
|
||||
|
||||
GType nice_candidate_get_type (void);
|
||||
|
||||
/**
|
||||
* NICE_TYPE_CANDIDATE:
|
||||
*
|
||||
* A boxed type for a #NiceCandidate.
|
||||
*/
|
||||
#define NICE_TYPE_CANDIDATE nice_candidate_get_type ()
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBNICE_CANDIDATE_H__ */
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of the Nice GLib ICE library.
|
||||
*
|
||||
* (C) 2008 Collabora Ltd.
|
||||
* Contact: Youness Alaoui
|
||||
* (C) 2008 Nokia Corporation. All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Nice GLib ICE library.
|
||||
*
|
||||
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
|
||||
* Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Youness Alaoui, Collabora Ltd.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
||||
* case the provisions of LGPL are applicable instead of those above. If you
|
||||
* wish to allow use of your version of this file only under the terms of the
|
||||
* LGPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replace
|
||||
* them with the notice and other provisions required by the LGPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef __LIBNICE_DEBUG_H__
|
||||
#define __LIBNICE_DEBUG_H__
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:debug
|
||||
* @short_description: Debug messages utility functions
|
||||
* @stability: Unstable
|
||||
*
|
||||
* <para>Libnice can output a lot of information when debug messages are enabled.
|
||||
* This can significantly help track down problems and/or understand what
|
||||
* it's doing.</para>
|
||||
*
|
||||
* <para>You can enable/disable the debug messages by calling nice_debug_enable()
|
||||
* or nice_debug_disable() and choosing whether you want only ICE debug messages
|
||||
* or also stun debug messages.</para>
|
||||
*
|
||||
* <para>By default, the debug messages are disabled, unless the environment
|
||||
* variable NICE_DEBUG is set, in which case, it must contain a comma separated
|
||||
* list of flags specifying which debug to enable.</para>
|
||||
* <para> The currently available flags are "nice", "stun", "pseudotcp",
|
||||
* "pseudotcp-verbose" or "all" to enable all debug messages.</para>
|
||||
* <para> If the 'pseudotcp' flag is enabled, then 'pseudotcp-verbose' gets
|
||||
* automatically disabled. This is to allow the use of the 'all' flag without
|
||||
* having verbose messages from pseudotcp. You can enable verbose debug messages
|
||||
* from the pseudotcp layer by specifying 'pseudotcp-verbose' without the
|
||||
* 'pseudotcp' flag.</para>
|
||||
*
|
||||
*
|
||||
* <para>This API is unstable and is subject to change at any time...
|
||||
* More flags are to come and a better API to enable/disable each flag
|
||||
* should be added.</para>
|
||||
*/
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* nice_debug_enable:
|
||||
* @with_stun: Also enable STUN debugging messages
|
||||
*
|
||||
* Enables libnice debug output to the terminal. Note that the
|
||||
* `G_MESSAGES_DEBUG` and `NICE_DEBUG` environment variables must be set to the
|
||||
* set of logging domains to print, in order for any output to be printed. Set
|
||||
* them to `all` to print all debugging messages, or any of the following
|
||||
* domains:
|
||||
* - `libnice-stun`
|
||||
* - `libnice-tests`
|
||||
* - `libnice-socket`
|
||||
* - `libnice`
|
||||
* - `libnice-pseudotcp`
|
||||
* - `libnice-pseudotcp-verbose`
|
||||
*/
|
||||
void nice_debug_enable (gboolean with_stun);
|
||||
|
||||
/**
|
||||
* nice_debug_disable:
|
||||
* @with_stun: Also disable stun debugging messages
|
||||
*
|
||||
* Disables libnice debug output to the terminal
|
||||
*/
|
||||
void nice_debug_disable (gboolean with_stun);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBNICE_DEBUG_H__ */
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* interfaces.h - Source for interface discovery code
|
||||
*
|
||||
* Farsight Helper functions
|
||||
* Copyright (C) 2006 Youness Alaoui <kakaroto@kakaroto.homelinux.net>
|
||||
* Copyright (C) 2008-2009 Collabora, Nokia
|
||||
* Contact: Youness Alaoui
|
||||
* Copyright (C) 2008-2009 Nokia Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __LIBNICE_INTERFACES_H__
|
||||
#define __LIBNICE_INTERFACES_H__
|
||||
|
||||
/**
|
||||
* SECTION:interfaces
|
||||
* @short_description: Utility functions to discover local network interfaces
|
||||
* @include: interfaces.h
|
||||
* @stability: Stable
|
||||
*
|
||||
* These utility functions allow the discovery of local network interfaces
|
||||
* in a portable manner, they also allow finding the local ip addresses or
|
||||
* the address allocated to a network interface.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* nice_interfaces_get_ip_for_interface:
|
||||
* @interface_name: name of local interface
|
||||
*
|
||||
* Retrieves the IP address of an interface by its name. If this fails, %NULL
|
||||
* is returned.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a newly-allocated string with the IP
|
||||
* address
|
||||
*/
|
||||
gchar * nice_interfaces_get_ip_for_interface (gchar *interface_name);
|
||||
|
||||
|
||||
/**
|
||||
* nice_interfaces_get_local_ips:
|
||||
* @include_loopback: Include any loopback devices
|
||||
*
|
||||
* Get a list of local ipv4 interface addresses
|
||||
*
|
||||
* Returns: (element-type utf8) (transfer full): a newly-allocated #GList of
|
||||
* strings. The caller must free it.
|
||||
*/
|
||||
|
||||
GList * nice_interfaces_get_local_ips (gboolean include_loopback);
|
||||
|
||||
|
||||
/**
|
||||
* nice_interfaces_get_local_interfaces:
|
||||
*
|
||||
* Get the list of local interfaces
|
||||
*
|
||||
* Returns: (element-type utf8) (transfer full): a newly-allocated #GList of
|
||||
* strings. The caller must free it.
|
||||
*/
|
||||
GList * nice_interfaces_get_local_interfaces (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBNICE_INTERFACES_H__ */
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the Nice GLib ICE library.
|
||||
*
|
||||
* (C) 2006-2009 Collabora Ltd.
|
||||
* Contact: Youness Alaoui
|
||||
* (C) 2006-2009 Nokia Corporation. All rights reserved.
|
||||
* Contact: Kai Vehmanen
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Nice GLib ICE library.
|
||||
*
|
||||
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
|
||||
* Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Dafydd Harries, Collabora Ltd.
|
||||
* Youness Alaoui, Collabora Ltd.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
||||
* case the provisions of LGPL are applicable instead of those above. If you
|
||||
* wish to allow use of your version of this file only under the terms of the
|
||||
* LGPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replace
|
||||
* them with the notice and other provisions required by the LGPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef _NICE_H
|
||||
#define _NICE_H
|
||||
|
||||
#include "agent.h"
|
||||
#include "interfaces.h"
|
||||
|
||||
#endif /* _NICE_H */
|
||||
|
||||
@@ -0,0 +1,599 @@
|
||||
/*
|
||||
* This file is part of the Nice GLib ICE library.
|
||||
*
|
||||
* (C) 2010, 2014 Collabora Ltd.
|
||||
* Contact: Philip Withnall
|
||||
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Nice GLib ICE library.
|
||||
*
|
||||
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
|
||||
* Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Youness Alaoui, Collabora Ltd.
|
||||
* Philip Withnall, Collabora Ltd.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of the
|
||||
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
||||
* case the provisions of LGPL are applicable instead of those above. If you
|
||||
* wish to allow use of your version of this file only under the terms of the
|
||||
* LGPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replace
|
||||
* them with the notice and other provisions required by the LGPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef __LIBNICE_PSEUDOTCP_H__
|
||||
#define __LIBNICE_PSEUDOTCP_H__
|
||||
|
||||
/**
|
||||
* SECTION:pseudotcp
|
||||
* @short_description: Pseudo TCP implementation
|
||||
* @include: pseudotcp.h
|
||||
* @stability: Stable
|
||||
*
|
||||
* The #PseudoTcpSocket is an object implementing a Pseudo Tcp Socket for use
|
||||
* over UDP.
|
||||
* The socket will implement a subset of the TCP stack to allow for a reliable
|
||||
* transport over non-reliable sockets (such as UDP).
|
||||
*
|
||||
* See the file tests/test-pseudotcp.c in the source package for an example
|
||||
* of how to use the object.
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#ifndef __GTK_DOC_IGNORE__
|
||||
#ifdef G_OS_WIN32
|
||||
# include <winsock2.h>
|
||||
|
||||
#ifndef ECONNABORTED
|
||||
# define ECONNABORTED WSAECONNABORTED
|
||||
#endif
|
||||
|
||||
#ifndef ENOTCONN
|
||||
# define ENOTCONN WSAENOTCONN
|
||||
#endif
|
||||
|
||||
#ifndef EWOULDBLOCK
|
||||
# define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#endif
|
||||
|
||||
#ifndef ECONNRESET
|
||||
# define ECONNRESET WSAECONNRESET
|
||||
#endif
|
||||
|
||||
#ifndef EMSGSIZE
|
||||
# define EMSGSIZE WSAEMSGSIZE
|
||||
#endif
|
||||
|
||||
#ifndef ETIMEDOUT
|
||||
# define ETIMEDOUT WSAETIMEDOUT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "agent.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* PseudoTcpSocket:
|
||||
*
|
||||
* The #PseudoTcpSocket is the GObject implementing the Pseudo TCP Socket
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
typedef struct _PseudoTcpSocket PseudoTcpSocket;
|
||||
|
||||
typedef struct _PseudoTcpSocketClass PseudoTcpSocketClass;
|
||||
|
||||
GType pseudo_tcp_socket_get_type (void);
|
||||
|
||||
/* TYPE MACROS */
|
||||
#define PSEUDO_TCP_SOCKET_TYPE \
|
||||
(pseudo_tcp_socket_get_type ())
|
||||
#define PSEUDO_TCP_SOCKET(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), PSEUDO_TCP_SOCKET_TYPE, \
|
||||
PseudoTcpSocket))
|
||||
#define PSEUDO_TCP_SOCKET_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass), PSEUDO_TCP_SOCKET_TYPE, \
|
||||
PseudoTcpSocketClass))
|
||||
#define IS_PSEUDO_TCP_SOCKET(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), PSEUDO_TCP_SOCKET_TYPE))
|
||||
#define IS_PSEUDO_TCP_SOCKET_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass), PSEUDO_TCP_SOCKET_TYPE))
|
||||
#define PSEUDOTCP_SOCKET_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), PSEUDO_TCP_SOCKET_TYPE, \
|
||||
PseudoTcpSocketClass))
|
||||
|
||||
/**
|
||||
* PseudoTcpDebugLevel:
|
||||
* @PSEUDO_TCP_DEBUG_NONE: Disable debug messages
|
||||
* @PSEUDO_TCP_DEBUG_NORMAL: Enable basic debug messages
|
||||
* @PSEUDO_TCP_DEBUG_VERBOSE: Enable verbose debug messages
|
||||
*
|
||||
* Valid values of debug levels to be set.
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
typedef enum {
|
||||
PSEUDO_TCP_DEBUG_NONE = 0,
|
||||
PSEUDO_TCP_DEBUG_NORMAL,
|
||||
PSEUDO_TCP_DEBUG_VERBOSE,
|
||||
} PseudoTcpDebugLevel;
|
||||
|
||||
/**
|
||||
* PseudoTcpState:
|
||||
* @PSEUDO_TCP_LISTEN: The socket's initial state. The socket isn't connected and is
|
||||
* listening for an incoming connection
|
||||
* @PSEUDO_TCP_SYN_SENT: The socket has sent a connection request (SYN) packet and is
|
||||
* waiting for an answer
|
||||
* @PSEUDO_TCP_SYN_RECEIVED: The socket has received a connection request (SYN) packet.
|
||||
* @PSEUDO_TCP_ESTABLISHED: The socket is connected
|
||||
* @PSEUDO_TCP_CLOSED: The socket has been closed
|
||||
* @PSEUDO_TCP_FIN_WAIT_1: The socket has been closed locally but not remotely
|
||||
* (Since: 0.1.8)
|
||||
* @PSEUDO_TCP_FIN_WAIT_2: The socket has been closed locally but not remotely
|
||||
* (Since: 0.1.8)
|
||||
* @PSEUDO_TCP_CLOSING: The socket has been closed locally and remotely
|
||||
* (Since: 0.1.8)
|
||||
* @PSEUDO_TCP_TIME_WAIT: The socket has been closed locally and remotely
|
||||
* (Since: 0.1.8)
|
||||
* @PSEUDO_TCP_CLOSE_WAIT: The socket has been closed remotely but not locally
|
||||
* (Since: 0.1.8)
|
||||
* @PSEUDO_TCP_LAST_ACK: The socket has been closed locally and remotely
|
||||
* (Since: 0.1.8)
|
||||
*
|
||||
* An enum representing the state of the #PseudoTcpSocket. These states
|
||||
* correspond to the TCP states in RFC 793.
|
||||
* <para> See also: #PseudoTcpSocket:state </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
typedef enum {
|
||||
PSEUDO_TCP_LISTEN,
|
||||
PSEUDO_TCP_SYN_SENT,
|
||||
PSEUDO_TCP_SYN_RECEIVED,
|
||||
PSEUDO_TCP_ESTABLISHED,
|
||||
PSEUDO_TCP_CLOSED,
|
||||
PSEUDO_TCP_FIN_WAIT_1,
|
||||
PSEUDO_TCP_FIN_WAIT_2,
|
||||
PSEUDO_TCP_CLOSING,
|
||||
PSEUDO_TCP_TIME_WAIT,
|
||||
PSEUDO_TCP_CLOSE_WAIT,
|
||||
PSEUDO_TCP_LAST_ACK,
|
||||
} PseudoTcpState;
|
||||
|
||||
/**
|
||||
* PseudoTcpWriteResult:
|
||||
* @WR_SUCCESS: The write operation was successful
|
||||
* @WR_TOO_LARGE: The socket type requires that message be sent atomically
|
||||
* and the size of the message to be sent made this impossible.
|
||||
* @WR_FAIL: There was an error sending the message
|
||||
*
|
||||
* An enum representing the result value of the write operation requested by
|
||||
* the #PseudoTcpSocket.
|
||||
* <para> See also: %PseudoTcpCallbacks:WritePacket </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
typedef enum {
|
||||
WR_SUCCESS,
|
||||
WR_TOO_LARGE,
|
||||
WR_FAIL
|
||||
} PseudoTcpWriteResult;
|
||||
|
||||
/**
|
||||
* PseudoTcpShutdown:
|
||||
* @PSEUDO_TCP_SHUTDOWN_RD: Shut down the local reader only
|
||||
* @PSEUDO_TCP_SHUTDOWN_WR: Shut down the local writer only
|
||||
* @PSEUDO_TCP_SHUTDOWN_RDWR: Shut down both reading and writing
|
||||
*
|
||||
* Options for which parts of a connection to shut down when calling
|
||||
* pseudo_tcp_socket_shutdown(). These correspond to the values passed to POSIX
|
||||
* shutdown().
|
||||
*
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
typedef enum {
|
||||
PSEUDO_TCP_SHUTDOWN_RD,
|
||||
PSEUDO_TCP_SHUTDOWN_WR,
|
||||
PSEUDO_TCP_SHUTDOWN_RDWR,
|
||||
} PseudoTcpShutdown;
|
||||
|
||||
/**
|
||||
* PseudoTcpCallbacks:
|
||||
* @user_data: A user defined pointer to be passed to the callbacks
|
||||
* @PseudoTcpOpened: The #PseudoTcpSocket is now connected
|
||||
* @PseudoTcpReadable: The socket is readable
|
||||
* @PseudoTcpWritable: The socket is writable
|
||||
* @PseudoTcpClosed: The socket was closed (both sides)
|
||||
* @WritePacket: This callback is called when the socket needs to send data.
|
||||
*
|
||||
* A structure containing callbacks functions that will be called by the
|
||||
* #PseudoTcpSocket when some events happen.
|
||||
* <para> See also: #PseudoTcpWriteResult </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
typedef struct {
|
||||
gpointer user_data;
|
||||
void (*PseudoTcpOpened) (PseudoTcpSocket *tcp, gpointer data);
|
||||
void (*PseudoTcpReadable) (PseudoTcpSocket *tcp, gpointer data);
|
||||
void (*PseudoTcpWritable) (PseudoTcpSocket *tcp, gpointer data);
|
||||
void (*PseudoTcpClosed) (PseudoTcpSocket *tcp, guint32 error, gpointer data);
|
||||
PseudoTcpWriteResult (*WritePacket) (PseudoTcpSocket *tcp,
|
||||
const gchar * buffer, guint32 len, gpointer data);
|
||||
} PseudoTcpCallbacks;
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_new:
|
||||
* @conversation: The conversation id for the socket.
|
||||
* @callbacks: A pointer to the #PseudoTcpCallbacks structure for getting
|
||||
* notified of the #PseudoTcpSocket events.
|
||||
*
|
||||
* Creates a new #PseudoTcpSocket for the specified conversation
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
The @callbacks must be non-NULL, in order to get notified of packets the
|
||||
socket needs to send.
|
||||
</para>
|
||||
<para>
|
||||
If the @callbacks structure was dynamicly allocated, it can be freed
|
||||
after the call @pseudo_tcp_socket_new
|
||||
</para>
|
||||
</note>
|
||||
*
|
||||
* Returns: The new #PseudoTcpSocket object, %NULL on error
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
PseudoTcpSocket *pseudo_tcp_socket_new (guint32 conversation,
|
||||
PseudoTcpCallbacks *callbacks);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_connect:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Connects the #PseudoTcpSocket to the peer with the same conversation id.
|
||||
* The connection will only be successful after the
|
||||
* %PseudoTcpCallbacks:PseudoTcpOpened callback is called
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure (not in %TCP_LISTEN state)
|
||||
* <para> See also: pseudo_tcp_socket_get_error() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_connect(PseudoTcpSocket *self);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_recv:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @buffer: The buffer to fill with received data
|
||||
* @len: The length of @buffer
|
||||
*
|
||||
* Receive data from the socket.
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
Only call this on the %PseudoTcpCallbacks:PseudoTcpReadable callback.
|
||||
</para>
|
||||
<para>
|
||||
This function should be called in a loop. If this function does not
|
||||
return -1 with EWOULDBLOCK as the error, the
|
||||
%PseudoTcpCallbacks:PseudoTcpReadable callback will not be called again.
|
||||
</para>
|
||||
</note>
|
||||
*
|
||||
* Returns: The number of bytes received or -1 in case of error
|
||||
* <para> See also: pseudo_tcp_socket_get_error() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
gint pseudo_tcp_socket_recv(PseudoTcpSocket *self, char * buffer, size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_send:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @buffer: The buffer with data to send
|
||||
* @len: The length of @buffer
|
||||
*
|
||||
* Send data on the socket.
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
If this function return -1 with EWOULDBLOCK as the error, or if the return
|
||||
value is lower than @len, then the %PseudoTcpCallbacks:PseudoTcpWritable
|
||||
callback will be called when the socket will become writable.
|
||||
</para>
|
||||
</note>
|
||||
*
|
||||
* Returns: The number of bytes sent or -1 in case of error
|
||||
* <para> See also: pseudo_tcp_socket_get_error() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
gint pseudo_tcp_socket_send(PseudoTcpSocket *self, const char * buffer,
|
||||
guint32 len);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_close:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @force: %TRUE to close the socket forcefully, %FALSE to close it gracefully
|
||||
*
|
||||
* Close the socket for sending. If @force is set to %FALSE, the socket will
|
||||
* finish sending pending data before closing. If it is set to %TRUE, the socket
|
||||
* will discard pending data and close the connection immediately (sending a TCP
|
||||
* RST segment).
|
||||
*
|
||||
* The socket will be closed in both directions – sending and receiving – and
|
||||
* any pending received data must be read before calling this function, by
|
||||
* calling pseudo_tcp_socket_recv() until it blocks. If any pending data is in
|
||||
* the receive buffer when pseudo_tcp_socket_close() is called, a TCP RST
|
||||
* segment will be sent to the peer to notify it of the data loss.
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
The %PseudoTcpCallbacks:PseudoTcpClosed callback will not be called once
|
||||
the socket gets closed. It is only used for aborted connection.
|
||||
Instead, the socket gets closed when the pseudo_tcp_socket_get_next_clock()
|
||||
function returns FALSE.
|
||||
</para>
|
||||
</note>
|
||||
*
|
||||
* <para> See also: pseudo_tcp_socket_get_next_clock() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
void pseudo_tcp_socket_close(PseudoTcpSocket *self, gboolean force);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_shutdown:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @how: The directions of the connection to shut down.
|
||||
*
|
||||
* Shut down sending, receiving, or both on the socket, depending on the value
|
||||
* of @how. The behaviour of pseudo_tcp_socket_send() and
|
||||
* pseudo_tcp_socket_recv() will immediately change after this function returns
|
||||
* (depending on the value of @how), though the socket may continue to process
|
||||
* network traffic in the background even if sending or receiving data is
|
||||
* forbidden.
|
||||
*
|
||||
* This is equivalent to the POSIX shutdown() function. Setting @how to
|
||||
* %PSEUDO_TCP_SHUTDOWN_RDWR is equivalent to calling pseudo_tcp_socket_close().
|
||||
*
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
void pseudo_tcp_socket_shutdown (PseudoTcpSocket *self, PseudoTcpShutdown how);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_get_error:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Return the last encountered error.
|
||||
*
|
||||
<note>
|
||||
<para>
|
||||
The return value can be :
|
||||
<para>
|
||||
EINVAL (for pseudo_tcp_socket_connect()).
|
||||
</para>
|
||||
<para>
|
||||
EWOULDBLOCK or ENOTCONN (for pseudo_tcp_socket_recv() and
|
||||
pseudo_tcp_socket_send()).
|
||||
</para>
|
||||
</para>
|
||||
</note>
|
||||
*
|
||||
* Returns: The error code
|
||||
* <para> See also: pseudo_tcp_socket_connect() </para>
|
||||
* <para> See also: pseudo_tcp_socket_recv() </para>
|
||||
* <para> See also: pseudo_tcp_socket_send() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
int pseudo_tcp_socket_get_error(PseudoTcpSocket *self);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_get_next_clock:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @timeout: A pointer to be filled with the new timeout.
|
||||
*
|
||||
* Call this to determine the timeout needed before the next time call
|
||||
* to pseudo_tcp_socket_notify_clock() should be made.
|
||||
*
|
||||
* Returns: %TRUE if @timeout was filled, %FALSE if the socket is closed and
|
||||
* ready to be destroyed.
|
||||
*
|
||||
* <para> See also: pseudo_tcp_socket_notify_clock() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_get_next_clock(PseudoTcpSocket *self,
|
||||
guint64 *timeout);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_notify_clock:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Start the processing of receiving data, pending data or syn/acks.
|
||||
* Call this based on timeout value returned by
|
||||
* pseudo_tcp_socket_get_next_clock().
|
||||
* It's ok to call this too frequently.
|
||||
*
|
||||
* <para> See also: pseudo_tcp_socket_get_next_clock() </para>
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
void pseudo_tcp_socket_notify_clock(PseudoTcpSocket *self);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_notify_mtu:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @mtu: The new MTU of the socket
|
||||
*
|
||||
* Set the MTU of the socket
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
void pseudo_tcp_socket_notify_mtu(PseudoTcpSocket *self, guint16 mtu);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_notify_packet:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @buffer: The buffer containing the received data
|
||||
* @len: The length of @buffer
|
||||
*
|
||||
* Notify the #PseudoTcpSocket when a new packet arrives
|
||||
*
|
||||
* Returns: %TRUE if the packet was processed successfully, %FALSE otherwise
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_notify_packet(PseudoTcpSocket *self,
|
||||
const gchar * buffer, guint32 len);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_notify_message:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @message: A #NiceInputMessage containing the received data.
|
||||
*
|
||||
* Notify the #PseudoTcpSocket that a new message has arrived, and enqueue the
|
||||
* data in its buffers to the #PseudoTcpSocket’s receive buffer.
|
||||
*
|
||||
* Returns: %TRUE if the packet was processed successfully, %FALSE otherwise
|
||||
*
|
||||
* Since: 0.1.5
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_notify_message (PseudoTcpSocket *self,
|
||||
NiceInputMessage *message);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_set_debug_level:
|
||||
* @level: The level of debug to set
|
||||
*
|
||||
* Sets the debug level to enable/disable normal/verbose debug messages.
|
||||
*
|
||||
* Since: 0.0.11
|
||||
*/
|
||||
void pseudo_tcp_set_debug_level (PseudoTcpDebugLevel level);
|
||||
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_get_available_bytes:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Gets the number of bytes of data in the buffer that can be read without
|
||||
* receiving more packets from the network.
|
||||
*
|
||||
* Returns: The number of bytes or -1 if the connection is not established
|
||||
*
|
||||
* Since: 0.1.5
|
||||
*/
|
||||
|
||||
gint pseudo_tcp_socket_get_available_bytes (PseudoTcpSocket *self);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_can_send:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Returns if there is space in the send buffer to send any data.
|
||||
*
|
||||
* Returns: %TRUE if data can be sent, %FALSE otherwise
|
||||
*
|
||||
* Since: 0.1.5
|
||||
*/
|
||||
|
||||
gboolean pseudo_tcp_socket_can_send (PseudoTcpSocket *self);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_get_available_send_space:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Gets the number of bytes of space available in the transmission buffer.
|
||||
*
|
||||
* Returns: The number of bytes, or 0 if the connection is not established.
|
||||
*
|
||||
* Since: 0.1.5
|
||||
*/
|
||||
gsize pseudo_tcp_socket_get_available_send_space (PseudoTcpSocket *self);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_set_time:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
* @current_time: Current monotonic time, in milliseconds; or zero to use the
|
||||
* system monotonic clock.
|
||||
*
|
||||
* Sets the current monotonic time to be used by the TCP socket when calculating
|
||||
* timeouts and expiry times. If this function is not called, or is called with
|
||||
* @current_time as zero, g_get_monotonic_time() will be used. Otherwise, the
|
||||
* specified @current_time will be used until it is updated by calling this
|
||||
* function again.
|
||||
*
|
||||
* This function is intended for testing only, and should not be used in
|
||||
* production code.
|
||||
*
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
void pseudo_tcp_socket_set_time (PseudoTcpSocket *self, guint32 current_time);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_is_closed:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Gets whether the socket is closed, with the shutdown handshake completed,
|
||||
* and both peers no longer able to read or write data to the connection.
|
||||
*
|
||||
* Returns: %TRUE if the socket is closed in both directions, %FALSE otherwise
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_is_closed (PseudoTcpSocket *self);
|
||||
|
||||
/**
|
||||
* pseudo_tcp_socket_is_closed_remotely:
|
||||
* @self: The #PseudoTcpSocket object.
|
||||
*
|
||||
* Gets whether the socket has been closed on the remote peer’s side of the
|
||||
* connection (i.e. whether pseudo_tcp_socket_close() has been called there).
|
||||
* This is guaranteed to return %TRUE if pseudo_tcp_socket_is_closed() returns
|
||||
* %TRUE. It will not return %TRUE after pseudo_tcp_socket_close() is called
|
||||
* until a FIN segment is received from the remote peer.
|
||||
*
|
||||
* Returns: %TRUE if the remote peer has closed its side of the connection,
|
||||
* %FALSE otherwise
|
||||
* Since: 0.1.8
|
||||
*/
|
||||
gboolean pseudo_tcp_socket_is_closed_remotely (PseudoTcpSocket *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBNICE_PSEUDOTCP_H__ */
|
||||
|
||||
Reference in New Issue
Block a user