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
bd4e444b
Commit
bd4e444b
authored
Jan 29, 2007
by
Dafydd Harries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor STUN handling code
darcs-hash:20070129185951-c9803-df57e1d824411b0e9766074e3ece5777bf896991.gz
parent
ae2172a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
21 deletions
+31
-21
agent/agent.c
agent/agent.c
+31
-21
No files found.
agent/agent.c
View file @
bd4e444b
...
@@ -338,6 +338,36 @@ _stream_lookup (NiceAgent *agent, guint stream_id)
...
@@ -338,6 +338,36 @@ _stream_lookup (NiceAgent *agent, guint stream_id)
}
}
static
void
_handle_stun
(
NiceAgent
*
agent
,
UDPSocket
*
sock
,
struct
sockaddr_in
from
,
StunMessage
*
msg
)
{
StunMessage
*
response
;
guint
len
;
gchar
*
packed
;
if
(
msg
->
type
!=
STUN_MESSAGE_BINDING_REQUEST
)
return
;
response
=
stun_message_new
(
STUN_MESSAGE_BINDING_RESPONSE
);
memcpy
(
response
->
transaction_id
,
msg
->
transaction_id
,
16
);
response
->
attributes
=
g_malloc0
(
2
*
sizeof
(
StunAttribute
));
response
->
attributes
[
0
]
=
stun_attribute_mapped_address_new
(
ntohl
(
from
.
sin_addr
.
s_addr
),
ntohs
(
from
.
sin_port
));
len
=
stun_message_pack
(
response
,
&
packed
);
udp_socket_send
(
sock
,
&
from
,
len
,
packed
);
g_free
(
packed
);
stun_message_free
(
response
);
/* XXX: perform a triggered connectivity check here */
/* or is that only for full implementations? */
}
/**
/**
* ice_agent_recv (agent, candidate)
* ice_agent_recv (agent, candidate)
*
*
...
@@ -420,30 +450,10 @@ nice_agent_recv (
...
@@ -420,30 +450,10 @@ nice_agent_recv (
if
(
msg
==
NULL
)
if
(
msg
==
NULL
)
return
;
return
;
if
(
msg
->
type
==
STUN_MESSAGE_BINDING_REQUEST
)
{
StunMessage
*
response
;
guint
len
;
gchar
*
packed
;
response
=
stun_message_new
(
STUN_MESSAGE_BINDING_RESPONSE
);
memcpy
(
response
->
transaction_id
,
msg
->
transaction_id
,
16
);
response
->
attributes
=
g_malloc0
(
2
*
sizeof
(
StunAttribute
));
response
->
attributes
[
0
]
=
stun_attribute_mapped_address_new
(
ntohl
(
from
.
sin_addr
.
s_addr
),
ntohs
(
from
.
sin_port
));
len
=
stun_message_pack
(
response
,
&
packed
);
udp_socket_send
(
&
(
candidate
->
sock
),
&
from
,
len
,
packed
);
g_free
(
packed
);
stun_message_free
(
response
);
/* XXX: perform a triggered connectivity check here */
/* or is that only for full implementations? */
}
/* XXX: handle the case where the incoming packet is a response for a
/* XXX: handle the case where the incoming packet is a response for a
* binding request we sent */
* binding request we sent */
_handle_stun
(
agent
,
&
(
candidate
->
sock
),
from
,
msg
);
stun_message_free
(
msg
);
stun_message_free
(
msg
);
}
}
}
}
...
...
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