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
e0abe3ad
Commit
e0abe3ad
authored
Feb 01, 2015
by
Chen Wei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only expose needed function from dict.c
parent
4aa849f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
23 deletions
+21
-23
Makefile
Makefile
+2
-2
src/dict.c
src/dict.c
+16
-13
src/dnsmasq.h
src/dnsmasq.h
+2
-7
src/option.c
src/option.c
+1
-1
No files found.
Makefile
View file @
e0abe3ad
...
...
@@ -24,7 +24,7 @@ MANDIR = $(PREFIX)/share/man
LOCALEDIR
=
$(PREFIX)
/share/locale
BUILDDIR
=
$(SRC)
DESTDIR
=
CFLAGS
=
-Wall
-W
-O2
CFLAGS
=
-Wall
-W
-O2
-g
LDFLAGS
=
COPTS
=
RPM_OPT_FLAGS
=
...
...
@@ -71,7 +71,7 @@ objs = cache.o rfc1035.o util.o option.o forward.o network.o \
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o
\
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o
\
dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o
\
domain.o dnssec.o blockdata.o tables.o loop.o inotify.o
domain.o dnssec.o blockdata.o tables.o loop.o inotify.o
dict.o
hdrs
=
dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h
\
dns-protocol.h radv-protocol.h ip6addr.h
...
...
src/dict.c
View file @
e0abe3ad
...
...
@@ -25,6 +25,12 @@
#define FNV_32_PRIME ((uint32_t)0x01000193)
#define max(A, B) ((A) > (B) ? (A) : (B))
/* prototypes */
static
struct
dict_node
*
add_or_replace_dictnode
(
struct
dict_node
*
node
,
char
*
label
);
static
struct
dict_node
*
lookup_dictnode
(
struct
dict_node
*
node
,
char
*
label
);
static
void
add_dicttree
(
struct
dict_node
*
node
,
struct
dict_node
*
sub
);
static
void
upsize_dicttree
(
struct
dict_node
*
np
);
/* hash function 1 for double hashing
* 32 bit Fowler/Noll/Vo hash */
static
inline
uint32_t
fnv_32_hash
(
char
*
str
)
...
...
@@ -80,8 +86,6 @@ static inline void memcpy_lower (void *dst, void *src, int len)
*++
d
=
'\0'
;
}
struct
dict_node
*
init_sub_dictnode
(
struct
dict_node
*
node
)
{
unsigned
n
;
...
...
@@ -99,7 +103,7 @@ struct dict_node * init_sub_dictnode (struct dict_node *node)
}
/* allocate and initialize a new node */
struct
dict_node
*
new_dictnode
(
char
*
label
,
int
label_len
,
int
level
)
struct
dict_node
*
new_dictnode
(
char
*
label
,
int
label_len
)
{
struct
dict_node
*
node
;
...
...
@@ -124,7 +128,6 @@ struct dict_node * new_dictnode (char *label, int label_len, int level)
node
->
sub_slots
=
0
;
node
->
sub_loadmax
=
0
;
node
->
sub_maxjump
=
0
;
node
->
level
=
level
;
node
->
sub
=
NULL
;
node
->
sets
=
NULL
;
node
->
sets_count
=
0
;
...
...
@@ -132,11 +135,10 @@ struct dict_node * new_dictnode (char *label, int label_len, int level)
return
node
;
}
/* double the slots of dns node, it calls with add_dicttree each other
* the table size starts with 2^2, so that the new size remains 2^x, the
* double hash used is choosed to work with 2^n slots and perform well */
void
upsize_dicttree
(
struct
dict_node
*
np
)
static
void
upsize_dicttree
(
struct
dict_node
*
np
)
{
struct
dict_node
**
oldnodes
;
unsigned
i
,
oldsize
;
...
...
@@ -163,7 +165,7 @@ void upsize_dicttree (struct dict_node *np)
}
/* add a sub-node, upsize if needed, calls with upsize_dicttree each other */
void
add_dicttree
(
struct
dict_node
*
node
,
struct
dict_node
*
sub
)
static
void
add_dicttree
(
struct
dict_node
*
node
,
struct
dict_node
*
sub
)
{
int
n
;
uint32_t
dh
,
idx
;
...
...
@@ -204,7 +206,8 @@ void add_dicttree (struct dict_node *node, struct dict_node *sub)
/* add a new subnode to node, or update the attr of the subnode with same
* label
* return the subnode */
struct
dict_node
*
add_or_replace_dictnode
(
struct
dict_node
*
node
,
char
*
label
)
static
struct
dict_node
*
add_or_replace_dictnode
(
struct
dict_node
*
node
,
char
*
label
)
{
struct
dict_node
*
np
;
...
...
@@ -214,7 +217,7 @@ struct dict_node * add_or_replace_dictnode (struct dict_node *node, char *label)
{
init_sub_dictnode
(
node
);
}
np
=
new_dictnode
(
label
,
strlen
(
label
)
,
node
->
level
+
1
);
np
=
new_dictnode
(
label
,
strlen
(
label
));
add_dicttree
(
node
,
np
);
}
...
...
@@ -223,7 +226,7 @@ struct dict_node * add_or_replace_dictnode (struct dict_node *node, char *label)
}
/* lookup the label in node's sub, return pointer if found, NULL if not */
st
ruct
dict_node
*
lookup_dictnode
(
struct
dict_node
*
node
,
char
*
label
)
st
atic
struct
dict_node
*
lookup_dictnode
(
struct
dict_node
*
node
,
char
*
label
)
{
uint32_t
h1
,
h2
,
dh
,
idx
;
struct
dict_node
*
np
;
...
...
@@ -351,8 +354,8 @@ struct dict_node * lookup_domain (struct dict_node *root, char *domain)
}
/* add a domain pattern in the form of google.com to root
* return
number of levels in that pattern, the level is unused now
*/
int
add_domain
(
struct
dict_node
*
root
,
char
*
domain
)
* return
the node with lowest hierarchy
*/
struct
dict_node
*
add_domain
(
struct
dict_node
*
root
,
char
*
domain
)
{
char
buf
[
MAXDNAME
];
char
*
labels
[
MAXLABELS
];
...
...
@@ -384,7 +387,7 @@ int add_domain (struct dict_node *root, char *domain)
node
=
add_or_replace_dictnode
(
node
,
labels
[
i
]);
}
return
node
->
level
;
return
node
;
}
/* free node and all sub-nodes recursively. Unused. */
...
...
src/dnsmasq.h
View file @
e0abe3ad
...
...
@@ -531,7 +531,6 @@ struct dict_node {
int
sub_maxjump
;
/* max jumps for insertion, upsize when reach */
char
**
sets
;
/* ipsets names end with NULL ptr */
int
sets_count
;
int
level
;
/* unused */
struct
dict_node
**
sub
;
};
...
...
@@ -1386,14 +1385,10 @@ int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags,
#endif
/* dict.c */
void
upsize_dicttree
(
struct
dict_node
*
np
);
void
add_dicttree
(
struct
dict_node
*
node
,
struct
dict_node
*
sub
);
struct
dict_node
*
new_dictnode
(
char
*
label
,
int
len
,
int
level
);
struct
dict_node
*
lookup_dictnode
(
struct
dict_node
*
node
,
char
*
label
);
struct
dict_node
*
new_dictnode
(
char
*
label
,
int
len
);
struct
dict_node
*
lookup_domain
(
struct
dict_node
*
root
,
char
*
domain
);
struct
dict_node
*
match_domain_ipsets
(
struct
dict_node
*
root
,
char
*
domain
);
int
add_domain
(
struct
dict_node
*
root
,
char
*
domain
);
struct
dict_node
*
add_or_replace_dictnode
(
struct
dict_node
*
node
,
char
*
label
);
struct
dict_node
*
add_domain
(
struct
dict_node
*
root
,
char
*
domain
);
void
free_dicttree
(
struct
dict_node
*
node
);
/* helper.c */
...
...
src/option.c
View file @
e0abe3ad
...
...
@@ -2347,7 +2347,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
char
*
domain
=
NULL
;
if
(
daemon
->
dh_ipsets
==
NULL
)
daemon
->
dh_ipsets
=
new_dictnode
(
NULL
,
0
,
0
);
daemon
->
dh_ipsets
=
new_dictnode
(
NULL
,
0
);
if
(
arg
&&
*
arg
==
'/'
)
{
...
...
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