Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
6bb6d6a0
Commit
6bb6d6a0
authored
Aug 04, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding udp turn socket factory
parent
68d331dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
203 additions
and
0 deletions
+203
-0
udp/Makefile.am
udp/Makefile.am
+2
-0
udp/udp-turn.c
udp/udp-turn.c
+152
-0
udp/udp-turn.h
udp/udp-turn.h
+49
-0
No files found.
udp/Makefile.am
View file @
6bb6d6a0
...
...
@@ -22,6 +22,8 @@ libudp_la_SOURCES = \
udp-generic.c
\
udp-bsd.h
\
udp-bsd.c
\
udp-turn.h
\
udp-turn.c
\
udp-fake.h
\
udp-fake.c
...
...
udp/udp-turn.c
0 → 100644
View file @
6bb6d6a0
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* Contact: Youness Alaoui
*
* 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.
* Rémi Denis-Courmont, Nokia
* 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.
*/
/*
* Implementation of UDP socket interface using Berkeley sockets. (See
* http://en.wikipedia.org/wiki/Berkeley_sockets.)
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "udp-turn.h"
#include "udp-bsd.h"
#include <stun/stunagent.h>
typedef
struct
{
StunAgent
agent
;
int
locked
;
NiceUDPSocket
udp_socket
;
}
turn_priv
;
static
gint
socket_recv
(
NiceUDPSocket
*
sock
,
NiceAddress
*
from
,
guint
len
,
gchar
*
buf
)
{
turn_priv
*
priv
=
(
turn_priv
*
)
sock
->
priv
;
return
nice_udp_socket_recv
(
&
priv
->
udp_socket
,
from
,
len
,
buf
);
}
static
gboolean
socket_send
(
NiceUDPSocket
*
sock
,
const
NiceAddress
*
to
,
guint
len
,
const
gchar
*
buf
)
{
turn_priv
*
priv
=
(
turn_priv
*
)
sock
->
priv
;
nice_udp_socket_send
(
&
priv
->
udp_socket
,
to
,
len
,
buf
);
return
TRUE
;
}
static
void
socket_close
(
NiceUDPSocket
*
sock
)
{
turn_priv
*
priv
=
(
turn_priv
*
)
sock
->
priv
;
nice_udp_socket_close
(
&
priv
->
udp_socket
);
g_free
(
priv
);
}
/*** NiceUDPSocketFactory ***/
static
gboolean
socket_factory_init_socket
(
G_GNUC_UNUSED
NiceUDPSocketFactory
*
man
,
NiceUDPSocket
*
sock
,
NiceAddress
*
addr
)
{
NiceUDPSocketFactory
*
udp_socket_factory
=
man
->
priv
;
turn_priv
*
priv
=
g_new0
(
turn_priv
,
1
);
if
(
nice_udp_socket_factory_make
(
udp_socket_factory
,
&
priv
->
udp_socket
,
addr
)
==
FALSE
)
{
g_free
(
priv
);
return
FALSE
;
}
stun_agent_init
(
&
priv
->
agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_IGNORE_CREDENTIALS
);
sock
->
fileno
=
priv
->
udp_socket
.
fileno
;
sock
->
send
=
socket_send
;
sock
->
recv
=
socket_recv
;
sock
->
close
=
socket_close
;
sock
->
priv
=
(
void
*
)
priv
;
return
TRUE
;
}
static
void
socket_factory_close
(
G_GNUC_UNUSED
NiceUDPSocketFactory
*
man
)
{
NiceUDPSocketFactory
*
udp_socket_factory
=
man
->
priv
;
nice_udp_socket_factory_close
(
udp_socket_factory
);
g_free
(
udp_socket_factory
);
}
NICEAPI_EXPORT
void
nice_udp_turn_socket_factory_init
(
G_GNUC_UNUSED
NiceUDPSocketFactory
*
man
)
{
NiceUDPSocketFactory
*
udp_socket_factory
=
g_new0
(
NiceUDPSocketFactory
,
1
);
man
->
init
=
socket_factory_init_socket
;
man
->
close
=
socket_factory_close
;
nice_udp_bsd_socket_factory_init
(
udp_socket_factory
);
man
->
priv
=
(
void
*
)
udp_socket_factory
;
}
udp/udp-turn.h
0 → 100644
View file @
6bb6d6a0
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* Contact: Youness Alaoui
*
* 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.
*
* 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 _GOOGLE_RELAY_H
#define _GOOGLE_RELAY_H
#include "udp.h"
G_BEGIN_DECLS
void
nice_udp_turn_socket_factory_init
(
NiceUDPSocketFactory
*
man
);
G_END_DECLS
#endif
/* _UDP_BSD_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment