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
84
Issues
84
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
c629542e
Commit
c629542e
authored
Oct 08, 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 dot1qTpFdbTable
Signed-off-by:
Michal Wasiak
<
michal.wasiak@gmail.com
>
parent
c9f75fe9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
116 deletions
+120
-116
Makefile
userspace/snmpd/bridge_mib/Makefile
+2
-1
Makefile
userspace/snmpd/bridge_mib/dot1qTpFdbTable/Makefile
+7
-0
dot1qTpFdbTable_data_access.c
.../bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_access.c
+56
-102
dot1qTpFdbTable_data_access.h
.../bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_access.h
+0
-13
dot1qTpFdbTable_data_get.c
...mpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_get.c
+49
-0
dot1qTpFdbTable_data_get.h
...mpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_get.h
+4
-0
init_bridge_mib.c
userspace/snmpd/bridge_mib/init_bridge_mib.c
+2
-0
No files found.
userspace/snmpd/bridge_mib/Makefile
View file @
c629542e
...
...
@@ -3,7 +3,8 @@
BRIDGE_DIRS
=
\
dot1dBasePortTable
\
dot1dTpFdbTable
\
dot1qFdbTable
dot1qFdbTable
\
dot1qTpFdbTable
\
BRIDGE_INCLUDE_DIRS
:=
$
(
addsuffix /Makefile,
$(BRIDGE_DIRS)
)
BRIDGE_INCLUDE_DIRS
:=
$
(
addprefix
$(BRIDGE_MIB_DIR)
/,
$(BRIDGE_INCLUDE_DIRS)
)
...
...
userspace/snmpd/bridge_mib/dot1qTpFdbTable/Makefile
0 → 100644
View file @
c629542e
BRIDGE_MIB_SRCS
+=
\
dot1qTpFdbTable/dot1qTpFdbTable.c
\
dot1qTpFdbTable/dot1qTpFdbTable_data_get.c
\
dot1qTpFdbTable/dot1qTpFdbTable_data_set.c
\
dot1qTpFdbTable/dot1qTpFdbTable_data_access.c
\
dot1qTpFdbTable/dot1qTpFdbTable_interface.c
userspace/snmpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_access.c
View file @
c629542e
...
...
@@ -13,6 +13,8 @@
/* include our parent header */
#include "dot1qTpFdbTable.h"
#include "wrsSnmp.h"
#include "snmp_shmem.h"
#include "dot1qTpFdbTable_data_access.h"
...
...
@@ -207,83 +209,43 @@ dot1qTpFdbTable_container_load(netsnmp_container *container)
dot1qTpFdbTable_rowreq_ctx
*
rowreq_ctx
;
size_t
count
=
0
;
/*
* temporary storage for index values
*/
/*
* dot1qFdbId(1)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/r/d/h
*/
u_long
dot1qFdbId
;
/*
* dot1qTpFdbAddress(1)/MacAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H
*/
char
dot1qTpFdbAddress
[
6
];
size_t
dot1qTpFdbAddress_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:dot1qTpFdbTable:dot1qTpFdbTable_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:dot1qTpFdbTable:dot1qTpFdbTable_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_fid_mac
);
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
/*
* TODO:351:M: |-> Load/update data in the dot1qTpFdbTable container.
* loop over your dot1qTpFdbTable 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 dot1qTpFdbTable rowreq context.
* |-> set indexes in new dot1qTpFdbTable rowreq context.
* data context will be set from the param (unless NULL,
* in which case a new data context will be allocated)
*/
...
...
@@ -293,8 +255,8 @@ dot1qTpFdbTable_container_load(netsnmp_container *container)
return
MFD_RESOURCE_UNAVAILABLE
;
}
if
(
MFD_SUCCESS
!=
dot1qTpFdbTable_indexes_set
(
rowreq_ctx
,
dot1qFdbI
d
,
dot1qTpFdbAddress
,
dot1qTpFdbAddress_len
,
rtu_htab_local
[
i
].
fi
d
,
(
char
*
)
rtu_htab_local
[
i
].
mac
,
ETH_ALEN
))
{
snmp_log
(
LOG_ERR
,
"error setting index while loading "
"dot1qTpFdbTable data.
\n
"
);
...
...
@@ -303,28 +265,31 @@ dot1qTpFdbTable_container_load(netsnmp_container *container)
}
/*
*
TODO:352:r: |
|-> populate dot1qTpFdbTable data context.
* Populate data context here.
(optionally, delay until row prep)
* |-> populate dot1qTpFdbTable 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 dot1qTpFdbPort
* dot1qTpFdbPort(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
*/
/** no mapping */
rowreq_ctx
->
data
.
dot1qTpFdbPort
=
dot1qTpFdbPort
;
/*
* setup/save data for dot1qTpFdbStatus
* dot1qTpFdbStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
*/
/** no mapping */
rowreq_ctx
->
data
.
dot1qTpFdbStatus
=
dot1qTpFdbStatus
;
/*
* setup/save data for dot1qTpFdbPort
* dot1qTpFdbPort(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
.
dot1qTpFdbPort
=
port
;
/*
* setup/save data for dot1qTpFdbStatus
* dot1qTpFdbStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
*/
/*
* |-> Define dot1qTpFdbStatus mapping.
* Map values between raw/native values and MIB values
*/
if
(
MFD_SUCCESS
!=
dot1qTpFdbStatus_map
(
&
rowreq_ctx
->
data
.
dot1qTpFdbStatus
,
rtu_htab_local
[
i
].
dynamic
))
{
return
MFD_ERROR
;
}
/*
* insert into table container
*/
...
...
@@ -332,17 +297,6 @@ dot1qTpFdbTable_container_load(netsnmp_container *container)
++
count
;
}
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
if
(
NULL
!=
filep
)
fclose
(
filep
);
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
DEBUGMSGT
((
"verbose:dot1qTpFdbTable:dot1qTpFdbTable_container_load"
,
"inserted %d records
\n
"
,
count
));
...
...
userspace/snmpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_access.h
View file @
c629542e
...
...
@@ -52,19 +52,6 @@ void dot1qTpFdbTable_container_free(netsnmp_container *container);
int
dot1qTpFdbTable_cache_load
(
netsnmp_container
*
container
);
void
dot1qTpFdbTable_cache_free
(
netsnmp_container
*
container
);
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
/* *********************************************************************
* Since we have no idea how you really access your data, we'll go with
* a worst case example: a flat text file.
*/
#define MAX_LINE_SIZE 256
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
int
dot1qTpFdbTable_row_prep
(
dot1qTpFdbTable_rowreq_ctx
*
rowreq_ctx
);
...
...
userspace/snmpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_get.c
View file @
c629542e
...
...
@@ -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 "dot1qTpFdbTable.h"
...
...
@@ -224,6 +227,52 @@ The status of this entry. The meanings of the values
* Its syntax is INTEGER (based on perltype INTEGER)
* The net-snmp type is ASN_INTEGER. The C type decl is long (u_long)
*/
/**
* map a value from its original native format to the MIB format.
*
* @retval MFD_SUCCESS : success
* @retval MFD_ERROR : Any other error
*
* @note parameters follow the memset convention (dest, src).
*
* @note generation and use of this function can be turned off by re-running
* mib2c after adding the following line to the file
* defaults/node-dot1qTpFdbStatus.m2d :
* @eval $m2c_node_skip_mapping = 1@
*
* @remark
* If the values for your data type don't exactly match the
* possible values defined by the mib, you should map them here.
* Otherwise, just do a direct copy.
*/
int
dot1qTpFdbStatus_map
(
u_long
*
mib_dot1qTpFdbStatus_val_ptr
,
u_long
raw_dot1qTpFdbStatus_val
)
{
netsnmp_assert
(
NULL
!=
mib_dot1qTpFdbStatus_val_ptr
);
DEBUGMSGTL
((
"verbose:dot1qTpFdbTable:dot1qTpFdbStatus_map"
,
"called
\n
"
));
/*
* TODO:241:o: |-> Implement dot1qTpFdbStatus enum mapping.
* uses INTERNAL_* macros defined in the header files
*/
switch
(
raw_dot1qTpFdbStatus_val
)
{
case
RTU_ENTRY_TYPE_DYNAMIC
:
*
mib_dot1qTpFdbStatus_val_ptr
=
DOT1QTPFDBSTATUS_LEARNED
;
break
;
case
RTU_ENTRY_TYPE_STATIC
:
*
mib_dot1qTpFdbStatus_val_ptr
=
DOT1QTPFDBSTATUS_MGMT
;
break
;
default:
*
mib_dot1qTpFdbStatus_val_ptr
=
DOT1QTPFDBSTATUS_OTHER
;
break
;
}
return
MFD_SUCCESS
;
}
/* dot1qTpFdbStatus_map */
/**
* Extract the current value of the dot1qTpFdbStatus data.
*
...
...
userspace/snmpd/bridge_mib/dot1qTpFdbTable/dot1qTpFdbTable_data_get.h
View file @
c629542e
...
...
@@ -41,8 +41,12 @@ extern "C" {
/*
* indexes
*/
int
dot1qFdbId_map
(
u_long
*
mib_dot1qFdbId_val_ptr
,
u_long
raw_dot1qFdbId_val
);
int
dot1qTpFdbAddress_map
(
char
**
mib_dot1qTpFdbAddress_val_ptr_ptr
,
size_t
*
mib_dot1qTpFdbAddress_val_ptr_len_ptr
,
char
*
raw_dot1qTpFdbAddress_val_ptr
,
size_t
raw_dot1qTpFdbAddress_val_ptr_len
,
int
allow_realloc
);
int
dot1qTpFdbPort_map
(
long
*
mib_dot1qTpFdbPort_val_ptr
,
long
raw_dot1qTpFdbPort_val
);
int
dot1qTpFdbPort_get
(
dot1qTpFdbTable_rowreq_ctx
*
rowreq_ctx
,
long
*
dot1qTpFdbPort_val_ptr
);
int
dot1qTpFdbStatus_map
(
u_long
*
mib_dot1qTpFdbStatus_val_ptr
,
u_long
raw_dot1qTpFdbStatus_val
);
int
dot1qTpFdbStatus_get
(
dot1qTpFdbTable_rowreq_ctx
*
rowreq_ctx
,
u_long
*
dot1qTpFdbStatus_val_ptr
);
...
...
userspace/snmpd/bridge_mib/init_bridge_mib.c
View file @
c629542e
...
...
@@ -12,6 +12,7 @@
#include "dot1dBasePortTable/dot1dBasePortTable.h"
#include "dot1dTpFdbTable/dot1dTpFdbTable.h"
#include "dot1qFdbTable/dot1qFdbTable.h"
#include "dot1qTpFdbTable/dot1qTpFdbTable.h"
void
init_bridge_mib
(
void
)
{
...
...
@@ -19,4 +20,5 @@ void init_bridge_mib(void)
init_dot1dBasePortTable
();
init_dot1dTpFdbTable
();
init_dot1qFdbTable
();
init_dot1qTpFdbTable
();
}
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