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
da1a1c21
Commit
da1a1c21
authored
May 08, 2008
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass compat flag everywhere to not put stun-server into packets in gtalk mode
parent
1aeb122c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
26 deletions
+30
-26
stun/stun-ice.c
stun/stun-ice.c
+3
-3
stun/stun-msg.h
stun/stun-msg.h
+4
-3
stun/stund.c
stun/stund.c
+3
-3
stun/stunsend.c
stun/stunsend.c
+12
-9
stun/tests/test-bind.c
stun/tests/test-bind.c
+4
-4
stun/tests/test-conncheck.c
stun/tests/test-conncheck.c
+1
-1
stun/tests/test-format.c
stun/tests/test-format.c
+3
-3
No files found.
stun/stun-ice.c
View file @
da1a1c21
...
@@ -60,7 +60,7 @@ stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req,
...
@@ -60,7 +60,7 @@ stun_bind_error (uint8_t *buf, size_t *plen, const uint8_t *req,
*
plen
=
0
;
*
plen
=
0
;
DBG
(
"STUN Error Reply (buffer size: %u)...
\n
"
,
(
unsigned
)
len
);
DBG
(
"STUN Error Reply (buffer size: %u)...
\n
"
,
(
unsigned
)
len
);
val
=
stun_init_error
(
buf
,
len
,
req
,
code
);
val
=
stun_init_error
(
buf
,
len
,
req
,
code
,
compat
);
if
(
val
)
if
(
val
)
return
val
;
return
val
;
...
@@ -111,7 +111,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
...
@@ -111,7 +111,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
if
(
stun_has_unknown
(
msg
))
if
(
stun_has_unknown
(
msg
))
{
{
DBG
(
" Unknown mandatory attributes in message.
\n
"
);
DBG
(
" Unknown mandatory attributes in message.
\n
"
);
val
=
stun_init_error_unknown
(
buf
,
len
,
msg
);
val
=
stun_init_error_unknown
(
buf
,
len
,
msg
,
compat
);
if
(
!
val
)
if
(
!
val
)
val
=
stun_finish_short
(
buf
,
&
len
,
NULL
,
pass
,
NULL
,
compat
);
val
=
stun_finish_short
(
buf
,
&
len
,
NULL
,
pass
,
NULL
,
compat
);
if
(
val
)
if
(
val
)
...
@@ -186,7 +186,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
...
@@ -186,7 +186,7 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
DBG
(
"STUN Role not specified by peer!
\n
"
);
DBG
(
"STUN Role not specified by peer!
\n
"
);
#endif
#endif
stun_init_response
(
buf
,
len
,
msg
);
stun_init_response
(
buf
,
len
,
msg
,
compat
);
if
(
compat
==
1
)
{
if
(
compat
==
1
)
{
val
=
stun_append_addr
(
buf
,
len
,
STUN_MAPPED_ADDRESS
,
src
,
srclen
);
val
=
stun_append_addr
(
buf
,
len
,
STUN_MAPPED_ADDRESS
,
src
,
srclen
);
}
else
{
}
else
{
...
...
stun/stun-msg.h
View file @
da1a1c21
...
@@ -546,7 +546,7 @@ void stun_init_indication (uint8_t *msg, stun_method_t m);
...
@@ -546,7 +546,7 @@ void stun_init_indication (uint8_t *msg, stun_method_t m);
*
*
* ans == req is allowed.
* ans == req is allowed.
*/
*/
void
stun_init_response
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
);
void
stun_init_response
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
compat
);
/**
/**
* Initializes a STUN error response message buffer with an ERROR-CODE
* Initializes a STUN error response message buffer with an ERROR-CODE
...
@@ -564,7 +564,7 @@ void stun_init_response (uint8_t *ans, size_t msize, const uint8_t *req);
...
@@ -564,7 +564,7 @@ void stun_init_response (uint8_t *ans, size_t msize, const uint8_t *req);
* ans == req is allowed.
* ans == req is allowed.
*/
*/
int
stun_init_error
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
stun_init_error
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
stun_error_t
err
);
stun_error_t
err
,
int
compat
);
/**
/**
* Initializes a STUN error response message buffer, in response to a valid
* Initializes a STUN error response message buffer, in response to a valid
...
@@ -578,7 +578,8 @@ int stun_init_error (uint8_t *ans, size_t msize, const uint8_t *req,
...
@@ -578,7 +578,8 @@ int stun_init_error (uint8_t *ans, size_t msize, const uint8_t *req,
*
*
* ans == req is allowed.
* ans == req is allowed.
*/
*/
int
stun_init_error_unknown
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
);
int
stun_init_error_unknown
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
compat
);
size_t
size_t
stun_finish_long
(
uint8_t
*
msg
,
size_t
*
restrict
plen
,
stun_finish_long
(
uint8_t
*
msg
,
size_t
*
restrict
plen
,
...
...
stun/stund.c
View file @
da1a1c21
...
@@ -213,14 +213,14 @@ static int dgram_process (int sock)
...
@@ -213,14 +213,14 @@ static int dgram_process (int sock)
/* Unknown attributes */
/* Unknown attributes */
if
(
stun_has_unknown
(
buf
))
if
(
stun_has_unknown
(
buf
))
{
{
stun_init_error_unknown
(
buf
,
sizeof
(
buf
),
buf
);
stun_init_error_unknown
(
buf
,
sizeof
(
buf
),
buf
,
0
);
goto
finish
;
goto
finish
;
}
}
switch
(
stun_get_method
(
buf
))
switch
(
stun_get_method
(
buf
))
{
{
case
STUN_BINDING
:
case
STUN_BINDING
:
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
,
0
);
if
(
stun_has_cookie
(
buf
))
if
(
stun_has_cookie
(
buf
))
stun_append_xor_addr
(
buf
,
sizeof
(
buf
),
stun_append_xor_addr
(
buf
,
sizeof
(
buf
),
STUN_XOR_MAPPED_ADDRESS
,
STUN_XOR_MAPPED_ADDRESS
,
...
@@ -231,7 +231,7 @@ static int dgram_process (int sock)
...
@@ -231,7 +231,7 @@ static int dgram_process (int sock)
break
;
break
;
default:
default:
stun_init_error
(
buf
,
sizeof
(
buf
),
buf
,
STUN_BAD_REQUEST
);
stun_init_error
(
buf
,
sizeof
(
buf
),
buf
,
STUN_BAD_REQUEST
,
0
);
}
}
finish:
finish:
...
...
stun/stunsend.c
View file @
da1a1c21
...
@@ -213,17 +213,19 @@ stun_append_string (uint8_t *restrict msg, size_t msize,
...
@@ -213,17 +213,19 @@ stun_append_string (uint8_t *restrict msg, size_t msize,
}
}
static
int
stun_append_server
(
uint8_t
*
restrict
msg
,
size_t
msize
)
static
int
stun_append_server
(
uint8_t
*
restrict
msg
,
size_t
msize
,
int
compat
)
{
{
static
const
char
server
[]
=
PACKAGE_STRING
;
static
const
char
server
[]
=
PACKAGE_STRING
;
assert
(
strlen
(
server
)
<
128
);
assert
(
strlen
(
server
)
<
128
);
// return stun_append_string (msg, msize, STUN_SERVER, server);
if
(
compat
==
1
)
return
0
;
return
0
;
else
return
stun_append_string
(
msg
,
msize
,
STUN_SERVER
,
server
);
}
}
void
stun_init_response
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
)
void
stun_init_response
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
compat
)
{
{
assert
(
stun_valid
(
req
));
assert
(
stun_valid
(
req
));
assert
(
stun_get_class
(
req
)
==
STUN_REQUEST
);
assert
(
stun_get_class
(
req
)
==
STUN_REQUEST
);
...
@@ -232,7 +234,7 @@ void stun_init_response (uint8_t *ans, size_t msize, const uint8_t *req)
...
@@ -232,7 +234,7 @@ void stun_init_response (uint8_t *ans, size_t msize, const uint8_t *req)
stun_init
(
ans
,
STUN_RESPONSE
,
stun_get_method
(
req
),
stun_id
(
req
));
stun_init
(
ans
,
STUN_RESPONSE
,
stun_get_method
(
req
),
stun_id
(
req
));
/* For RFC3489 compatibility, we cannot assume the cookie */
/* For RFC3489 compatibility, we cannot assume the cookie */
memcpy
(
ans
+
4
,
req
+
4
,
4
);
memcpy
(
ans
+
4
,
req
+
4
,
4
);
(
void
)
stun_append_server
(
ans
,
msize
);
(
void
)
stun_append_server
(
ans
,
msize
,
compat
);
}
}
...
@@ -320,7 +322,7 @@ stun_append_error (uint8_t *restrict msg, size_t msize, stun_error_t code)
...
@@ -320,7 +322,7 @@ stun_append_error (uint8_t *restrict msg, size_t msize, stun_error_t code)
int
stun_init_error
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
stun_init_error
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
stun_error_t
err
)
stun_error_t
err
,
int
compat
)
{
{
assert
(
stun_valid
(
req
));
assert
(
stun_valid
(
req
));
assert
(
msize
>=
20u
);
assert
(
msize
>=
20u
);
...
@@ -329,12 +331,13 @@ int stun_init_error (uint8_t *ans, size_t msize, const uint8_t *req,
...
@@ -329,12 +331,13 @@ int stun_init_error (uint8_t *ans, size_t msize, const uint8_t *req,
stun_init
(
ans
,
STUN_ERROR
,
stun_get_method
(
req
),
stun_id
(
req
));
stun_init
(
ans
,
STUN_ERROR
,
stun_get_method
(
req
),
stun_id
(
req
));
/* For RFC3489 compatibility, we cannot assume the cookie */
/* For RFC3489 compatibility, we cannot assume the cookie */
memcpy
(
ans
+
4
,
req
+
4
,
4
);
memcpy
(
ans
+
4
,
req
+
4
,
4
);
(
void
)
stun_append_server
(
ans
,
msize
);
(
void
)
stun_append_server
(
ans
,
msize
,
compat
);
return
stun_append_error
(
ans
,
msize
,
err
);
return
stun_append_error
(
ans
,
msize
,
err
);
}
}
int
stun_init_error_unknown
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
)
int
stun_init_error_unknown
(
uint8_t
*
ans
,
size_t
msize
,
const
uint8_t
*
req
,
int
compat
)
{
{
unsigned
counter
,
i
;
unsigned
counter
,
i
;
#ifdef HAVE_C_VARARRAYS
#ifdef HAVE_C_VARARRAYS
...
@@ -346,7 +349,7 @@ int stun_init_error_unknown (uint8_t *ans, size_t msize, const uint8_t *req)
...
@@ -346,7 +349,7 @@ int stun_init_error_unknown (uint8_t *ans, size_t msize, const uint8_t *req)
counter
=
stun_find_unknown
(
req
,
ids
,
sizeof
(
ids
)
/
sizeof
(
ids
[
0
]));
counter
=
stun_find_unknown
(
req
,
ids
,
sizeof
(
ids
)
/
sizeof
(
ids
[
0
]));
assert
(
counter
>
0
);
assert
(
counter
>
0
);
if
(
stun_init_error
(
ans
,
msize
,
req
,
STUN_UNKNOWN_ATTRIBUTE
))
if
(
stun_init_error
(
ans
,
msize
,
req
,
STUN_UNKNOWN_ATTRIBUTE
,
compat
))
return
ENOBUFS
;
return
ENOBUFS
;
for
(
i
=
0
;
i
<
counter
;
i
++
)
for
(
i
=
0
;
i
<
counter
;
i
++
)
...
...
stun/tests/test-bind.c
View file @
da1a1c21
...
@@ -266,7 +266,7 @@ static void responses (void)
...
@@ -266,7 +266,7 @@ static void responses (void)
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
assert
(
val
>=
0
);
assert
(
val
>=
0
);
stun_init_error
(
buf
,
sizeof
(
buf
),
buf
,
STUN_SERVER_ERROR
);
stun_init_error
(
buf
,
sizeof
(
buf
),
buf
,
STUN_SERVER_ERROR
,
0
);
len
=
sizeof
(
buf
);
len
=
sizeof
(
buf
);
val
=
stun_finish
(
buf
,
&
len
,
0
);
val
=
stun_finish
(
buf
,
&
len
,
0
);
assert
(
val
==
0
);
assert
(
val
==
0
);
...
@@ -284,7 +284,7 @@ static void responses (void)
...
@@ -284,7 +284,7 @@ static void responses (void)
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
assert
(
val
>=
0
);
assert
(
val
>=
0
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
,
0
);
val
=
stun_append_string
(
buf
,
sizeof
(
buf
),
0x6000
,
val
=
stun_append_string
(
buf
,
sizeof
(
buf
),
0x6000
,
"This is an unknown attribute!"
);
"This is an unknown attribute!"
);
assert
(
val
==
0
);
assert
(
val
==
0
);
...
@@ -306,7 +306,7 @@ static void responses (void)
...
@@ -306,7 +306,7 @@ static void responses (void)
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
assert
(
val
>=
0
);
assert
(
val
>=
0
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
,
0
);
len
=
sizeof
(
buf
);
len
=
sizeof
(
buf
);
val
=
stun_finish
(
buf
,
&
len
,
0
);
val
=
stun_finish
(
buf
,
&
len
,
0
);
assert
(
val
==
0
);
assert
(
val
==
0
);
...
@@ -325,7 +325,7 @@ static void responses (void)
...
@@ -325,7 +325,7 @@ static void responses (void)
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
val
=
recv
(
servfd
,
buf
,
1000
,
MSG_DONTWAIT
);
assert
(
val
>=
0
);
assert
(
val
>=
0
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
);
stun_init_response
(
buf
,
sizeof
(
buf
),
buf
,
0
);
val
=
stun_append_addr
(
buf
,
sizeof
(
buf
),
STUN_MAPPED_ADDRESS
,
val
=
stun_append_addr
(
buf
,
sizeof
(
buf
),
STUN_MAPPED_ADDRESS
,
(
struct
sockaddr
*
)
&
addr
,
addrlen
);
(
struct
sockaddr
*
)
&
addr
,
addrlen
);
assert
(
val
==
0
);
assert
(
val
==
0
);
...
...
stun/tests/test-conncheck.c
View file @
da1a1c21
...
@@ -75,7 +75,7 @@ int main (void)
...
@@ -75,7 +75,7 @@ int main (void)
/* Incorrect message class */
/* Incorrect message class */
stun_init_request
(
req
,
STUN_BINDING
);
stun_init_request
(
req
,
STUN_BINDING
);
stun_init_response
(
req
,
sizeof
(
req
),
req
);
stun_init_response
(
req
,
sizeof
(
req
),
req
,
0
);
len
=
sizeof
(
req
);
len
=
sizeof
(
req
);
val
=
stun_finish
(
req
,
&
len
,
0
);
val
=
stun_finish
(
req
,
&
len
,
0
);
assert
(
val
==
0
);
assert
(
val
==
0
);
...
...
stun/tests/test-format.c
View file @
da1a1c21
...
@@ -149,14 +149,14 @@ int main (void)
...
@@ -149,14 +149,14 @@ int main (void)
fatal
(
"Request formatting test failed"
);
fatal
(
"Request formatting test failed"
);
/* Response formatting test */
/* Response formatting test */
stun_init_response
(
msg
,
sizeof
(
msg
),
msg
);
stun_init_response
(
msg
,
sizeof
(
msg
),
msg
,
0
);
finish_check
(
msg
);
finish_check
(
msg
);
if
(
memcmp
(
msg
,
"
\x01\x01
"
,
2
))
if
(
memcmp
(
msg
,
"
\x01\x01
"
,
2
))
fatal
(
"Response formatting test failed"
);
fatal
(
"Response formatting test failed"
);
/* Error formatting test */
/* Error formatting test */
stun_init_request
(
msg
,
STUN_BINDING
);
stun_init_request
(
msg
,
STUN_BINDING
);
if
(
stun_init_error
(
msg
,
sizeof
(
msg
),
msg
,
400
))
if
(
stun_init_error
(
msg
,
sizeof
(
msg
),
msg
,
400
,
0
))
fatal
(
"Error initialization test failed"
);
fatal
(
"Error initialization test failed"
);
finish_check
(
msg
);
finish_check
(
msg
);
if
(
memcmp
(
msg
,
"
\x01\x11
"
,
2
))
if
(
memcmp
(
msg
,
"
\x01\x11
"
,
2
))
...
@@ -164,7 +164,7 @@ int main (void)
...
@@ -164,7 +164,7 @@ int main (void)
/* Unknown error formatting test */
/* Unknown error formatting test */
stun_init_request
(
msg
,
STUN_BINDING
);
stun_init_request
(
msg
,
STUN_BINDING
);
if
(
stun_init_error
(
msg
,
sizeof
(
msg
),
msg
,
666
))
if
(
stun_init_error
(
msg
,
sizeof
(
msg
),
msg
,
666
,
0
))
fatal
(
"Unknown error initialization test failed"
);
fatal
(
"Unknown error initialization test failed"
);
finish_check
(
msg
);
finish_check
(
msg
);
if
(
memcmp
(
msg
,
"
\x01\x11
"
,
2
))
if
(
memcmp
(
msg
,
"
\x01\x11
"
,
2
))
...
...
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