diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-08 22:56:18 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-08 22:56:18 +0000 |
commit | efb545b9bdd3934dcdbf9bc0890a42081b330049 (patch) | |
tree | 4dc9212e49a5dae9890bd324bcc9bf4941e2321d /networking/udhcp/serverpacket.c | |
parent | d1a84a2880073f6cc5e2f9f4e5f236cd110f01a0 (diff) | |
download | busybox-w32-efb545b9bdd3934dcdbf9bc0890a42081b330049.tar.gz busybox-w32-efb545b9bdd3934dcdbf9bc0890a42081b330049.tar.bz2 busybox-w32-efb545b9bdd3934dcdbf9bc0890a42081b330049.zip |
optimize 16- and 32-bit moves
function old new delta
udhcpd_main 1239 1257 +18
udhcp_add_simple_option 93 92 -1
buffer_read_le_u32 19 18 -1
unpack_gz_stream_with_info 526 520 -6
dnsd_main 1470 1463 -7
udhcp_run_script 1208 1186 -22
send_ACK 255 229 -26
arping_main 1661 1623 -38
send_offer 470 428 -42
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 18/-143) Total: -125 bytes
Diffstat (limited to 'networking/udhcp/serverpacket.c')
-rw-r--r-- | networking/udhcp/serverpacket.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c index dcc234c7d..fca685dd1 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c | |||
@@ -103,7 +103,8 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) | |||
103 | { | 103 | { |
104 | struct dhcpMessage packet; | 104 | struct dhcpMessage packet; |
105 | struct dhcpOfferedAddr *lease = NULL; | 105 | struct dhcpOfferedAddr *lease = NULL; |
106 | uint32_t req_align, lease_time_align = server_config.lease; | 106 | uint32_t req_align; |
107 | uint32_t lease_time_aligned = server_config.lease; | ||
107 | uint8_t *req, *lease_time; | 108 | uint8_t *req, *lease_time; |
108 | struct option_set *curr; | 109 | struct option_set *curr; |
109 | struct in_addr addr; | 110 | struct in_addr addr; |
@@ -120,7 +121,7 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) | |||
120 | lease = find_lease_by_chaddr(oldpacket->chaddr); | 121 | lease = find_lease_by_chaddr(oldpacket->chaddr); |
121 | if (lease) { | 122 | if (lease) { |
122 | if (!lease_expired(lease)) | 123 | if (!lease_expired(lease)) |
123 | lease_time_align = lease->expires - time(0); | 124 | lease_time_aligned = lease->expires - time(0); |
124 | packet.yiaddr = lease->yiaddr; | 125 | packet.yiaddr = lease->yiaddr; |
125 | /* Or the client has a requested ip */ | 126 | /* Or the client has a requested ip */ |
126 | } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) | 127 | } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) |
@@ -155,22 +156,22 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) | |||
155 | } | 156 | } |
156 | lease_time = get_option(oldpacket, DHCP_LEASE_TIME); | 157 | lease_time = get_option(oldpacket, DHCP_LEASE_TIME); |
157 | if (lease_time) { | 158 | if (lease_time) { |
158 | memcpy(&lease_time_align, lease_time, 4); | 159 | move_from_unaligned32(lease_time_aligned, lease_time); |
159 | lease_time_align = ntohl(lease_time_align); | 160 | lease_time_aligned = ntohl(lease_time_aligned); |
160 | if (lease_time_align > server_config.lease) | 161 | if (lease_time_aligned > server_config.lease) |
161 | lease_time_align = server_config.lease; | 162 | lease_time_aligned = server_config.lease; |
162 | } | 163 | } |
163 | 164 | ||
164 | /* Make sure we aren't just using the lease time from the previous offer */ | 165 | /* Make sure we aren't just using the lease time from the previous offer */ |
165 | if (lease_time_align < server_config.min_lease) | 166 | if (lease_time_aligned < server_config.min_lease) |
166 | lease_time_align = server_config.lease; | 167 | lease_time_aligned = server_config.lease; |
167 | /* ADDME: end of short circuit */ | 168 | /* ADDME: end of short circuit */ |
168 | } else { | 169 | } else { |
169 | /* It is a static lease... use it */ | 170 | /* It is a static lease... use it */ |
170 | packet.yiaddr = static_lease_ip; | 171 | packet.yiaddr = static_lease_ip; |
171 | } | 172 | } |
172 | 173 | ||
173 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); | 174 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_aligned)); |
174 | 175 | ||
175 | curr = server_config.options; | 176 | curr = server_config.options; |
176 | while (curr) { | 177 | while (curr) { |
@@ -203,7 +204,7 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) | |||
203 | struct dhcpMessage packet; | 204 | struct dhcpMessage packet; |
204 | struct option_set *curr; | 205 | struct option_set *curr; |
205 | uint8_t *lease_time; | 206 | uint8_t *lease_time; |
206 | uint32_t lease_time_align = server_config.lease; | 207 | uint32_t lease_time_aligned = server_config.lease; |
207 | struct in_addr addr; | 208 | struct in_addr addr; |
208 | 209 | ||
209 | init_packet(&packet, oldpacket, DHCPACK); | 210 | init_packet(&packet, oldpacket, DHCPACK); |
@@ -211,15 +212,15 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) | |||
211 | 212 | ||
212 | lease_time = get_option(oldpacket, DHCP_LEASE_TIME); | 213 | lease_time = get_option(oldpacket, DHCP_LEASE_TIME); |
213 | if (lease_time) { | 214 | if (lease_time) { |
214 | memcpy(&lease_time_align, lease_time, 4); | 215 | move_from_unaligned32(lease_time_aligned, lease_time); |
215 | lease_time_align = ntohl(lease_time_align); | 216 | lease_time_aligned = ntohl(lease_time_aligned); |
216 | if (lease_time_align > server_config.lease) | 217 | if (lease_time_aligned > server_config.lease) |
217 | lease_time_align = server_config.lease; | 218 | lease_time_aligned = server_config.lease; |
218 | else if (lease_time_align < server_config.min_lease) | 219 | else if (lease_time_aligned < server_config.min_lease) |
219 | lease_time_align = server_config.lease; | 220 | lease_time_aligned = server_config.lease; |
220 | } | 221 | } |
221 | 222 | ||
222 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); | 223 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_aligned)); |
223 | 224 | ||
224 | curr = server_config.options; | 225 | curr = server_config.options; |
225 | while (curr) { | 226 | while (curr) { |
@@ -236,7 +237,7 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) | |||
236 | if (send_packet(&packet, 0) < 0) | 237 | if (send_packet(&packet, 0) < 0) |
237 | return -1; | 238 | return -1; |
238 | 239 | ||
239 | add_lease(packet.chaddr, packet.yiaddr, lease_time_align); | 240 | add_lease(packet.chaddr, packet.yiaddr, lease_time_aligned); |
240 | if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { | 241 | if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { |
241 | /* rewrite the file with leases at every new acceptance */ | 242 | /* rewrite the file with leases at every new acceptance */ |
242 | write_leases(); | 243 | write_leases(); |