Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Host Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
network
Host Manager
Commits
07b1cae4
Commit
07b1cae4
authored
2 years ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
fix print format for dhcp lease-time remaining
parent
9d3585bd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/topology_main.c
+2
-4
2 additions, 4 deletions
src/topology_main.c
src/ubus.c
+1
-3
1 addition, 3 deletions
src/ubus.c
with
3 additions
and
7 deletions
src/topology_main.c
+
2
−
4
View file @
07b1cae4
...
@@ -222,20 +222,19 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
...
@@ -222,20 +222,19 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
int
cnt
=
0
;
int
cnt
=
0
;
int
ret
=
0
;
int
ret
=
0
;
fprintf
(
stderr
,
"%s: %d -------->
\n
"
,
__func__
,
__LINE__
);
f
=
fopen
(
"/var/dhcp.leases"
,
"r"
);
f
=
fopen
(
"/var/dhcp.leases"
,
"r"
);
if
(
!
f
)
if
(
!
f
)
return
-
1
;
return
-
1
;
while
(
fgets
(
line
,
sizeof
(
line
),
f
)
!=
NULL
)
{
while
(
fgets
(
line
,
sizeof
(
line
),
f
)
!=
NULL
)
{
long
leasetime
;
unsigned
long
leasetime
=
0
;
char
macaddr
[
18
]
=
{
0
};
char
macaddr
[
18
]
=
{
0
};
char
ipaddr
[
24
]
=
{
0
};
char
ipaddr
[
24
]
=
{
0
};
char
hostname
[
256
]
=
{
0
};
char
hostname
[
256
]
=
{
0
};
char
clid
[
256
]
=
{
0
};
char
clid
[
256
]
=
{
0
};
remove_newline
(
line
);
remove_newline
(
line
);
if
(
sscanf
(
line
,
"%l
d
%17s %23s %255s %255s"
,
&
leasetime
,
if
(
sscanf
(
line
,
"%l
u
%17s %23s %255s %255s"
,
&
leasetime
,
macaddr
,
ipaddr
,
hostname
,
clid
)
==
5
)
{
macaddr
,
ipaddr
,
hostname
,
clid
)
==
5
)
{
hosts
=
realloc
(
hosts
,
(
cnt
+
1
)
*
sizeof
(
struct
dhcp_clients
));
hosts
=
realloc
(
hosts
,
(
cnt
+
1
)
*
sizeof
(
struct
dhcp_clients
));
...
@@ -248,7 +247,6 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
...
@@ -248,7 +247,6 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
tmp
=
hosts
+
cnt
;
tmp
=
hosts
+
cnt
;
memset
(
tmp
,
0
,
sizeof
(
struct
dhcp_clients
));
memset
(
tmp
,
0
,
sizeof
(
struct
dhcp_clients
));
hwaddr_aton
(
macaddr
,
tmp
->
macaddr
);
hwaddr_aton
(
macaddr
,
tmp
->
macaddr
);
fprintf
(
stderr
,
"%s: host "
MACFMT
"
\n
"
,
__func__
,
MAC2STR
(
tmp
->
macaddr
));
strncpy
(
tmp
->
ipv4
,
ipaddr
,
sizeof
(
ipaddr
)
-
1
);
strncpy
(
tmp
->
ipv4
,
ipaddr
,
sizeof
(
ipaddr
)
-
1
);
strncpy
(
tmp
->
hostname
,
hostname
,
sizeof
(
hostname
)
-
1
);
strncpy
(
tmp
->
hostname
,
hostname
,
sizeof
(
hostname
)
-
1
);
tmp
->
leasetime
=
leasetime
;
tmp
->
leasetime
=
leasetime
;
...
...
This diff is collapsed.
Click to expand it.
src/ubus.c
+
1
−
3
View file @
07b1cae4
...
@@ -252,8 +252,6 @@ int topologyd_ubus_status(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -252,8 +252,6 @@ int topologyd_ubus_status(struct ubus_context *ctx, struct ubus_object *obj,
{
{
int
ret
=
0
;
int
ret
=
0
;
//ret = topology_get_status(p); // TODO
return
ret
;
return
ret
;
}
}
...
@@ -379,7 +377,7 @@ int topologyd_ubus_show_hosts(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -379,7 +377,7 @@ int topologyd_ubus_show_hosts(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_string
(
&
bb
,
"ipv4addr"
,
ip4buf
);
blobmsg_add_string
(
&
bb
,
"ipv4addr"
,
ip4buf
);
leasetime_rem
=
e
->
leasetime
?
e
->
leasetime
-
(
unsigned
long
)
time
(
NULL
)
:
0
;
leasetime_rem
=
e
->
leasetime
?
e
->
leasetime
-
(
unsigned
long
)
time
(
NULL
)
:
0
;
blobmsg_add_string
(
&
bb
,
"address_source"
,
leasetime_rem
?
"DHCP"
:
"Static"
);
blobmsg_add_string
(
&
bb
,
"address_source"
,
leasetime_rem
?
"DHCP"
:
"Static"
);
blobmsg_add_u
64
(
&
bb
,
"lease_time_remaining"
,
leasetime_rem
);
blobmsg_add_u
32
(
&
bb
,
"lease_time_remaining"
,
leasetime_rem
);
blobmsg_add_u8
(
&
bb
,
"iswifi"
,
e
->
type
==
NEIGH_TYPE_WIFI
?
true
:
false
);
blobmsg_add_u8
(
&
bb
,
"iswifi"
,
e
->
type
==
NEIGH_TYPE_WIFI
?
true
:
false
);
blobmsg_add_u8
(
&
bb
,
"is1905"
,
e
->
is1905
?
true
:
false
);
blobmsg_add_u8
(
&
bb
,
"is1905"
,
e
->
is1905
?
true
:
false
);
rtnl_neigh_state2str
(
e
->
state
,
statestr
,
sizeof
(
statestr
));
rtnl_neigh_state2str
(
e
->
state
,
statestr
,
sizeof
(
statestr
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment