Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICBM
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
detectors
DSSC
ICBM
Commits
4d32668b
Commit
4d32668b
authored
3 weeks ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Handle invalid mpod responses in REST API
parent
b31ac2ad
No related branches found
No related tags found
1 merge request
!6
Handle invalid channel replies
Pipeline
#166080
passed
3 weeks ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mpod.cpp
+5
-0
5 additions, 0 deletions
mpod.cpp
rest.cpp
+7
-2
7 additions, 2 deletions
rest.cpp
with
12 additions
and
2 deletions
mpod.cpp
+
5
−
0
View file @
4d32668b
...
...
@@ -142,6 +142,11 @@ bool MPOD::message(const SNMP::Message *message) {
// that far.
const
char
*
channel
=
strrchr
(
varbind
->
getName
(),
'.'
)
+
1
;
_channel
=
atoi
(
channel
);
// MPOD SNMP channel 0 does not exist (starts from 1; U0 is 1).
// Mark the channel as 0 if invalid data was received.
// This can be used later to validate a sent request.
_channel
=
found
?
_channel
:
0
;
}
// Return true if nodes found, that means this is a valid response from MPOD
return
found
;
...
...
This diff is collapsed.
Click to expand it.
rest.cpp
+
7
−
2
View file @
4d32668b
...
...
@@ -161,7 +161,7 @@ void sendSNMP() {
if
(
output
!=
NONE
&&
channel
!=
0
)
{
setChannelStateAndWait
(
&
ipAddr
,
channel
,
output
);
success
=
true
;
// validates input parameters, not MPOD status, reported separately
success
=
mpod
.
getChannel
()
?
true
:
false
;
}
String
http_msg
=
"{
\n
"
;
...
...
@@ -285,7 +285,12 @@ void pollMPODChannel() {
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
// Force loop to update now
ret
=
mpod
.
toJSON
();
if
(
mpod
.
getChannel
())
{
ret
=
mpod
.
toJSON
();
}
else
{
ret
=
"
\"
reason
\"
:
\"
Invalid channel
\"
"
;
channel
=
0
;
}
}
String
http_msg
=
"{
\n
"
;
...
...
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