View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5    *  tags. See the COPYRIGHT.txt in the distribution for a full listing of
6    * individual contributors.
7    *
8    *  All Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  package org.waarp.gateway.ftp.snmp;
21  
22  import org.snmp4j.smi.Counter64;
23  import org.snmp4j.smi.Integer32;
24  import org.snmp4j.smi.IpAddress;
25  import org.snmp4j.smi.Null;
26  import org.snmp4j.smi.OID;
27  import org.snmp4j.smi.OctetString;
28  import org.snmp4j.smi.Opaque;
29  import org.snmp4j.smi.SMIConstants;
30  import org.snmp4j.smi.Variable;
31  import org.waarp.snmp.interf.WaarpInterfaceVariableFactory;
32  
33  /**
34   * FTP Variable Factory for SNMP
35   */
36  public class FtpVariableFactory implements WaarpInterfaceVariableFactory {
37  
38    @Override
39    public final Variable getVariable(final OID oid, final int type,
40                                      final int mibLevel, final int entry) {
41      final Variable var;
42      switch (type) {
43        case SMIConstants.SYNTAX_INTEGER:
44          // case SMIConstants.SYNTAX_INTEGER32:
45          var = new Integer32();
46          break;
47        case SMIConstants.SYNTAX_OCTET_STRING:
48          // case SMIConstants.SYNTAX_BITS:
49          var = new OctetString();
50          break;
51        case SMIConstants.SYNTAX_NULL:
52          var = new Null();
53          break;
54        case SMIConstants.SYNTAX_OBJECT_IDENTIFIER:
55          var = new OID();
56          break;
57        case SMIConstants.SYNTAX_IPADDRESS:
58          var = new IpAddress();
59          break;
60        case SMIConstants.SYNTAX_COUNTER32:
61          var = new FtpCounter32(mibLevel, entry);
62          break;
63        case SMIConstants.SYNTAX_GAUGE32:
64          // case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
65          var = new FtpGauge32(mibLevel, entry);
66          break;
67        case SMIConstants.SYNTAX_TIMETICKS:
68          var = new FtpTimeTicks(mibLevel, entry);
69          break;
70        case SMIConstants.SYNTAX_OPAQUE:
71          var = new Opaque();
72          break;
73        case SMIConstants.SYNTAX_COUNTER64:
74          var = new Counter64();
75          break;
76        default:
77          throw new IllegalArgumentException("Unmanaged Type: " + type);
78      }
79      return var;
80    }
81  
82  }