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

📄 mteeventconf.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 2 页
字号:
        config_perror("unknown set OID");        return;    }    if (cp && *cp == '=') {        cp = skip_token( cp );   /* skip the '=' assignment character */    }    value = strtol( cp, NULL, 0);    /*     *  If the entry has parsed successfully, then create,     *     populate and activate the new event entry.     */    entry = _find_typed_mteEvent_entry(owner, ename, MTE_EVENT_SET);    if (!entry) {        return;    }    memcpy( entry->mteSetOID, name_buf, name_buf_len*sizeof(oid));    entry->mteSetOID_len = name_buf_len;    entry->mteSetValue   = value;    if (wild)        entry->flags       |= MTE_SET_FLAG_OBJWILD;    entry->mteEventActions |= MTE_EVENT_SET;    entry->flags           |= MTE_EVENT_FLAG_ENABLED |                              MTE_EVENT_FLAG_ACTIVE  |                              MTE_EVENT_FLAG_FIXED   |                              MTE_EVENT_FLAG_VALID;    return;}/* ============================== * *  Persistent (dynamic) configuration * * ============================== */voidparse_mteETable(const char *token, char *line ){    char   owner[MTE_STR1_LEN+1];    char   ename[MTE_STR1_LEN+1];    void  *vp;    size_t tmp;    size_t len;    struct mteEvent  *entry;    DEBUGMSGTL(("disman:event:conf", "Parsing mteEventTable config...  "));    /*     * Read in the index information for this entry     *  and create a (non-fixed) data structure for it.     */    memset( owner, 0, sizeof(owner));    memset( ename, 0, sizeof(ename));    len   = MTE_STR1_LEN; vp = owner;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    len   = MTE_STR1_LEN; vp = ename;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    entry = _find_mteEvent_entry( owner, ename );    DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));        /*     * Read in the accessible (event-independent) column values.     */    len   = MTE_STR2_LEN; vp = entry->mteEventComment;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    /*     * Skip the mteEventAction field, and note that the     *   boolean values are combined into a single field.     */    line  = read_config_read_data(ASN_UNSIGNED,  line, &tmp, NULL);    entry->flags |= (tmp &        (MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE));    /*     * XXX - Will need to read in the 'iquery' access information     */    entry->flags |= MTE_EVENT_FLAG_VALID;    DEBUGMSG(("disman:event:conf", "\n"));}voidparse_mteENotTable(const char *token, char *line){    char   owner[MTE_STR1_LEN+1];    char   ename[MTE_STR1_LEN+1];    void  *vp;    size_t len;    struct mteEvent  *entry;    DEBUGMSGTL(("disman:event:conf", "Parsing mteENotifyTable config...  "));    /*     * Read in the index information for this entry     *  and create a (non-fixed) data structure for it.     */    memset( owner, 0, sizeof(owner));    memset( ename, 0, sizeof(ename));    len   = MTE_STR1_LEN; vp = owner;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    len   = MTE_STR1_LEN; vp = ename;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    entry = _find_mteEvent_entry( owner, ename );    DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));    /*     * Read in the accessible column values.     */    vp = entry->mteNotification;    line  = read_config_read_data(ASN_OBJECT_ID, line, &vp,                                 &entry->mteNotification_len);    len   = MTE_STR1_LEN; vp = entry->mteNotifyOwner;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    len   = MTE_STR1_LEN; vp = entry->mteNotifyObjects;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    entry->mteEventActions |= MTE_EVENT_NOTIFICATION;    entry->flags           |= MTE_EVENT_FLAG_VALID;    DEBUGMSG(("disman:event:conf", "\n"));}voidparse_mteESetTable(const char *token, char *line){    char   owner[MTE_STR1_LEN+1];    char   ename[MTE_STR1_LEN+1];    void  *vp;    size_t len;    struct mteEvent  *entry;    DEBUGMSGTL(("disman:event:conf", "Parsing mteESetTable config...  "));    /*     * Read in the index information for this entry     *  and create a (non-fixed) data structure for it.     */    memset( owner, 0, sizeof(owner));    memset( ename, 0, sizeof(ename));    len   = MTE_STR1_LEN; vp = owner;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    len   = MTE_STR1_LEN; vp = ename;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    entry = _find_mteEvent_entry( owner, ename );    DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));    /*     * Read in the accessible column values.     */    vp = entry->mteSetOID;    line  = read_config_read_data(ASN_OBJECT_ID, line, &vp,                                 &entry->mteSetOID_len);    line  = read_config_read_data(ASN_UNSIGNED,  line,                                 &entry->mteSetValue, &len);    len   = MTE_STR2_LEN; vp = entry->mteSetTarget;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    len   = MTE_STR2_LEN; vp = entry->mteSetContext;    line  = read_config_read_data(ASN_OCTET_STR, line, &vp,  &len);    entry->mteEventActions |= MTE_EVENT_SET;    entry->flags           |= MTE_EVENT_FLAG_VALID;    DEBUGMSG(("disman:event:conf", "\n"));}intstore_mteETable(int majorID, int minorID, void *serverarg, void *clientarg){    char            line[SNMP_MAXBUF];    char           *cptr;    void           *vp;    size_t          tint;    netsnmp_tdata_row *row;    struct mteEvent  *entry;    DEBUGMSGTL(("disman:event:conf", "Storing mteEventTable config:\n"));    for (row = netsnmp_tdata_row_first( event_table_data );         row;         row = netsnmp_tdata_row_next( event_table_data, row )) {        /*         * Skip entries that were set up via static config directives         */        entry = (struct mteEvent *)netsnmp_tdata_row_entry( row );        if ( entry->flags & MTE_EVENT_FLAG_FIXED )            continue;        DEBUGMSGTL(("disman:event:conf", "  Storing (%s %s)\n",                         entry->mteOwner, entry->mteEName));        /*         * Save the basic mteEventTable entry...         */        memset(line, 0, sizeof(line));        strcat(line, "_mteETable ");        cptr = line + strlen(line);        vp   = entry->mteOwner;        tint = strlen( vp );        cptr = read_config_store_data( ASN_OCTET_STR, cptr, &vp,  &tint );        vp   = entry->mteEName;        tint = strlen( vp );        cptr = read_config_store_data( ASN_OCTET_STR, cptr, &vp,  &tint );        vp   = entry->mteEventComment; tint = strlen( vp );        cptr = read_config_store_data( ASN_OCTET_STR, cptr, &vp,  &tint );        /* ... (but skip the mteEventAction field)... */        tint = entry->flags & (MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE);         cptr = read_config_store_data( ASN_UNSIGNED,  cptr, &tint, NULL );        /* XXX - Need to store the 'iquery' access information */        snmpd_store_config(line);        /*         * ... then save Notify and/or Set entries separately         *   (The mteEventAction bits will be set when these are read in).         */        if ( entry->mteEventActions & MTE_EVENT_NOTIFICATION ) {            memset(line, 0, sizeof(line));            strcat(line, "_mteENotTable ");            cptr = line + strlen(line);                vp = entry->mteOwner;         tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp = entry->mteEName;         tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp   = entry->mteNotification;            cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp,                                          &entry->mteNotification_len);            vp = entry->mteNotifyOwner;   tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp = entry->mteNotifyObjects; tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            snmpd_store_config(line);        }        if ( entry->mteEventActions & MTE_EVENT_SET ) {            memset(line, 0, sizeof(line));            strcat(line, "_mteESetTable ");            cptr = line + strlen(line);                vp = entry->mteOwner;         tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp = entry->mteEName;         tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp   = entry->mteSetOID;            cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp,                                          &entry->mteSetOID_len);            tint = entry->mteSetValue;            cptr = read_config_store_data(ASN_INTEGER,   cptr, &tint, NULL);            vp = entry->mteSetTarget;     tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            vp = entry->mteSetContext;    tint = strlen( vp );            cptr = read_config_store_data(ASN_OCTET_STR, cptr, &vp, &tint );            tint = entry->flags & (MTE_SET_FLAG_OBJWILD|MTE_SET_FLAG_CTXWILD);             cptr = read_config_store_data(ASN_UNSIGNED,  cptr, &tint, NULL);            snmpd_store_config(line);        }    }    DEBUGMSGTL(("disman:event:conf", "  done.\n"));    return SNMPERR_SUCCESS;}intclear_mteETable(int majorID, int minorID, void *serverarg, void *clientarg){    netsnmp_tdata_row    *row;    netsnmp_variable_list owner_var;    /*     * We're only interested in entries set up via the config files     */    memset( &owner_var, 0, sizeof(netsnmp_variable_list));    snmp_set_var_typed_value( &owner_var,  ASN_OCTET_STR,                             "snmpd.conf", strlen("snmpd.conf"));    while (( row = netsnmp_tdata_row_next_byidx( event_table_data,                                                &owner_var ))) {        /*         * XXX - check for owner of "snmpd.conf"         *       and break at the end of these         */        netsnmp_tdata_remove_and_delete_row( event_table_data, row );    }    return SNMPERR_SUCCESS;}

⌨️ 快捷键说明

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