net-snmp 5.7
|
00001 /* 00002 * lcd_time.h 00003 */ 00004 00005 #ifndef _LCD_TIME_H 00006 #define _LCD_TIME_H 00007 00008 #ifdef __cplusplus 00009 extern "C" { 00010 #endif 00011 00012 00013 /* 00014 * undefine to enable time synchronization only on authenticated packets 00015 */ 00016 #define LCD_TIME_SYNC_OPT 1 00017 00018 /* 00019 * Macros and definitions. 00020 */ 00021 #define ETIMELIST_SIZE 23 00022 00023 00024 00025 typedef struct enginetime_struct { 00026 u_char *engineID; 00027 u_int engineID_len; 00028 00029 u_int engineTime; 00030 u_int engineBoot; 00031 /* 00032 * Time & boots values received from last authenticated 00033 * * message within the previous time window. 00034 */ 00035 00036 time_t lastReceivedEngineTime; 00037 /* 00038 * Timestamp made when engineTime/engineBoots was last 00039 * * updated. Measured in seconds. 00040 */ 00041 00042 #ifdef LCD_TIME_SYNC_OPT 00043 u_int authenticatedFlag; 00044 #endif 00045 struct enginetime_struct *next; 00046 } enginetime , *Enginetime; 00047 00048 00049 00050 00051 /* 00052 * Macros for streamlined engineID existence checks -- 00053 * 00054 * e is char *engineID, 00055 * e_l is u_int engineID_len. 00056 * 00057 * 00058 * ISENGINEKNOWN(e, e_l) 00059 * Returns: 00060 * TRUE If engineID is recoreded in the EngineID List; 00061 * FALSE Otherwise. 00062 * 00063 * ENSURE_ENGINE_RECORD(e, e_l) 00064 * Adds the given engineID to the EngineID List if it does not exist 00065 * already. engineID is added with a <enginetime, engineboots> 00066 * tuple of <0,0>. ALWAYS succeeds -- except in case of a 00067 * fatal internal error. 00068 * Returns: 00069 * SNMPERR_SUCCESS On success; 00070 * SNMPERR_GENERR Otherwise. 00071 * 00072 * MAKENEW_ENGINE_RECORD(e, e_l) 00073 * Returns: 00074 * SNMPERR_SUCCESS If engineID already exists in the EngineID List; 00075 * SNMPERR_GENERR Otherwise -and- invokes ENSURE_ENGINE_RECORD() 00076 * to add an entry to the EngineID List. 00077 * 00078 * XXX Requres the following declaration in modules calling ISENGINEKNOWN(): 00079 * static u_int dummy_etime, dummy_eboot; 00080 */ 00081 #define ISENGINEKNOWN(e, e_l) \ 00082 ( (get_enginetime(e, e_l, \ 00083 &dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS) \ 00084 ? TRUE \ 00085 : FALSE ) 00086 00087 #define ENSURE_ENGINE_RECORD(e, e_l) \ 00088 ( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS) \ 00089 ? SNMPERR_SUCCESS \ 00090 : SNMPERR_GENERR ) 00091 00092 #define MAKENEW_ENGINE_RECORD(e, e_l) \ 00093 ( (ISENGINEKNOWN(e, e_l) == TRUE) \ 00094 ? SNMPERR_SUCCESS \ 00095 : (ENSURE_ENGINE_RECORD(e, e_l), SNMPERR_GENERR) ) 00096 00097 00098 00099 /* 00100 * Prototypes. 00101 */ 00102 int get_enginetime(const u_char * engineID, u_int engineID_len, 00103 u_int * engine_boot, 00104 u_int * engine_time, 00105 u_int authenticated); 00106 00107 int get_enginetime_ex(u_char * engineID, 00108 u_int engineID_len, 00109 u_int * engine_boot, 00110 u_int * engine_time, 00111 u_int * last_engine_time, 00112 u_int authenticated); 00113 00114 int set_enginetime(const u_char * engineID, u_int engineID_len, 00115 u_int engine_boot, u_int engine_time, 00116 u_int authenticated); 00117 00118 00119 00120 00121 00122 00123 00124 Enginetime 00125 search_enginetime_list(const u_char * engineID, u_int engineID_len); 00126 00127 int hash_engineID(const u_char * engineID, u_int engineID_len); 00128 00129 void dump_etimelist_entry(Enginetime e, int count); 00130 void dump_etimelist(void); 00131 void free_etimelist(void); 00132 void free_enginetime(unsigned char *engineID, size_t engineID_len); 00133 00134 #ifdef __cplusplus 00135 } 00136 #endif 00137 #endif /* _LCD_TIME_H */