aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-21 16:06:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-21 16:06:34 +0200
commit831844c13931f14bd0433c1eb848c863288a8c06 (patch)
tree51e7177686e048f748c71f8de353506731d4d06c /networking/udhcp/dhcpd.c
parentd8740b265a4d4e428b3494089d5a86e1ec90238a (diff)
downloadbusybox-w32-831844c13931f14bd0433c1eb848c863288a8c06.tar.gz
busybox-w32-831844c13931f14bd0433c1eb848c863288a8c06.tar.bz2
busybox-w32-831844c13931f14bd0433c1eb848c863288a8c06.zip
udhcpd: fix printing of static leases
function old new delta read_staticlease 299 282 -17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--networking/udhcp/dhcpd.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 3d60abf8f..058f86bca 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -66,13 +66,14 @@ static void add_static_lease(struct static_lease **st_lease_pp,
66 struct static_lease *st_lease; 66 struct static_lease *st_lease;
67 unsigned optlen; 67 unsigned optlen;
68 68
69 optlen = (opts ? 1+1+strnlen(opts, 120) : 0);
70
69 /* Find the tail of the list */ 71 /* Find the tail of the list */
70 while ((st_lease = *st_lease_pp) != NULL) { 72 while ((st_lease = *st_lease_pp) != NULL) {
71 st_lease_pp = &st_lease->next; 73 st_lease_pp = &st_lease->next;
72 } 74 }
73 75
74 /* Add new node */ 76 /* Add new node */
75 optlen = (opts ? 1+1+strnlen(opts, 120) : 0);
76 *st_lease_pp = st_lease = xzalloc(sizeof(*st_lease) + optlen); 77 *st_lease_pp = st_lease = xzalloc(sizeof(*st_lease) + optlen);
77 memcpy(st_lease->mac, mac, 6); 78 memcpy(st_lease->mac, mac, 6);
78 st_lease->nip = nip; 79 st_lease->nip = nip;
@@ -83,6 +84,17 @@ static void add_static_lease(struct static_lease **st_lease_pp,
83 st_lease->opt[OPT_LEN] = optlen; 84 st_lease->opt[OPT_LEN] = optlen;
84 memcpy(&st_lease->opt[OPT_DATA], opts, optlen); 85 memcpy(&st_lease->opt[OPT_DATA], opts, optlen);
85 } 86 }
87
88#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
89 /* Print out static leases just to check what's going on */
90 if (dhcp_verbose >= 2) {
91 bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
92 st_lease->mac[0], st_lease->mac[1], st_lease->mac[2],
93 st_lease->mac[3], st_lease->mac[4], st_lease->mac[5],
94 st_lease->nip
95 );
96 }
97#endif
86} 98}
87 99
88/* Find static lease IP by mac */ 100/* Find static lease IP by mac */
@@ -112,30 +124,6 @@ static int is_nip_reserved_as_static(uint32_t nip)
112 return 0; 124 return 0;
113} 125}
114 126
115#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
116/* Print out static leases just to check what's going on */
117/* Takes the address of the pointer to the static_leases linked list */
118static void log_static_leases(struct static_lease **st_lease_pp)
119{
120 struct static_lease *cur;
121
122 if (dhcp_verbose < 2)
123 return;
124
125 cur = *st_lease_pp;
126 while (cur) {
127 bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
128 cur->mac[0], cur->mac[1], cur->mac[2],
129 cur->mac[3], cur->mac[4], cur->mac[5],
130 cur->nip
131 );
132 cur = cur->next;
133 }
134}
135#else
136# define log_static_leases(st_lease_pp) ((void)0)
137#endif
138
139/* Find the oldest expired lease, NULL if there are no expired leases */ 127/* Find the oldest expired lease, NULL if there are no expired leases */
140static struct dyn_lease *oldest_expired_lease(void) 128static struct dyn_lease *oldest_expired_lease(void)
141{ 129{
@@ -380,8 +368,6 @@ static int FAST_FUNC read_staticlease(const char *const_line, void *arg)
380 368
381 add_static_lease(arg, (uint8_t*) &mac_bytes, nip, opts); 369 add_static_lease(arg, (uint8_t*) &mac_bytes, nip, opts);
382 370
383 log_static_leases(arg);
384
385 return 1; 371 return 1;
386} 372}
387 373