Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
Dnsmasq
Commits
5a56f881
Commit
5a56f881
authored
Feb 01, 2015
by
Chen Wei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generalize the dict_node structure
add a void *obj to contain any pointer.
parent
e0abe3ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
16 deletions
+27
-16
src/dict.c
src/dict.c
+4
-5
src/dnsmasq.h
src/dnsmasq.h
+9
-4
src/forward.c
src/forward.c
+5
-1
src/option.c
src/option.c
+9
-6
No files found.
src/dict.c
View file @
5a56f881
...
...
@@ -129,8 +129,7 @@ struct dict_node * new_dictnode (char *label, int label_len)
node
->
sub_loadmax
=
0
;
node
->
sub_maxjump
=
0
;
node
->
sub
=
NULL
;
node
->
sets
=
NULL
;
node
->
sets_count
=
0
;
node
->
obj
=
NULL
;
return
node
;
}
...
...
@@ -304,7 +303,7 @@ struct dict_node * match_domain_ipsets (struct dict_node *root, char *domain)
if
(
node
==
NULL
)
break
;
if
(
node
->
sets
!=
NULL
)
if
(
node
->
obj
!=
NULL
)
res
=
node
;
}
...
...
@@ -406,8 +405,8 @@ void free_dicttree (struct dict_node *node)
if
(
np
->
label
!=
NULL
)
free
(
np
->
label
);
if
(
np
->
sets
!=
NULL
)
free
(
np
->
sets
);
if
(
np
->
obj
!=
NULL
)
free
(
np
->
obj
);
free_dicttree
(
np
);
}
...
...
src/dnsmasq.h
View file @
5a56f881
...
...
@@ -517,23 +517,28 @@ struct ipsets {
};
/* a dictionary node for open addressing hash table
* it has a key, "label", and several values.
* it has a key, "label", and a value "obj" as container, there are several
* other values for maintaining the hash table and lookup
*
* For ipsets match, only INSERT and LOOKUP operation needed
*/
struct
dict_node
{
char
*
label
;
/* key */
void
*
obj
;
/* the value, can point to anything */
uint32_t
h1
;
/* from hash function 1, fnv_32_hash */
uint32_t
h2
;
/* from hash function 2, bernstein_odd */
int
sub_count
;
/* items stored in sub */
unsigned
sub_slots
;
/* size of hash table sub */
int
sub_count
;
/* items stored in sub */
int
sub_loadmax
;
/* max items stored before upsize sub */
int
sub_maxjump
;
/* max jumps for insertion, upsize when reach */
char
**
sets
;
/* ipsets names end with NULL ptr */
int
sets_count
;
struct
dict_node
**
sub
;
};
struct
ipsets_names
{
char
**
sets
;
/* ipsets names end with NULL ptr */
int
count
;
};
struct
irec
{
union
mysockaddr
addr
;
struct
in_addr
netmask
;
/* only valid for IPv4 */
...
...
src/forward.c
View file @
5a56f881
...
...
@@ -535,6 +535,7 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
int
munged
=
0
,
is_sign
;
size_t
plen
;
struct
dict_node
*
np
;
struct
ipsets_names
*
obj
;
(
void
)
ad_reqd
;
(
void
)
do_bit
;
...
...
@@ -544,7 +545,10 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
{
np
=
match_domain_ipsets
(
daemon
->
dh_ipsets
,
daemon
->
namebuff
);
if
(
np
!=
NULL
)
sets
=
np
->
sets
;
{
obj
=
(
struct
ipsets_names
*
)
np
->
obj
;
sets
=
obj
->
sets
;
}
}
#endif
...
...
src/option.c
View file @
5a56f881
...
...
@@ -2208,6 +2208,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
case
LOPT_LOCAL
:
/* --local */
case
'A'
:
/* --address */
case
LOPT_NO_REBIND
:
/* --rebind-domain-ok */
//TODO fast hash lookup
{
struct
server
*
serv
,
*
newlist
=
NULL
;
...
...
@@ -2343,7 +2344,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
char
**
sets
,
**
sets_pos
;
int
sets_count
=
0
;
unhide_metas
(
arg
);
struct
dict_node
*
np
;
struct
dict_node
*
np
=
NULL
;
struct
ipsets_names
*
obj
;
char
*
domain
=
NULL
;
if
(
daemon
->
dh_ipsets
==
NULL
)
...
...
@@ -2366,7 +2368,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
option
=
'?'
;
if
(
domain
!=
NULL
)
add_domain
(
daemon
->
dh_ipsets
,
domain
);
np
=
add_domain
(
daemon
->
dh_ipsets
,
domain
);
arg
=
end
;
}
...
...
@@ -2394,11 +2396,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
while
(
end
);
*
sets_pos
=
NULL
;
if
(
domain
!=
NULL
)
if
(
np
!=
NULL
)
{
np
=
lookup_domain
(
daemon
->
dh_ipsets
,
domain
);
np
->
sets
=
sets
;
np
->
sets_count
=
sets_count
;
obj
=
opt_malloc
(
sizeof
(
struct
ipsets_names
));
obj
->
sets
=
sets
;
obj
->
count
=
sets_count
;
np
->
obj
=
(
void
*
)
obj
;
}
break
;
...
...
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