diff options
author | Denis Vlasenko | 2008-12-08 22:56:18 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-12-08 22:56:18 +0000 |
commit | efb545b9bdd3934dcdbf9bc0890a42081b330049 (patch) | |
tree | 4dc9212e49a5dae9890bd324bcc9bf4941e2321d /networking/udhcp/serverpacket.c | |
parent | d1a84a2880073f6cc5e2f9f4e5f236cd110f01a0 (diff) | |
download | busybox-efb545b9bdd3934dcdbf9bc0890a42081b330049.zip busybox-efb545b9bdd3934dcdbf9bc0890a42081b330049.tar.gz |
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 dcc234c..fca685d 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c @@ -103,7 +103,8 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) { struct dhcpMessage packet; struct dhcpOfferedAddr *lease = NULL; - uint32_t req_align, lease_time_align = server_config.lease; + uint32_t req_align; + uint32_t lease_time_aligned = server_config.lease; uint8_t *req, *lease_time; struct option_set *curr; struct in_addr addr; @@ -120,7 +121,7 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) lease = find_lease_by_chaddr(oldpacket->chaddr); if (lease) { if (!lease_expired(lease)) - lease_time_align = lease->expires - time(0); + lease_time_aligned = lease->expires - time(0); packet.yiaddr = lease->yiaddr; /* Or the client has a requested ip */ } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) @@ -155,22 +156,22 @@ int FAST_FUNC send_offer(struct dhcpMessage *oldpacket) } lease_time = get_option(oldpacket, DHCP_LEASE_TIME); if (lease_time) { - memcpy(&lease_time_align, lease_time, 4); - lease_time_align = ntohl(lease_time_align); - if (lease_time_align > server_config.lease) - lease_time_align = server_config.lease; + move_from_unaligned32(lease_time_aligned, lease_time); + lease_time_aligned = ntohl(lease_time_aligned); + if (lease_time_aligned > server_config.lease) + lease_time_aligned = server_config.lease; } /* Make sure we aren't just using the lease time from the previous offer */ - if (lease_time_align < server_config.min_lease) - lease_time_align = server_config.lease; + if (lease_time_aligned < server_config.min_lease) + lease_time_aligned = server_config.lease; /* ADDME: end of short circuit */ } else { /* It is a static lease... use it */ packet.yiaddr = static_lease_ip; } - add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); + add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_aligned)); curr = server_config.options; while (curr) { @@ -203,7 +204,7 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) struct dhcpMessage packet; struct option_set *curr; uint8_t *lease_time; - uint32_t lease_time_align = server_config.lease; + uint32_t lease_time_aligned = server_config.lease; struct in_addr addr; init_packet(&packet, oldpacket, DHCPACK); @@ -211,15 +212,15 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) lease_time = get_option(oldpacket, DHCP_LEASE_TIME); if (lease_time) { - memcpy(&lease_time_align, lease_time, 4); - lease_time_align = ntohl(lease_time_align); - if (lease_time_align > server_config.lease) - lease_time_align = server_config.lease; - else if (lease_time_align < server_config.min_lease) - lease_time_align = server_config.lease; + move_from_unaligned32(lease_time_aligned, lease_time); + lease_time_aligned = ntohl(lease_time_aligned); + if (lease_time_aligned > server_config.lease) + lease_time_aligned = server_config.lease; + else if (lease_time_aligned < server_config.min_lease) + lease_time_aligned = server_config.lease; } - add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); + add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_aligned)); curr = server_config.options; while (curr) { @@ -236,7 +237,7 @@ int FAST_FUNC send_ACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) if (send_packet(&packet, 0) < 0) return -1; - add_lease(packet.chaddr, packet.yiaddr, lease_time_align); + add_lease(packet.chaddr, packet.yiaddr, lease_time_aligned); if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { /* rewrite the file with leases at every new acceptance */ write_leases(); |