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
4d62aa55
Commit
4d62aa55
authored
Feb 14, 2019
by
Adam Wujek
💬
Committed by
Grzegorz Daniluk
Jan 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/snmp: update wrsPtpInstanceTable to have two indexes
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
b99a2553
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
77 deletions
+110
-77
WR-SWITCH-MIB.txt
userspace/snmpd/WR-SWITCH-MIB.txt
+39
-17
wrsPtpInstanceTable.c
userspace/snmpd/wrsPtpInstanceTable.c
+66
-57
wrsPtpInstanceTable.h
userspace/snmpd/wrsPtpInstanceTable.h
+5
-3
No files found.
userspace/snmpd/WR-SWITCH-MIB.txt
View file @
4d62aa55
...
...
@@ -2627,22 +2627,28 @@ wrsPtpInstanceEntry OBJECT-TYPE
STATUS current
DESCRIPTION
"An entry containing pstats counters"
INDEX { wrsPtpInstanceIndex }
INDEX { wrsPtpInstance
PortIndex, wrsPtpInstanceOnPort
Index }
::= { wrsPtpInstanceTable 1 }
WrsPtpInstanceEntry ::=
SEQUENCE {
wrsPtpInstanceIndex Unsigned32,
wrsPtpInstancePort Integer,
wrsPtpInstancePortIndex Unsigned32,
wrsPtpInstanceOnPortIndex Unsigned32,
wrsPtpInstancePort INTEGER,
wrsPtpInstancePortInstance INTEGER,
wrsPtpInstancePortName DisplayString,
wrsPtpInstanceName DisplayString,
wrsPtpInstanceState INTEGER,
wrsPtpInstanceStateNext INTEGER,
wrsPtpInstanceRole INTEGER,
wrsPtpInstanceMechanism INTEGER,
wrsPtpInstanceProto INTEGER
wrsPtpInstanceProto INTEGER,
wrsPtpInstanceExt INTEGER,
wrsPtpInstancePeerMac PhysAddress,
wrsPtpInstancePeerVid INTEGER,
}
wrsPtpInstanceIndex OBJECT-TYPE
wrsPtpInstance
Port
Index OBJECT-TYPE
SYNTAX Unsigned32
MAX-ACCESS not-accessible
STATUS current
...
...
@@ -2650,13 +2656,29 @@ wrsPtpInstanceIndex OBJECT-TYPE
"Index for wrsPtpInstanceTable"
::= { wrsPtpInstanceEntry 1 }
wrsPtpInstanceOnPortIndex OBJECT-TYPE
SYNTAX Unsigned32
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Index for wrsPtpInstanceTable"
::= { wrsPtpInstanceEntry 2 }
wrsPtpInstancePort OBJECT-TYPE
SYNTAX I
nteger
SYNTAX I
NTEGER
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Port number on which an instance is running"
::= { wrsPtpInstanceEntry 2 }
::= { wrsPtpInstanceEntry 3 }
wrsPtpInstancePortInstance OBJECT-TYPE
SYNTAX INTEGER
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Index of an instance running on a port"
::= { wrsPtpInstanceEntry 4 }
wrsPtpInstancePortName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..12))
...
...
@@ -2664,7 +2686,7 @@ wrsPtpInstancePortName OBJECT-TYPE
STATUS current
DESCRIPTION
"Port name of port"
::= { wrsPtpInstanceEntry
3
}
::= { wrsPtpInstanceEntry
5
}
wrsPtpInstanceName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..12))
...
...
@@ -2672,7 +2694,7 @@ wrsPtpInstanceName OBJECT-TYPE
STATUS current
DESCRIPTION
"Name of an instance"
::= { wrsPtpInstanceEntry
4
}
::= { wrsPtpInstanceEntry
6
}
wrsPtpInstanceState OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2709,7 +2731,7 @@ wrsPtpInstanceState OBJECT-TYPE
STATUS current
DESCRIPTION
"Name of instance"
::= { wrsPtpInstanceEntry
5
}
::= { wrsPtpInstanceEntry
7
}
wrsPtpInstanceStateNext OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2746,7 +2768,7 @@ wrsPtpInstanceStateNext OBJECT-TYPE
STATUS current
DESCRIPTION
"Name of instance"
::= { wrsPtpInstanceEntry
6
}
::= { wrsPtpInstanceEntry
8
}
wrsPtpInstanceRole OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2759,7 +2781,7 @@ wrsPtpInstanceRole OBJECT-TYPE
STATUS current
DESCRIPTION
"Role of instance"
::= { wrsPtpInstanceEntry
7
}
::= { wrsPtpInstanceEntry
9
}
wrsPtpInstanceMechanism OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2771,7 +2793,7 @@ wrsPtpInstanceMechanism OBJECT-TYPE
STATUS current
DESCRIPTION
"Mechanism used by an instance"
::= { wrsPtpInstanceEntry
8
}
::= { wrsPtpInstanceEntry
10
}
wrsPtpInstanceProto OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2784,7 +2806,7 @@ wrsPtpInstanceProto OBJECT-TYPE
STATUS current
DESCRIPTION
"Protocol used by an instance"
::= { wrsPtpInstanceEntry
9
}
::= { wrsPtpInstanceEntry
11
}
wrsPtpInstanceExt OBJECT-TYPE
SYNTAX INTEGER {
...
...
@@ -2796,7 +2818,7 @@ wrsPtpInstanceExt OBJECT-TYPE
STATUS current
DESCRIPTION
"Extension used by an instance"
::= { wrsPtpInstanceEntry 1
0
}
::= { wrsPtpInstanceEntry 1
2
}
wrsPtpInstancePeerMac OBJECT-TYPE
SYNTAX PhysAddress
...
...
@@ -2804,7 +2826,7 @@ wrsPtpInstancePeerMac OBJECT-TYPE
STATUS current
DESCRIPTION
"VID used by an instance"
::= { wrsPtpInstanceEntry 1
1
}
::= { wrsPtpInstanceEntry 1
3
}
wrsPtpInstancePeerVid OBJECT-TYPE
SYNTAX Integer
...
...
@@ -2812,7 +2834,7 @@ wrsPtpInstancePeerVid OBJECT-TYPE
STATUS current
DESCRIPTION
"VID used by an instance"
::= { wrsPtpInstanceEntry 1
2
}
::= { wrsPtpInstanceEntry 1
4
}
--wrsNetworking
--Configuration
...
...
userspace/snmpd/wrsPtpInstanceTable.c
View file @
4d62aa55
...
...
@@ -6,8 +6,10 @@ struct wrsPtpInstanceTable_s wrsPtpInstanceTable_array[PP_MAX_LINKS];
static
struct
pickinfo
wrsPtpInstanceTable_pickinfo
[]
=
{
/* Warning: strings are a special case for snmp format */
FIELD
(
wrsPtpInstanceTable_s
,
ASN_UNSIGNED
,
wrsPtpInstanceIndex
),
/* not reported */
FIELD
(
wrsPtpInstanceTable_s
,
ASN_UNSIGNED
,
wrsPtpInstancePortIndex
),
/* not reported */
FIELD
(
wrsPtpInstanceTable_s
,
ASN_UNSIGNED
,
wrsPtpInstanceOnPortIndex
),
/* not reported */
FIELD
(
wrsPtpInstanceTable_s
,
ASN_INTEGER
,
wrsPtpInstancePort
),
FIELD
(
wrsPtpInstanceTable_s
,
ASN_INTEGER
,
wrsPtpInstancePortInstance
),
FIELD
(
wrsPtpInstanceTable_s
,
ASN_OCTET_STR
,
wrsPtpInstancePortName
),
FIELD
(
wrsPtpInstanceTable_s
,
ASN_OCTET_STR
,
wrsPtpInstanceName
),
FIELD
(
wrsPtpInstanceTable_s
,
ASN_INTEGER
,
wrsPtpInstanceState
),
...
...
@@ -41,6 +43,9 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
struct
pp_instance
*
ppsi_i
;
char
*
tmp_name
;
struct
hal_port_state
*
p
;
int
phys_port
;
int
last_port
=
0
;
int
instance_on_port
=
0
;
/* number of rows does not change for wrsPortStatusTable */
if
(
n_rows
)
...
...
@@ -84,17 +89,28 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
tmp_name
=
(
char
*
)
wrs_shm_follow
(
ppsi_head
,
ppsi_i
->
port_name
);
strncpy
(
i_a
[
i
].
wrsPtpInstanceName
,
tmp_name
,
1
2
);
i_a
[
i
].
wrsPtpInstanceName
[
1
1
]
=
'\0'
;
strncpy
(
i_a
[
i
].
wrsPtpInstanceName
,
tmp_name
,
1
6
);
i_a
[
i
].
wrsPtpInstanceName
[
1
5
]
=
'\0'
;
tmp_name
=
(
char
*
)
wrs_shm_follow
(
ppsi_head
,
ppsi_i
->
iface_name
);
strncpy
(
i_a
[
i
].
wrsPtpInstancePortName
,
tmp_name
,
1
2
);
i_a
[
i
].
wrsPtpInstancePortName
[
1
1
]
=
'\0'
;
strncpy
(
i_a
[
i
].
wrsPtpInstancePortName
,
tmp_name
,
1
6
);
i_a
[
i
].
wrsPtpInstancePortName
[
1
5
]
=
'\0'
;
p
=
pp_wrs_lookup_port
(
tmp_name
);
if
(
p
)
i_a
[
i
].
wrsPtpInstancePort
=
p
->
hw_index
+
1
;
if
(
p
)
{
phys_port
=
p
->
hw_index
+
1
;
i_a
[
i
].
wrsPtpInstancePort
=
phys_port
;
if
(
last_port
==
phys_port
)
instance_on_port
++
;
else
instance_on_port
=
1
;
last_port
=
phys_port
;
}
i_a
[
i
].
wrsPtpInstancePortInstance
=
instance_on_port
;
i_a
[
i
].
wrsPtpInstanceState
=
ppsi_i
->
state
;
i_a
[
i
].
wrsPtpInstanceStateNext
=
ppsi_i
->
next_state
;
...
...
@@ -127,57 +143,49 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
* one for each table */
static
unsigned
int
t_n_rows
;
/* template n_rows */
struct
coordinates_s
{
int
port
;
int
inst
;
};
struct
coordinates_s
inst_c
;
static
netsnmp_variable_list
*
table_next_entry
(
void
**
loop_context
,
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
{
inst_c
.
inst
++
;
if
(
inst_c
.
inst
>
1
){
inst_c
.
inst
=
0
;
inst_c
.
port
++
;
}
if
(
inst_c
.
port
>
5
){
return
NULL
;
int
i
=
(
int
)(
intptr_t
)(
*
loop_context
);
netsnmp_variable_list
*
idx
=
index
;
// snmp_log(LOG_ERR, "%s: loop_context %d\n", __func__, i);
if
(
i
>=
t_n_rows
)
{
return
NULL
;
/* no more */
snmp_log
(
LOG_ERR
,
"%s: no more
\n
"
,
__func__
);
}
/* create the line ID from counter number */
// i = (intptr_t)*loop_context;
// if (i >= t_n_rows)
// return NULL; /* no more */
// i++
;
/* Create the row OID: only the counter index */
snmp_set_var_value
(
index
,
(
u_char
*
)
&
inst_c
.
port
,
sizeof
(
inst_c
.
port
));
snmp_set_var_value
(
index
->
next_variable
,
(
u_char
*
)
&
inst_c
.
inst
,
sizeof
(
inst_c
.
inst
))
;
/* Set the data context (1..4)
* Cannot be set to 0, because netsnmp_extract_iterator_context returns
* NULL in function wrsPstats_handler when table is over */
*
data_context
=
(
void
*
)
&
inst_c
;
/* and set the loop context for the next iteration */
*
loop_context
=
(
void
*
)
&
inst_c
;
/* Embed into index part of OID a port number */
snmp_set_var_typed_value
(
idx
,
ASN_INTEGER
,
(
u_char
*
)
&
wrsPtpInstanceTable_array
[
i
].
wrsPtpInstancePort
,
sizeof
(
uint32_t
))
;
/* Embed into index part of OID an instance index on port */
idx
=
idx
->
next_variable
;
snmp_set_var_typed_value
(
idx
,
ASN_INTEGER
,
(
u_char
*
)
&
wrsPtpInstanceTable_array
[
i
].
wrsPtpInstancePortInstance
,
sizeof
(
uint32_t
));
*
data_context
=
&
wrsPtpInstanceTable_array
[
i
]
;
*
loop_context
=
(
void
*
)(
intptr_t
)(
++
i
);
return
index
;
}
static
netsnmp_variable_list
*
table_first_entry
(
void
**
loop_context
,
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
{
inst_c
.
port
=
0
;
inst_c
.
inst
=
0
;
*
loop_context
=
0
;
*
data_context
=
0
;
// snmp_log(LOG_ERR, "%s\n", __func__);
/* reset internal position, so "next" is "first" */
*
loop_context
=
&
inst_c
;
/* first counter */
return
table_next_entry
(
loop_context
,
data_context
,
index
,
data
);
}
...
...
@@ -190,13 +198,15 @@ table_handler(netsnmp_mib_handler *handler,
netsnmp_request_info
*
request
;
netsnmp_variable_list
*
requestvb
;
netsnmp_table_request_info
*
table_info
;
struct
wrsPtpInstanceTable_s
*
entry
;
struct
pickinfo
*
pi
;
int
row
,
subid
;
int
subid
;
int
len
;
void
*
ptr
;
struct
counter64
tmp_counter64
;
// snmp_log(LOG_ERR, "%s: before mode check\n", __func__);
switch
(
reqinfo
->
mode
)
{
case
MODE_GET
:
/* "break;" so read code is not indented too much */
...
...
@@ -219,24 +229,23 @@ table_handler(netsnmp_mib_handler *handler,
for
(
request
=
requests
;
request
;
request
=
request
->
next
)
{
struct
coordinates_s
*
xxx
;
requestvb
=
request
->
requestvb
;
/* "context" is the row number */
xxx
=
(
struct
coordinates_s
*
)
netsnmp_extract_iterator_context
(
request
);
if
(
!
xxx
)
entry
=
(
struct
wrsPtpInstanceTable_s
*
)
netsnmp_extract_iterator_context
(
request
);
if
(
!
entry
)
{
/* NULL returned from
* netsnmp_extract_iterator_context shuld be
* interpreted as end of table */
break
;
/* change range of row (1..X (snmp is 1 based) ->
* 0..X (wrs_t_table_array/data array is 0 based)) */
row
=
5
;
* netsnmp_extract_iterator_context shuld be
* interpreted as end of table */
continue
;
}
table_info
=
netsnmp_extract_table_info
(
request
);
subid
=
table_info
->
colnum
-
1
;
// snmp_log(LOG_ERR, "%s: %d\n", __func__, subid);
pi
=
wrsPtpInstanceTable_pickinfo
+
subid
;
ptr
=
(
void
*
)(
wrsPtpInstanceTable_array
+
row
)
+
pi
->
offset
;
ptr
=
(
void
*
)(
entry
)
+
pi
->
offset
;
/* snmp_set_var_typed_value function does not support counter64
* as a uint64_t, but as a struct counter64. Their binary
* representation differs by order of 32bit words. We fill
...
...
userspace/snmpd/wrsPtpInstanceTable.h
View file @
4d62aa55
...
...
@@ -6,11 +6,13 @@
struct
wrsPtpInstanceTable_s
{
uint32_t
wrsPtpInstanceIndex
;
/* not reported, index fields has t o be marked
uint32_t
wrsPtpInstance
Port
Index
;
/* not reported, index fields has t o be marked
* as not-accessible in MIB */
uint32_t
wrsPtpInstanceOnPortIndex
;
/* port on which ptp instance is running (index+1) */
int
wrsPtpInstancePort
;
/* port on which ptp instance is running (index+1) */
char
wrsPtpInstancePortName
[
12
];
/* port name on which ptp instance is running (wriX) */
char
wrsPtpInstanceName
[
12
];
/* Instance name */
int
wrsPtpInstancePortInstance
;
/* serial of instance running on a given port */
char
wrsPtpInstancePortName
[
16
];
/* port name on which ptp instance is running (wriX) */
char
wrsPtpInstanceName
[
16
];
/* Instance name */
int
wrsPtpInstanceState
;
int
wrsPtpInstanceStateNext
;
int
wrsPtpInstanceRole
;
...
...
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