Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wr-switch-sw
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor 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
This is an archived project. Repository and other project resources are read-only.
white-rabbit
wr-switch-sw
Commits
d3a45929
Commit
d3a45929
authored
10 years ago
by
Alessandro Rubini
Browse files
Options
Downloads
Patches
Plain Diff
snmp library: use real versions from 'wrs_version -t'
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
a00bfae8
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/wrs-build.in
+9
-7
9 additions, 7 deletions
doc/wrs-build.in
userspace/snmpd/wrsVersion.c
+46
-11
46 additions, 11 deletions
userspace/snmpd/wrsVersion.c
with
55 additions
and
18 deletions
doc/wrs-build.in
+
9
−
7
View file @
d3a45929
...
...
@@ -1668,7 +1668,9 @@ is an environment variable pointing to this package:
Using SNMP version 1 instead of 2c 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 ==========================================================================
...
...
This diff is collapsed.
Click to expand it.
userspace/snmpd/wrsVersion.c
+
46
−
11
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
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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