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

📄 baby_steps.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 2 页
字号:
        }#ifdef BABY_STEPS_NEXT_MODE        /*         * I can't remember why I wanted the next mode in the request,         * but it's not used anywhere, so don't use this code. saved,         * in case I remember why I thought needed it. - rstory 040911         */        if((BABY_STEPS_PER_MODE_MAX - 1) == i)            reqinfo->next_mode_ok = BABY_STEP_NONE;        else {            if(BSTEP_USE_ORIGINAL == mode_map_ptr[i+1])                reqinfo->next_mode_ok = save_mode;            else                reqinfo->next_mode_ok = mode_map_ptr[i+1];        }#endif        /*         * call handlers for baby step         */        rc = netsnmp_call_next_handler(handler, reginfo, reqinfo,                                       requests);        /*         * check for error calling handler (unlikely, but...)         */        if(rc) {            DEBUGMSGTL(("baby_steps", "   ERROR:handler error\n"));            break;        }        /*         * check for errors in any of the requests for GET-like, reserve1,         * reserve2 and action. (there is no recovery from errors         * in commit, free or undo.)         */        if (MODE_IS_GET(save_mode)            || (save_mode < SNMP_MSG_INTERNAL_SET_COMMIT)) {            rc = netsnmp_check_requests_error(requests);            if(rc) {                DEBUGMSGTL(("baby_steps", "   ERROR:request error\n"));                break;            }        }    }    /*     * restore original mode     */    reqinfo->mode = save_mode;        return rc;}/** initializes the baby_steps helper which then registers a baby_steps *  handler as a run-time injectable handler for configuration file *  use. */voidnetsnmp_baby_steps_handler_init(void){    netsnmp_register_handler_by_name("baby_steps",                                     netsnmp_baby_steps_handler_get(BABY_STEP_ALL));}/** @} *//** @defgroup baby_steps baby_steps_access_multiplexer: calls individual access methods based on baby_step mode. *  @ingroup handler *  @{ *//** returns a baby_steps handler that can be injected into a given *  handler chain. */netsnmp_mib_handler *netsnmp_baby_steps_access_multiplexer_get(netsnmp_baby_steps_access_methods *am){    netsnmp_mib_handler *mh;    mh = netsnmp_create_handler("baby_steps_mux",                                _baby_steps_access_multiplexer);    if(!mh)        return NULL;    mh->myvoid = am;    mh->flags |= MIB_HANDLER_AUTO_NEXT;        return mh;}/** @internal Implements the baby_steps handler */static int_baby_steps_access_multiplexer(netsnmp_mib_handler *handler,                               netsnmp_handler_registration *reginfo,                               netsnmp_agent_request_info *reqinfo,                               netsnmp_request_info *requests){    void *temp_void;    Netsnmp_Node_Handler *method = NULL;    netsnmp_baby_steps_access_methods *access_methods;    int rc = SNMP_ERR_NOERROR;    /** call handlers should enforce these */    netsnmp_assert((handler!=NULL) && (reginfo!=NULL) && (reqinfo!=NULL) &&                   (requests!=NULL));    DEBUGMSGT(("baby_steps_mux", "mode %s\n",               se_find_label_in_slist("babystep_mode",reqinfo->mode)));    access_methods = (netsnmp_baby_steps_access_methods *)handler->myvoid;    if(!access_methods) {        snmp_log(LOG_ERR,"baby_steps_access_multiplexer has no methods\n");        return SNMPERR_GENERR;    }    switch(reqinfo->mode) {            case MODE_BSTEP_PRE_REQUEST:        if( access_methods->pre_request )            method = access_methods->pre_request;        break;            case MODE_BSTEP_OBJECT_LOOKUP:        if( access_methods->object_lookup )            method = access_methods->object_lookup;        break;    case SNMP_MSG_GET:    case SNMP_MSG_GETNEXT:        if( access_methods->get_values )            method = access_methods->get_values;        break;            case MODE_BSTEP_CHECK_VALUE:        if( access_methods->object_syntax_checks )            method = access_methods->object_syntax_checks;        break;    case MODE_BSTEP_ROW_CREATE:        if( access_methods->row_creation )            method = access_methods->row_creation;        break;    case MODE_BSTEP_UNDO_SETUP:        if( access_methods->undo_setup )            method = access_methods->undo_setup;        break;    case MODE_BSTEP_SET_VALUE:        if( access_methods->set_values )            method = access_methods->set_values;        break;    case MODE_BSTEP_CHECK_CONSISTENCY:        if( access_methods->consistency_checks )            method = access_methods->consistency_checks;        break;    case MODE_BSTEP_UNDO_SET:        if( access_methods->undo_sets )            method = access_methods->undo_sets;        break;    case MODE_BSTEP_COMMIT:        if( access_methods->commit )            method = access_methods->commit;        break;    case MODE_BSTEP_UNDO_COMMIT:        if( access_methods->undo_commit )            method = access_methods->undo_commit;        break;    case MODE_BSTEP_IRREVERSIBLE_COMMIT:        if( access_methods->irreversible_commit )            method = access_methods->irreversible_commit;        break;    case MODE_BSTEP_UNDO_CLEANUP:        if( access_methods->undo_cleanup )            method = access_methods->undo_cleanup;        break;            case MODE_BSTEP_POST_REQUEST:        if( access_methods->post_request )            method = access_methods->post_request;        break;    default:        snmp_log(LOG_ERR,"unknown mode %d\n", reqinfo->mode);        return SNMP_ERR_GENERR;    }    /*     * if method exists, set up handler void and call method.     */    if(NULL != method) {        temp_void = handler->myvoid;        handler->myvoid = access_methods->my_access_void;        rc = (*method)(handler, reginfo, reqinfo, requests);        handler->myvoid = temp_void;    }    else {        rc = SNMP_ERR_GENERR;        snmp_log(LOG_ERR,"baby steps multiplexer handler called for a mode "                 "with no handler\n");        netsnmp_assert(NULL != method);    }    /*     * don't call any lower handlers, it will be done for us      * since we set MIB_HANDLER_AUTO_NEXT     */    return rc;}/* * give a baby step mode, return the flag for that mode */intnetsnmp_baby_step_mode2flag( u_int mode ){    switch( mode ) {        case MODE_BSTEP_OBJECT_LOOKUP:            return BABY_STEP_OBJECT_LOOKUP;        case MODE_BSTEP_SET_VALUE:            return BABY_STEP_SET_VALUE;        case MODE_BSTEP_IRREVERSIBLE_COMMIT:            return BABY_STEP_IRREVERSIBLE_COMMIT;        case MODE_BSTEP_CHECK_VALUE:            return BABY_STEP_CHECK_VALUE;        case MODE_BSTEP_PRE_REQUEST:            return BABY_STEP_PRE_REQUEST;        case MODE_BSTEP_POST_REQUEST:            return BABY_STEP_POST_REQUEST;        case MODE_BSTEP_UNDO_SETUP:            return BABY_STEP_UNDO_SETUP;        case MODE_BSTEP_UNDO_CLEANUP:            return BABY_STEP_UNDO_CLEANUP;        case MODE_BSTEP_UNDO_SET:            return BABY_STEP_UNDO_SET;        case MODE_BSTEP_ROW_CREATE:            return BABY_STEP_ROW_CREATE;        case MODE_BSTEP_CHECK_CONSISTENCY:            return BABY_STEP_CHECK_CONSISTENCY;        case MODE_BSTEP_COMMIT:            return BABY_STEP_COMMIT;        case MODE_BSTEP_UNDO_COMMIT:            return BABY_STEP_UNDO_COMMIT;        default:            netsnmp_assert("unknown flag");            break;    }    return 0;}

⌨️ 快捷键说明

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