+/* vi: set sw=4 ts=4: */
/*
* static_leases.c -- Couple of functions to assist with storing and
* retrieving data for static leases
*
*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "static_leases.h"
+#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
* Address to a 4 byte ip address */
int addStaticLease(struct static_lease **lease_struct, uint8_t *mac, uint32_t *ip)
{
-
struct static_lease *cur;
struct static_lease *new_static_lease;
new_static_lease->next = NULL;
/* If it's the first node to be added... */
- if(*lease_struct == NULL)
- {
+ if (*lease_struct == NULL) {
*lease_struct = new_static_lease;
- }
- else
- {
+ } else {
cur = *lease_struct;
- while(cur->next != NULL)
- {
+ while (cur->next) {
cur = cur->next;
}
}
return 1;
-
}
/* Check to see if a mac has an associated static lease */
return_ip = 0;
- while(cur != NULL)
- {
+ while (cur) {
/* If the client has the correct mac */
- if(memcmp(cur->mac, mac, 6) == 0)
- {
+ if (memcmp(cur->mac, mac, 6) == 0) {
return_ip = *(cur->ip);
}
}
return return_ip;
-
}
/* Check to see if an ip is reserved as a static ip */
uint32_t return_val = 0;
- while(cur != NULL)
- {
+ while (cur) {
/* If the client has the correct ip */
- if(*cur->ip == ip)
+ if (*cur->ip == ip)
return_val = 1;
cur = cur->next;
}
return return_val;
-
}
-#ifdef UDHCP_DEBUG
+#if ENABLE_FEATURE_UDHCP_DEBUG
/* Print out static leases just to check what's going on */
/* Takes the address of the pointer to the static_leases linked list */
void printStaticLeases(struct static_lease **arg)
/* Get a pointer to the linked list */
struct static_lease *cur = *arg;
- while(cur != NULL)
- {
+ while (cur) {
/* printf("PrintStaticLeases: Lease mac Address: %x\n", cur->mac); */
printf("PrintStaticLeases: Lease mac Value: %x\n", *(cur->mac));
/* printf("PrintStaticLeases: Lease ip Address: %x\n", cur->ip); */
cur = cur->next;
}
-
-
}
#endif
-
-
-