Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
map-topology
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
Container registry
Model registry
Operate
Environments
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
Multi-AP
map-topology
Commits
63cea91e
Commit
63cea91e
authored
4 years ago
by
Nevadita
Browse files
Options
Downloads
Patches
Plain Diff
map-topology:Adding status changes and making changelog array dynamic
parent
95da3106
No related branches found
No related tags found
1 merge request
!5
map-topology:Adding status changes and making changelog array dynamic
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+21
-9
21 additions, 9 deletions
README.md
src/topologyd.c
+34
-8
34 additions, 8 deletions
src/topologyd.c
src/topologyd.h
+2
-1
2 additions, 1 deletion
src/topologyd.h
with
57 additions
and
18 deletions
README.md
+
21
−
9
View file @
63cea91e
...
@@ -82,17 +82,29 @@ root@iopsys:~$ ubus call topology dump
...
@@ -82,17 +82,29 @@ root@iopsys:~$ ubus call topology dump
}
}
#To show the topology changelogs -
#To show the topology changelogs -
root@iopsys:~
$
ubus call topology changelog
root@iopsys:~
#
ubus call topology changelog
{
{
"changelog"
:
[
"num_changelog"
: 2,
{
"changelog"
:
[
<TODO>
{
}
,
"reporter"
:
"00:22:07:6d:3d:8e"
,
{
"reporter_interface"
:
"00:22:07:70:f5:6c"
,
<TODO>
"neighbor"
:
"00:22:07:6d:3d:8e"
,
}
"is1905_neighbor"
:
"true"
,
]
"event_type"
:
"add"
,
"timestamp"
:
"2020-07-06T11:51:54"
}
,
{
"reporter"
:
"00:22:07:ae:ed:fd"
,
"reporter_interface"
:
"00:22:07:70:f5:6c"
,
"neighbor"
:
"00:22:07:ae:ed:fd"
,
"is1905_neighbor"
:
"true"
,
"event_type"
:
"add"
,
"timestamp"
:
"2020-07-06T11:56:01"
}
]
}
}
````
````
### Testing
### Testing
...
...
This diff is collapsed.
Click to expand it.
src/topologyd.c
+
34
−
8
View file @
63cea91e
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
static
int
signal_pending
;
static
int
signal_pending
;
extern
int
refresh_int
;
extern
int
refresh_int
;
extern
const
char
*
ubus_socket
;
extern
const
char
*
ubus_socket
;
uint32_t
topology_log_max
;
static
void
topologyd_sighandler
(
int
sig
)
static
void
topologyd_sighandler
(
int
sig
)
{
{
...
@@ -296,13 +297,16 @@ void topologyd_print_changelog(struct blob_buf *bb, struct topologyd_private *pr
...
@@ -296,13 +297,16 @@ void topologyd_print_changelog(struct blob_buf *bb, struct topologyd_private *pr
char
rpt_ifmacstr
[
18
]
=
{
0
};
char
rpt_ifmacstr
[
18
]
=
{
0
};
char
rpt_macstr
[
18
]
=
{
0
};
char
rpt_macstr
[
18
]
=
{
0
};
char
nbr_macstr
[
18
]
=
{
0
};
char
nbr_macstr
[
18
]
=
{
0
};
char
*
timestring
;
void
*
t
;
void
*
t
;
int
i
;
int
i
;
struct
tm
*
info
;
struct
tm
*
info
;
time_t
tmp_t
;
time_t
tmp_t
;
char
str_tm
[
20
];
dbg
(
"changelog start value is [%d] end value is [%d]"
,
start
,
end
);
dbg
(
"changelog start value is [%d] end value is [%d]"
,
start
,
end
);
if
(
bb
==
NULL
||
priv
==
NULL
)
return
;
for
(
i
=
start
;
i
<=
end
;
i
++
)
{
for
(
i
=
start
;
i
<=
end
;
i
++
)
{
log
=
&
priv
->
topo
.
changelog
[
i
];
log
=
&
priv
->
topo
.
changelog
[
i
];
t
=
blobmsg_open_table
(
bb
,
NULL
);
t
=
blobmsg_open_table
(
bb
,
NULL
);
...
@@ -324,8 +328,8 @@ void topologyd_print_changelog(struct blob_buf *bb, struct topologyd_private *pr
...
@@ -324,8 +328,8 @@ void topologyd_print_changelog(struct blob_buf *bb, struct topologyd_private *pr
tmp_t
=
log
->
timestamp
;
tmp_t
=
log
->
timestamp
;
info
=
localtime
(
&
tmp_t
);
info
=
localtime
(
&
tmp_t
);
timestr
ing
=
asctime
(
info
);
strf
time
(
str
_tm
,
sizeof
str_tm
,
"%Y-%m-%dT%H:%M:%S"
,
info
);
blobmsg_add_string
(
bb
,
"timestamp"
,
timestring
);
blobmsg_add_string
(
bb
,
"timestamp"
,
str_tm
);
blobmsg_close_table
(
bb
,
t
);
blobmsg_close_table
(
bb
,
t
);
}
}
}
}
...
@@ -340,7 +344,7 @@ void topologyd_dump_changelog(struct topologyd_private *priv, struct blob_buf *b
...
@@ -340,7 +344,7 @@ void topologyd_dump_changelog(struct topologyd_private *priv, struct blob_buf *b
return
;
return
;
}
}
if
(
priv
->
topo
.
changelog_front
>
priv
->
topo
.
changelog_rear
)
{
if
(
priv
->
topo
.
changelog_front
>
priv
->
topo
.
changelog_rear
)
{
topologyd_print_changelog
(
bb
,
priv
,
priv
->
topo
.
changelog_front
,
TOPOLOGY_LOG_MAX
-
1
);
topologyd_print_changelog
(
bb
,
priv
,
priv
->
topo
.
changelog_front
,
topology_log_max
-
1
);
topologyd_print_changelog
(
bb
,
priv
,
0
,
priv
->
topo
.
changelog_rear
);
topologyd_print_changelog
(
bb
,
priv
,
0
,
priv
->
topo
.
changelog_rear
);
}
}
else
{
else
{
...
@@ -406,6 +410,17 @@ static void topologyd_periodic_refresh(struct uloop_timeout *t)
...
@@ -406,6 +410,17 @@ static void topologyd_periodic_refresh(struct uloop_timeout *t)
uloop_timeout_set
(
&
priv
->
refresh_timer
,
priv
->
refresh_int
*
1000
);
uloop_timeout_set
(
&
priv
->
refresh_timer
,
priv
->
refresh_int
*
1000
);
}
}
static
void
topologyd_change_status
(
struct
uloop_timeout
*
t
)
{
struct
topologyd_private
*
priv
=
container_of
(
t
,
struct
topologyd_private
,
status_timer
);
dbg
(
"Change the status of topology...
\n
"
);
priv
->
status
=
1
;
}
static
void
topologyd_start_heartbeat
(
struct
uloop_timeout
*
t
)
static
void
topologyd_start_heartbeat
(
struct
uloop_timeout
*
t
)
{
{
struct
topologyd_private
*
priv
=
struct
topologyd_private
*
priv
=
...
@@ -441,9 +456,10 @@ static int topologyd_run(struct topologyd_private *priv)
...
@@ -441,9 +456,10 @@ static int topologyd_run(struct topologyd_private *priv)
if
(
priv
->
refresh_int
==
0
)
if
(
priv
->
refresh_int
==
0
)
priv
->
refresh_int
=
TOPOLOGY_REFRESH_INT
;
priv
->
refresh_int
=
TOPOLOGY_REFRESH_INT
;
topologyd_start_heartbeat
(
&
priv
->
heartbeat
);
topologyd_start_heartbeat
(
&
priv
->
heartbeat
);
topologyd_periodic_refresh
(
&
priv
->
refresh_timer
);
topologyd_periodic_refresh
(
&
priv
->
refresh_timer
);
uloop_timeout_set
(
&
priv
->
status_timer
,
90
*
1000
);
//initalize the changelog values
//initalize the changelog values
priv
->
topo
.
changelog_front
=
priv
->
topo
.
changelog_rear
=
-
1
;
priv
->
topo
.
changelog_front
=
priv
->
topo
.
changelog_rear
=
-
1
;
...
@@ -558,6 +574,13 @@ int topologyd_start(void)
...
@@ -558,6 +574,13 @@ int topologyd_start(void)
priv
->
refresh_timer
.
cb
=
topologyd_periodic_refresh
;
priv
->
refresh_timer
.
cb
=
topologyd_periodic_refresh
;
priv
->
heartbeat
.
cb
=
topologyd_start_heartbeat
;
priv
->
heartbeat
.
cb
=
topologyd_start_heartbeat
;
priv
->
topo
.
changelog
=
(
struct
topology_changelog
*
)
malloc
((
priv
->
config
.
maxlog
)
*
sizeof
(
struct
topology_changelog
));
topology_log_max
=
priv
->
config
.
maxlog
;
dbg
(
"Dynamic array size %d"
,
priv
->
config
.
maxlog
);
priv
->
status
=
0
;
priv
->
status_timer
.
cb
=
topologyd_change_status
;
if
(
!
priv
->
config
.
enabled
)
{
if
(
!
priv
->
config
.
enabled
)
{
info
(
"topologyd not enabled.
\n
"
);
info
(
"topologyd not enabled.
\n
"
);
...
@@ -593,7 +616,7 @@ void topologyd_stop(struct topologyd_private *priv)
...
@@ -593,7 +616,7 @@ void topologyd_stop(struct topologyd_private *priv)
// Check if the changelog queue is full
// Check if the changelog queue is full
int
is_full
(
struct
topology
*
t
)
int
is_full
(
struct
topology
*
t
)
{
{
if
((
t
->
changelog_front
==
t
->
changelog_rear
+
1
)
||
(
t
->
changelog_front
==
0
&&
t
->
changelog_rear
==
TOPOLOGY_LOG_MAX
-
1
))
if
((
t
->
changelog_front
==
t
->
changelog_rear
+
1
)
||
(
t
->
changelog_front
==
0
&&
t
->
changelog_rear
==
topology_log_max
-
1
))
return
1
;
return
1
;
return
0
;
return
0
;
}
}
...
@@ -605,13 +628,13 @@ void enqueue_changelog(struct topology *t, struct topology_changelog *c)
...
@@ -605,13 +628,13 @@ void enqueue_changelog(struct topology *t, struct topology_changelog *c)
struct
topology_changelog
*
elem
;
struct
topology_changelog
*
elem
;
if
(
is_full
(
t
))
{
if
(
is_full
(
t
))
{
dbg
(
"Changelog queue is full deleting the front node
\n
"
);
dbg
(
"Changelog queue is full deleting the front node
\n
"
);
t
->
changelog_front
=
(
t
->
changelog_front
+
1
)
%
TOPOLOGY_LOG_MAX
;
t
->
changelog_front
=
(
t
->
changelog_front
+
1
)
%
topology_log_max
;
t
->
num_changelog
--
;
t
->
num_changelog
--
;
}
}
if
(
t
->
changelog_front
==
-
1
)
if
(
t
->
changelog_front
==
-
1
)
t
->
changelog_front
=
0
;
t
->
changelog_front
=
0
;
t
->
changelog_rear
=
(
t
->
changelog_rear
+
1
)
%
TOPOLOGY_LOG_MAX
;
t
->
changelog_rear
=
(
t
->
changelog_rear
+
1
)
%
topology_log_max
;
elem
=&
(
t
->
changelog
[
t
->
changelog_rear
]);
elem
=&
(
t
->
changelog
[
t
->
changelog_rear
]);
memset
(
elem
,
0
,
sizeof
(
struct
topology_changelog
));
memset
(
elem
,
0
,
sizeof
(
struct
topology_changelog
));
memcpy
(
elem
->
rpt_macaddr
,
c
->
rpt_macaddr
,
6
);
memcpy
(
elem
->
rpt_macaddr
,
c
->
rpt_macaddr
,
6
);
...
@@ -629,6 +652,9 @@ void changelog_copy_node_info(struct topologyd_private *t, struct node *p, int32
...
@@ -629,6 +652,9 @@ void changelog_copy_node_info(struct topologyd_private *t, struct node *p, int32
dbg
(
"Inside changelog_copy_node_info
\n
"
);
dbg
(
"Inside changelog_copy_node_info
\n
"
);
struct
topology_changelog
elem
;
struct
topology_changelog
elem
;
if
(
t
==
NULL
||
p
==
NULL
)
return
;
if
(
event
==
0
)
if
(
event
==
0
)
memcpy
(
elem
.
rpt_macaddr
,
p
->
hwaddr
,
6
);
memcpy
(
elem
.
rpt_macaddr
,
p
->
hwaddr
,
6
);
else
else
...
...
This diff is collapsed.
Click to expand it.
src/topologyd.h
+
2
−
1
View file @
63cea91e
...
@@ -62,7 +62,7 @@ struct topology {
...
@@ -62,7 +62,7 @@ struct topology {
uint32_t
state
;
uint32_t
state
;
int32_t
num_nodes
;
int32_t
num_nodes
;
uint32_t
num_changelog
;
uint32_t
num_changelog
;
struct
topology_changelog
changelog
[
TOPOLOGY_LOG_MAX
]
;
struct
topology_changelog
*
changelog
;
int32_t
changelog_front
;
int32_t
changelog_front
;
int32_t
changelog_rear
;
int32_t
changelog_rear
;
struct
hlist_head
node_htable
[
NODE_HTABLE_SIZE
];
struct
hlist_head
node_htable
[
NODE_HTABLE_SIZE
];
...
@@ -84,6 +84,7 @@ struct topologyd_private {
...
@@ -84,6 +84,7 @@ struct topologyd_private {
struct
ubus_event_handler
ev
;
struct
ubus_event_handler
ev
;
struct
uloop_timeout
heartbeat
;
struct
uloop_timeout
heartbeat
;
struct
uloop_timeout
refresh_timer
;
struct
uloop_timeout
refresh_timer
;
struct
uloop_timeout
status_timer
;
struct
ubus_object
obj
;
struct
ubus_object
obj
;
struct
topologyd_config
config
;
struct
topologyd_config
config
;
ieee1905_object_t
ieee1905
;
ieee1905_object_t
ieee1905
;
...
...
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