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
fa9ce90f
Commit
fa9ce90f
authored
1 year ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
add 'dump' ubus method to dump topology
parent
dd1c6126
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#109299
passed
1 year ago
Stage: static_code_analysis
Stage: compile_test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ubus.c
+48
-3
48 additions, 3 deletions
src/ubus.c
with
48 additions
and
3 deletions
src/ubus.c
+
48
−
3
View file @
fa9ce90f
...
...
@@ -346,13 +346,58 @@ int hostmngr_get_interface_network(struct hostmngr_private *priv)
return
ret
;
}
int
hostmngr_ubus_neighbors
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
void
hostmngr_topology_dump_cb
(
struct
ubus_request
*
req
,
int
type
,
struct
blob_attr
*
msg
)
{
struct
blob_buf
*
bb
=
(
struct
blob_buf
*
)
req
->
priv
;
struct
json_object
*
jmsg
;
char
*
jstr
;
blob_buf_init
(
bb
,
0
);
jstr
=
blobmsg_format_json
(
msg
,
true
);
if
(
!
jstr
)
return
;
jmsg
=
json_tokener_parse
(
jstr
);
if
(
!
jmsg
)
goto
out_str
;
if
(
!
json_object_is_type
(
jmsg
,
json_type_object
))
goto
out_json
;
if
(
!
blobmsg_add_json_from_string
(
bb
,
jstr
))
dbg
(
"%s: blobmsg from json-string error
\n
"
,
__func__
);
out_json:
json_object_put
(
jmsg
);
out_str:
free
(
jstr
);
}
int
hostmngr_ubus_dump_topology
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
//struct hostmngr_private *p = container_of(obj, struct i1905_private, obj);
struct
hostmngr_private
*
p
=
container_of
(
obj
,
struct
hostmngr_private
,
obj
);
const
char
*
topology_objname
=
"topology"
;
struct
blob_buf
bi
=
{
0
};
struct
blob_buf
bo
=
{
0
};
uint32_t
id
;
int
ret
=
0
;
id
=
lookup_object
(
p
->
bus
,
topology_objname
);
if
(
id
==
OBJECT_INVALID
)
return
UBUS_STATUS_NOT_FOUND
;
/* ubus call topology dump */
blob_buf_init
(
&
bi
,
0
);
ret
=
ubus_invoke
(
p
->
bus
,
id
,
"dump"
,
bi
.
head
,
hostmngr_topology_dump_cb
,
&
bo
,
2000
);
if
(
ret
==
UBUS_STATUS_OK
)
ubus_send_reply
(
ctx
,
req
,
bo
.
head
);
blob_buf_free
(
&
bi
);
blob_buf_free
(
&
bo
);
return
ret
;
}
...
...
@@ -705,9 +750,9 @@ int hostmngr_publish_object(struct hostmngr_private *p, const char *objname)
struct
ubus_object
*
obj
;
struct
ubus_method
m
[
5
]
=
{
UBUS_METHOD_NOARG
(
"show"
,
hostmngr_ubus_show_hosts
),
UBUS_METHOD_NOARG
(
"dump"
,
hostmngr_ubus_dump_topology
),
UBUS_METHOD_NOARG
(
"history"
,
hostmngr_ubus_show_history
),
UBUS_METHOD_NOARG
(
"arptable"
,
hostmngr_ubus_show_arptable
),
UBUS_METHOD_NOARG
(
"neighbors"
,
hostmngr_ubus_neighbors
),
UBUS_METHOD_NOARG
(
"debug"
,
hostmngr_ubus_debug_output
),
};
int
num_methods
=
ARRAY_SIZE
(
m
);
...
...
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