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
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
38b1e1cc
Commit
38b1e1cc
authored
Apr 18, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/snmp: add support for counter64
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
8b534e10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
snmp.c
lib/snmp.c
+15
-2
No files found.
lib/snmp.c
View file @
38b1e1cc
...
...
@@ -65,6 +65,9 @@
/* used to define write only OIDs */
#define NO_SET NULL
/* limit string len */
#define MAX_OCTET_STR_LEN 32
#define OID_FIELD_STRUCT(_oid, _getf, _setf, _asn, _type, _pointer, _field) { \
.oid_match = _oid, \
.oid_len = sizeof(_oid), \
...
...
@@ -124,9 +127,11 @@ static struct wrpc_socket __static_snmp_socket = {
};
static
struct
wrpc_socket
*
snmp_socket
;
static
int
get_value
(
uint8_t
*
buf
,
uint8_t
asn
,
void
*
p
);
static
int
get_pp
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
get_p
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
get_i32sat
(
uint8_t
*
buf
,
uint8_t
asn
,
void
*
p
);
static
int
set_value
(
uint8_t
*
set_buff
,
struct
snmp_oid
*
obj
,
void
*
p
);
static
int
set_pp
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
set_p
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
...
...
@@ -181,10 +186,10 @@ static int get_date(uint8_t *buf, struct snmp_oid *obj)
return
2
+
buf
[
1
];
}
#define MAX_OCTET_STR_LEN 32
static
int
get_value
(
uint8_t
*
buf
,
uint8_t
asn
,
void
*
p
)
{
uint32_t
tmp
;
uint64_t
tmp_uint64
;
uint8_t
*
oid_data
=
buf
+
2
;
uint8_t
*
len
;
...
...
@@ -198,6 +203,14 @@ static int get_value(uint8_t *buf, uint8_t asn, void *p)
*
len
=
sizeof
(
tmp
);
snmp_verbose
(
"%s: 0x%x
\n
"
,
__func__
,
*
(
uint32_t
*
)
p
);
break
;
case
ASN_COUNTER64
:
tmp_uint64
=
*
(
uint64_t
*
)
p
;
memcpy
(
oid_data
,
&
tmp_uint64
,
sizeof
(
tmp_uint64
));
*
len
=
sizeof
(
tmp_uint64
);
/* Our printf has disabled printing of 64bit values */
snmp_verbose
(
"%s: 64bit value 0x%08x|%08x
\n
"
,
__func__
,
(
uint32_t
)(
tmp_uint64
>>
32
),
(
uint32_t
)
tmp_uint64
);
break
;
case
ASN_OCTET_STR
:
*
len
=
strnlen
((
char
*
)
p
,
MAX_OCTET_STR_LEN
-
1
);
memcpy
(
oid_data
,
p
,
*
len
+
1
);
...
...
@@ -229,7 +242,7 @@ static int get_i32sat(uint8_t *buf, uint8_t asn, void *p)
/* if we want to modify an object we need to do that on a copy,
* otherwise pointers to the values will be overwritten */
tmp_int64
=
*
(
int64_t
*
)
p
;
/*
gcc doesn't support printing
64bit values */
/*
Our printf has disabled printing of
64bit values */
snmp_verbose
(
"%s: 64bit value 0x%08x|%08x
\n
"
,
__func__
,
(
int32_t
)((
tmp_int64
)
>>
32
),
(
uint32_t
)
tmp_int64
);
/* saturate int32 */
...
...
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