1 /* vi: set sw=4 ts=4: */
3 * Storing and retrieving data for static leases
5 * Wade Berrier <wberrier@myrealbox.com> September 2004
7 * Licensed under GPLv2, see file LICENSE in this source tree.
12 /* Takes the address of the pointer to the static_leases linked list,
13 * address to a 6 byte mac address,
14 * 4 byte IP address */
15 void FAST_FUNC
add_static_lease(struct static_lease
**st_lease_pp
,
19 struct static_lease
*st_lease
;
21 /* Find the tail of the list */
22 while ((st_lease
= *st_lease_pp
) != NULL
) {
23 st_lease_pp
= &st_lease
->next
;
27 *st_lease_pp
= st_lease
= xzalloc(sizeof(*st_lease
));
28 memcpy(st_lease
->mac
, mac
, 6);
30 /*st_lease->next = NULL;*/
33 /* Find static lease IP by mac */
34 uint32_t FAST_FUNC
get_static_nip_by_mac(struct static_lease
*st_lease
, void *mac
)
37 if (memcmp(st_lease
->mac
, mac
, 6) == 0)
39 st_lease
= st_lease
->next
;
45 /* Check to see if an IP is reserved as a static IP */
46 int FAST_FUNC
is_nip_reserved(struct static_lease
*st_lease
, uint32_t nip
)
49 if (st_lease
->nip
== nip
)
51 st_lease
= st_lease
->next
;
57 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
58 /* Print out static leases just to check what's going on */
59 /* Takes the address of the pointer to the static_leases linked list */
60 void FAST_FUNC
log_static_leases(struct static_lease
**st_lease_pp
)
62 struct static_lease
*cur
;
69 bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
70 cur
->mac
[0], cur
->mac
[1], cur
->mac
[2],
71 cur
->mac
[3], cur
->mac
[4], cur
->mac
[5],