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