Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
b0dc18ac
Commit
b0dc18ac
authored
Mar 30, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/snmp: support returning error for different community name
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
f5041333
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
snmp.c
lib/snmp.c
+18
-7
No files found.
lib/snmp.c
View file @
b0dc18ac
...
...
@@ -299,9 +299,11 @@ static struct snmp_oid oid_array[] = {
#define BYTE_VERSION 0xfa
/* indexes of bytes in snmp packet */
#define BYTE_PACKET_SIZE_i 1
#define BYTE_PDU_i 13
#define BYTE_ERROR_i 23
#define BYTE_ERROR_INDEX_i 26
#define BYTE_COMMUNITY_LEN_i 6
/* indexes below are without the length of the community string */
#define BYTE_PDU_i 7
#define BYTE_ERROR_i 17
#define BYTE_ERROR_INDEX_i 20
static
uint8_t
match_array
[]
=
{
0x30
,
BYTE_SIZE
,
...
...
@@ -329,14 +331,23 @@ static void print_oid_verbose(uint8_t *oid, int len) {
snmp_verbose
(
".%d"
,
*
(
oid
+
i
));
}
/* Limit community length. Standard says nothing about maximum length, but we
* want to limit it to save memory */
#define MAX_COMMUNITY_LEN 32
/* prepare packet to return error, leave the rest of packet as it was */
static
uint8_t
snmp_prepare_error
(
uint8_t
*
buf
,
uint8_t
error
)
{
uint8_t
ret_size
;
buf
[
BYTE_PDU_i
]
=
SNMP_GET_RESPONSE
;
buf
[
BYTE_ERROR_i
]
=
error
;
buf
[
BYTE_ERROR_INDEX_i
]
=
1
;
uint8_t
community_len
;
community_len
=
buf
[
BYTE_COMMUNITY_LEN_i
];
/* If community_len is too long, it will return malformed
* packet, but at least something useful for debugging */
community_len
=
min
(
community_len
,
MAX_COMMUNITY_LEN
);
buf
[
BYTE_PDU_i
+
community_len
]
=
SNMP_GET_RESPONSE
;
buf
[
BYTE_ERROR_i
+
community_len
]
=
error
;
buf
[
BYTE_ERROR_INDEX_i
+
community_len
]
=
1
;
ret_size
=
buf
[
BYTE_PACKET_SIZE_i
]
+
2
;
snmp_verbose
(
"%s: error returning %i bytes
\n
"
,
__func__
,
ret_size
);
return
ret_size
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment