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
98c098bf
Commit
98c098bf
authored
Jan 08, 2014
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move blockdata to it's own file.
parent
c47e3ba4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
85 deletions
+104
-85
Makefile
Makefile
+1
-1
bld/Android.mk
bld/Android.mk
+1
-1
src/blockdata.c
src/blockdata.c
+99
-0
src/cache.c
src/cache.c
+1
-83
src/dnsmasq.h
src/dnsmasq.h
+2
-0
No files found.
Makefile
View file @
98c098bf
...
...
@@ -68,7 +68,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 dnssec-openssl.o
domain.o dnssec.o dnssec-openssl.o
blockdata.o
hdrs
=
dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h
\
dns-protocol.h radv-protocol.h
...
...
bld/Android.mk
View file @
98c098bf
...
...
@@ -9,7 +9,7 @@ LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
rfc2131.c tftp.c util.c conntrack.c
\
dhcp6.c rfc3315.c dhcp-common.c outpacket.c
\
radv.c slaac.c auth.c ipset.c domain.c
\
dnssec.c dnssec-openssl.c
dnssec.c dnssec-openssl.c
blockdata.c
LOCAL_MODULE
:=
dnsmasq
...
...
src/blockdata.c
0 → 100644
View file @
98c098bf
/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dnsmasq.h"
#ifdef HAVE_DNSSEC
static
struct
blockdata
*
keyblock_free
=
NULL
;
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
)
{
struct
blockdata
*
block
,
*
ret
=
NULL
;
struct
blockdata
**
prev
=
&
ret
;
size_t
blen
;
while
(
len
>
0
)
{
if
(
keyblock_free
)
{
block
=
keyblock_free
;
keyblock_free
=
block
->
next
;
}
else
block
=
whine_malloc
(
sizeof
(
struct
blockdata
));
if
(
!
block
)
{
/* failed to alloc, free partial chain */
blockdata_free
(
ret
);
return
NULL
;
}
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
memcpy
(
block
->
key
,
data
,
blen
);
data
+=
blen
;
len
-=
blen
;
*
prev
=
block
;
prev
=
&
block
->
next
;
block
->
next
=
NULL
;
}
return
ret
;
}
size_t
blockdata_walk
(
struct
blockdata
**
key
,
unsigned
char
**
p
,
size_t
cnt
)
{
if
(
*
p
==
NULL
)
*
p
=
(
*
key
)
->
key
;
else
if
(
*
p
==
(
*
key
)
->
key
+
KEYBLOCK_LEN
)
{
*
key
=
(
*
key
)
->
next
;
if
(
*
key
==
NULL
)
return
0
;
*
p
=
(
*
key
)
->
key
;
}
return
MIN
(
cnt
,
(
size_t
)((
*
key
)
->
key
+
KEYBLOCK_LEN
-
(
*
p
)));
}
void
blockdata_free
(
struct
blockdata
*
blocks
)
{
struct
blockdata
*
tmp
;
if
(
blocks
)
{
for
(
tmp
=
blocks
;
tmp
->
next
;
tmp
=
tmp
->
next
);
tmp
->
next
=
keyblock_free
;
keyblock_free
=
blocks
;
}
}
void
blockdata_retrieve
(
struct
blockdata
*
block
,
size_t
len
,
void
*
data
)
{
size_t
blen
;
struct
blockdata
*
b
;
for
(
b
=
block
;
len
>
0
&&
b
;
b
=
b
->
next
)
{
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
memcpy
(
data
,
b
->
key
,
blen
);
data
+=
blen
;
len
-=
blen
;
}
}
#endif
src/cache.c
View file @
98c098bf
...
...
@@ -25,9 +25,6 @@ static int cache_inserted = 0, cache_live_freed = 0, insert_error;
static
union
bigname
*
big_free
=
NULL
;
static
int
bignames_left
,
hash_size
;
static
int
uid
=
1
;
#ifdef HAVE_DNSSEC
static
struct
blockdata
*
keyblock_free
=
NULL
;
#endif
/* type->string mapping: this is also used by the name-hash function as a mixing table. */
static
const
struct
{
...
...
@@ -1394,83 +1391,4 @@ void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
my_syslog
(
LOG_INFO
,
"%s %s %s %s"
,
source
,
name
,
verb
,
dest
);
}
#ifdef HAVE_DNSSEC
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
)
{
struct
blockdata
*
block
,
*
ret
=
NULL
;
struct
blockdata
**
prev
=
&
ret
;
size_t
blen
;
while
(
len
>
0
)
{
if
(
keyblock_free
)
{
block
=
keyblock_free
;
keyblock_free
=
block
->
next
;
}
else
block
=
whine_malloc
(
sizeof
(
struct
blockdata
));
if
(
!
block
)
{
/* failed to alloc, free partial chain */
blockdata_free
(
ret
);
return
NULL
;
}
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
memcpy
(
block
->
key
,
data
,
blen
);
data
+=
blen
;
len
-=
blen
;
*
prev
=
block
;
prev
=
&
block
->
next
;
block
->
next
=
NULL
;
}
return
ret
;
}
size_t
blockdata_walk
(
struct
blockdata
**
key
,
unsigned
char
**
p
,
size_t
cnt
)
{
if
(
*
p
==
NULL
)
*
p
=
(
*
key
)
->
key
;
else
if
(
*
p
==
(
*
key
)
->
key
+
KEYBLOCK_LEN
)
{
*
key
=
(
*
key
)
->
next
;
if
(
*
key
==
NULL
)
return
0
;
*
p
=
(
*
key
)
->
key
;
}
return
MIN
(
cnt
,
(
*
key
)
->
key
+
KEYBLOCK_LEN
-
(
*
p
));
}
void
blockdata_free
(
struct
blockdata
*
blocks
)
{
struct
blockdata
*
tmp
;
if
(
blocks
)
{
for
(
tmp
=
blocks
;
tmp
->
next
;
tmp
=
tmp
->
next
);
tmp
->
next
=
keyblock_free
;
keyblock_free
=
blocks
;
}
}
void
blockdata_retrieve
(
struct
blockdata
*
block
,
size_t
len
,
void
*
data
)
{
size_t
blen
;
struct
blockdata
*
b
;
for
(
b
=
block
;
len
>
0
&&
b
;
b
=
b
->
next
)
{
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
memcpy
(
data
,
b
->
key
,
blen
);
data
+=
blen
;
len
-=
blen
;
}
}
#endif
src/dnsmasq.h
View file @
98c098bf
...
...
@@ -987,6 +987,8 @@ void dump_cache(time_t now);
char
*
cache_get_name
(
struct
crec
*
crecp
);
char
*
cache_get_cname_target
(
struct
crec
*
crecp
);
struct
crec
*
cache_enumerate
(
int
init
);
/* blockdata.c */
#ifdef HAVE_DNSSEC
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
);
size_t
blockdata_walk
(
struct
blockdata
**
key
,
unsigned
char
**
p
,
size_t
cnt
);
...
...
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