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
6fba1cbb
Commit
6fba1cbb
authored
Oct 07, 2020
by
Michal Wasiak
Committed by
Adam Wujek
Oct 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snmp/bridge_mib: update dot1dTpFdbTable
Signed-off-by:
Michal Wasiak
<
michal.wasiak@gmail.com
>
parent
69622293
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
145 deletions
+76
-145
Makefile
userspace/snmpd/bridge_mib/Makefile
+1
-0
Makefile
userspace/snmpd/bridge_mib/dot1dTpFdbTable/Makefile
+7
-0
dot1dTpFdbTable_data_access.c
.../bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_data_access.c
+57
-111
dot1dTpFdbTable_data_get.c
...mpd/bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_data_get.c
+9
-22
dot1dTpFdbTable_enums.h
.../snmpd/bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_enums.h
+0
-12
init_bridge_mib.c
userspace/snmpd/bridge_mib/init_bridge_mib.c
+2
-0
No files found.
userspace/snmpd/bridge_mib/Makefile
View file @
6fba1cbb
-include
../Makefile.specific
BRIDGE_DIRS
=
\
dot1dTpFdbTable
\
dot1qFdbTable
BRIDGE_INCLUDE_DIRS
:=
$
(
addsuffix /Makefile,
$(BRIDGE_DIRS)
)
...
...
userspace/snmpd/bridge_mib/dot1dTpFdbTable/Makefile
0 → 100644
View file @
6fba1cbb
BRIDGE_MIB_SRCS
+=
\
dot1dTpFdbTable/dot1dTpFdbTable.c
\
dot1dTpFdbTable/dot1dTpFdbTable_data_get.c
\
dot1dTpFdbTable/dot1dTpFdbTable_data_set.c
\
dot1dTpFdbTable/dot1dTpFdbTable_data_access.c
\
dot1dTpFdbTable/dot1dTpFdbTable_interface.c
userspace/snmpd/bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_data_access.c
View file @
6fba1cbb
...
...
@@ -13,6 +13,8 @@
/* include our parent header */
#include "dot1dTpFdbTable.h"
#include "wrsSnmp.h"
#include "snmp_shmem.h"
#include "dot1dTpFdbTable_data_access.h"
...
...
@@ -207,79 +209,43 @@ dot1dTpFdbTable_container_load(netsnmp_container *container)
dot1dTpFdbTable_rowreq_ctx
*
rowreq_ctx
;
size_t
count
=
0
;
/*
* temporary storage for index values
*/
/*
* dot1dTpFdbAddress(1)/MacAddress/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H
*/
char
dot1dTpFdbAddress
[
6
];
size_t
dot1dTpFdbAddress_len
;
/*
* this example code is based on a data source that is a
* text file to be read and parsed.
*/
FILE
*
filep
;
char
line
[
MAX_LINE_SIZE
];
int
i
;
uint32_t
port_mask
;
int
port
;
int
htab_read_entries
;
struct
rtu_filtering_entry
rtu_htab_local
[
RTU_BUCKETS
*
HTAB_ENTRIES
];
DEBUGMSGTL
((
"verbose:dot1dTpFdbTable:dot1dTpFdbTable_container_load"
,
"called
\n
"
));
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
/*
* open our data file.
*/
filep
=
fopen
(
"/etc/dummy.conf"
,
"r"
);
if
(
NULL
==
filep
)
{
return
MFD_RESOURCE_UNAVAILABLE
;
/* read filter entires from shm to local memory for data consistency */
if
(
shmem_rtu_read_htab
(
rtu_htab_local
,
&
htab_read_entries
))
{
DEBUGMSGTL
((
"verbose:dot1dTpFdbTable:dot1dTpFdbTable_container_load"
,
"Too many retries while reading htab entries from RTUd shmem
\n
"
));
return
MFD_RESOURCE_UNAVAILABLE
;
}
qsort
(
rtu_htab_local
,
htab_read_entries
,
sizeof
(
struct
rtu_filtering_entry
),
cmp_rtu_entries_mac
);
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
/*
* TODO:351:M: |-> Load/update data in the dot1dTpFdbTable container.
* loop over your dot1dTpFdbTable data, allocate a rowreq context,
* set the index(es) [and data, optionally] and insert into
* the container.
*/
while
(
1
)
{
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
/*
* get a line (skip blank lines)
*/
do
{
if
(
!
fgets
(
line
,
sizeof
(
line
),
filep
))
{
/* we're done */
fclose
(
filep
);
filep
=
NULL
;
}
}
while
(
filep
&&
(
line
[
0
]
==
'\n'
));
for
(
i
=
0
;
i
<
htab_read_entries
;
i
++
)
{
/* skip invalid entires */
if
(
!
rtu_htab_local
[
i
].
valid
)
continue
;
/*
* check for end of data
*/
if
(
NULL
==
filep
)
break
;
/* count ports in mask */
if
(
bitCount
(
rtu_htab_local
[
i
].
port_mask_dst
)
!=
1
)
{
/* no ports assigned or multicast */
continue
;
}
/* skip if destination is CPU */
if
(
rtu_htab_local
[
i
].
port_mask_dst
==
1
<<
hal_nports_local
)
{
continue
;
}
/*
* parse line into variables
*/
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
/*
*
TODO:352:M: |
|-> set indexes in new dot1dTpFdbTable rowreq context.
* |-> set indexes in new dot1dTpFdbTable rowreq context.
* data context will be set from the param (unless NULL,
* in which case a new data context will be allocated)
*/
...
...
@@ -289,7 +255,7 @@ dot1dTpFdbTable_container_load(netsnmp_container *container)
return
MFD_RESOURCE_UNAVAILABLE
;
}
if
(
MFD_SUCCESS
!=
dot1dTpFdbTable_indexes_set
(
rowreq_ctx
,
dot1dTpFdbAddress
,
dot1dTpFdbAddress_len
,
(
char
*
)
rtu_htab_local
[
i
].
mac
,
ETH_ALEN
))
{
snmp_log
(
LOG_ERR
,
"error setting index while loading "
"dot1dTpFdbTable data.
\n
"
);
...
...
@@ -298,41 +264,31 @@ dot1dTpFdbTable_container_load(netsnmp_container *container)
}
/*
*
TODO:352:r: |
|-> populate dot1dTpFdbTable data context.
* Populate data context here.
(optionally, delay until row prep)
* |-> populate dot1dTpFdbTable data context.
* Populate data context here.
*/
/*
* TRANSIENT or semi-TRANSIENT data:
* copy data or save any info needed to do it in row_prep.
*/
/*
* setup/save data for dot1dTpFdbPort
* dot1dTpFdbPort(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
*/
/*
* TODO:246:r: |-> Define dot1dTpFdbPort mapping.
* Map values between raw/native values and MIB values
*
* Integer based value can usually just do a direct copy.
*/
rowreq_ctx
->
data
.
dot1dTpFdbPort
=
dot1dTpFdbPort
;
/*
* setup/save data for dot1dTpFdbStatus
* dot1dTpFdbStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
*/
/*
* TODO:246:r: |-> Define dot1dTpFdbStatus mapping.
* Map values between raw/native values and MIB values
*
* enums usually need mapping.
*/
if
(
MFD_SUCCESS
!=
dot1dTpFdbStatus_map
(
&
rowreq_ctx
->
data
.
dot1dTpFdbStatus
,
dot1dTpFdbStatus
))
{
return
MFD_ERROR
;
}
/*
* setup/save data for dot1dTpFdbPort
* dot1dTpFdbPort(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
*/
port_mask
=
rtu_htab_local
[
i
].
port_mask_dst
;
for
(
port
=
1
;
port_mask
>
1
;
port
++
,
port_mask
>>=
1
)
{}
rowreq_ctx
->
data
.
dot1dTpFdbPort
=
port
;
/*
* setup/save data for dot1dTpFdbStatus
* dot1dTpFdbStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
*/
/*
* |-> Define dot1dTpFdbStatus mapping.
* Map values between raw/native values and MIB values
*/
if
(
MFD_SUCCESS
!=
dot1dTpFdbStatus_map
(
&
rowreq_ctx
->
data
.
dot1dTpFdbStatus
,
rtu_htab_local
[
i
].
dynamic
))
{
return
MFD_ERROR
;
}
/*
* insert into table container
*/
...
...
@@ -340,17 +296,6 @@ dot1dTpFdbTable_container_load(netsnmp_container *container)
++
count
;
}
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
if
(
NULL
!=
filep
)
fclose
(
filep
);
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
DEBUGMSGT
((
"verbose:dot1dTpFdbTable:dot1dTpFdbTable_container_load"
,
"inserted %d records
\n
"
,
count
));
...
...
@@ -378,6 +323,7 @@ dot1dTpFdbTable_container_free(netsnmp_container *container)
/*
* TODO:380:M: Free dot1dTpFdbTable container data.
*/
/* A: no need to do anything here */
}
/* dot1dTpFdbTable_container_free */
/**
...
...
@@ -405,7 +351,7 @@ dot1dTpFdbTable_row_prep( dot1dTpFdbTable_rowreq_ctx *rowreq_ctx)
* If populating row data was delayed, this is the place to
* fill in the row for this request.
*/
/* A: no need to do anything here */
return
MFD_SUCCESS
;
}
/* dot1dTpFdbTable_row_prep */
...
...
userspace/snmpd/bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_data_get.c
View file @
6fba1cbb
...
...
@@ -10,6 +10,9 @@
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "wrsSnmp.h"
#include "snmp_shmem.h"
/* include our parent header */
#include "dot1dTpFdbTable.h"
...
...
@@ -243,35 +246,19 @@ dot1dTpFdbStatus_map(u_long *mib_dot1dTpFdbStatus_val_ptr, u_long raw_dot1dTpFdb
netsnmp_assert
(
NULL
!=
mib_dot1dTpFdbStatus_val_ptr
);
DEBUGMSGTL
((
"verbose:dot1dTpFdbTable:dot1dTpFdbStatus_map"
,
"called
\n
"
));
/*
* TODO:241:o: |-> Implement dot1dTpFdbStatus enum mapping.
* uses INTERNAL_* macros defined in the header files
*/
switch
(
raw_dot1dTpFdbStatus_val
)
{
case
INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_OTHER
:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_OTHER
;
break
;
case
INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_INVALID
:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_INVALID
;
break
;
case
INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_LEARNED
:
switch
(
raw_dot1dTpFdbStatus_val
)
{
case
RTU_ENTRY_TYPE_DYNAMIC
:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_LEARNED
;
break
;
case
INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_SELF
:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_SELF
;
break
;
case
INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_MGMT
:
case
RTU_ENTRY_TYPE_STATIC
:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_MGMT
;
break
;
default:
snmp_log
(
LOG_ERR
,
"couldn't map value %ld for dot1dTpFdbStatus
\n
"
,
raw_dot1dTpFdbStatus_val
)
;
return
MFD_ERROR
;
default:
*
mib_dot1dTpFdbStatus_val_ptr
=
DOT1DTPFDBSTATUS_OTHER
;
break
;
}
return
MFD_SUCCESS
;
...
...
userspace/snmpd/bridge_mib/dot1dTpFdbTable/dot1dTpFdbTable_enums.h
View file @
6fba1cbb
...
...
@@ -49,18 +49,6 @@ extern "C" {
#endif
/* DOT1DTPFDBSTATUS_ENUMS */
/*
* TODO:140:o: Define your interal representation of dot1dTpFdbStatus enums.
* (used for value mapping; see notes at top of file)
*/
#define INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_OTHER 1
#define INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_INVALID 2
#define INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_LEARNED 3
#define INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_SELF 4
#define INTERNAL_DOT1DTPFDBTABLE_DOT1DTPFDBSTATUS_MGMT 5
#ifdef __cplusplus
}
...
...
userspace/snmpd/bridge_mib/init_bridge_mib.c
View file @
6fba1cbb
...
...
@@ -8,9 +8,11 @@
/* The sub-init functions */
#include "wrsSnmp.h"
#include "snmp_shmem.h"
#include "dot1dTpFdbTable/dot1dTpFdbTable.h"
#include "dot1qFdbTable/dot1qFdbTable.h"
void
init_bridge_mib
(
void
)
{
init_dot1dTpFdbTable
();
init_dot1qFdbTable
();
}
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