/
Dot1dTpFdbTableTracker.java
209 lines (187 loc) · 7.49 KB
/
Dot1dTpFdbTableTracker.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2006-2012 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/
package org.opennms.netmgt.enlinkd.snmp;
import org.opennms.netmgt.model.BridgeMacLink;
import org.opennms.netmgt.model.BridgeMacLink.BridgeDot1qTpFdbStatus;
import org.opennms.netmgt.snmp.RowCallback;
import org.opennms.netmgt.snmp.SnmpInstId;
import org.opennms.netmgt.snmp.SnmpObjId;
import org.opennms.netmgt.snmp.SnmpRowResult;
import org.opennms.netmgt.snmp.TableTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*<P>The Dot1dTpFdbTableTracker class is designed to hold all the MIB-II
* information for one entry in the MIB II dot1dBridge.dot1dTp.dot1dTpFdbTable.
* The table effectively contains a list of these entries, each entry having information
* about bridge forwarding table.</P>
*
* <P>This object is used by the Dot1dTpFdbTable to hold information
* single entries in the table. See the Dot1dTpFdbTable documentation
* form more information.</P>
*
* @author <A HREF="mailto:rssntn67@yahoo.it">Antonio</A>
* @see Dot1dTpFdbTable
* @see <A HREF="http://www.ietf.org/rfc/rfc1213.txt">RFC1213</A>
* @version $Id: $
*/
public class Dot1dTpFdbTableTracker extends TableTracker {
private final static Logger LOG = LoggerFactory.getLogger(Dot1dTpFdbTableTracker.class);
/**
* The status of the info in FDB table entry The status of this entry. The
* meanings of the values are: learned(3) : the value of the corresponding
* instance of dot1dTpFdbPort was learned, and is being used.
*/
public static final int SNMP_DOT1D_FDB_STATUS_LEARNED = 3;
public final static SnmpObjId DOT1D_TP_FDB_ADDRESS = SnmpObjId.get(".1.3.6.1.2.1.17.4.3.1.1");
public final static SnmpObjId DOT1D_TP_FDB_PORT = SnmpObjId.get(".1.3.6.1.2.1.17.4.3.1.2");
public final static SnmpObjId DOT1D_TP_FDB_STATUS = SnmpObjId.get(".1.3.6.1.2.1.17.4.3.1.3");
public static final SnmpObjId[] ms_elemList = new SnmpObjId[] {
/**
* A unicast MAC address for which the bridge has
* forwarding and/or filtering information.
* REFERENCE
"IEEE 802.1D-1998: clause 7.9.1, 7.9.2"
*/
DOT1D_TP_FDB_ADDRESS,
/**
* Either the value '0', or the port number of the
* port on which a frame having a source address
* equal to the value of the corresponding instance
* of dot1dTpFdbAddress has been seen. A value of
* '0' indicates that the port number has not been
* learned but that the bridge does have some
* forwarding/filtering information about this
* address (e.g. in the dot1dStaticTable).
* Implementors are encouraged to assign the port
* value to this object whenever it is learned even
* for addresses for which the corresponding value of
* dot1dTpFdbStatus is not learned(3).
*/
DOT1D_TP_FDB_PORT,
/**
* "The status of this entry. The meanings of the
* values are:
* other(1) - none of the following. This would
* include the case where some other MIB object
* (not the corresponding instance of
* dot1dTpFdbPort, nor an entry in the
* dot1dStaticTable) is being used to determine if
* and how frames addressed to the value of the
* corresponding instance of dot1dTpFdbAddress are
* being forwarded.
* invalid(2) - this entry is no longer valid (e.g.,
* it was learned but has since aged out), but has
* not yet been flushed from the table.
* learned(3) - the value of the corresponding instance
* of dot1dTpFdbPort was learned, and is being
* used.
* self(4) - the value of the corresponding instance of
* dot1dTpFdbAddress represents one of the bridge's
* addresses. The corresponding instance of
* dot1dTpFdbPort indicates which of the bridge's
* ports has this address.
* mgmt(5) - the value of the corresponding instance of
* dot1dTpFdbAddress is also the value of an
* existing instance of dot1dStaticAddress."
*/
DOT1D_TP_FDB_STATUS
};
public class Dot1dTpFdbRow extends SnmpRowResult {
public Dot1dTpFdbRow(int columnCount, SnmpInstId instance) {
super(columnCount, instance);
}
/**
* <p>getDot1dTpFdbAddress</p>
*
* @return a {@link java.lang.String} object.
*/
public String getDot1dTpFdbAddress() {
return getValue(DOT1D_TP_FDB_ADDRESS).toHexString();
}
/**
* <p>getDot1dTpFdbPort</p>
*
* @return a int.
*/
public Integer getDot1dTpFdbPort() {
return getValue(DOT1D_TP_FDB_PORT).toInt();
}
/**
* <p>getDot1dTpFdbStatus</p>
*
* @return a int.
*/
public Integer getDot1dTpFdbStatus() {
return getValue(DOT1D_TP_FDB_STATUS).toInt();
}
public BridgeMacLink getLink() {
LOG.info("processDot1qTpFdbRow: row count: {}", getColumnCount());
BridgeMacLink link = new BridgeMacLink();
link.setBridgePort(getDot1dTpFdbPort());
link.setMacAddress(getDot1dTpFdbAddress());
link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.get(getDot1dTpFdbStatus()));
return link;
}
}
/**
* <P>The class constructor used to initialize the
* object to its initial state. Although the
* object's member variables can change after an
* instance is created, this constructor will
* initialize all the variables as per their named
* variable from the passed array of SNMP varbinds.</P>
*
* <P>If the information in the object should not be
* modified then a <EM>final</EM> modifier can be
* applied to the created object.</P>
*/
public Dot1dTpFdbTableTracker() {
super(ms_elemList);
}
public Dot1dTpFdbTableTracker(RowCallback rowProcessor) {
super(rowProcessor, ms_elemList);
}
/** {@inheritDoc} */
@Override
public SnmpRowResult createRowResult(final int columnCount, final SnmpInstId instance) {
return new Dot1dTpFdbRow(columnCount, instance);
}
/** {@inheritDoc} */
@Override
public void rowCompleted(final SnmpRowResult row) {
processDot1dTpFdbRow((Dot1dTpFdbRow)row);
}
/**
* <p>processIpNetToMediaRow</p>
*
* @param row a {@link org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker.Dot1dTpFdbRow} object.
*/
public void processDot1dTpFdbRow(final Dot1dTpFdbRow row) {
}
}