summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/dhcpd.c59
-rw-r--r--networking/udhcp/dhcpd.h13
-rw-r--r--networking/udhcp/static_leases.c55
3 files changed, 58 insertions, 69 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 8bd65df..b625756 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -39,7 +39,64 @@
#include "dhcpc.h"
#include "dhcpd.h"
-/* on these functions, make sure your datatype matches */
+/* Takes the address of the pointer to the static_leases linked list,
+ * address to a 6 byte mac address,
+ * 4 byte IP address */
+static void 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 */
+static uint32_t 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;
+}
+
+#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 */
+static void 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;
+ }
+}
+#else
+# define log_static_leases(st_lease_pp) ((void)0)
+#endif
+
+/* On these functions, make sure your datatype matches */
static int FAST_FUNC read_str(const char *line, void *arg)
{
char **dest = arg;
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 08c9e8c..b8d94a7 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -102,20 +102,7 @@ struct dyn_lease *find_lease_by_mac(const uint8_t *mac) FAST_FUNC;
struct dyn_lease *find_lease_by_nip(uint32_t nip) FAST_FUNC;
uint32_t find_free_or_expired_nip(const uint8_t *safe_mac, unsigned arpping_ms) FAST_FUNC;
-
-/* Config file parser will pass static lease info to this function
- * which will add it to a data structure that can be searched later */
-void add_static_lease(struct static_lease **st_lease_pp, uint8_t *mac, uint32_t nip) FAST_FUNC;
-/* Find static lease IP by mac */
-uint32_t get_static_nip_by_mac(struct static_lease *st_lease, void *arg) FAST_FUNC;
-/* Check to see if an IP is reserved as a static IP */
int is_nip_reserved(struct static_lease *st_lease, uint32_t nip) FAST_FUNC;
-/* Print out static leases just to check what's going on (debug code) */
-#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
-void log_static_leases(struct static_lease **st_lease_pp) FAST_FUNC;
-#else
-# define log_static_leases(st_lease_pp) ((void)0)
-#endif
POP_SAVED_FUNCTION_VISIBILITY
diff --git a/networking/udhcp/static_leases.c b/networking/udhcp/static_leases.c
index b7f9e5c..3be7a52 100644
--- a/networking/udhcp/static_leases.c
+++ b/networking/udhcp/static_leases.c
@@ -9,39 +9,6 @@
#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)
{
@@ -53,25 +20,3 @@ int FAST_FUNC is_nip_reserved(struct static_lease *st_lease, uint32_t nip)
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