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