1 /**
2 * This file is part of Waarp Project.
3 *
4 * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the
5 * COPYRIGHT.txt in the distribution for a full listing of individual contributors.
6 *
7 * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of
8 * the GNU General Public License as published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 * Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with Waarp . If not, see
16 * <http://www.gnu.org/licenses/>.
17 */
18 package org.waarp.gateway.ftp.snmp;
19
20 import org.snmp4j.smi.Counter64;
21 import org.snmp4j.smi.Integer32;
22 import org.snmp4j.smi.IpAddress;
23 import org.snmp4j.smi.Null;
24 import org.snmp4j.smi.OID;
25 import org.snmp4j.smi.OctetString;
26 import org.snmp4j.smi.Opaque;
27 import org.snmp4j.smi.SMIConstants;
28 import org.snmp4j.smi.Variable;
29 import org.waarp.snmp.interf.WaarpInterfaceVariableFactory;
30
31 /**
32 * FTP Variable Factory for SNMP
33 *
34 * @author Frederic Bregier
35 *
36 */
37 public class FtpVariableFactory implements WaarpInterfaceVariableFactory {
38
39 @Override
40 public Variable getVariable(OID oid, int type, int mibLevel, int entry) {
41 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: " +
78 type);
79 }
80 return var;
81 }
82
83 }