...
 
Commits (203)
......@@ -68,6 +68,8 @@ agent/test-restart
agent/test-thread
agent/Nice-*.gir
agent/Nice-*.typelib
agent/agent-enum-types.c
agent/agent-enum-types.h
# stun/ stuff
......@@ -134,7 +136,6 @@ tests/test-add-remove-stream
tests/test-address
tests/test-bsd
tests/test-build-io-stream
tests/test-dribble
tests/test-fallback
tests/test-fullmode
tests/test-icetcp
......@@ -145,6 +146,7 @@ tests/test-io-stream-thread
tests/test-io-stream-pollable
tests/test-send-recv
tests/test-mainloop
tests/test-new-trickle
tests/test-priority
tests/test-pseudotcp
tests/test-pseudotcp-fin
......@@ -153,8 +155,15 @@ tests/test-pseudotcp-fin
tests/test-restart
tests/test-tcp
tests/test-thread
tests/test-new-dribble
tests/test-trickle
tests/test-nomination
tests/test-credentials
tests/test-different-number-streams
tests/test-drop-invalid
tests/test-gstreamer
tests/test-socket-is-based-on
tests/test-turn
tests/test-udp-turn-fragmentation
# examples/ stuff
examples/simple-example
......@@ -185,3 +194,6 @@ ar-lib
# Code coverage
lcov/
# Meson builddir
_build/
image: registry.freedesktop.org/libnice/libnice/build-tools:centos-7
stages:
- build
- test
- deploy
build-and-test:
build autotools:
stage: build
image: registry.freedesktop.org/libnice/libnice/centos7/autotools-build
except:
- schedules
before_script:
- yum install -y net-tools
script:
- ifconfig
- export BUILD_ID="libnice-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
......@@ -16,27 +16,212 @@ build-and-test:
- mkdir "$PREFIX"
- ./autogen.sh --prefix="$PREFIX" --enable-compile-warnings=error --enable-gtk-doc --enable-introspection
- make
#- make check
- make install
#- make distcheck
artifacts:
when: on_failure
paths:
- nice/test-suite.log
- random/test-suite.log
- tests/test-suite.log
- stun/tests/test-suite.log
- config.log
untracked: true
test autotools:
stage: test
image: registry.freedesktop.org/libnice/libnice/centos7/autotools-build
except:
- schedules
dependencies:
- build autotools
script:
- ifconfig
- make check
artifacts:
when: always
paths:
- config.log
- nice/test-suite.log
- random/test-suite.log
- tests/test-suite.log
- stun/tests/test-suite.log
- docs/reference/libnice/test-suite.log
test autotools valgrind:
extends: test autotools
allow_failure: true
script:
- ifconfig
- make check-valgrind
distcheck autotools:
stage: test
image: registry.freedesktop.org/libnice/libnice/centos7/autotools-build
except:
- schedules
dependencies:
- build autotools
script:
- ifconfig
- make distcheck
artifacts:
paths:
- libnice-*.tar.gz
build meson:
stage: build
image: registry.freedesktop.org/libnice/libnice/centos7/meson-build
variables:
PREFIX: "${CI_PROJECT_DIR}/libnice-prefix"
except:
- schedules
before_script:
- mkdir -p "${CI_PROJECT_DIR}"
script:
## && true to make gitlab-ci happy
- source scl_source enable rh-python36 && true
- meson --werror --warnlevel 2 -Dgtk_doc=enabled --prefix=$PREFIX build/
- ninja-build -C build/
artifacts:
paths:
- build/
build msys2:
image: 'registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v6'
stage: 'build'
tags:
- 'docker'
- 'windows'
- '1607'
variables:
MESON_ARGS: >
--prefix=${CI_PROJECT_DIR}/libnice-prefix
# Make sure any failure in PowerShell scripts is fatal
ErrorActionPreference: 'Stop'
WarningPreference: 'Stop'
before_script:
- pip3 install -U meson
script:
# For some reason, options are separated by newline instead of space, so we
# have to replace them first.
- $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
- $env:PATH += ";C:\msys64\usr\bin;C:\msys64\mingw64/bin;C:\msys64\mingw32/bin"
# Build and run the tests.
# This is part of the same job due to a bug in the gitlab-runner
# that prevents us from exporting artifacts with docker-windows
# executors. It has since been fixed in gitlab 12.1, but
# we are blocked from upgrading currently.
#
# Gitlab Runner issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/4291
# Blocked upgrade issue: https://gitlab.freedesktop.org/gstreamer/gst-ci/issues/6#note_192780
- C:\msys64\usr\bin\bash -c "meson build $env:MESON_ARGS &&
ninja -C build &&
meson test -C build --print-errorlogs --suite libnice"
.build msvc:
extends: build msys2
script:
# For some reason, options are separated by newline instead of space, so we
# have to replace them first.
- $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
# Build and run the tests.
# This is part of the same job due to a bug in the gitlab-runner
# that prevents us from exporting artifacts with docker-windows
# executors. It has since been fixed in gitlab 12.1, but
# we are blocked from upgrading currently.
#
# Gitlab Runner issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/4291
# Blocked upgrade issue: https://gitlab.freedesktop.org/gstreamer/gst-ci/issues/6#note_192780
- New-Item -Path subprojects -Name openssl.wrap -Value "[wrap-git]`r`ndirectory=openssl`r`nurl=https://gitlab.freedesktop.org/libnice/openssl-binaries-for-ci.git`r`nrevision=1.1.1c`r`n"
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
meson subprojects download &&
meson wrap promote subprojects\glib\subprojects\libffi.wrap &&
meson wrap promote subprojects\glib\subprojects\zlib.wrap &&
meson wrap promote subprojects\glib\subprojects\proxy-libintl.wrap &&
meson subprojects download"
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
meson build $env:MESON_ARGS &&
ninja -C build &&
meson test -C build --print-errorlogs --suite libnice"
build msvc amd64:
extends: .build msvc
variables:
ARCH: 'amd64'
build msvc x86:
extends: .build msvc
variables:
ARCH: 'x86'
test meson:
stage: test
image: registry.freedesktop.org/libnice/libnice/centos7/meson-build
allow_failure: true
dependencies:
- build meson
except:
- schedules
script:
- ifconfig
- source scl_source enable rh-python36 && true
- meson test -C build/ --print-errorlogs
artifacts:
when: on_failure
paths:
- build/meson-logs/
test valgrind meson:
extends: test meson
script:
- ifconfig
- source scl_source enable rh-python36 && true
- meson test -C build/ --setup valgrind --print-errorlogs
doc-and-install meson:
stage: test
image: registry.freedesktop.org/libnice/libnice/centos7/meson-build
dependencies:
- build meson
except:
- schedules
variables:
PREFIX: "${CI_PROJECT_DIR}/libnice-prefix"
script:
- source scl_source enable rh-python36 && true
- ninja-build -C build/ libnice-doc
- ninja-build -C build/ install
- ls -lR ${PREFIX}
artifacts:
paths:
- build/docs/reference/libnice/html/
submit-to-coverity:
image: registry.freedesktop.org/libnice/libnice/build-tools/coverity:2017.07
stage: build
stage: test
image: registry.freedesktop.org/libnice/libnice/centos7/autotools-build
variables:
COVERITY_PROJECT: libnice
only:
- schedules
dependencies: []
script:
- curl -v https://scan.coverity.com/download/linux64 -o coverity_tool.tgz --form token="${COVERITY_TOKEN}" --form project="${COVERITY_PROJECT}" && tar xf coverity_tool.tgz && rm coverity_tool.tgz
- mv cov-analysis-linux64-* cov-analysis-linux64
- ./autogen.sh --prefix="$PREFIX" --disable-gtk-doc --disable-introspection
- make clean
- export PATH="$PATH:/root/cov-analysis-linux64-2017.07/bin"
- export PATH="$PATH:${CI_PROJECT_DIR}/cov-analysis-linux64/bin"
- echo $PATH
- cov-build --dir cov-int make -j4
- tar czvf libnice.tgz cov-int
- curl --form token=$COVERITY_TOKEN --form email=olivier.crete@ocrete.ca --form file=@libnice.tgz --form version="${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}" --form description="CI weekly run" https://scan.coverity.com/builds?project=libnice
pages:
stage: deploy
dependencies:
- doc-and-install meson
only:
- tags
artifacts:
paths:
- public
script:
- mv build/docs/reference/libnice/html/ public/
......@@ -26,15 +26,14 @@ DISTCHECK_CONFIGURE_FLAGS = --disable-assert -enable-gtk-doc --enable-introspect
EXTRA_DIST = \
COPYING.LGPL \
COPYING.MPL \
README.win32 \
autogen.sh \
common.mk \
scripts/lcov.mk \
scripts/lcov.sh \
scripts/valgrind-test-driver \
win32 \
win32/vs9/libnice.def \
m4/introspection.m4
m4/introspection.m4 \
meson.build \
meson_options.txt
MAINTAINERCLEANFILES = ar-lib
......@@ -42,23 +41,6 @@ dist_check_SCRIPTS = \
scripts/check-symbols.sh \
scripts/make-symbol-list.sh
# Generate the win32 DLL symbol export file.
# The stun_*() symbols at the end have historically been exported on Windows
# but not Linux, for no particular reason. They can’t be removed without
# breaking ABI. FIXME: Remove them when we next break ABI.
win32/vs9/libnice.def: nice/libnice.sym
$(MKDIR_P) $(dir $@)
$(AM_V_GEN)(echo "LIBRARY libnice"; \
echo ""; \
echo "EXPORTS"; \
echo ""; \
cat $<; \
echo "stun_debug"; \
echo "stun_debug_bytes"; \
echo "stun_hash_creds") > $@
CLEANFILES += win32/vs9/libnice.def
lcov:
find -name '*.gcda' -delete
$(MAKE) $(AM_MAKEFLAGS) check
......
libnice 0.1.16 (2019-05-09)
===========================
Add API to make it easier to implement ICE trickle
Add async closing of agent, to cleanly close TURN allocations
Add Google non-standard NOMINATION STUN attribute
Fix tests on Windows
Fix some racy tests
libnice 0.1.15 (2018-12-27)
===========================
Add support for Regular Nomination
Removal of the global lock over all agents
Add method to compare candidate targets
Added optional Meson build system, future releases will remove autotools
Renamed all members of PseudoTcpState enum (compile-time API change)
Now drops all packets from addresses that have not been validated by an ICE check
Multiple improvements to ICE interoperability
Improved RFC compliance
Improved OC2007 compatibility mode alternate-server support
libnice 0.1.14 (2017-04-03)
===========================
Improved RFC compliance
......
......@@ -5,7 +5,7 @@ Nice: GLib ICE library
Copyright
---------
(C) 2006-2017 Collabora Ltd.
(C) 2006-2018 Collabora Ltd.
(C) 2006-2011 Nokia Corporation
License
......@@ -16,9 +16,9 @@ See the file COPYING.
Requirements
------------
glib >= 2.44
glib >= 2.54
pkg-config
gnutls >= 2.12.0
gnutls >= 2.12.0 or OpenSSL
gupnp-igd >= 0.1.2 (optional)
gstreamer-0.10 >= 0.10.0 (optional)
gstreamer-1.0 (optional)
......@@ -32,9 +32,6 @@ Please refer to the INSTALL file for more details.
If you are building from git, you must first run the ./autogen.sh script
to generate the configure file for you.
To build on Windows, please refer to the README.win32 file for build instructions
using Microsoft Visual Studio.
Structure
---------
......
Microsoft Visual Studio v9.0 (aka Microsoft Visual Studio 2008)
---------------------------------------------------------------
1) Download prerequisites (glib, zlib and gettext-runtime)
Go to http://www.gtk.org/download/win32.php
Download GLib Run-time and Dev packages. At time of writing GLib current version is 2.28.8.
Links are
http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip
http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib-dev_2.28.8-1_win32.zip
Download zlib and gettext-runtime Run-time package. At time of writing zlib current version is 1.2.5
and gettext-runtime current version is 0.18.1.1
Links are
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib_1.2.5-2_win32.zip
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
Please not: these packages are no longer supported by libnice and newer packages are not provided.
You could use a gstreamer windows build for a current GLib build. Install the devel and runtime installer
and copy the glib directory over to your libnice source file as described below
http://gstreamer.freedesktop.org/data/pkg/windows/
libnice compiles fine with the version 1.4.5
2) Put glib in the correct path
Create a folder glib under libnice root as in the following picture:
libnice
|--- agent
|--- docs
|--- glib <--------------
|--- gst
| ...
|--- tests
|--- win32
| AUTHORS
| ...
| TODO
Expand glib_<current-version>_win32.zip, glib-dev_<current-version>_win32.zip,
zlib_<current-version>_win32.zip and gettext-runtime_<current-version>_win32.zip under glib
folder.
The tree should be like the following picture:
libnice
|--- ...
|--- glib
|-------- bin
|-------- etc
|-------- include
|-------- lib
|-------- manifest
|-------- share
|-------- src
|--- ...
3) Open win32/libnice.sln with Microsoft Visual Studio 2008
Build solution, output will be on libnice/win32/vs9/libnice/bin/Win32_Debug or libnice/win32/vs9/libnice/bin/Win32_Release
depending on the configuration chosen.
......@@ -30,6 +30,15 @@ CLEANFILES += $(BUILT_SOURCES)
noinst_LTLIBRARIES = libagent.la
pkginclude_HEADERS = \
agent.h \
candidate.h \
debug.h \
address.h \
interfaces.h \
pseudotcp.h \
$(NULL)
libagent_la_SOURCES = \
address.h \
address.c \
......@@ -60,22 +69,22 @@ libagent_la_SOURCES = \
outputstream.c \
$(BUILT_SOURCES)
agent-enum-types.h: agent.h Makefile
agent-enum-types.h: $(pkginclude_HEADERS) Makefile
$(AM_V_GEN)$(GLIB_MKENUMS) \
--fhead "#ifndef __AGENT_ENUM_TYPES_H__\n#define __AGENT_ENUM_TYPES_H__ 1\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
--fprod "/* enumerations from \"@filename@\" */\n" \
--vhead "GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define NICE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
--ftail "G_END_DECLS\n\n#endif /* !AGENT_ENUM_TYPES_H */" \
$(addprefix $(srcdir)/,agent.h) > $@
$(addprefix $(srcdir)/,$(pkginclude_HEADERS)) > $@
agent-enum-types.c: agent.h Makefile agent-enum-types.h
agent-enum-types.c: $(pkginclude_HEADERS) Makefile agent-enum-types.h
$(AM_V_GEN)$(GLIB_MKENUMS) \
--fhead "#include <config.h>\n#include <glib-object.h>\n#include \"agent.h\"\n#include \"agent-enum-types.h\"" \
--fhead "#include <config.h>\n#include <glib-object.h>\n#include \"agent.h\"\n#include \"pseudotcp.h\"\n#include \"agent-enum-types.h\"" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType type = 0;\n if (!type) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
--vtail " { 0, NULL, NULL }\n };\n type = g_@type@_register_static (\"@EnumName@\", values);\n }\n return type;\n}\n\n" \
$(addprefix $(srcdir)/,agent.h) > $@
$(addprefix $(srcdir)/,$(pkginclude_HEADERS)) > $@
libagent_la_LIBADD = \
$(top_builddir)/random/libnice-random.la \
......@@ -89,15 +98,6 @@ libagent_la_DEPENDENCIES = \
$(top_builddir)/socket/libsocket.la \
$(top_builddir)/stun/libstun.la
pkginclude_HEADERS = \
agent.h \
candidate.h \
debug.h \
address.h \
interfaces.h \
pseudotcp.h \
$(NULL)
if WINDOWS
libagent_la_LIBADD += -liphlpapi -lws2_32
endif
......@@ -131,3 +131,5 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
EXTRA_DIST = meson.build
......@@ -122,22 +122,12 @@ nice_input_message_iter_compare (const NiceInputMessageIter *a,
((obj)->compatibility == NICE_COMPATIBILITY_RFC5245 || \
(obj)->compatibility == NICE_COMPATIBILITY_OC2007R2)
/* A grace period before declaring a component as failed, in msecs. This
* delay is added to reduce the chance to see the agent receiving new
* stun activity just after the conncheck list has been declared failed,
* reactiviting conncheck activity, and causing a (valid) state
* transitions like that: connecting -> failed -> connecting ->
* connected -> ready.
* Such transitions are not buggy per-se, but may break the
* test-suite, that counts precisely the number of time each state
* has been set, and doesnt expect these transcient failed states.
*/
#define NICE_AGENT_MAX_TIMER_GRACE_PERIOD 1000
struct _NiceAgent
{
GObject parent; /* gobject pointer */
GMutex agent_mutex; /* Mutex used for thread-safe lib */
gboolean full_mode; /* property: full-mode */
gchar *stun_server_ip; /* property: STUN server IP */
guint stun_server_port; /* property: STUN server port */
......@@ -154,6 +144,8 @@ struct _NiceAgent
guint stun_initial_timeout; /* property: stun initial timeout, RTO */
guint stun_reliable_timeout; /* property: stun reliable timeout */
NiceNominationMode nomination_mode; /* property: Nomination mode */
gboolean support_renomination; /* property: support RENOMINATION STUN attribute */
guint idle_timeout; /* property: conncheck timeout before stop */
GSList *local_addresses; /* list of NiceAddresses for local
interfaces */
......@@ -188,8 +180,9 @@ struct _NiceAgent
guint16 rfc4571_expecting_length;
gboolean use_ice_udp;
gboolean use_ice_tcp;
gboolean use_ice_trickle;
guint conncheck_timer_grace_period; /* ongoing delay before timer stop */
guint conncheck_ongoing_idle_delay; /* ongoing delay before timer stop */
gboolean controlling_mode; /* controlling mode used by the
conncheck */
/* XXX: add pointer to internal data struct for ABI-safe extensions */
......@@ -208,8 +201,8 @@ NiceStream *agent_find_stream (NiceAgent *agent, guint stream_id);
void agent_gathering_done (NiceAgent *agent);
void agent_signal_gathering_done (NiceAgent *agent);
void agent_lock (void);
void agent_unlock (void);
void agent_lock (NiceAgent *agent);
void agent_unlock (NiceAgent *agent);
void agent_unlock_and_emit (NiceAgent *agent);
void agent_signal_new_selected_pair (
......@@ -235,8 +228,14 @@ void agent_signal_initial_binding_request_received (NiceAgent *agent, NiceStream
guint64 agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandidate *remote);
typedef gboolean (*NiceTimeoutLockedCallback)(NiceAgent *agent,
gpointer user_data);
void agent_timeout_add_with_context (NiceAgent *agent, GSource **out,
const gchar *name, guint interval, GSourceFunc function, gpointer data);
const gchar *name, guint interval, NiceTimeoutLockedCallback function,
gpointer data);
void agent_timeout_add_seconds_with_context (NiceAgent *agent, GSource **out,
const gchar *name, guint interval, NiceTimeoutLockedCallback function,
gpointer data);
StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent);
StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent);
......@@ -269,6 +268,9 @@ compact_output_message (const NiceOutputMessage *message, gsize *buffer_length);
gsize
output_message_get_size (const NiceOutputMessage *message);
gsize
input_message_get_size (const NiceInputMessage *message);
gssize agent_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len,
const gchar *buf);
......@@ -315,4 +317,12 @@ void nice_debug (const char *fmt, ...) G_GNUC_PRINTF (1, 2);
void nice_debug_verbose (const char *fmt, ...) G_GNUC_PRINTF (1, 2);
#endif
#if !GLIB_CHECK_VERSION(2, 59, 0)
#if __GNUC__ > 6
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
#else
#define G_GNUC_FALLTHROUGH
#endif /* __GNUC__ */
#endif
#endif /*_NICE_AGENT_PRIV_H */
This diff is collapsed.
......@@ -404,6 +404,9 @@ typedef enum
* is aggrssive mode (see #NiceNominationMode).
* @NICE_AGENT_OPTION_RELIABLE: Enables reliable mode, possibly using PseudoTCP, * see nice_agent_new_reliable().
* @NICE_AGENT_OPTION_LITE_MODE: Enable lite mode
* @NICE_AGENT_OPTION_ICE_TRICKLE: Enable ICE trickle mode
* @NICE_AGENT_OPTION_SUPPORT_RENOMINATION: Enable renomination triggered by NOMINATION STUN attribute
* proposed here: https://tools.ietf.org/html/draft-thatcher-ice-renomination-00
*
* These are options that can be passed to nice_agent_new_full(). They set
* various properties on the agent. Not including them sets the property to
......@@ -415,6 +418,8 @@ typedef enum {
NICE_AGENT_OPTION_REGULAR_NOMINATION = 1 << 0,
NICE_AGENT_OPTION_RELIABLE = 1 << 1,
NICE_AGENT_OPTION_LITE_MODE = 1 << 2,
NICE_AGENT_OPTION_ICE_TRICKLE = 1 << 3,
NICE_AGENT_OPTION_SUPPORT_RENOMINATION = 1 << 4,
} NiceAgentOption;
/**
......@@ -1487,15 +1492,6 @@ nice_agent_generate_local_candidate_sdp (
* Parse an SDP string and extracts candidates and credentials from it and sets
* them on the agent.
*
<note>
<para>
This function will return an error if a stream has not been assigned a name
with nice_agent_set_stream_name() as it becomes troublesome to assign the
streams from the agent to the streams in the SDP.
</para>
</note>
*
*
* <para>See also: nice_agent_set_stream_name() </para>
* <para>See also: nice_agent_generate_local_sdp() </para>
* <para>See also: nice_agent_parse_remote_stream_sdp() </para>
......@@ -1640,6 +1636,74 @@ nice_agent_get_component_state (NiceAgent *agent,
guint stream_id,
guint component_id);
/**
* nice_agent_peer_candidate_gathering_done:
* @agent: The #NiceAgent Object
* @stream_id: The ID of the stream
*
* Notifies the agent that the remote peer has concluded candidate gathering and
* thus no more remote candidates are expected to arrive for @stream_id.
*
* This will allow the stream components without a successful connectivity check
* to stop waiting for more candidates to come and finally transit into
* %NICE_COMPONENT_STATE_FAILED.
*
* Calling the function has an effect only when #NiceAgent:trickle-ice is %TRUE.
*
* Returns: %FALSE if the stream could not be found, %TRUE otherwise
*
* Since: 0.1.16
*/
gboolean
nice_agent_peer_candidate_gathering_done (
NiceAgent *agent,
guint stream_id);
/**
* nice_agent_close_async:
* @agent: The #NiceAgent object
* @callback: (nullable): A callback that will be called when the closing is
* complete
* @callback_data: (nullable): A pointer that will be passed to the callback
*
* Asynchronously closes resources the agent has allocated on remote servers.
*
* The agent will call the callback in the current #GMainContext in
* which this function is called. The #GAsyncResult in the callback
* can be ignored as this operation never fails.
*
* Calling this function before freeing the agent makes sure the allocated relay
* ports aren't left behind on TURN server but properly removed.
*
* Since: 0.1.16
*/
void
nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback,
gpointer callback_data);
/**
* nice_agent_get_sockets:
* @agent: The #NiceAgent Object
* @stream_id: The ID of the stream
* @component_id: The ID of the component
*
* Each component can have multiple sockets, this is an API to retrieve them all
* to be able to set properties. Most of the sockets for a component are created when
* calling nice_agent_gather_candidates(), so this API should be called right after to
* able to set properties on the sockets before they are used.
*
* These sockets can be a mix of UDP & TCP sockets depending on the compatibility mode
* and options that have been set.
*
* Returns: (element-type GSocket) (transfer full): An array
* containing all of the sockets for this component. Free with
* g_ptr_array_unref() when done.
*
* Since: 0.1.17
*/
GPtrArray *
nice_agent_get_sockets (NiceAgent *agent, guint stream_id, guint component_id);
G_END_DECLS
#endif /* __LIBNICE_AGENT_H__ */
......@@ -141,6 +141,10 @@ typedef struct _TurnServer TurnServer;
* @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
......@@ -152,6 +156,10 @@ struct _TurnServer
NiceAddress server;
gchar *username;
gchar *password;
guint8 *decoded_username;
guint8 *decoded_password;
gsize decoded_username_len;
gsize decoded_password_len;
NiceRelayType type;
};
......
This diff is collapsed.
......@@ -69,7 +69,6 @@ typedef struct _IncomingCheck IncomingCheck;
struct _CandidatePairKeepalive
{
NiceAgent *agent;
GSource *tick_source;
guint stream_id;
guint component_id;
......@@ -162,7 +161,7 @@ struct _NiceComponent {
GList *valid_candidates; /* list of owned remote NiceCandidates that are part of valid pairs */
GSList *socket_sources; /* list of SocketSource objs; must only grow monotonically */
guint socket_sources_age; /* incremented when socket_sources changes */
GSList *incoming_checks; /* list of IncomingCheck objs */
GQueue incoming_checks; /* list of IncomingCheck objs */
GList *turn_servers; /* List of TurnServer objs */
CandidatePair selected_pair; /* independent from checklists,
see ICE 11.1. "Sending Media" (ID-19) */
......@@ -200,10 +199,8 @@ struct _NiceComponent {
recv_messages */
GError **recv_buf_error; /* error information about failed reads */
NiceAgent *agent; /* unowned, immutable: can be accessed without holding the
* agent lock */
NiceStream *stream; /* unowned, immutable: can be accessed without holding
* the agent lock */
GWeakRef agent_ref;
guint stream_id;
StunAgent stun_agent; /* This stun agent is used to validate all stun requests */
......@@ -238,7 +235,7 @@ NiceComponent *
nice_component_new (guint component_id, NiceAgent *agent, NiceStream *stream);
void
nice_component_close (NiceComponent *component);
nice_component_close (NiceAgent *agent, NiceComponent *component);
gboolean
nice_component_find_pair (NiceComponent *component, NiceAgent *agent,
......@@ -248,7 +245,7 @@ void
nice_component_restart (NiceComponent *component);
void
nice_component_update_selected_pair (NiceComponent *component,
nice_component_update_selected_pair (NiceAgent *agent, NiceComponent *component,
const CandidatePair *pair);
NiceCandidate *
......@@ -263,7 +260,8 @@ void
nice_component_attach_socket (NiceComponent *component, NiceSocket *nsocket);
void
nice_component_remove_socket (NiceComponent *component, NiceSocket *nsocket);
nice_component_remove_socket (NiceAgent *agent, NiceComponent *component,
NiceSocket *nsocket);
void
nice_component_detach_all_sockets (NiceComponent *component);
......@@ -285,12 +283,12 @@ nice_component_set_io_callback (NiceComponent *component,
NiceInputMessage *recv_messages, guint n_recv_messages,
GError **error);
void
nice_component_emit_io_callback (NiceComponent *component,
nice_component_emit_io_callback (NiceAgent *agent, NiceComponent *component,
const guint8 *buf, gsize buf_len);
gboolean
nice_component_has_io_callback (NiceComponent *component);
void
nice_component_clean_turn_servers (NiceComponent *component);
nice_component_clean_turn_servers (NiceAgent *agent, NiceComponent *component);
TurnServer *
......@@ -304,13 +302,15 @@ void
turn_server_unref (TurnServer *turn);
void
nice_component_add_valid_candidate (NiceComponent *component,
nice_component_add_valid_candidate (NiceAgent *agent, NiceComponent *component,
const NiceCandidate *candidate);
gboolean
nice_component_verify_remote_candidate (NiceComponent *component,
const NiceAddress *address, NiceSocket *nicesock);
GPtrArray *
nice_component_get_sockets (NiceComponent *component);
G_END_DECLS
......
This diff is collapsed.
......@@ -83,7 +83,6 @@ struct _StunTransaction
struct _CandidateCheckPair
{
NiceAgent *agent; /* back pointer to owner */
guint stream_id;
guint component_id;
NiceCandidate *local;
......@@ -112,13 +111,15 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair);
void conn_check_prune_stream (NiceAgent *agent, NiceStream *stream);
gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *udp_socket, const NiceAddress *from, gchar *buf, guint len);
gint conn_check_compare (const CandidateCheckPair *a, const CandidateCheckPair *b);
void conn_check_remote_candidates_set(NiceAgent *agent, NiceStream *stream, NiceComponent *component);
void conn_check_remote_credentials_set(NiceAgent *agent, NiceStream *stream);
NiceCandidateTransport conn_check_match_transport (NiceCandidateTransport transport);
void
conn_check_prune_socket (NiceAgent *agent, NiceStream *stream, NiceComponent *component,
NiceSocket *sock);
guint32 ensure_unique_priority (NiceComponent *component, guint32 priority);
guint32 ensure_unique_priority (NiceStream *stream, NiceComponent *component,
guint32 priority);
void recalculate_pair_priorities (NiceAgent *agent);
#endif /*_NICE_CONNCHECK_H */
......@@ -61,8 +61,7 @@ static const GDebugKey keys[] = {
{ (gchar *)"nice", NICE_DEBUG_NICE },
{ (gchar *)"pseudotcp", NICE_DEBUG_PSEUDOTCP },
{ (gchar *)"pseudotcp-verbose", NICE_DEBUG_PSEUDOTCP_VERBOSE },
{ (gchar *)"nice-verbose", NICE_DEBUG_NICE_VERBOSE },
{ NULL, 0},
{ (gchar *)"nice-verbose", NICE_DEBUG_NICE_VERBOSE }
};
static const GDebugKey gkeys[] = {
......@@ -70,8 +69,7 @@ static const GDebugKey gkeys[] = {
{ (gchar *)"libnice", NICE_DEBUG_NICE },
{ (gchar *)"libnice-pseudotcp", NICE_DEBUG_PSEUDOTCP },
{ (gchar *)"libnice-pseudotcp-verbose", NICE_DEBUG_PSEUDOTCP_VERBOSE },
{ (gchar *)"libnice-verbose", NICE_DEBUG_NICE_VERBOSE },
{ NULL, 0},
{ (gchar *)"libnice-verbose", NICE_DEBUG_NICE_VERBOSE }
};
static void
......@@ -97,9 +95,9 @@ void nice_debug_init (void)
gflags_string = g_getenv ("G_MESSAGES_DEBUG");
if (flags_string)
flags = g_parse_debug_string (flags_string, keys, 4);
flags = g_parse_debug_string (flags_string, keys, G_N_ELEMENTS (keys));
if (gflags_string)
flags |= g_parse_debug_string (gflags_string, gkeys, 4);
flags |= g_parse_debug_string (gflags_string, gkeys, G_N_ELEMENTS (gkeys));
if (gflags_string && strstr (gflags_string, "libnice-pseudotcp-verbose"))
flags |= NICE_DEBUG_PSEUDOTCP_VERBOSE;
if (gflags_string && strstr (gflags_string, "libnice-verbose")) {
......@@ -167,7 +165,7 @@ void nice_debug (const char *fmt, ...)
void nice_debug_verbose (const char *fmt, ...)
{
va_list ap;
if (debug_verbose_enabled) {
if (debug_enabled && debug_verbose_enabled) {
va_start (ap, fmt);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, fmt, ap);
va_end (ap);
......
This diff is collapsed.
......@@ -46,15 +46,14 @@
typedef struct
{
NiceAgent *agent; /* back pointer to owner */
NiceCandidateType type; /* candidate type STUN or TURN */
NiceSocket *nicesock; /* XXX: should be taken from local cand: existing socket to use */
NiceAddress server; /* STUN/TURN server address */
GTimeVal next_tick; /* next tick timestamp */
gboolean pending; /* is discovery in progress? */
gboolean done; /* is discovery complete? */
NiceStream *stream;
NiceComponent *component;
guint stream_id;
guint component_id;
TurnServer *turn;
StunAgent stun_agent;
StunTimer timer;
......@@ -66,12 +65,11 @@ typedef struct
typedef struct
{
NiceAgent *agent; /* back pointer to owner */
NiceSocket *nicesock; /* existing socket to use */
NiceAddress server; /* STUN/TURN server address */
NiceCandidate *candidate; /* candidate to refresh */
NiceStream *stream;
NiceComponent *component;
guint stream_id;
guint component_id;
StunAgent stun_agent;
GSource *timer_source;
GSource *tick_source;
......@@ -80,13 +78,20 @@ typedef struct
StunMessage stun_message;
uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_resp_msg;
gboolean disposing;
GDestroyNotify destroy_cb;
gpointer destroy_cb_data;
} CandidateRefresh;
void refresh_free (NiceAgent *agent);
void refresh_prune_stream (NiceAgent *agent, guint stream_id);
void refresh_free (NiceAgent *agent, CandidateRefresh *refresh);
void refresh_prune_agent_async (NiceAgent *agent,
NiceTimeoutLockedCallback function, gpointer user_data);
void refresh_prune_stream_async (NiceAgent *agent, NiceStream *stream,
NiceTimeoutLockedCallback function);
void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate);
void refresh_prune_socket (NiceAgent *agent, NiceSocket *sock);
void refresh_cancel (CandidateRefresh *refresh);
void refresh_prune_candidate_async (NiceAgent *agent, NiceCandidate *candidate,
NiceTimeoutLockedCallback function);
void discovery_free (NiceAgent *agent);
......@@ -143,6 +148,7 @@ discovery_add_peer_reflexive_candidate (
NiceAgent *agent,
guint stream_id,
guint component_id,
guint32 priority,
NiceAddress *address,
NiceSocket *base_socket,
NiceCandidate *local,
......
......@@ -341,7 +341,7 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable,
if (agent == NULL)
return TRUE;
agent_lock ();
agent_lock (agent);
/* Shut down the read side of the pseudo-TCP stream, if it still exists. */
if (agent_find_component (agent, priv->stream_id, priv->component_id,
......@@ -350,7 +350,7 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable,
pseudo_tcp_socket_shutdown (component->tcp, PSEUDO_TCP_SHUTDOWN_RD);
}
agent_unlock ();
agent_unlock (agent);
g_object_unref (agent);
......@@ -376,7 +376,7 @@ nice_input_stream_is_readable (GPollableInputStream *stream)
if (agent == NULL)
return FALSE;
agent_lock ();
agent_lock (agent);
if (!agent_find_component (agent, priv->stream_id, priv->component_id,
&_stream, &component)) {
......@@ -405,7 +405,7 @@ nice_input_stream_is_readable (GPollableInputStream *stream)
}
done:
agent_unlock ();
agent_unlock (agent);
g_object_unref (agent);
......
......@@ -73,6 +73,13 @@
#endif /* G_OS_UNIX */
#ifdef IGNORED_IFACE_PREFIX
static const gchar *ignored_iface_prefix_list[] = {
IGNORED_IFACE_PREFIX,
NULL
};
#endif
#if (defined(G_OS_UNIX) && defined(HAVE_GETIFADDRS)) || defined(G_OS_WIN32)
/* Works on both UNIX and Windows. Magic! */
static gchar *
......@@ -143,7 +150,7 @@ nice_interfaces_get_local_interfaces (void)
struct ifconf ifc;
if ((sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
nice_debug ("error : Cannot open socket to retreive interface list");
nice_debug ("error : Cannot open socket to retrieve interface list");
return NULL;
}
......@@ -193,6 +200,7 @@ nice_interfaces_is_private_ip (const struct sockaddr *_sa)
union {
const struct sockaddr *addr;
const struct sockaddr_in *in;
const struct sockaddr_in6 *in6;
} sa;
sa.addr = _sa;
......@@ -213,6 +221,15 @@ nice_interfaces_is_private_ip (const struct sockaddr *_sa)
/* 169.254.x.x/16 (for APIPA) */
if (sa.in->sin_addr.s_addr >> 16 == 0xA9FE)
return TRUE;
} else if (sa.addr->sa_family == AF_INET6) {
/* fc00::/7 Unique local address (ULA) */
if ((sa.in6->sin6_addr.s6_addr[0] & 0xFE) == 0xFC)
return TRUE;
/* fe80::/10 link-local address */
if ( (sa.in6->sin6_addr.s6_addr[0] == 0xFE) &&
((sa.in6->sin6_addr.s6_addr[1] & 0xC0) == 0x80))
return TRUE;
}
return FALSE;
......@@ -243,7 +260,10 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
GList *ips = NULL;
struct ifaddrs *ifa, *results;
GList *loopbacks = NULL;
#ifdef IGNORED_IFACE_PREFIX
const gchar **prefix;
gboolean ignored = FALSE;
#endif
if (getifaddrs (&results) < 0)
return NULL;
......@@ -256,6 +276,10 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
if ((ifa->ifa_flags & IFF_UP) == 0)
continue;
/* no ip address from interface that isn't running */
if ((ifa->ifa_flags & IFF_RUNNING) == 0)
continue;
if (ifa->ifa_addr == NULL)
continue;
......@@ -276,18 +300,29 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
nice_debug ("Ignoring loopback interface");
g_free (addr_string);
}
continue;
}
#ifdef IGNORED_IFACE_PREFIX
} else if (g_str_has_prefix (ifa->ifa_name, IGNORED_IFACE_PREFIX)) {
nice_debug ("Ignoring interface %s as it matches prefix %s",
ifa->ifa_name, IGNORED_IFACE_PREFIX);
g_free (addr_string);
#endif
} else {
if (nice_interfaces_is_private_ip (ifa->ifa_addr))
ips = add_ip_to_list (ips, addr_string, TRUE);
else
ips = add_ip_to_list (ips, addr_string, FALSE);
ignored = FALSE;
for (prefix = ignored_iface_prefix_list; *prefix; prefix++) {
if (g_str_has_prefix (ifa->ifa_name, *prefix)) {
nice_debug ("Ignoring interface %s as it matches prefix %s",
ifa->ifa_name, *prefix);
g_free (addr_string);
ignored = true;
break;
}
}
if (ignored)
continue;
#endif
if (nice_interfaces_is_private_ip (ifa->ifa_addr))
ips = add_ip_to_list (ips, addr_string, TRUE);
else
ips = add_ip_to_list (ips, addr_string, FALSE);
}
freeifaddrs (results);
......@@ -309,10 +344,14 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
struct ifreq *ifr;
struct ifconf ifc;
struct sockaddr_in *sa;
gchar *loopback = NULL;
GList *loopbacks = NULL;
#ifdef IGNORED_IFACE_PREFIX
const gchar **prefix;
gboolean ignored = FALSE;
#endif
if ((sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
nice_debug ("Error : Cannot open socket to retreive interface list");
nice_debug ("Error : Cannot open socket to retrieve interface list");
return NULL;
}
......@@ -350,28 +389,52 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
" Skipping...", ifr->ifr_name);
continue; /* failed to get flags, skip it */
}
/* no ip address from interface that is down */
if ((ifr->ifr_flags & IFF_UP) == 0)
continue;
/* no ip address from interface that isn't running */
if ((ifr->ifr_flags & IFF_RUNNING) == 0)
continue;
sa = (struct sockaddr_in *) &ifr->ifr_addr;
nice_debug ("Interface: %s", ifr->ifr_name);
nice_debug ("IP Address: %s", inet_ntoa (sa->sin_addr));
if ((ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){
if (include_loopback)
loopback = g_strdup (inet_ntoa (sa->sin_addr));
loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa->sin_addr)), TRUE);
else
nice_debug ("Ignoring loopback interface");
} else {
if (nice_interfaces_is_private_ip ((struct sockaddr *) sa)) {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), TRUE);
} else {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), FALSE);
continue;
}
#ifdef IGNORED_IFACE_PREFIX
for (prefix = ignored_iface_prefix_list; *prefix; prefix++) {
if (g_str_has_prefix (ifr->ifr_name, *prefix)) {
nice_debug ("Ignoring interface %s as it matches prefix %s",
ifr->ifr_name, *prefix);
ignored = true;
break;
}
}
if (ignored)
continue;
#endif
if (nice_interfaces_is_private_ip ((struct sockaddr *) sa)) {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), TRUE);
} else {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), FALSE);
}
}
close (sockfd);
free (ifc.ifc_req);
if (loopback)
ips = add_ip_to_list (ips, loopback, TRUE);
if (loopbacks)
ips = g_list_concat (ips, loopbacks);
return ips;
}
......@@ -395,7 +458,7 @@ nice_interfaces_get_ip_for_interface (gchar *interface_name)
g_strlcpy (ifr.ifr_name, interface_name, sizeof (ifr.ifr_name));
if ((sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
nice_debug ("Error : Cannot open socket to retreive interface list");
nice_debug ("Error : Cannot open socket to retrieve interface list");
return NULL;
}
......@@ -458,7 +521,7 @@ SOCKET nice_interfaces_get_WSA_socket ()
if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) {
nice_debug ("Error : Could not open socket to retreive interface list,"
nice_debug ("Error : Could not open socket to retrieve interface list,"
" error no : %d", WSAGetLastError ());
return INVALID_SOCKET;
}
......
agent_headers = files([
'address.h',
'agent.h',
'candidate.h',
'debug.h',
'interfaces.h',
'pseudotcp.h',
])
install_headers(agent_headers, subdir : 'nice')
agent_include = include_directories('.')
agent_sources = files([
'address.c',
'agent.c',
'candidate.c',
'component.c',
'conncheck.c',
'debug.c',
'discovery.c',
'inputstream.c',
'interfaces.c',
'iostream.c',
'outputstream.c',
'pseudotcp.c',
'stream.c',
])
gnome = import('gnome')
agent_enum_types_c = gnome.mkenums('agent-enum-types.c', sources : agent_headers,
fhead: '#include <config.h>\n#include <glib-object.h>\n#include "agent.h"\n#include "pseudotcp.h"\n#include "agent-enum-types.h"',
fprod: '\n/* enumerations from "@filename@" */',
vhead: 'GType\n@enum_name@_get_type (void)\n{\n static GType type = 0;\n if (!type) {\n static const G@Type@Value values[] = {',
vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
vtail: ' { 0, NULL, NULL }\n };\n type = g_@type@_register_static ("@EnumName@", values);\n }\n return type;\n}\n\n')
agent_enum_types_h = gnome.mkenums('agent-enum-types.h', sources : agent_headers,
fhead: '#ifndef __AGENT_ENUM_TYPES_H__\n#define __AGENT_ENUM_TYPES_H__ 1\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
fprod: '/* enumerations from "@filename@" */\n',
vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define NICE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
ftail: 'G_END_DECLS\n\n#endif /* !AGENT_ENUM_TYPES_H */')
libagent = static_library('agent',
agent_enum_types_c, agent_enum_types_h, agent_sources,
c_args: ['-DG_LOG_DOMAIN="libnice"'],
include_directories: nice_incs,
dependencies: nice_deps,
install: false)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -87,6 +87,7 @@ struct _NiceStream {
gchar remote_password[NICE_STREAM_MAX_PWD];
gboolean gathering;
gboolean gathering_started;
gboolean peer_gathering_done;
gint tos;
guint tick_counter;
};
......@@ -98,10 +99,10 @@ typedef struct {
GType nice_stream_get_type (void);
NiceStream *
nice_stream_new (guint n_components, NiceAgent *agent);
nice_stream_new (guint stream_id, guint n_components, NiceAgent *agent);
void
nice_stream_close (NiceStream *stream);
nice_stream_close (NiceAgent *agent, NiceStream *stream);
NiceComponent *
nice_stream_find_component_by_id (NiceStream *stream, guint id);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,3 +24,4 @@ test_LDADD = libnice-random.la $(GLIB_LIBS)
TESTS = $(check_PROGRAMS)
EXTRA_DIST = meson.build
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.