mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
8f2e99c813
function old new delta udhcpd_main 1501 1531 +30 d6_recv_raw_packet 251 264 +13 perform_d6_release 188 198 +10 udhcpc6_main 2443 2449 +6 udhcp_recv_raw_packet 582 588 +6 udhcp_recv_kernel_packet 132 138 +6 send_d6_renew 140 146 +6 d6_recv_kernel_packet 118 124 +6 send_renew 77 82 +5 send_discover 85 90 +5 send_decline 84 89 +5 send_d6_select 97 102 +5 send_d6_discover 174 179 +5 perform_release 167 172 +5 count_lines 72 74 +2 udhcpc_main 2836 2837 +1 bb_info_msg 125 - -125 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180) Total: -63 bytes text data bss dec hex filename 924935 906 17160 943001 e6399 busybox_old 924736 906 17160 942802 e62d2 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
78 lines
1.8 KiB
C
78 lines
1.8 KiB
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* Storing and retrieving data for static leases
|
|
*
|
|
* Wade Berrier <wberrier@myrealbox.com> September 2004
|
|
*
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
|
*/
|
|
#include "common.h"
|
|
#include "dhcpd.h"
|
|
|
|
/* Takes the address of the pointer to the static_leases linked list,
|
|
* address to a 6 byte mac address,
|
|
* 4 byte IP address */
|
|
void FAST_FUNC add_static_lease(struct static_lease **st_lease_pp,
|
|
uint8_t *mac,
|
|
uint32_t nip)
|
|
{
|
|
struct static_lease *st_lease;
|
|
|
|
/* Find the tail of the list */
|
|
while ((st_lease = *st_lease_pp) != NULL) {
|
|
st_lease_pp = &st_lease->next;
|
|
}
|
|
|
|
/* Add new node */
|
|
*st_lease_pp = st_lease = xzalloc(sizeof(*st_lease));
|
|
memcpy(st_lease->mac, mac, 6);
|
|
st_lease->nip = nip;
|
|
/*st_lease->next = NULL;*/
|
|
}
|
|
|
|
/* Find static lease IP by mac */
|
|
uint32_t FAST_FUNC get_static_nip_by_mac(struct static_lease *st_lease, void *mac)
|
|
{
|
|
while (st_lease) {
|
|
if (memcmp(st_lease->mac, mac, 6) == 0)
|
|
return st_lease->nip;
|
|
st_lease = st_lease->next;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Check to see if an IP is reserved as a static IP */
|
|
int FAST_FUNC is_nip_reserved(struct static_lease *st_lease, uint32_t nip)
|
|
{
|
|
while (st_lease) {
|
|
if (st_lease->nip == nip)
|
|
return 1;
|
|
st_lease = st_lease->next;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
|
|
/* Print out static leases just to check what's going on */
|
|
/* Takes the address of the pointer to the static_leases linked list */
|
|
void FAST_FUNC log_static_leases(struct static_lease **st_lease_pp)
|
|
{
|
|
struct static_lease *cur;
|
|
|
|
if (dhcp_verbose < 2)
|
|
return;
|
|
|
|
cur = *st_lease_pp;
|
|
while (cur) {
|
|
bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
|
|
cur->mac[0], cur->mac[1], cur->mac[2],
|
|
cur->mac[3], cur->mac[4], cur->mac[5],
|
|
cur->nip
|
|
);
|
|
cur = cur->next;
|
|
}
|
|
}
|
|
#endif
|