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
c361d8e1
Commit
c361d8e1
authored
Oct 28, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove iovec dependency for crc32. Use a custom simple structure to do that
parent
c4a0384b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
stun/stun3489bis.c
stun/stun3489bis.c
+8
-8
stun/stuncrc32.c
stun/stuncrc32.c
+3
-3
stun/stuncrc32.h
stun/stuncrc32.h
+7
-2
No files found.
stun/stun3489bis.c
View file @
c361d8e1
...
...
@@ -49,20 +49,20 @@
uint32_t
stun_fingerprint
(
const
uint8_t
*
msg
,
size_t
len
)
{
struct
iovec
iov
[
3
];
crc_data
data
[
3
];
uint16_t
fakelen
=
htons
(
len
-
20u
);
// assert (len >= 28u);
iov
[
0
].
iov_base
=
(
void
*
)
msg
;
iov
[
0
].
iov_
len
=
2
;
iov
[
1
].
iov_base
=
&
fakelen
;
iov
[
1
].
iov_
len
=
2
;
iov
[
2
].
iov_base
=
(
void
*
)(
msg
+
4
);
data
[
0
].
buf
=
(
void
*
)
msg
;
data
[
0
].
len
=
2
;
data
[
1
].
buf
=
&
fakelen
;
data
[
1
].
len
=
2
;
data
[
2
].
buf
=
(
void
*
)(
msg
+
4
);
/* first 4 bytes done, last 8 bytes not summed */
iov
[
2
].
iov_
len
=
len
-
12u
;
data
[
2
].
len
=
len
-
12u
;
return
htonl
(
crc32
(
iov
,
sizeof
(
iov
)
/
sizeof
(
iov
[
0
])
)
^
0x5354554e
);
return
htonl
(
crc32
(
data
,
3
)
^
0x5354554e
);
}
bool
stun_has_cookie
(
const
StunMessage
*
msg
)
...
...
stun/stuncrc32.c
View file @
c361d8e1
...
...
@@ -137,15 +137,15 @@ static const uint32_t crc32_tab[] = {
};
uint32_t
crc32
(
const
struct
iovec
*
iov
,
size_t
n
)
uint32_t
crc32
(
const
crc_data
data
,
size_t
n
)
{
size_t
i
;
uint32_t
crc
=
0xffffffff
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
const
uint8_t
*
p
=
iov
[
i
].
iov_base
;
size_t
size
=
iov
[
i
].
iov_
len
;
const
uint8_t
*
p
=
data
[
i
].
buf
;
size_t
size
=
data
[
i
].
len
;
while
(
size
--
)
crc
=
crc32_tab
[(
crc
^
*
p
++
)
&
0xFF
]
^
(
crc
>>
8
);
...
...
stun/stuncrc32.h
View file @
c361d8e1
...
...
@@ -40,8 +40,13 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/uio.h>
uint32_t
crc32
(
const
struct
iovec
*
iov
,
size_t
n
);
typedef
struct
{
uint8_t
*
buf
;
size_t
len
;
}
crc_data
;
uint32_t
crc32
(
const
crc_data
*
data
,
size_t
n
);
#endif
/* _CRC32_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