Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
bcfcece5
Commit
bcfcece5
authored
Jan 28, 1999
by
Bob Halley
Browse files
add dns_name_hash
parent
54a58e49
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/dns/include/dns/name.h
View file @
bcfcece5
...
...
@@ -243,6 +243,16 @@ isc_boolean_t dns_name_isabsolute(dns_name_t *name);
* FALSE The last label in 'name' is not the root label.
*/
unsigned
int
dns_name_hash
(
dns_name_t
*
name
);
/*
* Provide a hash value for 'name'.
*
* Requires:
* 'name' is a valid name
*
* Returns:
* A hash value
*/
/***
*** Comparisons
...
...
lib/dns/name.c
View file @
bcfcece5
...
...
@@ -294,6 +294,44 @@ dns_name_isabsolute(dns_name_t *name) {
return
(
ISC_FALSE
);
}
unsigned
int
dns_name_hash
(
dns_name_t
*
name
)
{
unsigned
int
length
;
const
char
*
s
;
unsigned
int
h
=
0
;
unsigned
int
g
;
/*
* Provide a hash value for 'name'.
*/
REQUIRE
(
VALID_NAME
(
name
));
if
(
name
->
labels
==
0
)
return
(
0
);
length
=
name
->
length
;
if
(
length
>
16
)
length
=
16
;
/*
* P. J. Weinberger's hash function, adapted from p. 436 of
* _Compilers: Principles, Techniques, and Tools_, Aho, Sethi
* and Ullman, Addison-Wesley, 1986, ISBN 0-201-10088-6.
*/
s
=
name
->
ndata
;
while
(
length
>
0
)
{
h
=
(
h
<<
4
)
+
*
s
;
if
((
g
=
(
h
&
0xf0000000
))
!=
0
)
{
h
=
h
^
(
g
>>
24
);
h
=
h
^
g
;
}
s
++
;
length
--
;
}
return
(
h
);
}
int
dns_name_compare
(
dns_name_t
*
name1
,
dns_name_t
*
name2
)
{
unsigned
int
l1
,
l2
,
l
,
count1
,
count2
,
count
;
...
...
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