entityPhysical

xiaoxiao2021-02-28  48

/*  * Note: this file originally auto-generated by mib2c using  *        $  */ #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #include "entityPhysical_access.h" #include "entityPhysical_enums.h" T_TableIndex1  *gp_entPhysicalTableHead =NULL; MIBIDSTRUCT  *findTableNode(T_TableSimple *theRowHead,                           const unsigned int magic, int maxCol); static T_SNMPMapTable gt_entPhysicalTableIDMap[] = { {0, COLUMN_ENTPHYSICALDESCR}, {1, COLUMN_ENTPHYSICALVENDORTYPE},  {2, COLUMN_ENTPHYSICALCONTAINEDIN}, {3, COLUMN_ENTPHYSICALCLASS}, {4, COLUMN_ENTPHYSICALPARENTRELPOS}, {5, COLUMN_ENTPHYSICALNAME}, {6, COLUMN_ENTPHYSICALHARDWAREREV}, {7, COLUMN_ENTPHYSICALFIRMWAREREV}, {8, COLUMN_ENTPHYSICALSOFTWAREREV}, {9, COLUMN_ENTPHYSICALSERIALNUM}, {10, COLUMN_ENTPHYSICALMFGNAME}, {11, COLUMN_ENTPHYSICALMODELNAME},     {12, COLUMN_ENTPHYSICALALIAS}, {13, COLUMN_ENTPHYSICALASSETID},     {14, COLUMN_ENTPHYSICALISFRU}, {15, COLUMN_ENTPHYSICALMFGDATE},     {16, COLUMN_ENTPHYSICALURIS}   }; #define COLUMN_ENTPHYSICALTABLE_MAX (  sizeof(gt_entPhysicalTableIDMap) / sizeof(T_SNMPMapTable)  ) /** returns the first data point within the entPhysicalTable table data.     Set the my_loop_context variable to the first data point structure     of your choice (from which you can find the next one).  This could     be anything from the first node in a linked list, to an integer     pointer containing the beginning of an array variable.     Set the my_data_context variable to something to be returned to     you later that will provide you with the data to return in a given     row.  This could be the same pointer as what my_loop_context is     set to, or something different.     The put_index_data variable contains a list of snmp variable     bindings, one for each index in your table.  Set the values of     each appropriately according to the data matching the first row     and return the put_index_data variable at the end of the function. */ netsnmp_variable_list * entPhysicalTable_get_first_data_point(void **my_loop_context,                                       void **my_data_context,                                       netsnmp_variable_list *                                       put_index_data,                                       netsnmp_iterator_info *mydata) {     netsnmp_variable_list *vptr;     *my_loop_context = gp_entPhysicalTableHead ;    *my_data_context = gp_entPhysicalTableHead ;     vptr = put_index_data;     snmp_set_var_value(vptr, (u_char *)&(gp_entPhysicalTableHead->index) ,                        sizeof(gp_entPhysicalTableHead->index) );     vptr = vptr->next_variable;     return put_index_data; } /** functionally the same as entPhysicalTable_get_first_data_point, but    my_loop_context has already been set to a previous value and should    be updated to the next in the list.  For example, if it was a    linked list, you might want to cast it to your local data type and    then return my_loop_context->next.  The my_data_context pointer    should be set to something you need later and the indexes in    put_index_data updated again. */ netsnmp_variable_list * entPhysicalTable_get_next_data_point(void **my_loop_context,                                      void **my_data_context,                                      netsnmp_variable_list *                                      put_index_data,                                      netsnmp_iterator_info *mydata) {     //netsnmp_variable_list *vptr;    // 获取迭代器中的用户数据 T_TableIndex1  *temp =  (T_TableIndex1 *)*my_loop_context;     T_TableIndex1  *nowData=NULL; if(temp->next == NULL)     { *my_loop_context = NULL; *my_data_context = NULL ;         DEBUGMSG(("entityPhysical","--IN realData_single_get_next_data_point:RawHead = NULL\n")); return NULL;        } // 迭代器:控制如何获取下一个数据     nowData =  temp->next;     *my_loop_context = nowData;     *my_data_context = nowData;    // vptr = put_index_data; if( NULL != nowData )     {         DEBUGMSGTL(("entityPhysical","--index =%d\n",nowData->index));     snmp_set_var_value(put_index_data, (u_char *)&(nowData->index) ,sizeof(nowData->index) ); }     //vptr = vptr->next_variable;     return put_index_data; } /** Create a data_context for non-existent rows that SETs are performed on.  *  return a void * pointer which will be passed to subsequent get_XXX  *  and set_XXX functions for data retrieval and modification during  *  this SET request.  *  *  The indexes are encoded (in order) into the index_data pointer,  *  and the column object which triggered the row creation is available  *  via the column parameter, if it would be helpful to use that information.  */ void           * entPhysicalTable_create_data_context(netsnmp_variable_list * index_data,                                      int column) {     return NULL;                /* XXX: you likely want to return a real pointer */ } /** If the implemented set_* functions don't operate directly on the    real-live data (which is actually recommended), then this function    can be used to take a given my_data_context pointer and "commit" it    to whereever the modified data needs to be put back to.  For    example, if this was a routing table you could publish the modified    routes back into the kernel at this point.    new_or_del will be set to 1 if new, or -1 if it should be deleted    or 0 if it is just a modification of an existing row.    If you free the data yourself, make sure to *my_data_context = NULL */ int entPhysicalTable_commit_row(void **my_data_context, int new_or_del) {     /** Add any necessary commit code here */     /*      */     /*      * return no errors.  And there shouldn't be any!!!  Ever!!!  You      * should have checked the values long before this.       */     return SNMP_ERR_NOERROR; } /*  * User-defined data access functions (per column) for data in table entPhysicalTable   */ /*  * NOTE:  * - these get_ routines MUST return data that will not be freed (ie,  *   use static variables or persistent data).  It will be copied, if  *   needed, immediately after the get_ routine has been called.  * - these SET routines must copy the incoming data and can not take  *   ownership of the memory passed in by the val pointer.  */ // ********************   1. entPhysicalIndex  ************************ long    * get_entPhysicalIndex(void *data_context, size_t *ret_len) { // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; if(NULL == myData) return NULL;   *ret_len = sizeof(myData->index); return (long *)&(myData->index); } // ********************   2. entPhysicalDescr ********************** /** XXX: return a data pointer to the data for the entPhysicalDescr column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalDescr(void *data_context, size_t *ret_len) {                static char descr[]="lucc";               /**   static char descr[255]; int no = 0; MIBIDSTRUCT  *findedNode = NULL; // 获取迭代器中的用户数据 T_TableIndex1  *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALDESCR,    COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)   return NULL; no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no)); snmp_get_data(SHM_REALDATA,no,255,descr);               **/ *ret_len = strlen(descr); return (char *) &descr;     //return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   3. entPhysicalVendorType  *********************** /** XXX: return a data pointer to the data for the entPhysicalVendorType column and set          ret_len to its proper size in bytes. */ oid            * get_entPhysicalVendorType(void *data_context, size_t *ret_len) { static oid vendortype[3]={1,2,3};         /**         static oid vendortype[3]; int no = 0; MIBIDSTRUCT  *findedNode = NULL; // 获取迭代器中的用户数据 T_TableIndex1  *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALVENDORTYPE,    COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)   return NULL; no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));         snmp_get_data(SHM_REALDATA,no,255,vendortype);          **/           *ret_len = sizeof(vendortype); return (oid *) &vendortype;    // return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   4. entPhysicalContainedIn  *********************** /** XXX: return a data pointer to the data for the entPhysicalContainedIn column and set          ret_len to its proper size in bytes. */ long           * get_entPhysicalContainedIn(void *data_context, size_t *ret_len) {     static long containedin; int no = 0; MIBIDSTRUCT  *findedNode = NULL;   // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALCONTAINEDIN, COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)        return NULL;   no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));   snmp_get_data(SHM_REALDATA,no,sizeof(long),&containedin);  *ret_len = sizeof(containedin); return  &containedin;    //return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   5. entPhysicalClass  *********************** /** XXX: return a data pointer to the data for the entPhysicalClass column and set          ret_len to its proper size in bytes. */ long           * get_entPhysicalClass(void *data_context, size_t *ret_len) {      static long class; int no = 0; MIBIDSTRUCT  *findedNode = NULL;   // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALCLASS, COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)        return NULL;   no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));   snmp_get_data(SHM_REALDATA,no,sizeof(long),&class);  *ret_len = sizeof(class); return  &class;     //return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   6. entPhysicalParentRelPos  *********************** /** XXX: return a data pointer to the data for the entPhysicalParentRelPos column and set          ret_len to its proper size in bytes. */ long           * get_entPhysicalParentRelPos(void *data_context, size_t *ret_len) {      static long parentrelpos; int no = 0; MIBIDSTRUCT  *findedNode = NULL;   // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALPARENTRELPOS, COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)        return NULL;   no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));   snmp_get_data(SHM_REALDATA,no,sizeof(long),&parentrelpos);  *ret_len = sizeof(parentrelpos); return  &parentrelpos;      // return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   7. entPhysicalName  *********************** /** XXX: return a data pointer to the data for the entPhysicalName column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalName(void *data_context, size_t *ret_len) { static char name[]="ODN";         /*         static char name[255]; int no = 0; MIBIDSTRUCT  *findedNode = NULL; // 获取迭代器中的用户数据 T_TableIndex1  *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALNAME,   COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)   return NULL; no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no)); snmp_get_data(SHM_REALDATA,no,255,name);          */ *ret_len = strlen(name); return (char *) &name;     //return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   8. entPhysicalHardwareRev  *********************** /** XXX: return a data pointer to the data for the entPhysicalHardwareRev column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalHardwareRev(void *data_context, size_t *ret_len) {          static char hardwarerev[]="1.01.01";          /*          static char hardwarerev[255]; int no = 0; MIBIDSTRUCT  *findedNode = NULL;   // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALHARDWAREREV, COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)        return NULL;   no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));   snmp_get_data(SHM_REALDATA,no,255,hardwarerev);          */  *ret_len = strlen(hardwarerev); return  (char *) &hardwarerev;       //return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalFirmwareRev column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalFirmwareRev(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } // ********************   9. entPhysicalSoftwareRev  *********************** /** XXX: return a data pointer to the data for the entPhysicalSoftwareRev column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalSoftwareRev(void *data_context, size_t *ret_len) {                    static char softwarerev[]="2.02.02";          /*     static char softwarerev[255]; int no = 0; MIBIDSTRUCT  *findedNode = NULL;   // 获取迭代器中的用户数据 T_TableIndex1 *myData =  (T_TableIndex1 *)data_context; findedNode = findTableNode(myData->list_node,COLUMN_ENTPHYSICALSOFTWAREREV, COLUMN_ENTPHYSICALTABLE_MAX); if(findedNode == NULL)        return NULL;   no = findedNode->t_tacheID.ipcNo; DEBUGMSG(("entityPhysical","--get_realTimeDataX1 = %d\n",no));   snmp_get_data(SHM_REALDATA,no,255,softwarerev);           */              *ret_len = strlen(softwarerev); return (char *) &softwarerev ;    //return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalSerialNum column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalSerialNum(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: Set the value of the entPhysicalSerialNum column and return          SNMP_ERR_NOERROR on success          SNMP_ERR_XXX     for SNMP deterministic error codes          SNMP_ERR_GENERR  on generic failures (a last result response). */ int set_entPhysicalSerialNum(void *data_context, char *val, size_t val_len) {     return SNMP_ERR_NOERROR;      /** XXX: change if an error occurs */ } /** XXX: return a data pointer to the data for the entPhysicalMfgName column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalMfgName(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalModelName column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalModelName(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalAlias column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalAlias(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: Set the value of the entPhysicalAlias column and return          SNMP_ERR_NOERROR on success          SNMP_ERR_XXX     for SNMP deterministic error codes          SNMP_ERR_GENERR  on generic failures (a last result response). */ int set_entPhysicalAlias(void *data_context, char *val, size_t val_len) {     return SNMP_ERR_NOERROR;      /** XXX: change if an error occurs */ } /** XXX: return a data pointer to the data for the entPhysicalAssetID column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalAssetID(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: Set the value of the entPhysicalAssetID column and return          SNMP_ERR_NOERROR on success          SNMP_ERR_XXX     for SNMP deterministic error codes          SNMP_ERR_GENERR  on generic failures (a last result response). */ int set_entPhysicalAssetID(void *data_context, char *val, size_t val_len) {     return SNMP_ERR_NOERROR;      /** XXX: change if an error occurs */ } /** XXX: return a data pointer to the data for the entPhysicalIsFRU column and set          ret_len to its proper size in bytes. */ long           * get_entPhysicalIsFRU(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalMfgDate column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalMfgDate(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: return a data pointer to the data for the entPhysicalUris column and set          ret_len to its proper size in bytes. */ char           * get_entPhysicalUris(void *data_context, size_t *ret_len) {     return NULL;   /** XXX: replace this with a pointer to a real value */ } /** XXX: Set the value of the entPhysicalUris column and return          SNMP_ERR_NOERROR on success          SNMP_ERR_XXX     for SNMP deterministic error codes          SNMP_ERR_GENERR  on generic failures (a last result response). */ int set_entPhysicalUris(void *data_context, char *val, size_t val_len) {     return SNMP_ERR_NOERROR;      /** XXX: change if an error occurs */ } void init_table_entity_physical(void) {        // 初始化两行两列的实时数据    init_singleIndexTable( &gp_entPhysicalTableHead,              gt_entPhysicalTableIDMap,COLUMN_ENTPHYSICALTABLE_MAX,           GROUP_NUM,0 ); }   
转载请注明原文地址: https://www.6miu.com/read-2631936.html

最新回复(0)