lcd_time.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:4k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * lcd_time.h
  3.  */
  4. #ifndef _LCD_TIME_H
  5. #define _LCD_TIME_H
  6. #ifdef __cplusplus
  7. extern          "C" {
  8. #endif
  9.     /*
  10.      * undefine to enable time synchronization only on authenticated packets 
  11.      */
  12. #define LCD_TIME_SYNC_OPT 1
  13.     /*
  14.      * Macros and definitions.
  15.      */
  16. #define ETIMELIST_SIZE 23
  17.     typedef struct enginetime_struct {
  18.         u_char         *engineID;
  19.         u_int           engineID_len;
  20.         u_int           engineTime;
  21.         u_int           engineBoot;
  22.         /*
  23.          * Time & boots values received from last authenticated
  24.          * *   message within the previous time window.
  25.          */
  26.         time_t          lastReceivedEngineTime;
  27.         /*
  28.          * Timestamp made when engineTime/engineBoots was last
  29.          * *   updated.  Measured in seconds.
  30.          */
  31. #ifdef LCD_TIME_SYNC_OPT
  32.         u_int           authenticatedFlag;
  33. #endif
  34.         struct enginetime_struct *next;
  35.     } enginetime   , *Enginetime;
  36.     /*
  37.      * Macros for streamlined engineID existence checks --
  38.      *
  39.      *      e       is char *engineID,
  40.      *      e_l     is u_int engineID_len.
  41.      *
  42.      *
  43.      *  ISENGINEKNOWN(e, e_l)
  44.      *      Returns:
  45.      *              TRUE    If engineID is recoreded in the EngineID List;
  46.      *              FALSE   Otherwise.
  47.      *
  48.      *  ENSURE_ENGINE_RECORD(e, e_l)
  49.      *      Adds the given engineID to the EngineID List if it does not exist
  50.      *              already.  engineID is added with a <enginetime, engineboots>
  51.      *              tuple of <0,0>.  ALWAYS succeeds -- except in case of a
  52.      *              fatal internal error.
  53.      *      Returns:
  54.      *              SNMPERR_SUCCESS On success;
  55.      *              SNMPERR_GENERR  Otherwise.
  56.      *
  57.      *  MAKENEW_ENGINE_RECORD(e, e_l)
  58.      *      Returns:
  59.      *              SNMPERR_SUCCESS If engineID already exists in the EngineID List;
  60.      *              SNMPERR_GENERR  Otherwise -and- invokes ENSURE_ENGINE_RECORD()
  61.      *                                      to add an entry to the EngineID List.
  62.      *
  63.      * XXX  Requres the following declaration in modules calling ISENGINEKNOWN():
  64.      *      static u_int    dummy_etime, dummy_eboot;
  65.      */
  66. #define ISENGINEKNOWN(e, e_l)
  67. ( (get_enginetime(e, e_l,
  68. &dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)
  69. ? TRUE
  70. : FALSE )
  71. #define ENSURE_ENGINE_RECORD(e, e_l)
  72. ( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS)
  73. ? SNMPERR_SUCCESS
  74. : SNMPERR_GENERR )
  75. #define MAKENEW_ENGINE_RECORD(e, e_l)
  76. ( (ISENGINEKNOWN(e, e_l) == TRUE)
  77. ? SNMPERR_SUCCESS
  78. : (ENSURE_ENGINE_RECORD(e, e_l), SNMPERR_GENERR) )
  79.     /*
  80.      * Prototypes.
  81.      */
  82.     int             get_enginetime(u_char * engineID, u_int engineID_len,
  83.                                    u_int * engine_boot,
  84.                                    u_int * engine_time,
  85.                                    u_int authenticated);
  86.     int             get_enginetime_ex(u_char * engineID,
  87.                                       u_int engineID_len,
  88.                                       u_int * engine_boot,
  89.                                       u_int * engine_time,
  90.                                       u_int * last_engine_time,
  91.                                       u_int authenticated);
  92.     int             set_enginetime(u_char * engineID, u_int engineID_len,
  93.                                    u_int engine_boot, u_int engine_time,
  94.                                    u_int authenticated);
  95.          
  96.          
  97.          
  98.          
  99.          
  100.          
  101.         Enginetime
  102.         search_enginetime_list(u_char * engineID, u_int engineID_len);
  103.     int             hash_engineID(u_char * engineID, u_int engineID_len);
  104.     void            dump_etimelist_entry(Enginetime e, int count);
  105.     void            dump_etimelist(void);
  106.     void            free_enginetime(unsigned char *engineID, size_t engineID_len);
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif                          /* _LCD_TIME_H */