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.agent.DuplicateRegistrationException;
23  import org.snmp4j.agent.MOScope;
24  import org.snmp4j.agent.MOServer;
25  import org.snmp4j.agent.mo.MOAccessImpl;
26  import org.snmp4j.agent.mo.snmp.SNMPv2MIB;
27  import org.snmp4j.agent.mo.snmp.SysUpTime;
28  import org.snmp4j.mp.SnmpConstants;
29  import org.snmp4j.smi.Integer32;
30  import org.snmp4j.smi.OID;
31  import org.snmp4j.smi.OctetString;
32  import org.snmp4j.smi.SMIConstants;
33  import org.snmp4j.smi.TimeTicks;
34  import org.snmp4j.smi.VariableBinding;
35  import org.waarp.common.command.ReplyCode;
36  import org.waarp.common.logging.WaarpLogger;
37  import org.waarp.common.logging.WaarpLoggerFactory;
38  import org.waarp.common.utility.Version;
39  import org.waarp.gateway.ftp.config.FileBasedConfiguration;
40  import org.waarp.gateway.ftp.database.data.DbTransferLog;
41  import org.waarp.snmp.WaarpSnmpAgent;
42  import org.waarp.snmp.interf.WaarpInterfaceMib;
43  import org.waarp.snmp.r66.WaarpPrivateMib;
44  import org.waarp.snmp.utils.MemoryGauge32;
45  import org.waarp.snmp.utils.MemoryGauge32.MemoryType;
46  import org.waarp.snmp.utils.WaarpEntry;
47  import org.waarp.snmp.utils.WaarpMORow;
48  import org.waarp.snmp.utils.WaarpMOScalar;
49  import org.waarp.snmp.utils.WaarpUptime;
50  
51  /**
52   * FTP Private MIB implementation
53   */
54  public class FtpPrivateMib implements WaarpInterfaceMib {
55    /**
56     * Internal Logger
57     */
58    private static final WaarpLogger logger =
59        WaarpLoggerFactory.getLogger(FtpPrivateMib.class);
60  
61    public static final String SnmpName = "Waarp GW FTP SNMP";
62  
63    public static final int SnmpPrivateId = 66666;
64  
65    public static final int SnmpFtpId = 21;
66  
67    public static final String SnmpDefaultAuthor = "Frederic Bregier";
68  
69    public static final String SnmpVersion =
70        "Waarp GW FTP " + Version.fullIdentifier();
71  
72    public static final String SnmpDefaultLocalization = "Paris, France";
73  
74    public static final int SnmpService = 72;
75  
76    /**
77     * SnmpConstants.sysObjectID
78     */
79    public final OID ggObjectId; // will be smiPrivateCode.typeWaarp
80  
81    /**
82     * SnmpConstants.sysUpTime
83     */
84    public SysUpTime upTime;
85  
86    /**
87     * need to add ".port" like "6666" Only in TCP (no UDP supported for Waarp)
88     * <p>
89     * example: rootEnterpriseMib+"66666"+".1.1.4.";
90     */
91    public final String applicationProtocolBase;
92  
93    /**
94     * will be = new OID(applicationProtocolBase+port);
95     */
96    public final OID applicationProtocol;
97  
98    /**
99     * root OID in String
100    */
101   public final String srootOIDWaarp;
102 
103   /**
104    * root OID
105    */
106   public final OID rootOIDWaarp;
107 
108   /**
109    * Used in Notify
110    */
111   public final OID rootOIDWaarpNotif;
112 
113   /**
114    * Used in Notify Start or Shutdown
115    */
116   public final OID rootOIDWaarpNotifStartOrShutdown;
117 
118   /**
119    * Info static part
120    */
121   public final OID rootOIDWaarpInfo;
122 
123   /**
124    * Info Row access
125    */
126   public WaarpMORow rowInfo;
127 
128   /**
129    * Global dynamic part
130    */
131   public final OID rootOIDWaarpGlobal;
132 
133   /**
134    * Global Row access
135    */
136   public WaarpMORow rowGlobal;
137 
138   /**
139    * Uptime OID
140    */
141   public final OID rootOIDWaarpGlobalUptime;
142 
143   /**
144    * Corresponding UpTime in Mib
145    */
146   public WaarpMOScalar scalarUptime;
147 
148   /**
149    * Detailed dynamic part
150    */
151   public final OID rootOIDWaarpDetailed;
152 
153   /**
154    * Detailed Row access
155    */
156   public WaarpMORow rowDetailed;
157 
158   /**
159    * Error dynamic part
160    */
161   public final OID rootOIDWaarpError;
162 
163   /**
164    * Error Row access
165    */
166   public WaarpMORow rowError;
167 
168   /**
169    * New SNMPV2 MIB
170    */
171   public SNMPv2MIB snmpv2;
172 
173   /**
174    * Corresponding agent
175    */
176   public WaarpSnmpAgent agent;
177 
178   /**
179    * @param port port used by FTP server
180    */
181   public FtpPrivateMib(final int port) {
182     srootOIDWaarp = rootEnterpriseMib + "." + SnmpPrivateId + '.' + SnmpFtpId;
183     applicationProtocolBase = srootOIDWaarp + ".1.1.4.";
184     ggObjectId = new OID(srootOIDWaarp);
185     applicationProtocol = new OID(applicationProtocolBase + port);
186     rootOIDWaarp = new OID(srootOIDWaarp);
187     rootOIDWaarpInfo = new OID(srootOIDWaarp + ".1");
188     rootOIDWaarpGlobal = new OID(srootOIDWaarp + ".2");
189     rootOIDWaarpGlobalUptime = new OID(
190         rootOIDWaarpGlobal + "." + WaarpGlobalValuesIndex.applUptime.getOID() +
191         ".0");
192     rootOIDWaarpDetailed = new OID(srootOIDWaarp + ".3");
193     rootOIDWaarpError = new OID(srootOIDWaarp + ".4");
194     rootOIDWaarpNotif = new OID(srootOIDWaarp + ".5.1");
195     rootOIDWaarpNotifStartOrShutdown = new OID(srootOIDWaarp + ".5.1.1.1");
196   }
197 
198   /**
199    * Unregister and Register again the SNMPv2MIB with System adapted to this
200    * Mib
201    *
202    * @throws DuplicateRegistrationException
203    */
204   protected final void agentRegisterSystem()
205       throws DuplicateRegistrationException {
206     // Since BaseAgent registers some mibs by default we need to unregister
207     // one before we register our own sysDescr. Normally you would
208     // override that method and register the mibs that you need
209 
210     agent.unregisterManagedObject(agent.getSnmpv2MIB());
211 
212     // Register a system description, use one from you product environment
213     // to test with
214     snmpv2 = new SNMPv2MIB(new OctetString(SnmpName), ggObjectId,
215                            new Integer32(SnmpService));
216     snmpv2.setContact(new OctetString(SnmpDefaultAuthor));
217     snmpv2.setLocation(new OctetString(SnmpDefaultLocalization));
218     snmpv2.setName(new OctetString(SnmpVersion));
219     snmpv2.registerMOs(agent.getServer(), null);
220     if (logger.isDebugEnabled()) {
221       logger.debug(
222           "SNMPV2: " + snmpv2.getContact() + ':' + snmpv2.getDescr() + ':' +
223           snmpv2.getLocation() + ':' + snmpv2.getName() + ':' +
224           snmpv2.getObjectID() + ':' + snmpv2.getServices() + ':' +
225           snmpv2.getUpTime());
226     }
227     // Save UpTime reference since used everywhere
228     upTime = snmpv2.getSysUpTime();
229   }
230 
231   /**
232    * Register this MIB
233    *
234    * @throws DuplicateRegistrationException
235    */
236   protected final void agentRegisterWaarpMib()
237       throws DuplicateRegistrationException {
238     logger.debug("registerGGMib");
239     // register Static info
240     rowInfo = new WaarpMORow(this, rootOIDWaarpInfo, WaarpDefinition,
241                              MibLevel.staticInfo.ordinal());
242     rowInfo.setValue(WaarpDefinitionIndex.applName.ordinal(),
243                      "Waarp " + "GatewayFtp");
244     rowInfo.setValue(WaarpDefinitionIndex.applServerName.ordinal(),
245                      FileBasedConfiguration.fileBasedConfiguration.getHostId());
246     rowInfo.setValue(WaarpDefinitionIndex.applVersion.ordinal(),
247                      Version.fullIdentifier());
248     rowInfo.setValue(WaarpDefinitionIndex.applDescription.ordinal(),
249                      "Waarp Gateway Ftp: FTP Gateway");
250     rowInfo.setValue(WaarpDefinitionIndex.applURL.ordinal(),
251                      "http://waarp.github.com/Waarp");
252     rowInfo.setValue(WaarpDefinitionIndex.applApplicationProtocol.ordinal(),
253                      applicationProtocol);
254 
255     rowInfo.registerMOs(agent.getServer(), null);
256     // register General info
257     rowGlobal = new WaarpMORow(this, rootOIDWaarpGlobal, WaarpGlobalValues,
258                                MibLevel.globalInfo.ordinal());
259     WaarpMOScalar memoryScalar =
260         rowGlobal.getRow()[WaarpGlobalValuesIndex.memoryTotal.ordinal()];
261     memoryScalar.setValue(new MemoryGauge32(MemoryType.TotalMemory));
262     memoryScalar =
263         rowGlobal.getRow()[WaarpGlobalValuesIndex.memoryFree.ordinal()];
264     memoryScalar.setValue(new MemoryGauge32(MemoryType.FreeMemory));
265     memoryScalar =
266         rowGlobal.getRow()[WaarpGlobalValuesIndex.memoryUsed.ordinal()];
267     memoryScalar.setValue(new MemoryGauge32(MemoryType.UsedMemory));
268     rowGlobal.registerMOs(agent.getServer(), null);
269     // setup UpTime to SysUpTime and change status
270     scalarUptime =
271         rowGlobal.getRow()[WaarpGlobalValuesIndex.applUptime.ordinal()];
272     scalarUptime.setValue(new WaarpUptime(upTime));
273     changeStatus(OperStatus.restarting);
274     changeStatus(OperStatus.up);
275     // register Detailed info
276     rowDetailed =
277         new WaarpMORow(this, rootOIDWaarpDetailed, WaarpDetailedValues,
278                        MibLevel.detailedInfo.ordinal());
279     rowDetailed.registerMOs(agent.getServer(), null);
280     // register Error info
281     rowError = new WaarpMORow(this, rootOIDWaarpError, WaarpErrorValues,
282                               MibLevel.errorInfo.ordinal());
283     rowError.registerMOs(agent.getServer(), null);
284   }
285 
286   /**
287    * Unregister this MIB
288    */
289   protected final void agentUnregisterMibs() {
290     logger.debug("UnRegisterWaarp");
291     rowInfo.unregisterMOs(agent.getServer(), agent.getDefaultContext());
292     rowGlobal.unregisterMOs(agent.getServer(), agent.getDefaultContext());
293     rowDetailed.unregisterMOs(agent.getServer(), agent.getDefaultContext());
294     rowError.unregisterMOs(agent.getServer(), agent.getDefaultContext());
295   }
296 
297   @Override
298   public final void registerMOs(final MOServer moServer,
299                                 final OctetString octetString)
300       throws DuplicateRegistrationException {
301     agentRegisterSystem();
302     agentRegisterWaarpMib();
303   }
304 
305   @Override
306   public final void unregisterMOs(final MOServer moServer,
307                                   final OctetString octetString) {
308     agentUnregisterMibs();
309   }
310 
311   @Override
312   public final void setAgent(final WaarpSnmpAgent agent) {
313     this.agent = agent;
314   }
315 
316   @Override
317   public final OID getBaseOidStartOrShutdown() {
318     return rootOIDWaarpNotifStartOrShutdown;
319   }
320 
321   @Override
322   public final SNMPv2MIB getSNMPv2MIB() {
323     return snmpv2;
324   }
325 
326   @Override
327   public final void updateServices(final WaarpMOScalar scalar) {
328     // Nothing
329   }
330 
331   @Override
332   public final void updateServices(final MOScope range) {
333     // Nothing
334   }
335 
336   /**
337    * Change the status and the LastChange Timeticks
338    *
339    * @param status
340    */
341   public final void changeStatus(final OperStatus status) {
342     final WaarpMOScalar statusScalar =
343         rowGlobal.getRow()[WaarpGlobalValuesIndex.applOperStatus.ordinal()];
344     final Integer32 var = (Integer32) statusScalar.getValue();
345     if (var.getValue() != status.status) {
346       var.setValue(status.status);
347       final WaarpMOScalar lastTimeScalar =
348           rowGlobal.getRow()[WaarpGlobalValuesIndex.applLastChange.ordinal()];
349       final TimeTicks time = (TimeTicks) lastTimeScalar.getValue();
350       time.setValue(upTime.get().getValue());
351     }
352   }
353 
354   /**
355    * Send a notification (trap or inform) for Shutdown event
356    *
357    * @param message
358    * @param message2
359    */
360   public final void notifyStartStop(final String message,
361                                     final String message2) {
362     if (!TrapLevel.StartStop.isLevelValid(agent.getTrapLevel())) {
363       return;
364     }
365     notify(NotificationElements.TrapShutdown, message, message2);
366   }
367 
368   /**
369    * Send a notification (trap or inform) for Error event
370    *
371    * @param message
372    * @param message2
373    */
374   public final void notifyError(final String message, final String message2) {
375     if (!TrapLevel.Alert.isLevelValid(agent.getTrapLevel())) {
376       return;
377     }
378     notify(NotificationElements.TrapError, message, message2);
379   }
380 
381   /**
382    * Send a notification (trap or inform) for Server Overloaded event
383    *
384    * @param message
385    * @param message2
386    */
387   public final void notifyOverloaded(final String message,
388                                      final String message2) {
389     if (!TrapLevel.Warning.isLevelValid(agent.getTrapLevel())) {
390       return;
391     }
392     notify(NotificationElements.TrapOverloaded, message, message2);
393   }
394 
395   /**
396    * Send a notification (trap or inform) for Warning event
397    *
398    * @param message
399    * @param message2
400    */
401   public final void notifyWarning(final String message, final String message2) {
402     if (!TrapLevel.Warning.isLevelValid(agent.getTrapLevel())) {
403       return;
404     }
405     notify(NotificationElements.TrapWarning, message, message2);
406   }
407 
408   /**
409    * Send a notification (trap or inform) for Warning/Error event on a single
410    * Transfer Task
411    *
412    * @param message
413    * @param runner
414    */
415   public final void notifyInfoTask(final String message,
416                                    final DbTransferLog runner) {
417     if (!TrapLevel.All.isLevelValid(agent.getTrapLevel())) {
418       return;
419     }
420     if (logger.isDebugEnabled()) {
421       logger.debug(
422           "Notify: " + NotificationElements.InfoTask + ':' + message + ':' +
423           runner);
424     }
425     long delay =
426         (runner.getStart().getTime() - agent.getUptimeSystemTime()) / 10;
427     if (delay < 0) {
428       delay = 0;
429     }
430     agent.getNotificationOriginator().notify(new OctetString("public"),
431                                              NotificationElements.InfoTask.getOID(
432                                                  rootOIDWaarpNotif),
433                                              new VariableBinding[] {
434                                                  new VariableBinding(
435                                                      NotificationElements.InfoTask.getOID(
436                                                          rootOIDWaarpNotif, 1),
437                                                      new OctetString(
438                                                          NotificationElements.InfoTask.name())),
439                                                  new VariableBinding(
440                                                      NotificationElements.InfoTask.getOID(
441                                                          rootOIDWaarpNotif, 1),
442                                                      new OctetString(message)),
443                                                  // Start of Task
444                                                  new VariableBinding(
445                                                      NotificationElements.InfoTask.getOID(
446                                                          rootOIDWaarpNotif,
447                                                          NotificationTasks.filenameInfo.getOID()),
448                                                      new OctetString(
449                                                          runner.getFilename())),
450                                                  new VariableBinding(
451                                                      NotificationElements.InfoTask.getOID(
452                                                          rootOIDWaarpNotif,
453                                                          NotificationTasks.modeTransInfo.getOID()),
454                                                      new OctetString(
455                                                          runner.getMode())),
456                                                  new VariableBinding(
457                                                      NotificationElements.InfoTask.getOID(
458                                                          rootOIDWaarpNotif,
459                                                          NotificationTasks.startTransInfo.getOID()),
460                                                      new TimeTicks(delay)),
461                                                  new VariableBinding(
462                                                      NotificationElements.InfoTask.getOID(
463                                                          rootOIDWaarpNotif,
464                                                          NotificationTasks.infoStatusInfo.getOID()),
465                                                      new OctetString(
466                                                          runner.getErrorInfo()
467                                                                .getMesg())),
468                                                  new VariableBinding(
469                                                      NotificationElements.InfoTask.getOID(
470                                                          rootOIDWaarpNotif,
471                                                          NotificationTasks.userIdInfo.getOID()),
472                                                      new OctetString(
473                                                          runner.getUser())),
474                                                  new VariableBinding(
475                                                      NotificationElements.InfoTask.getOID(
476                                                          rootOIDWaarpNotif,
477                                                          NotificationTasks.accountId.getOID()),
478                                                      new OctetString(
479                                                          runner.getAccount())),
480                                                  new VariableBinding(
481                                                      NotificationElements.InfoTask.getOID(
482                                                          rootOIDWaarpNotif,
483                                                          NotificationTasks.specialIdInfo.getOID()),
484                                                      new OctetString(
485                                                          String.valueOf(
486                                                              runner.getSpecialId()))),
487                                                  // End of Task
488                                                  new VariableBinding(
489                                                      SnmpConstants.sysDescr,
490                                                      snmpv2.getDescr()),
491                                                  new VariableBinding(
492                                                      SnmpConstants.sysObjectID,
493                                                      snmpv2.getObjectID()),
494                                                  new VariableBinding(
495                                                      SnmpConstants.sysContact,
496                                                      snmpv2.getContact()),
497                                                  new VariableBinding(
498                                                      SnmpConstants.sysName,
499                                                      snmpv2.getName()),
500                                                  new VariableBinding(
501                                                      SnmpConstants.sysLocation,
502                                                      snmpv2.getLocation())
503                                              });
504   }
505 
506   /**
507    * Trap/Notification
508    *
509    * @param element
510    * @param message
511    * @param message2
512    */
513   private void notify(final NotificationElements element, final String message,
514                       final String message2) {
515     if (logger.isDebugEnabled()) {
516       logger.debug("Notify: " + element + ':' + message + ':' + message2);
517     }
518     agent.getNotificationOriginator()
519          .notify(new OctetString("public"), element.getOID(rootOIDWaarpNotif),
520                  new VariableBinding[] {
521                      new VariableBinding(element.getOID(rootOIDWaarpNotif, 1),
522                                          new OctetString(element.name())),
523                      new VariableBinding(element.getOID(rootOIDWaarpNotif, 1),
524                                          new OctetString(message)),
525                      new VariableBinding(element.getOID(rootOIDWaarpNotif, 1),
526                                          new OctetString(message2)),
527                      new VariableBinding(SnmpConstants.sysDescr,
528                                          snmpv2.getDescr()),
529                      new VariableBinding(SnmpConstants.sysObjectID,
530                                          snmpv2.getObjectID()),
531                      new VariableBinding(SnmpConstants.sysContact,
532                                          snmpv2.getContact()),
533                      new VariableBinding(SnmpConstants.sysName,
534                                          snmpv2.getName()),
535                      new VariableBinding(SnmpConstants.sysLocation,
536                                          snmpv2.getLocation())
537                  });
538   }
539 
540   /**
541    * MIB entry levels
542    */
543   public enum MibLevel {
544     staticInfo, globalInfo, detailedInfo, errorInfo, trapInfo
545   }
546 
547   // From now the MIB definition
548 
549   /**
550    * Notification Elements
551    */
552   public enum NotificationElements {
553     TrapShutdown(1), TrapError(2), TrapWarning(3), TrapOverloaded(4),
554     InfoTask(5);
555 
556     public final int[] oid;
557 
558     NotificationElements(final int oid) {
559       this.oid = new int[] { oid };
560     }
561 
562     public final OID getOID(final OID oidBase) {
563       return new OID(oidBase.getValue(), oid);
564     }
565 
566     public final OID getOID(final OID oidBase, final int rank) {
567       final int[] ids = { oid[0], rank };
568       return new OID(oidBase.getValue(), ids);
569     }
570   }
571 
572   /**
573    * Notification for a task trap
574    */
575   public enum NotificationTasks {
576     filenameInfo, modeTransInfo, startTransInfo, infoStatusInfo, userIdInfo,
577     accountId, specialIdInfo;
578 
579     public final int getOID() {
580       return ordinal() + 1;
581     }
582   }
583 
584   /**
585    * Definition part
586    */
587   public enum WaarpDefinitionIndex {
588     applName, applServerName, applVersion, applDescription, applURL,
589     applApplicationProtocol;
590 
591     public final int getOID() {
592       return ordinal() + 1;
593     }
594   }
595 
596   /**
597    * Definition part
598    */
599   public static final WaarpEntry[] WaarpDefinition =
600       WaarpPrivateMib.WaarpDefinition;
601 
602   /**
603    * Global part
604    */
605   public enum WaarpGlobalValuesIndex {
606     applUptime, applOperStatus, applLastChange, applInboundAssociations,
607     applOutboundAssociations, applAccumInboundAssociations,
608     applAccumOutboundAssociations, applLastInboundActivity,
609     applLastOutboundActivity, applRejectedInboundAssociations,
610     applFailedOutboundAssociations, applInboundBandwidthKBS,
611     applOutboundBandwidthKBS, nbInfoUnknown, nbInfoNotUpdated,
612     nbInfoInterrupted, nbInfoToSubmit, nbInfoError, nbInfoRunning, nbInfoDone,
613     nbAllTransfer, memoryTotal, memoryFree, memoryUsed, nbThreads,
614     nbNetworkConnection;
615 
616     public final int getOID() {
617       return ordinal() + 1;
618     }
619   }
620 
621   /**
622    * Global part
623    */
624   public static final WaarpEntry[] WaarpGlobalValues =
625       WaarpPrivateMib.WaarpGlobalValues;
626 
627   /**
628    * Detailed part
629    */
630   public enum WaarpDetailedValuesIndex {
631     reply_000(ReplyCode.REPLY_000_SPECIAL_NOSTATUS),
632     reply_110(ReplyCode.REPLY_110_RESTART_MARKER_REPLY),
633     reply_120(ReplyCode.REPLY_120_SERVICE_READY_IN_NNN_MINUTES),
634     reply_125(ReplyCode.REPLY_125_DATA_CONNECTION_ALREADY_OPEN),
635     reply_150(ReplyCode.REPLY_150_FILE_STATUS_OKAY),
636     reply_200(ReplyCode.REPLY_200_COMMAND_OKAY),
637     reply_202(ReplyCode.REPLY_202_COMMAND_NOT_IMPLEMENTED),
638     reply_211(ReplyCode.REPLY_211_SYSTEM_STATUS_REPLY),
639     reply_212(ReplyCode.REPLY_212_DIRECTORY_STATUS),
640     reply_213(ReplyCode.REPLY_213_FILE_STATUS),
641     reply_214(ReplyCode.REPLY_214_HELP_MESSAGE),
642     reply_215(ReplyCode.REPLY_215_NAME_SYSTEM_TYPE),
643     reply_220(ReplyCode.REPLY_220_SERVICE_READY),
644     reply_221(ReplyCode.REPLY_221_CLOSING_CONTROL_CONNECTION),
645     reply_225(ReplyCode.REPLY_225_DATA_CONNECTION_OPEN_NO_TRANSFER_IN_PROGRESS),
646     reply_226(ReplyCode.REPLY_226_CLOSING_DATA_CONNECTION),
647     reply_227(ReplyCode.REPLY_227_ENTERING_PASSIVE_MODE),
648     reply_229(ReplyCode.REPLY_229_ENTERING_PASSIVE_MODE),
649     reply_230(ReplyCode.REPLY_230_USER_LOGGED_IN),
650     reply_232(ReplyCode.REPLY_232_USER_LOGGED_IN),
651     reply_234(ReplyCode.REPLY_234_SECURITY_DATA_EXCHANGE_COMPLETE),
652     reply_250(ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY),
653     reply_257(ReplyCode.REPLY_257_PATHNAME_CREATED),
654     reply_331(ReplyCode.REPLY_331_USER_NAME_OKAY_NEED_PASSWORD),
655     reply_332(ReplyCode.REPLY_332_NEED_ACCOUNT_FOR_LOGIN), reply_350(
656         ReplyCode.REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION);
657 
658     public final ReplyCode code;
659 
660     WaarpDetailedValuesIndex(final ReplyCode code) {
661       this.code = code;
662     }
663 
664     public final int getOID() {
665       return ordinal() + 1;
666     }
667   }
668 
669   /**
670    * Detailed part
671    */
672   public static final WaarpEntry[] WaarpDetailedValues = {
673       // reply_000,
674       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
675                      MOAccessImpl.ACCESS_READ_ONLY),
676       // reply_110,
677       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
678                      MOAccessImpl.ACCESS_READ_ONLY),
679       // reply_120,
680       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
681                      MOAccessImpl.ACCESS_READ_ONLY),
682       // reply_125,
683       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
684                      MOAccessImpl.ACCESS_READ_ONLY),
685       // reply_150,
686       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
687                      MOAccessImpl.ACCESS_READ_ONLY),
688       // reply_200,
689       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
690                      MOAccessImpl.ACCESS_READ_ONLY),
691       // reply_202,
692       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
693                      MOAccessImpl.ACCESS_READ_ONLY),
694       // reply_211,
695       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
696                      MOAccessImpl.ACCESS_READ_ONLY),
697       // reply_212,
698       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
699                      MOAccessImpl.ACCESS_READ_ONLY),
700       // reply_213,
701       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
702                      MOAccessImpl.ACCESS_READ_ONLY),
703       // reply_214,
704       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
705                      MOAccessImpl.ACCESS_READ_ONLY),
706       // reply_215,
707       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
708                      MOAccessImpl.ACCESS_READ_ONLY),
709       // reply_220,
710       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
711                      MOAccessImpl.ACCESS_READ_ONLY),
712       // reply_221,
713       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
714                      MOAccessImpl.ACCESS_READ_ONLY),
715       // reply_225,
716       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
717                      MOAccessImpl.ACCESS_READ_ONLY),
718       // reply_226,
719       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
720                      MOAccessImpl.ACCESS_READ_ONLY),
721       // reply_227,
722       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
723                      MOAccessImpl.ACCESS_READ_ONLY),
724       // reply_229,
725       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
726                      MOAccessImpl.ACCESS_READ_ONLY),
727       // reply_230,
728       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
729                      MOAccessImpl.ACCESS_READ_ONLY),
730       // reply_232,
731       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
732                      MOAccessImpl.ACCESS_READ_ONLY),
733       // reply_234,
734       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
735                      MOAccessImpl.ACCESS_READ_ONLY),
736       // reply_250,
737       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
738                      MOAccessImpl.ACCESS_READ_ONLY),
739       // reply_257,
740       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
741                      MOAccessImpl.ACCESS_READ_ONLY),
742       // reply_331,
743       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
744                      MOAccessImpl.ACCESS_READ_ONLY),
745       // reply_332,
746       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
747                      MOAccessImpl.ACCESS_READ_ONLY),
748       // reply_350
749       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32, MOAccessImpl.ACCESS_READ_ONLY)
750   };
751 
752   /**
753    * Error part
754    */
755   public enum WaarpErrorValuesIndex {
756     reply_421(
757         ReplyCode.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION),
758     reply_425(ReplyCode.REPLY_425_CANT_OPEN_DATA_CONNECTION),
759     reply_426(ReplyCode.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED),
760     reply_431(
761         ReplyCode.REPLY_431_NEED_UNAVAILABLE_RESOURCE_TO_PROCESS_SECURITY),
762     reply_450(ReplyCode.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN),
763     reply_451(ReplyCode.REPLY_451_REQUESTED_ACTION_ABORTED),
764     reply_452(ReplyCode.REPLY_452_REQUESTED_ACTION_NOT_TAKEN),
765     reply_500(ReplyCode.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED),
766     reply_501(ReplyCode.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS),
767     reply_502(ReplyCode.REPLY_502_COMMAND_NOT_IMPLEMENTED),
768     reply_503(ReplyCode.REPLY_503_BAD_SEQUENCE_OF_COMMANDS),
769     reply_504(ReplyCode.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER),
770     reply_522(
771         ReplyCode.REPLY_522_EXTENDED_PORT_FAILURE_UNKNOWN_NETWORK_PROTOCOL),
772     reply_530(ReplyCode.REPLY_530_NOT_LOGGED_IN),
773     reply_532(ReplyCode.REPLY_532_NEED_ACCOUNT_FOR_STORING_FILES), reply_533(
774         ReplyCode.REPLY_533_COMMAND_PROTECTION_LEVEL_DENIED_FOR_POLICY_REASONS),
775     reply_534(ReplyCode.REPLY_534_REQUEST_DENIED_FOR_POLICY_REASONS),
776     reply_535(ReplyCode.REPLY_535_FAILED_SECURITY_CHECK),
777     reply_536(ReplyCode.REPLY_536_REQUESTED_PROT_LEVEL_NOT_SUPPORTED),
778     reply_550(ReplyCode.REPLY_550_REQUESTED_ACTION_NOT_TAKEN),
779     reply_551(ReplyCode.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN),
780     reply_552(
781         ReplyCode.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE),
782     reply_553(
783         ReplyCode.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED);
784 
785     public final ReplyCode code;
786 
787     WaarpErrorValuesIndex(final ReplyCode code) {
788       this.code = code;
789     }
790 
791     public final int getOID() {
792       return ordinal() + 1;
793     }
794   }
795 
796   /**
797    * Error part
798    */
799   public static final WaarpEntry[] WaarpErrorValues = {
800       // reply_421,
801       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
802                      MOAccessImpl.ACCESS_READ_ONLY),
803       // reply_425,
804       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
805                      MOAccessImpl.ACCESS_READ_ONLY),
806       // reply_426,
807       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
808                      MOAccessImpl.ACCESS_READ_ONLY),
809       // reply_431,
810       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
811                      MOAccessImpl.ACCESS_READ_ONLY),
812       // reply_450,
813       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
814                      MOAccessImpl.ACCESS_READ_ONLY),
815       // reply_451,
816       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
817                      MOAccessImpl.ACCESS_READ_ONLY),
818       // reply_452,
819       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
820                      MOAccessImpl.ACCESS_READ_ONLY),
821       // reply_500,
822       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
823                      MOAccessImpl.ACCESS_READ_ONLY),
824       // reply_501,
825       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
826                      MOAccessImpl.ACCESS_READ_ONLY),
827       // reply_502,
828       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
829                      MOAccessImpl.ACCESS_READ_ONLY),
830       // reply_503,
831       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
832                      MOAccessImpl.ACCESS_READ_ONLY),
833       // reply_504,
834       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
835                      MOAccessImpl.ACCESS_READ_ONLY),
836       // reply_522,
837       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
838                      MOAccessImpl.ACCESS_READ_ONLY),
839       // reply_530,
840       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
841                      MOAccessImpl.ACCESS_READ_ONLY),
842       // reply_532,
843       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
844                      MOAccessImpl.ACCESS_READ_ONLY),
845       // reply_533,
846       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
847                      MOAccessImpl.ACCESS_READ_ONLY),
848       // reply_534,
849       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
850                      MOAccessImpl.ACCESS_READ_ONLY),
851       // reply_535,
852       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
853                      MOAccessImpl.ACCESS_READ_ONLY),
854       // reply_536,
855       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
856                      MOAccessImpl.ACCESS_READ_ONLY),
857       // reply_550,
858       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
859                      MOAccessImpl.ACCESS_READ_ONLY),
860       // reply_551,
861       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
862                      MOAccessImpl.ACCESS_READ_ONLY),
863       // reply_552,
864       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32,
865                      MOAccessImpl.ACCESS_READ_ONLY),
866       // reply_553
867       new WaarpEntry(SMIConstants.SYNTAX_GAUGE32, MOAccessImpl.ACCESS_READ_ONLY)
868   };
869 
870   /**
871    * Oper Status (as defined in Net Application SNMP)
872    */
873   public enum OperStatus {
874     up(1), down(2), halted(3), congested(4), restarting(5), quiescing(6);
875 
876     public final int status;
877 
878     OperStatus(final int status) {
879       this.status = status;
880     }
881   }
882 
883 }