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
47608fde
Commit
47608fde
authored
Mar 04, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/snmp: add support for ASN_OCTET_STR
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
186cc157
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
snmp.c
lib/snmp.c
+15
-5
No files found.
lib/snmp.c
View file @
47608fde
...
...
@@ -94,18 +94,28 @@ static int fill_date(uint8_t *buf, struct snmp_oid *obj)
return
2
+
buf
[
1
];
}
#define MAX_OCTET_STR_LEN 32
static
int
fill_struct_asn
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
)
{
uint32_t
tmp
;
uint8_t
*
oid_data
=
buf
+
2
;
void
*
src_data
=
(
*
(
obj
->
p
))
+
obj
->
offset
;
uint8_t
*
len
;
buf
[
0
]
=
obj
->
asn
;
len
=
&
buf
[
1
];
switch
(
obj
->
asn
){
case
ASN_COUNTER
:
case
ASN_INTEGER
:
tmp
=
htonl
(
*
(
uint32_t
*
)(
*
(
obj
->
p
)
+
obj
->
offset
));
memcpy
(
buf
+
2
,
&
tmp
,
sizeof
(
tmp
));
buf
[
1
]
=
sizeof
(
tmp
);
snmp_verbose
(
"fill_struct_asn 0x%x
\n
"
,
*
(
uint32_t
*
)(
*
(
obj
->
p
)
+
obj
->
offset
));
tmp
=
htonl
(
*
(
uint32_t
*
)
src_data
);
memcpy
(
oid_data
,
&
tmp
,
sizeof
(
tmp
));
*
len
=
sizeof
(
tmp
);
snmp_verbose
(
"fill_struct_asn 0x%x
\n
"
,
*
(
uint32_t
*
)
src_data
);
break
;
case
ASN_OCTET_STR
:
*
len
=
strnlen
((
char
*
)
src_data
,
MAX_OCTET_STR_LEN
-
1
);
memcpy
(
oid_data
,
src_data
,
*
len
+
1
);
snmp_verbose
(
"fill_struct_asn %s len %d
\n
"
,
(
char
*
)
src_data
,
*
len
);
break
;
default:
break
;
...
...
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