mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 00:06:59 +00:00
analyze, getdata: write functions in frequency order
According to test data free is seen most often in leases file. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
72a41d8086
commit
5f59daa692
2 changed files with 20 additions and 15 deletions
|
|
@ -84,12 +84,12 @@ int do_counting(void)
|
||||||
}
|
}
|
||||||
/* IP in range */
|
/* IP in range */
|
||||||
switch (l->type) {
|
switch (l->type) {
|
||||||
case ACTIVE:
|
|
||||||
range_p->count++;
|
|
||||||
break;
|
|
||||||
case FREE:
|
case FREE:
|
||||||
range_p->touched++;
|
range_p->touched++;
|
||||||
break;
|
break;
|
||||||
|
case ACTIVE:
|
||||||
|
range_p->count++;
|
||||||
|
break;
|
||||||
case BACKUP:
|
case BACKUP:
|
||||||
range_p->backups++;
|
range_p->backups++;
|
||||||
break;
|
break;
|
||||||
|
|
@ -97,12 +97,12 @@ int do_counting(void)
|
||||||
|
|
||||||
if (range_p->shared_net) {
|
if (range_p->shared_net) {
|
||||||
switch (l->type) {
|
switch (l->type) {
|
||||||
case ACTIVE:
|
|
||||||
range_p->shared_net->used++;
|
|
||||||
break;
|
|
||||||
case FREE:
|
case FREE:
|
||||||
range_p->shared_net->touched++;
|
range_p->shared_net->touched++;
|
||||||
break;
|
break;
|
||||||
|
case ACTIVE:
|
||||||
|
range_p->shared_net->used++;
|
||||||
|
break;
|
||||||
case BACKUP:
|
case BACKUP:
|
||||||
range_p->shared_net->backups++;
|
range_p->shared_net->backups++;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -116,29 +116,34 @@ int parse_leases(void)
|
||||||
nth_field(2, ipstring, ipstring);
|
nth_field(2, ipstring, ipstring);
|
||||||
inet_aton(ipstring, &inp);
|
inet_aton(ipstring, &inp);
|
||||||
sw_active_lease = 0;
|
sw_active_lease = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (xstrstr(line, " binding state free", 20)) {
|
||||||
|
/* remove old entry, if exists */
|
||||||
|
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
||||||
|
delete_lease(lease);
|
||||||
|
}
|
||||||
|
add_lease(htonl(inp.s_addr), FREE);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
/* Copy IP to correct array */
|
/* Copy IP to correct array */
|
||||||
else if (xstrstr(line, " binding state active", 22)) {
|
if (xstrstr(line, " binding state active", 22)) {
|
||||||
/* remove old entry, if exists */
|
/* remove old entry, if exists */
|
||||||
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
||||||
delete_lease(lease);
|
delete_lease(lease);
|
||||||
}
|
}
|
||||||
add_lease(htonl(inp.s_addr), ACTIVE);
|
add_lease(htonl(inp.s_addr), ACTIVE);
|
||||||
sw_active_lease = 1;
|
sw_active_lease = 1;
|
||||||
} else if (xstrstr(line, " binding state free", 20)) {
|
continue;
|
||||||
/* remove old entry, if exists */
|
}
|
||||||
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
if (xstrstr(line, " binding state backup", 22)) {
|
||||||
delete_lease(lease);
|
|
||||||
}
|
|
||||||
add_lease(htonl(inp.s_addr), FREE);
|
|
||||||
} else if (xstrstr(line, " binding state backup", 22)) {
|
|
||||||
/* remove old entry, if exists */
|
/* remove old entry, if exists */
|
||||||
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
if ((lease = find_lease(htonl(inp.s_addr))) != NULL) {
|
||||||
delete_lease(lease);
|
delete_lease(lease);
|
||||||
}
|
}
|
||||||
add_lease(htonl(inp.s_addr), BACKUP);
|
add_lease(htonl(inp.s_addr), BACKUP);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((macaddr != NULL)
|
if ((macaddr != NULL)
|
||||||
&& (sw_active_lease == 1)
|
&& (sw_active_lease == 1)
|
||||||
&& (xstrstr(line, " hardware ethernet", 19))) {
|
&& (xstrstr(line, " hardware ethernet", 19))) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue