snmp_timer.c
资源名称:snmp.src.rar [点击查看]
上传用户:cxs890
上传日期:2021-05-22
资源大小:347k
文件大小:2k
源码类别:
SNMP编程
开发平台:
C/C++
- #ifdef OS_VXWORKS
- #include <libsys/vos/vos_rtos.h>
- #else
- #include <psos.h>
- #include <libsys/assert.h>
- #endif
- #include "config.h"
- #include "snmp_timer.h"
- extern void snmp_timeout(void);
- #ifdef OS_VXWORKS
- extern int32 vty_console_output(const char *fmt, ...);
- #else
- extern int vty_console_output(const char *fmt, ...);
- #endif
- /* Set a SNMP timer */
- void
- set_SNMPtimer(t,interval)
- struct SNMPtimer *t;
- uint32 interval;
- {
- if(t == NULLTIMER)
- return;
- /* Set timer type as CALLBACK */
- /*使用循环定时器TIMER_LOOP,不再每次超时重新启动定时器,孙希2003.1.8
- t->type=TIMER_CALLBACK_METHOD|TIMER_LOOP;*/
- /* Set callback function */
- t->user_data.cb.fun=(void*)t->func;
- /* Set callback function paremeter */
- t->user_data.cb.arg=(uint32)t->arg;
- /* Set timeout interval*/
- t->timeout = interval;
- }
- /*Create a SNMP timer 99.12.10*/
- void create_SNMPtimer(struct SNMPtimer *t)
- {
- if(t == NULLTIMER)
- return;
- #if 0
- if(sys_add_timer(t->type,&(t->user_data),/*t->timeout,*/&(t->timerID))!=NOERR){
- vty_console_output("error: SNMP create timern");
- t->timerID = 0;
- }
- #else
- {
- uint32 args[4];
- args[0] = (uint32)(t->arg);
- #ifdef OS_VXWORKS
- t->timerID = sys_task_create("SN_T", SYS_TASK_PRI_NORMAL, 0, 10240, t->func, args, 1);
- #else
- t_create("SN_T", 128, 10240, 10240, 0, &t->timerID);
- #endif
- }
- #endif
- return;
- }
- /* Start a SNMP timer */
- void
- start_SNMPtimer(t)
- struct SNMPtimer *t;
- {
- #ifndef OS_VXWORKS
- ULONG args[4];
- #endif
- if(t == NULLTIMER||t->timerID==0)
- return;
- #if 0
- if (sys_start_timer(t->timerID,t->timeout) != NOERR){
- vty_console_output("error: SNMP start timern");
- }
- #else
- #ifdef OS_VXWORKS
- sys_task_start(t->timerID);
- #else
- t_start(t->timerID, T_SUPV | T_PREEMPT | T_NOTSLICE, t->func, args);
- #endif
- #endif
- }
- /* Stop a SNMP timer */
- void
- stop_SNMPtimer(timer)
- struct SNMPtimer *timer;
- {
- if(timer == NULLTIMER||timer->timerID==0)
- return;
- #if 0
- if (sys_stop_timer(timer->timerID) != NOERR){
- vty_console_output("error: SNMP stop timern");
- }
- #else
- ASSERT(0);
- #endif
- }
- /* Remove a SNMP timer 99.12.10 */
- void
- remove_SNMPtimer(timer)
- struct SNMPtimer *timer;
- {
- if(timer == NULLTIMER||timer->timerID==0)
- return;
- if (sys_delete_timer((ULONG)timer->timerID) != NOERR){
- vty_console_output("error: SNMP delete timern");
- }
- }