⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmptask.c

📁 这里包含了风河vxworks系统中的官方例程的C源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** ****************************************************************************** **** snmpTask.c Last build date: Fri Sep 12 11:58:57 1997 **** from files: ****  ../mibs/rfc1155.smi, ../mibs/rfc1213.mib, snmpMib2.mib, snmpMy.mib **** starting from node: wrs ****************************************************************************** ****************************************************************************** */#include <asn1conf.h>#include <asn1.h>#include <buffer.h>#include <mib.h>#include <snmpdLib.h>#include <snmpdefs.h>#include <snmp.h>#include <auxfuncs.h>#include <symLib.h>#include <sysSymTbl.h>#include <a_out.h>#include "snmpTask.h"#include <private/taskLibP.h>#include "mibleaf.h"/* * Method routines for the taskTable: * *   taskId -- read-only *  This is the task ID assigned by VxWorks to a task in the * system. A taskId of zero specifies a new task. * *   taskName -- read-write *  This is the name of the VxWorks task.  This value can * only be specified (set) at task creation. * *   taskPriority -- read-write * The priority of the VxWorks task.  This value can be * in the range from 0, the highest priority, * to 255, the lowest priority. * *   taskStatus -- read-write * This field specifies the current task status.  It * can be used to change the current task state. * For example, to suspend a task, the value of * taskStatus is changed to task-suspended, * to delete a task the value is changed to * task-deleted, etc... * *   taskOptions -- read-write * This value represents the sum of the following * options: *  * value      option *  1        VX_SUPERVISOR_MODE(read-only) *  2        VX_UNBREAKABLE    (break points ignored) *  4        VX_DEALLOC_STACK  (deallocate stack) *  8        VX_FP_TASK        (floating point support) * 16        VX_STDIO          (read-only) * 128        VX_PRIVATE_ENV    (private env. variables) * 256        VX_NO_STACK_FILL  (don't fill stack) *  * All the options above can be set at task creation time. * However, once the task is executing the only option * that can be changed is VX_UNBREAKABLE.  The option is * toggled based on the current setting. * *   taskMain -- read-write * This is the name of the entry function for the VxWorks * task.  This name can only be specified when a task * is created (entry added in the table).  The symbol * must exist in the VxWorks target. * *   taskStackPtr -- read-only * This is the saved stack pointer for the task. * *   taskStackBase -- read-only * This is the address of the bottom of the stack of * the VxWorks task. * *   taskStackPos -- read-only * This is the effective top of the stack in the current * task state. * *   taskStackEnd -- read-only * This is the address of the top of the stack of the * VxWorks task. * *   taskStackSize -- read-write * This is the actual size of the stack in bytes.  The * size of the stack can only be specified at task * creation (adding an entry to the table). * *   taskStackSizeUsage -- read-only * The number of bytes currently in use by the task from  * the stack. * *   taskStackMaxUsed -- read-only * This is the maximum number of bytes that have been used * by the task from the stack. * *   taskStackFree -- read-only * This is the number of bytes that are free currently in  * the task stack. * *   taskErrorStatus -- read-only * This is the most recent error status for this task. *//* Locals */LOCAL TASK_DESC sysTaskVars;	/* Used as an argument in taskInfoGet */LOCAL int taskIdList[MAXTASKS];LOCAL int numTasks;LOCAL STRUCT_taskEntry data;	/* Used in taskInfoFill */LOCAL int varSet = 0;		/* Used in the undo process *//* Forward Declarations */int taskEntCmp (const void *, const void *);void taskInfoFill (TASK_DESC *);void taskEntryUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T *);int taskSet (STRUCT_taskEntry *);int optionsSet (STRUCT_taskEntry *);/* An internal routine to retrieve the values of the variables, used * by the method routines taskEntry_get and taskEntry_next. */static int taskEntry_get_value  (  OIDC_T      lastmatch,  SNMP_PKT_T *pktp,  VB_T       *vbp,  STRUCT_taskEntry *pData  )     {  switch(lastmatch) {  case LEAF_taskId:    getproc_got_int32(pktp, vbp, pData->taskId);        break;  case LEAF_taskName:    getproc_got_string(pktp, vbp, strlen(pData->taskName), pData->taskName, 0, VT_STRING);    break;  case LEAF_taskPriority:    getproc_got_int32(pktp, vbp, pData->taskPriority);    break;  case LEAF_taskStatus:    /* Values:     *  task-ready(1)     = VAL_taskStatus_task_ready     *  task-suspended(2) = VAL_taskStatus_task_suspended     *  task-delay(3)     = VAL_taskStatus_task_delay     *  task-deleted(4)   = VAL_taskStatus_task_deleted     */    getproc_got_int32(pktp, vbp, pData->taskStatus);    break;  case LEAF_taskOptions:    getproc_got_int32(pktp, vbp, pData->taskOptions);    break;  case LEAF_taskMain:    getproc_got_string(pktp, vbp, strlen(pData->taskMain), pData->taskMain, 0, VT_STRING);    break;  case LEAF_taskStackPtr:    getproc_got_uint32(pktp, vbp, pData->taskStackPtr, VT_GAUGE);    break;  case LEAF_taskStackBase:    getproc_got_uint32(pktp, vbp, pData->taskStackBase, VT_GAUGE);    break;  case LEAF_taskStackPos:    getproc_got_uint32(pktp, vbp, pData->taskStackPos, VT_GAUGE);    break;  case LEAF_taskStackEnd:    getproc_got_uint32(pktp, vbp, pData->taskStackEnd, VT_GAUGE);    break;  case LEAF_taskStackSize:    getproc_got_uint32(pktp, vbp, pData->taskStackSize, VT_GAUGE);    break;  case LEAF_taskStackSizeUsage:    getproc_got_uint32(pktp, vbp, pData->taskStackSizeUsage, VT_GAUGE);    break;  case LEAF_taskStackMaxUsed:    getproc_got_uint32(pktp, vbp, pData->taskStackMaxUsed, VT_GAUGE);    break;  case LEAF_taskStackFree:    getproc_got_uint32(pktp, vbp, pData->taskStackFree, VT_GAUGE);    break;  case LEAF_taskErrorStatus:    getproc_got_int32(pktp, vbp, pData->taskErrorStatus);    break;  default:    return GEN_ERR;  }  return NO_ERROR;}/******************************************************************** ** This function copies the entries from the TASC_DESC structure ** into the STRUCT_taskEntry structure. ** */void taskInfoFill   (  TASK_DESC *pSysTemp  ) {  int 	     value = 0;  SYM_TYPE   stype;  data.taskId = pSysTemp->td_id;  strcpy (data.taskName, pSysTemp->td_name);  data.taskPriority = pSysTemp->td_priority;  switch (pSysTemp->td_status) {  case WIND_READY:                data.taskStatus = VAL_taskStatus_task_ready;                break;  case WIND_SUSPEND:                data.taskStatus = VAL_taskStatus_task_suspended;                break;  case WIND_PEND:  case WIND_DELAY:                data.taskStatus = VAL_taskStatus_task_delay;                break;   case WIND_DEAD:                data.taskStatus = VAL_taskStatus_task_deleted;                break;  }  data.taskOptions = pSysTemp->td_options;  if ((_func_symFindByValueAndType != (FUNCPTR) NULL) && (sysSymTbl != NULL))	        (* _func_symFindByValueAndType) (sysSymTbl, pSysTemp->td_entry, data.taskMain, &value, &stype, N_EXT | N_TEXT, N_EXT | N_TEXT);  data.taskStackPtr = (UINT_32_T) pSysTemp->td_sp;  data.taskStackBase = (UINT_32_T) pSysTemp->td_pStackBase;  data.taskStackPos = (UINT_32_T) pSysTemp->td_pStackLimit;  data.taskStackEnd = (UINT_32_T) pSysTemp->td_pStackEnd;  data.taskStackSize = pSysTemp->td_stackSize;  data.taskStackSizeUsage = pSysTemp->td_stackCurrent;  data.taskStackMaxUsed = pSysTemp->td_stackHigh;  data.taskStackFree = pSysTemp->td_stackMargin;  data.taskErrorStatus = pSysTemp->td_errorStatus;}/******************************************************************* ** This is the get method routine for the task table entries ** */void taskEntry_get  (  OIDC_T      lastmatch,  int         compc,  OIDC_T     *compl,  SNMP_PKT_T *pktp,  VB_T       *vbp  ){  int error;  SYM_TYPE stype;  /* find all the varbinds that share the same getproc and instance */  snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);  if (compc != TASK_TBL_INDEX_LEN) {     for (; vbp;vbp = vbp->vb_link)	getproc_nosuchins (pktp, vbp);    return;  }    if (taskInfoGet (*compl, &sysTaskVars) != OK) {	for ( ; vbp; vbp = vbp->vb_link)		getproc_error(pktp, vbp, GEN_ERR);	return;  }  /* Assign sysTaskVars values to data */  taskInfoFill (&sysTaskVars);    /* retrieve all the values from the same data structure */  for ( ; vbp; vbp = vbp->vb_link) 	if ((error = taskEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, &data)) != NO_ERROR)		getproc_error(pktp, vbp, GEN_ERR);}/********************************************************************* ** This is the next method routine for the task table entries. ** */void taskEntry_next  (  OIDC_T      lastmatch,  int         compc,  OIDC_T     *compl,  SNMP_PKT_T *pktp,  VB_T       *vbp){  int		i = 0;  OIDC_T	taskIndex[TASK_TBL_INDEX_LEN];  /* find all the varbinds that share the same getproc and instance */  snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);  /* Get the tasklist and sort it */  numTasks = taskIdListGet (taskIdList, MAXTASKS);  qsort (taskIdList, numTasks, sizeof (UINT_32_T), taskEntCmp);  if (compc != 0) {  /* See if the task id given exists */  	for (i=0; i<numTasks; i++) {		if (taskIdList[i] > (*compl) && taskInfoGet (taskIdList[i], &sysTaskVars) == OK) {			taskInfoFill (&sysTaskVars);			break;		}	}  	if (i >= numTasks) {		for (; vbp; vbp=vbp->vb_link)			nextproc_no_next(pktp, vbp);		return;	}  }   /* We have to fetch the first entry */  else {	taskInfoGet (taskIdList[0], &sysTaskVars);	taskInfoFill (&sysTaskVars);  }  memset (taskIndex, 0, TASK_TBL_INDEX_LEN * sizeof (OIDC_T));  memcpy (taskIndex, &taskIdList[i], TASK_TBL_INDEX_LEN * sizeof (OIDC_T));    /* we found a next so get the values and set the instance for all     * the varbinds for this row of this table.     */  for ( ; vbp ; vbp = vbp->vb_link) {	nextproc_next_instance(pktp, vbp, TASK_TBL_INDEX_LEN, taskIndex);	taskEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, &data);  }}/**************************************************************** ** This is the compare routine used when a qsort is  ** performed in the next method routine. ** */int taskEntCmp  (  const void * pValue1,  const void * pValue2  ){    return (*((int *)pValue1) - *((int *)pValue2));}/**************************************************************** ** This is the test routine that validates all the entries in

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -