Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
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
White Rabbit Switch - Software
Commits
d3a45929
Commit
d3a45929
authored
Jul 29, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snmp library: use real versions from 'wrs_version -t'
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
a00bfae8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
18 deletions
+55
-18
wrs-build.in
doc/wrs-build.in
+9
-7
wrsVersion.c
userspace/snmpd/wrsVersion.c
+46
-11
No files found.
doc/wrs-build.in
View file @
d3a45929
...
...
@@ -1668,7 +1668,9 @@ is an environment variable pointing to this package:
Using
SNMP
version
1
instead
of
2
c
is
fine
as
well
,
but
you
won
't receive
the 64-bit values for slave/tracking information.
The output you will get back is something like the following:
The output you will get back is something like the following. Clearly
the software commit in this example is my own development version while writing
this section:
@smallexample
WR-SWITCH-MIB::wrsScalar.0 = INTEGER: 2
...
...
@@ -1695,12 +1697,12 @@ WR-SWITCH-MIB::portLink.16 = INTEGER: down(0)
[...]
WR-SWITCH-MIB::portPeer.18 = Hex-STRING: FF FF FF FF FF FF FF FF
WR-SWITCH-MIB::ppsiPort.5 = Hex-STRING: FF FF FF FF FF FF FF FF
WR-SWITCH-MIB::wrsVersionSw.0 = STRING:
fake-v4.0-rc1
WR-SWITCH-MIB::wrsVersionGw1.0 = STRING:
fake-
7cce708
WR-SWITCH-MIB::wrsVersionGw2.0 = STRING:
fake-
5118070
WR-SWITCH-MIB::wrsVersionGw3.0 = STRING:
fake-
7efeb16
WR-SWITCH-MIB::wrsVersionHw1.0 = STRING:
fake-
3.30
WR-SWITCH-MIB::wrsVersionHw2.0 = STRING:
fake-
LX240T
WR-SWITCH-MIB::wrsVersionSw.0 = STRING:
v4.0-rc1-42-gcec7805+
WR-SWITCH-MIB::wrsVersionGw1.0 = STRING: 7cce708
WR-SWITCH-MIB::wrsVersionGw2.0 = STRING: 5118070
WR-SWITCH-MIB::wrsVersionGw3.0 = STRING: 7efeb16
WR-SWITCH-MIB::wrsVersionHw1.0 = STRING: 3.30
WR-SWITCH-MIB::wrsVersionHw2.0 = STRING: LX240T
@end smallexample
@c ==========================================================================
...
...
userspace/snmpd/wrsVersion.c
View file @
d3a45929
...
...
@@ -13,9 +13,22 @@
/* Our structure for caching data */
#define VERSION_N_STRINGS 6
/* sw, 3 gw, 2 hw */
static
struct
wrs_version
{
char
*
value
[
VERSION_N_STRINGS
];
}
wrs_version
;
struct
wrs_v_item
{
char
*
key
;
char
*
value
;
};
static
struct
wrs_v_item
wrs_version
[]
=
{
/* Warning: the order here msut match the MIB file */
[
0
]
=
{.
key
=
"software-version:"
},
[
1
]
=
{
"wr_switch_hdl-commit:"
},
[
2
]
=
{
"general-cores-commit:"
},
[
3
]
=
{
"wr-cores-commit:"
},
[
4
]
=
{
"pcb-version:"
},
[
5
]
=
{
"fpga-type:"
},
};
static
int
version_group
(
netsnmp_mib_handler
*
handler
,
netsnmp_handler_registration
*
reginfo
,
...
...
@@ -32,7 +45,7 @@ static int version_group(netsnmp_mib_handler *handler,
requests
->
requestvb
->
name_length
-
2
];
s
=
wrs_version
.
value
[
obj
-
1
]
;
s
=
wrs_version
[
obj
-
1
].
value
?
:
"unknown"
;
snmp_set_var_typed_value
(
requests
->
requestvb
,
ASN_OCTET_STR
,
s
,
strlen
(
s
));
break
;
...
...
@@ -44,6 +57,34 @@ static int version_group(netsnmp_mib_handler *handler,
return
SNMP_ERR_NOERROR
;
}
/*
* We parse versions at initialization time, as they won't change.
* FIXME: we should factorize parsing, this duplicates ./wrsPpsi.c
* (while being different, as here we need simpler stuff)
*/
static
void
wrs_v_init
(
void
)
{
char
s
[
80
],
key
[
40
],
value
[
40
];
FILE
*
f
=
popen
(
"/wr/bin/wrsw_version -t"
,
"r"
);
int
i
;
if
(
!
f
)
{
/* The "unknown" above will apply, bad but acceptable */
return
;
}
while
(
fgets
(
s
,
sizeof
(
s
),
f
))
{
if
(
sscanf
(
s
,
"%s %[^
\n
]"
,
key
,
value
)
!=
2
)
continue
;
/* error... */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
wrs_version
);
i
++
)
{
if
(
strcmp
(
key
,
wrs_version
[
i
].
key
))
continue
;
wrs_version
[
i
].
value
=
strdup
(
value
);
}
}
pclose
(
f
);
}
void
init_wrsVersion
(
void
)
{
...
...
@@ -51,13 +92,7 @@ init_wrsVersion(void)
const
oid
wrsVersion_oid
[]
=
{
WRS_OID
,
4
};
netsnmp_handler_registration
*
hreg
;
/* FIXME.... */
wrs_version
.
value
[
0
]
=
"fake-v4.0-rc1"
;
wrs_version
.
value
[
1
]
=
"fake-7cce708"
;
wrs_version
.
value
[
2
]
=
"fake-5118070"
;
wrs_version
.
value
[
3
]
=
"fake-7efeb16"
;
wrs_version
.
value
[
4
]
=
"fake-3.30"
;
wrs_version
.
value
[
5
]
=
"fake-LX240T"
;
wrs_v_init
();
/* do the registration */
hreg
=
netsnmp_create_handler_registration
(
...
...
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