Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
dhcp
Commits
12c9957e
Commit
12c9957e
authored
Jan 25, 2000
by
Ted Lemon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New malloc debug scheme. Support variable scoping.
parent
3185c188
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
162 additions
and
121 deletions
+162
-121
server/bootp.c
server/bootp.c
+32
-23
server/class.c
server/class.c
+18
-19
server/dhcp.c
server/dhcp.c
+112
-79
No files found.
server/bootp.c
View file @
12c9957e
...
...
@@ -22,7 +22,7 @@
#ifndef lint
static
char
copyright
[]
=
"$Id: bootp.c,v 1.5
8
2000/01/
0
5
18:12:09
mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.
\n
"
;
"$Id: bootp.c,v 1.5
9
2000/01/
2
5
01:32:41
mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.
\n
"
;
#endif
/* not lint */
#include "dhcpd.h"
...
...
@@ -115,44 +115,47 @@ void bootp (packet)
/* Run the executable statements to compute the client and server
options. */
option_state_allocate
(
&
options
,
"bootrequest"
);
option_state_allocate
(
&
options
,
MDL
);
/* Execute the subnet statements. */
execute_statements_in_scope
(
packet
,
lease
,
packet
->
options
,
options
,
lease
->
subnet
->
group
,
&
lease
->
scope
,
lease
->
subnet
->
group
,
(
struct
group
*
)
0
);
/* Execute statements from class scopes. */
for
(
i
=
packet
->
class_count
;
i
>
0
;
i
--
)
{
execute_statements_in_scope
(
packet
,
lease
,
packet
->
options
,
options
,
packet
->
classes
[
i
-
1
]
->
group
,
&
lease
->
scope
,
packet
->
classes
[
i
-
1
]
->
group
,
lease
->
subnet
->
group
);
}
/* Execute the host statements. */
execute_statements_in_scope
(
packet
,
lease
,
packet
->
options
,
options
,
&
lease
->
scope
,
hp
->
group
,
subnet
->
group
);
/* Drop the request if it's not allowed for this client. */
if
((
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_ALLOW_BOOTP
))
&&
!
evaluate_boolean_option_cache
(
&
ignorep
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
{
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
{
if
(
!
ignorep
)
log_info
(
"%s: bootp disallowed"
,
msgbuf
);
option_state_dereference
(
&
options
,
"bootrequest"
);
static_lease_dereference
(
lease
,
"bootrequest"
);
option_state_dereference
(
&
options
,
MDL
);
static_lease_dereference
(
lease
,
MDL
);
return
;
}
if
((
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_ALLOW_BOOTING
))
&&
!
evaluate_boolean_option_cache
(
&
ignorep
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
{
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
{
if
(
!
ignorep
)
log_info
(
"%s: booting disallowed"
,
msgbuf
);
option_state_dereference
(
&
options
,
"bootrequest"
);
static_lease_dereference
(
lease
,
"bootrequest"
);
option_state_dereference
(
&
options
,
MDL
);
static_lease_dereference
(
lease
,
MDL
);
return
;
}
...
...
@@ -166,8 +169,9 @@ void bootp (packet)
if
(
!
packet
->
options_valid
&&
!
(
evaluate_boolean_option_cache
(
&
ignorep
,
packet
,
lease
,
packet
->
options
,
options
,
&
lease
->
scope
,
lookup_option
(
&
server_universe
,
options
,
SV_ALWAYS_REPLY_RFC1048
))))
{
SV_ALWAYS_REPLY_RFC1048
)
,
MDL
)))
{
memcpy
(
outgoing
.
raw
->
options
,
packet
->
raw
->
options
,
DHCP_OPTION_LEN
);
outgoing
.
packet_length
=
BOOTP_MIN_LEN
;
...
...
@@ -179,7 +183,7 @@ void bootp (packet)
oc
=
(
struct
option_cache
*
)
0
;
i
=
DHO_SUBNET_MASK
;
if
(
!
lookup_option
(
&
dhcp_universe
,
options
,
i
))
{
if
(
option_cache_allocate
(
&
oc
,
"ack_lease"
))
{
if
(
option_cache_allocate
(
&
oc
,
MDL
))
{
if
(
make_const_data
(
&
oc
->
expression
,
lease
->
subnet
->
netmask
.
iabuf
,
...
...
@@ -189,7 +193,7 @@ void bootp (packet)
save_option
(
&
dhcp_universe
,
options
,
oc
);
}
option_cache_dereference
(
&
oc
,
"ack_lease"
);
option_cache_dereference
(
&
oc
,
MDL
);
}
}
...
...
@@ -200,6 +204,7 @@ void bootp (packet)
outgoing
.
packet_length
=
cons_options
(
packet
,
outgoing
.
raw
,
lease
,
0
,
packet
->
options
,
options
,
&
lease
->
scope
,
0
,
0
,
1
,
(
struct
data_string
*
)
0
);
if
(
outgoing
.
packet_length
<
BOOTP_MIN_LEN
)
outgoing
.
packet_length
=
BOOTP_MIN_LEN
;
...
...
@@ -222,7 +227,8 @@ void bootp (packet)
if
((
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_ALWAYS_BROADCAST
))
&&
evaluate_boolean_option_cache
(
&
ignorep
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
raw
.
flags
|=
htons
(
BOOTP_BROADCAST
);
/* Figure out the address of the next server. */
...
...
@@ -230,11 +236,12 @@ void bootp (packet)
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_NEXT_SERVER
);
if
(
oc
&&
evaluate_option_cache
(
&
d1
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
{
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
{
/* If there was more than one answer, take the first. */
if
(
d1
.
len
>=
4
&&
d1
.
data
)
memcpy
(
&
raw
.
siaddr
,
d1
.
data
,
4
);
data_string_forget
(
&
d1
,
"bootrequest"
);
data_string_forget
(
&
d1
,
MDL
);
}
else
{
if
(
lease
->
subnet
->
shared_network
->
interface
)
raw
.
siaddr
=
(
lease
->
subnet
->
shared_network
->
...
...
@@ -249,13 +256,14 @@ void bootp (packet)
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_FILENAME
);
if
(
oc
&&
evaluate_option_cache
(
&
d1
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
{
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
{
memcpy
(
raw
.
file
,
d1
.
data
,
d1
.
len
>
sizeof
raw
.
file
?
sizeof
raw
.
file
:
d1
.
len
);
if
(
sizeof
raw
.
file
>
d1
.
len
)
memset
(
&
raw
.
file
[
d1
.
len
],
0
,
(
sizeof
raw
.
file
)
-
d1
.
len
);
data_string_forget
(
&
d1
,
"bootrequest"
);
data_string_forget
(
&
d1
,
MDL
);
}
else
memcpy
(
raw
.
file
,
packet
->
raw
->
file
,
sizeof
raw
.
file
);
...
...
@@ -263,22 +271,23 @@ void bootp (packet)
oc
=
lookup_option
(
&
server_universe
,
options
,
SV_SERVER_NAME
);
if
(
oc
&&
evaluate_option_cache
(
&
d1
,
packet
,
lease
,
packet
->
options
,
options
,
oc
))
{
packet
->
options
,
options
,
&
lease
->
scope
,
oc
,
MDL
))
{
memcpy
(
raw
.
sname
,
d1
.
data
,
d1
.
len
>
sizeof
raw
.
sname
?
sizeof
raw
.
sname
:
d1
.
len
);
if
(
sizeof
raw
.
sname
>
d1
.
len
)
memset
(
&
raw
.
sname
[
d1
.
len
],
0
,
(
sizeof
raw
.
sname
)
-
d1
.
len
);
data_string_forget
(
&
d1
,
"bootrequest"
);
data_string_forget
(
&
d1
,
MDL
);
}
/* Execute the commit statements, if there are any. */
execute_statements
(
packet
,
lease
,
packet
->
options
,
options
,
lease
->
on_commit
);
options
,
&
lease
->
scope
,
lease
->
on_commit
);
/* We're done with the option state. */
option_state_dereference
(
&
options
,
"bootrequest"
);
static_lease_dereference
(
lease
,
"bootrequest"
);
option_state_dereference
(
&
options
,
MDL
);
static_lease_dereference
(
lease
,
MDL
);
/* Set up the hardware destination address... */
hto
.
hbuf
[
0
]
=
packet
->
raw
->
htype
;
...
...
server/class.c
View file @
12c9957e
...
...
@@ -22,7 +22,7 @@
#ifndef lint
static
char
copyright
[]
=
"$Id: class.c,v 1.1
5 1999/10
/2
1
0
3:09:13
mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.
\n
"
;
"$Id: class.c,v 1.1
6 2000/01
/2
5
0
1:36:29
mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.
\n
"
;
#endif
/* not lint */
#include "dhcpd.h"
...
...
@@ -46,14 +46,12 @@ void classification_setup ()
/* eval ... */
rules
=
(
struct
executable_statement
*
)
0
;
if
(
!
executable_statement_allocate
(
&
rules
,
"default collection check rule"
))
if
(
!
executable_statement_allocate
(
&
rules
,
MDL
))
log_fatal
(
"Can't allocate check of default collection"
);
rules
->
op
=
eval_statement
;
/* check-collection "default" */
if
(
!
expression_allocate
(
&
rules
->
data
.
eval
,
"default check expression"
))
if
(
!
expression_allocate
(
&
rules
->
data
.
eval
,
MDL
))
log_fatal
(
"Can't allocate default check expression"
);
rules
->
data
.
eval
->
op
=
expr_check
;
rules
->
data
.
eval
->
data
.
check
=
&
default_collection
;
...
...
@@ -65,7 +63,7 @@ void classify_client (packet)
struct
packet
*
packet
;
{
execute_statements
(
packet
,
(
struct
lease
*
)
0
,
packet
->
options
,
(
struct
option_state
*
)
0
,
(
struct
option_state
*
)
0
,
&
global_scope
,
default_classification_rules
);
}
...
...
@@ -91,7 +89,7 @@ int check_collection (packet, lease, collection)
status
=
(
evaluate_data_expression
(
&
data
,
packet
,
lease
,
packet
->
options
,
(
struct
option_state
*
)
0
,
class
->
submatch
));
&
lease
->
scope
,
class
->
submatch
));
if
(
status
)
{
if
((
nc
=
((
struct
class
*
)
hash_lookup
(
class
->
hash
,
...
...
@@ -102,21 +100,21 @@ int check_collection (packet, lease, collection)
print_hex_1
(
data
.
len
,
data
.
data
,
60
));
#endif
data_string_forget
(
&
data
,
"check_collection"
);
data_string_forget
(
&
data
,
MDL
);
classify
(
packet
,
nc
);
matched
=
1
;
continue
;
}
if
(
!
class
->
spawning
)
if
(
!
class
->
spawning
)
{
data_string_forget
(
&
data
,
MDL
);
continue
;
}
#if defined (DEBUG_CLASS_MATCHING)
log_info
(
"spawning subclass %s."
,
print_hex_1
(
data
.
len
,
data
.
data
,
60
));
#endif
nc
=
(
struct
class
*
)
dmalloc
(
sizeof
(
struct
class
),
"class spawn"
);
dmalloc
(
sizeof
(
struct
class
),
MDL
);
memset
(
nc
,
0
,
sizeof
*
nc
);
nc
->
group
=
class
->
group
;
nc
->
superclass
=
class
;
...
...
@@ -127,14 +125,16 @@ int check_collection (packet, lease, collection)
(
dmalloc
(
nc
->
lease_limit
*
sizeof
(
struct
lease
*
),
"check_collection"
));
MDL
));
if
(
!
nc
->
billed_leases
)
{
log_error
(
"no memory for%s"
,
" billing"
);
data_string_forget
(
&
nc
->
hash_string
,
"check_collection"
);
dfree
(
nc
,
"check_collection"
);
MDL
);
dfree
(
nc
,
MDL
);
data_string_forget
(
&
data
,
MDL
);
continue
;
}
memset
(
nc
->
billed_leases
,
0
,
...
...
@@ -142,8 +142,8 @@ int check_collection (packet, lease, collection)
sizeof
nc
->
billed_leases
));
}
data_string_copy
(
&
nc
->
hash_string
,
&
data
,
"check_collection"
);
data_string_forget
(
&
data
,
"check_collection"
);
MDL
);
data_string_forget
(
&
data
,
MDL
);
if
(
!
class
->
hash
)
class
->
hash
=
new_hash
();
add_hash
(
class
->
hash
,
...
...
@@ -152,13 +152,12 @@ int check_collection (packet, lease, collection)
(
unsigned
char
*
)
nc
);
classify
(
packet
,
nc
);
}
data_string_forget
(
&
data
,
"check_collection"
);
}
status
=
(
evaluate_boolean_expression_result
(
&
ignorep
,
packet
,
lease
,
packet
->
options
,
(
struct
option_state
*
)
0
,
class
->
expr
));
&
lease
->
scope
,
class
->
expr
));
if
(
status
)
{
matched
=
1
;
#if defined (DEBUG_CLASS_MATCHING)
...
...
server/dhcp.c
View file @
12c9957e
This diff is collapsed.
Click to expand it.
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