aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 8bd65df52..b625756f9 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -39,7 +39,64 @@
39#include "dhcpc.h" 39#include "dhcpc.h"
40#include "dhcpd.h" 40#include "dhcpd.h"
41 41
42/* on these functions, make sure your datatype matches */ 42/* Takes the address of the pointer to the static_leases linked list,
43 * address to a 6 byte mac address,
44 * 4 byte IP address */
45static void add_static_lease(struct static_lease **st_lease_pp,
46 uint8_t *mac,
47 uint32_t nip)
48{
49 struct static_lease *st_lease;
50
51 /* Find the tail of the list */
52 while ((st_lease = *st_lease_pp) != NULL) {
53 st_lease_pp = &st_lease->next;
54 }
55
56 /* Add new node */
57 *st_lease_pp = st_lease = xzalloc(sizeof(*st_lease));
58 memcpy(st_lease->mac, mac, 6);
59 st_lease->nip = nip;
60 /*st_lease->next = NULL;*/
61}
62
63/* Find static lease IP by mac */
64static uint32_t get_static_nip_by_mac(struct static_lease *st_lease, void *mac)
65{
66 while (st_lease) {
67 if (memcmp(st_lease->mac, mac, 6) == 0)
68 return st_lease->nip;
69 st_lease = st_lease->next;
70 }
71
72 return 0;
73}
74
75#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
76/* Print out static leases just to check what's going on */
77/* Takes the address of the pointer to the static_leases linked list */
78static void log_static_leases(struct static_lease **st_lease_pp)
79{
80 struct static_lease *cur;
81
82 if (dhcp_verbose < 2)
83 return;
84
85 cur = *st_lease_pp;
86 while (cur) {
87 bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
88 cur->mac[0], cur->mac[1], cur->mac[2],
89 cur->mac[3], cur->mac[4], cur->mac[5],
90 cur->nip
91 );
92 cur = cur->next;
93 }
94}
95#else
96# define log_static_leases(st_lease_pp) ((void)0)
97#endif
98
99/* On these functions, make sure your datatype matches */
43static int FAST_FUNC read_str(const char *line, void *arg) 100static int FAST_FUNC read_str(const char *line, void *arg)
44{ 101{
45 char **dest = arg; 102 char **dest = arg;