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
b34ed789
Commit
b34ed789
authored
Jul 30, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simpler method for generating the username. also fix a typo, and add support for msn usernames
parent
7a16e23d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
agent/conncheck.c
agent/conncheck.c
+28
-24
No files found.
agent/conncheck.c
View file @
b34ed789
...
@@ -967,10 +967,11 @@ gboolean conn_check_prune_stream (NiceAgent *agent, Stream *stream)
...
@@ -967,10 +967,11 @@ gboolean conn_check_prune_stream (NiceAgent *agent, Stream *stream)
*/
*/
static
static
size_t
priv_gen_username
(
NiceAgent
*
agent
,
guint
component_id
,
size_t
priv_gen_username
(
NiceAgent
*
agent
,
guint
component_id
,
uint8_t
*
remote
,
size_t
remote_len
,
uint8_t
*
local
,
size_t
local_len
,
gchar
*
remote
,
gchar
*
local
,
uint8_t
*
dest
,
guint
dest_len
)
uint8_t
*
dest
,
guint
dest_len
)
{
{
guint
len
=
0
;
guint
len
=
0
;
gsize
remote_len
=
strlen
(
remote
);
gsize
local_len
=
strlen
(
local
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_ID19
&&
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_ID19
&&
dest_len
>=
remote_len
+
local_len
+
1
)
{
dest_len
>=
remote_len
+
local_len
+
1
)
{
...
@@ -989,10 +990,18 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
...
@@ -989,10 +990,18 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
gchar
component_str
[
10
];
gchar
component_str
[
10
];
g_snprintf
(
component_str
,
sizeof
(
component_str
),
"%d"
,
component_id
);
g_snprintf
(
component_str
,
sizeof
(
component_str
),
"%d"
,
component_id
);
guchar
*
local_decoded
=
NULL
;
if
(
dest_len
>=
remote_len
+
local_len
+
3
+
2
*
strlen
(
component_str
))
{
guchar
*
remote_decoded
=
NULL
;
memcpy
(
dest
,
remote
,
remote_len
);
gsize
local_decoded_len
;
len
+=
remote_len
;
gsize
remote_decoded_len
;
local_decoded
=
g_base64_decode
(
local
,
&
local_decoded_len
);
remote_decoded
=
g_base64_decode
(
remote
,
&
remote_decoded_len
);
if
(
dest_len
>=
remote_decoded_len
+
local_decoded_len
+
3
+
2
*
strlen
(
component_str
))
{
memcpy
(
dest
,
remote_decoded
,
remote_decoded_len
);
len
+=
remote_decoded_len
;
memcpy
(
dest
+
len
,
":"
,
1
);
memcpy
(
dest
+
len
,
":"
,
1
);
len
++
;
len
++
;
memcpy
(
dest
+
len
,
component_str
,
strlen
(
component_str
));
memcpy
(
dest
+
len
,
component_str
,
strlen
(
component_str
));
...
@@ -1001,13 +1010,16 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
...
@@ -1001,13 +1010,16 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
memcpy
(
dest
+
len
,
":"
,
1
);
memcpy
(
dest
+
len
,
":"
,
1
);
len
++
;
len
++
;
memcpy
(
dest
+
len
,
local
,
local
_len
);
memcpy
(
dest
+
len
,
local
_decoded
,
local_decoded
_len
);
len
+=
local_len
;
len
+=
local_
decoded_
len
;
memcpy
(
dest
+
len
,
":"
,
1
);
memcpy
(
dest
+
len
,
":"
,
1
);
len
++
;
len
++
;
memcpy
(
dest
+
len
,
component_str
,
strlen
(
component_str
));;
memcpy
(
dest
+
len
,
component_str
,
strlen
(
component_str
));;
len
+=
strlen
(
component_str
);
len
+=
strlen
(
component_str
);
}
}
g_free
(
local_decoded
);
g_free
(
remote_decoded
);
}
}
return
len
;
return
len
;
...
@@ -1023,42 +1035,34 @@ size_t priv_create_username (NiceAgent *agent, Stream *stream,
...
@@ -1023,42 +1035,34 @@ size_t priv_create_username (NiceAgent *agent, Stream *stream,
guint
component_id
,
NiceCandidate
*
remote
,
NiceCandidate
*
local
,
guint
component_id
,
NiceCandidate
*
remote
,
NiceCandidate
*
local
,
uint8_t
*
dest
,
guint
dest_len
,
gboolean
inbound
)
uint8_t
*
dest
,
guint
dest_len
,
gboolean
inbound
)
{
{
uint8_t
*
local_username
=
NULL
;
gchar
*
local_username
=
NULL
;
size_t
local_username_len
=
0
;
gchar
*
remote_username
=
NULL
;
uint8_t
*
remote_username
=
NULL
;
size_t
remote_username_len
=
0
;
if
(
remote
&&
remote
->
username
)
{
if
(
remote
&&
remote
->
username
)
{
remote_username
=
(
uint8_t
*
)
remote
->
username
;
remote_username
=
remote
->
username
;
remote_username_len
=
(
size_t
)
strlen
(
remote
->
username
);
}
}
if
(
local
&&
local
->
username
)
{
if
(
local
&&
local
->
username
)
{
local_username
=
(
uint8_t
*
)
remote
->
username
;
local_username
=
local
->
username
;
local_username_len
=
(
size_t
)
strlen
(
remote
->
username
);
}
}
if
(
stream
)
{
if
(
stream
)
{
if
(
remote_username
==
NULL
)
{
if
(
remote_username
==
NULL
)
{
remote_username
=
(
uint8_t
*
)
stream
->
remote_ufrag
;
remote_username
=
stream
->
remote_ufrag
;
remote_username_len
=
(
size_t
)
strlen
(
stream
->
remote_ufrag
);
}
}
if
(
local_username
==
NULL
)
{
if
(
local_username
==
NULL
)
{
local_username
=
(
uint8_t
*
)
stream
->
local_ufrag
;
local_username
=
stream
->
local_ufrag
;
local_username_len
=
(
size_t
)
strlen
(
stream
->
local_ufrag
);
}
}
}
}
if
(
local_username
&&
remote_username
)
{
if
(
local_username
&&
remote_username
)
{
if
(
inbound
)
{
if
(
inbound
)
{
return
priv_gen_username
(
agent
,
component_id
,
return
priv_gen_username
(
agent
,
component_id
,
local_username
,
local_username_len
,
local_username
,
remote_username
,
dest
,
dest_len
);
remote_username
,
remote_username_len
,
dest
,
dest_len
);
}
else
{
}
else
{
return
priv_gen_username
(
agent
,
component_id
,
return
priv_gen_username
(
agent
,
component_id
,
remote_username
,
remote_username_len
,
remote_username
,
local_username
,
dest
,
dest_len
);
local_username
,
local_username_len
,
dest
,
dest_len
);
}
}
}
}
...
...
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