Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
216b820d
Commit
216b820d
authored
May 25, 2017
by
Arnim Läuger
Committed by
Marcel Stör
May 25, 2017
Browse files
Ensure standard DHCP message length when sending response to clients (#1985)
parent
2c553583
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/include/lwip/app/dhcpserver.h
View file @
216b820d
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
#define USE_DNS
#define USE_DNS
#define DHCP_MSGOPTIONS_MIN_LEN 312
typedef
struct
dhcps_state
{
typedef
struct
dhcps_state
{
sint16_t
state
;
sint16_t
state
;
}
dhcps_state
;
}
dhcps_state
;
...
...
app/lwip/app/dhcpserver.c
View file @
216b820d
...
@@ -298,7 +298,8 @@ static void ICACHE_FLASH_ATTR send_offer(struct dhcps_msg *m)
...
@@ -298,7 +298,8 @@ static void ICACHE_FLASH_ATTR send_offer(struct dhcps_msg *m)
end
=
add_offer_options
(
end
);
end
=
add_offer_options
(
end
);
end
=
add_end
(
end
);
end
=
add_end
(
end
);
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
),
PBUF_RAM
);
// ensure that not more than the minimum options length is transmitted
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
)
-
sizeof
(
m
->
options
)
+
DHCP_MSGOPTIONS_MIN_LEN
,
PBUF_RAM
);
#if DHCPS_DEBUG
#if DHCPS_DEBUG
os_printf
(
"udhcp: send_offer>>p->ref = %d
\n
"
,
p
->
ref
);
os_printf
(
"udhcp: send_offer>>p->ref = %d
\n
"
,
p
->
ref
);
#endif
#endif
...
@@ -358,7 +359,8 @@ static void ICACHE_FLASH_ATTR send_nak(struct dhcps_msg *m)
...
@@ -358,7 +359,8 @@ static void ICACHE_FLASH_ATTR send_nak(struct dhcps_msg *m)
end
=
add_msg_type
(
&
m
->
options
[
4
],
DHCPNAK
);
end
=
add_msg_type
(
&
m
->
options
[
4
],
DHCPNAK
);
end
=
add_end
(
end
);
end
=
add_end
(
end
);
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
),
PBUF_RAM
);
// ensure that not more than the minimum options length is transmitted
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
)
-
sizeof
(
m
->
options
)
+
DHCP_MSGOPTIONS_MIN_LEN
,
PBUF_RAM
);
#if DHCPS_DEBUG
#if DHCPS_DEBUG
os_printf
(
"udhcp: send_nak>>p->ref = %d
\n
"
,
p
->
ref
);
os_printf
(
"udhcp: send_nak>>p->ref = %d
\n
"
,
p
->
ref
);
#endif
#endif
...
@@ -418,8 +420,9 @@ static void ICACHE_FLASH_ATTR send_ack(struct dhcps_msg *m)
...
@@ -418,8 +420,9 @@ static void ICACHE_FLASH_ATTR send_ack(struct dhcps_msg *m)
end
=
add_msg_type
(
&
m
->
options
[
4
],
DHCPACK
);
end
=
add_msg_type
(
&
m
->
options
[
4
],
DHCPACK
);
end
=
add_offer_options
(
end
);
end
=
add_offer_options
(
end
);
end
=
add_end
(
end
);
end
=
add_end
(
end
);
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
),
PBUF_RAM
);
// ensure that not more than the minimum options length is transmitted
p
=
pbuf_alloc
(
PBUF_TRANSPORT
,
sizeof
(
struct
dhcps_msg
)
-
sizeof
(
m
->
options
)
+
DHCP_MSGOPTIONS_MIN_LEN
,
PBUF_RAM
);
#if DHCPS_DEBUG
#if DHCPS_DEBUG
os_printf
(
"udhcp: send_ack>>p->ref = %d
\n
"
,
p
->
ref
);
os_printf
(
"udhcp: send_ack>>p->ref = %d
\n
"
,
p
->
ref
);
#endif
#endif
...
...
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