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

📄 traceroutectltable.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 5 页
字号:
    return count;}inttraceRouteProbeHistoryTable_delLast(struct traceRouteCtlTable_data                                    *thedata){    struct traceRouteProbeHistoryTable_data *p = NULL;    struct header_complex_index *hciptr1 = NULL;    struct header_complex_index *hciptr2 = NULL;    struct header_complex_index *hcilast = NULL;    struct traceRouteProbeHistoryTable_data *StorageDel = NULL;    struct traceRouteProbeHistoryTable_data *StorageTmp = NULL;    netsnmp_variable_list *vars = NULL;    netsnmp_variable_list *vars_temp = NULL;    oid             newoid[MAX_OID_LEN];    size_t          newoid_len = 0;    time_t          last_time = 2147483647;    struct tm      *tp = NULL;    tp = (struct tm *) malloc(sizeof(struct tm));    if (tp == NULL) {        exit(1);    }    snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen);   /* traceRouteCtlOwnerIndex */    snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen);       /* traceRouteCtlOperationName */    bzero(newoid, sizeof(oid) * MAX_OID_LEN);    header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);    for (hcilast = hciptr2 = traceRouteProbeHistoryTableStorage;         hciptr2 != NULL; hciptr2 = hciptr2->next) {        if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)            == 0) {            StorageTmp =                header_complex_get_from_oid                (traceRouteProbeHistoryTableStorage, hciptr2->name,                 hciptr2->namelen);            strptime(StorageTmp->traceRouteProbeHistoryTime, "%c", tp);            if (last_time > timegm(tp)) {                last_time = timegm(tp);                hcilast = hciptr2;            }        }    }    StorageDel =        header_complex_extract_entry(&traceRouteProbeHistoryTableStorage,                                     hcilast);    DEBUGMSGTL(("traceRouteProbeHistoryTable",                "delete the last one success!\n"));    vars = NULL;    free(tp);    tp = NULL;}voidtraceRouteCtlTable_cleaner(struct header_complex_index *thestuff){    struct header_complex_index *hciptr = NULL;    struct traceRouteCtlTable_data *StorageDel = NULL;    DEBUGMSGTL(("traceRouteCtlTable", "cleanerout  "));    for (hciptr = thestuff; hciptr != NULL; hciptr = hciptr->next) {        StorageDel =            header_complex_extract_entry(&traceRouteCtlTableStorage,                                         hciptr);        if (StorageDel != NULL) {            free(StorageDel->traceRouteCtlOwnerIndex);            StorageDel->traceRouteCtlOwnerIndex = NULL;            free(StorageDel->traceRouteCtlTestName);            StorageDel->traceRouteCtlTestName = NULL;            free(StorageDel->traceRouteCtlTargetAddress);            StorageDel->traceRouteCtlTargetAddress = NULL;            free(StorageDel->traceRouteCtlSourceAddress);            StorageDel->traceRouteCtlSourceAddress = NULL;            free(StorageDel->traceRouteCtlMiscOptions);            StorageDel->traceRouteCtlMiscOptions = NULL;            free(StorageDel->traceRouteCtlDescr);            StorageDel->traceRouteCtlDescr = NULL;            free(StorageDel->traceRouteCtlTrapGeneration);            StorageDel->traceRouteCtlTrapGeneration = NULL;            free(StorageDel->traceRouteCtlType);            StorageDel->traceRouteCtlType = NULL;            free(StorageDel);            StorageDel = NULL;        }        DEBUGMSGTL(("traceRouteCtlTable", "cleaner  "));    }}/* * parse_mteObjectsTable(): *   parses .conf file entries needed to configure the mib. */voidparse_traceRouteCtlTable(const char *token, char *line){    size_t          tmpint;    struct traceRouteCtlTable_data *StorageTmp =        SNMP_MALLOC_STRUCT(traceRouteCtlTable_data);    DEBUGMSGTL(("traceRouteCtlTable", "parsing config...  "));    if (StorageTmp == NULL) {        config_perror("malloc failure");        return;    }    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlOwnerIndex,                              &StorageTmp->traceRouteCtlOwnerIndexLen);    if (StorageTmp->traceRouteCtlOwnerIndex == NULL) {        config_perror("invalid specification for traceRouteCtlOwnerIndex");        return;    }    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlTestName,                              &StorageTmp->traceRouteCtlTestNameLen);    if (StorageTmp->traceRouteCtlTestName == NULL) {        config_perror("invalid specification for traceRouteCtlTestName");        return;    }    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlTargetAddressType,                              &tmpint);    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlTargetAddress,                              &StorageTmp->traceRouteCtlTargetAddressLen);    if (StorageTmp->traceRouteCtlTargetAddress == NULL) {        config_perror            ("invalid specification for traceRouteCtlTargetAddress");        return;    }    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlByPassRouteTable,                              &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlDataSize, &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlTimeOut, &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlProbesPerHop,                              &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlPort, &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlMaxTtl, &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlDSField, &tmpint);    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlSourceAddressType,                              &tmpint);    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlSourceAddress,                              &StorageTmp->traceRouteCtlSourceAddressLen);    if (StorageTmp->traceRouteCtlSourceAddress == NULL) {        config_perror            ("invalid specification for traceRouteCtlSourceAddress");        return;    }    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlIfIndex, &tmpint);    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlMiscOptions,                              &StorageTmp->traceRouteCtlMiscOptionsLen);    if (StorageTmp->traceRouteCtlMiscOptions == NULL) {        config_perror            ("invalid specification for traceRouteCtlMiscOptions");        return;    }    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlMaxFailures,                              &tmpint);    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlDontFragment,                              &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlInitialTtl,                              &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlFrequency,                              &tmpint);    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlStorageType,                              &tmpint);    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlAdminStatus,                              &tmpint);    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlDescr,                              &StorageTmp->traceRouteCtlDescrLen);    if (StorageTmp->traceRouteCtlDescr == NULL) {        config_perror("invalid specification for traceRouteCtlTrapDescr");        return;    }    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteCtlMaxRows, &tmpint);    line =        read_config_read_data(ASN_OCTET_STR, line,                              &StorageTmp->traceRouteCtlTrapGeneration,                              &StorageTmp->traceRouteCtlTrapGenerationLen);    if (StorageTmp->traceRouteCtlTrapGeneration == NULL) {        config_perror            ("invalid specification for traceRouteCtlTrapGeneration");        return;    }    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlCreateHopsEntries,                              &tmpint);    line =        read_config_read_data(ASN_OBJECT_ID, line,                              &StorageTmp->traceRouteCtlType,                              &StorageTmp->traceRouteCtlTypeLen);    if (StorageTmp->traceRouteCtlType == NULL) {        config_perror("invalid specification for traceRouteCtlType");        return;    }    line =        read_config_read_data(ASN_INTEGER, line,                              &StorageTmp->traceRouteCtlRowStatus,                              &tmpint);    line =        read_config_read_data(ASN_UNSIGNED, line,                              &StorageTmp->traceRouteProbeHistoryMaxIndex,                              &tmpint);    StorageTmp->storageType = ST_NONVOLATILE;    traceRouteCtlTable_add(StorageTmp);    /*     traceRouteCtlTable_cleaner(traceRouteCtlTableStorage); */    DEBUGMSGTL(("traceRouteCtlTable", "done.\n"));}/* * store_traceRouteCtlTable(): *   stores .conf file entries needed to configure the mib. */intstore_traceRouteCtlTable(int majorID, int minorID, void *serverarg,                         void *clientarg){    char            line[SNMP_MAXBUF];    char           *cptr = NULL;    size_t          tmpint;    struct traceRouteCtlTable_data *StorageTmp = NULL;    struct header_complex_index *hcindex = NULL;    DEBUGMSGTL(("traceRouteCtlTable", "storing data...  "));    for (hcindex = traceRouteCtlTableStorage; hcindex != NULL;         hcindex = hcindex->next) {        StorageTmp = (struct traceRouteCtlTable_data *) hcindex->data;        if (StorageTmp->storageType != ST_READONLY) {            memset(line, 0, sizeof(line));            strcat(line, "traceRouteCtlTable ");            cptr = line + strlen(line);            cptr =                read_config_store_data(ASN_OCTET_STR, cptr,                                       &StorageTmp->                                       traceRouteCtlOwnerIndex,                                       &StorageTmp->                                       traceRouteCtlOwnerIndexLen);            cptr =                read_config_store_data(ASN_OCTET_STR, cptr,                                       &StorageTmp->traceRouteCtlTestName,                                       &StorageTmp->                                       traceRouteCtlTestNameLen);            cptr =

⌨️ 快捷键说明

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