Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
BIND
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
637
Issues
637
List
Boards
Labels
Service Desk
Milestones
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
ISC Open Source Projects
BIND
Commits
0a9fedaf
Commit
0a9fedaf
authored
Dec 15, 1999
by
Michael Graff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an LFSR to generate unpredictable IDs.
parent
21cbbc3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
60 deletions
+33
-60
lib/dns/dispatch.c
lib/dns/dispatch.c
+33
-60
No files found.
lib/dns/dispatch.c
View file @
0a9fedaf
...
...
@@ -24,6 +24,7 @@
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/lfsr.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/socket.h>
...
...
@@ -87,7 +88,7 @@ struct dns_dispatch {
ISC_LIST
(
dns_dispentry_t
)
rq_handlers
;
/* request handler list */
ISC_LIST
(
dns_dispatchevent_t
)
rq_events
;
/* holder for rq events */
dns_tcpmsg_t
tcpmsg
;
/* for tcp streams */
isc_
int32_t
qid_state
;
/* state generator info */
isc_
lfsr_t
qid_lfsr
;
/* state generator info */
unsigned
int
qid_hashsize
;
/* hash table size */
unsigned
int
qid_mask
;
/* mask for hash table */
dns_displist_t
*
qid_table
;
/* the table itself */
...
...
@@ -105,54 +106,37 @@ struct dns_dispatch {
/*
* statics.
*/
static
dns_dispentry_t
*
bucket_search
(
dns_dispatch_t
*
,
isc_sockaddr_t
*
,
dns_messageid_t
,
unsigned
int
);
static
void
destroy
(
dns_dispatch_t
*
);
static
void
udp_recv
(
isc_task_t
*
,
isc_event_t
*
);
static
void
tcp_recv
(
isc_task_t
*
,
isc_event_t
*
);
static
void
startrecv
(
dns_dispatch_t
*
);
static
dns_messageid_t
randomid
(
dns_dispatch_t
*
);
static
unsigned
int
hash
(
dns_dispatch_t
*
,
isc_sockaddr_t
*
,
dns_messageid_t
);
static
void
free_buffer
(
dns_dispatch_t
*
disp
,
void
*
buf
,
unsigned
int
len
);
static
void
*
allocate_buffer
(
dns_dispatch_t
*
disp
,
unsigned
int
len
);
static
inline
void
free_event
(
dns_dispatch_t
*
disp
,
dns_dispatchevent_t
*
ev
);
static
inline
dns_dispatchevent_t
*
allocate_event
(
dns_dispatch_t
*
disp
);
static
dns_dispentry_t
*
bucket_search
(
dns_dispatch_t
*
,
isc_sockaddr_t
*
,
dns_messageid_t
,
unsigned
int
);
static
void
destroy
(
dns_dispatch_t
*
);
static
void
udp_recv
(
isc_task_t
*
,
isc_event_t
*
);
static
void
tcp_recv
(
isc_task_t
*
,
isc_event_t
*
);
static
inline
void
startrecv
(
dns_dispatch_t
*
);
static
dns_messageid_t
randomid
(
dns_dispatch_t
*
);
static
unsigned
int
hash
(
dns_dispatch_t
*
,
isc_sockaddr_t
*
,
dns_messageid_t
);
static
void
free_buffer
(
dns_dispatch_t
*
disp
,
void
*
buf
,
unsigned
int
len
);
static
void
*
allocate_buffer
(
dns_dispatch_t
*
disp
,
unsigned
int
len
);
static
inline
void
free_event
(
dns_dispatch_t
*
disp
,
dns_dispatchevent_t
*
ev
);
static
inline
dns_dispatchevent_t
*
allocate_event
(
dns_dispatch_t
*
disp
);
static
void
do_next_request
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
void
do_next_response
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
void
do_cancel
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
dns_dispentry_t
*
linear_first
(
dns_dispatch_t
*
disp
);
static
dns_dispentry_t
*
linear_next
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
void
do_next_request
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
void
do_next_response
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
static
void
do_cancel
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
/*
* Return an unpredictable message ID.
*/
static
inline
dns_messageid_t
randomid
(
dns_dispatch_t
*
disp
)
{
isc_uint32_t
id
;
static
dns_dispentry_t
*
linear_first
(
dns_dispatch_t
*
disp
);
id
=
isc_lfsr_generate
(
&
disp
->
qid_lfsr
);
static
dns_dispentry_t
*
linear_next
(
dns_dispatch_t
*
disp
,
dns_dispentry_t
*
resp
);
return
((
dns_messageid_t
)(
id
&
0x0000ffff
));
}
static
dns_dispentry_t
*
linear_first
(
dns_dispatch_t
*
disp
)
...
...
@@ -212,18 +196,6 @@ hash(dns_dispatch_t *disp, isc_sockaddr_t *dest, dns_messageid_t id)
return
(
ret
);
}
/*
* Return a random message ID. For now this isn't too clever...
* XXXMLG
*/
static
dns_messageid_t
randomid
(
dns_dispatch_t
*
disp
)
{
disp
->
qid_state
+=
7
;
return
((
dns_messageid_t
)
disp
->
qid_state
);
}
/*
* Called when refcount reaches 0 (and safe to destroy)
*/
...
...
@@ -919,9 +891,10 @@ dns_dispatch_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
}
/*
* should initialize qid_state here XXXMLG
* Initialize to a 32-bit LFSR.
* x^31 + x^6 + x^4 + x^2 + x + 1
*/
disp
->
qid_state
=
(
unsigned
int
)
disp
;
isc_lfsr_init
(
&
disp
->
qid_lfsr
,
random
(),
32
,
0x80000057U
)
;
disp
->
magic
=
DISPATCH_MAGIC
;
...
...
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