📄 tcpconnectiontable_interface.c
字号:
* shutdown the container */ _tcpConnectionTable_container_shutdown(&tcpConnectionTable_if_ctx);}voidtcpConnectionTable_valid_columns_set(netsnmp_column_info *vc){ tcpConnectionTable_if_ctx.tbl_info.valid_columns = vc;} /* tcpConnectionTable_valid_columns_set *//** * @internal * convert the index component stored in the context to an oid */inttcpConnectionTable_index_to_oid(netsnmp_index * oid_idx, tcpConnectionTable_mib_index * mib_idx){ int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ netsnmp_variable_list var_tcpConnectionLocalAddressType; /* * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_tcpConnectionLocalAddress; /* * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_tcpConnectionLocalPort; /* * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ netsnmp_variable_list var_tcpConnectionRemAddressType; /* * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_tcpConnectionRemAddress; /* * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_tcpConnectionRemPort; /* * set up varbinds */ memset(&var_tcpConnectionLocalAddressType, 0x00, sizeof(var_tcpConnectionLocalAddressType)); var_tcpConnectionLocalAddressType.type = ASN_INTEGER; memset(&var_tcpConnectionLocalAddress, 0x00, sizeof(var_tcpConnectionLocalAddress)); var_tcpConnectionLocalAddress.type = ASN_OCTET_STR; memset(&var_tcpConnectionLocalPort, 0x00, sizeof(var_tcpConnectionLocalPort)); var_tcpConnectionLocalPort.type = ASN_UNSIGNED; memset(&var_tcpConnectionRemAddressType, 0x00, sizeof(var_tcpConnectionRemAddressType)); var_tcpConnectionRemAddressType.type = ASN_INTEGER; memset(&var_tcpConnectionRemAddress, 0x00, sizeof(var_tcpConnectionRemAddress)); var_tcpConnectionRemAddress.type = ASN_OCTET_STR; memset(&var_tcpConnectionRemPort, 0x00, sizeof(var_tcpConnectionRemPort)); var_tcpConnectionRemPort.type = ASN_UNSIGNED; /* * chain temp index varbinds together */ var_tcpConnectionLocalAddressType.next_variable = &var_tcpConnectionLocalAddress; var_tcpConnectionLocalAddress.next_variable = &var_tcpConnectionLocalPort; var_tcpConnectionLocalPort.next_variable = &var_tcpConnectionRemAddressType; var_tcpConnectionRemAddressType.next_variable = &var_tcpConnectionRemAddress; var_tcpConnectionRemAddress.next_variable = &var_tcpConnectionRemPort; var_tcpConnectionRemPort.next_variable = NULL; DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_index_to_oid", "called\n")); /* * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ snmp_set_var_value(&var_tcpConnectionLocalAddressType, (u_char *) & mib_idx->tcpConnectionLocalAddressType, sizeof(mib_idx->tcpConnectionLocalAddressType)); /* * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ snmp_set_var_value(&var_tcpConnectionLocalAddress, (u_char *) & mib_idx->tcpConnectionLocalAddress, mib_idx->tcpConnectionLocalAddress_len * sizeof(mib_idx->tcpConnectionLocalAddress[0])); /* * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ snmp_set_var_value(&var_tcpConnectionLocalPort, (u_char *) & mib_idx->tcpConnectionLocalPort, sizeof(mib_idx->tcpConnectionLocalPort)); /* * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ snmp_set_var_value(&var_tcpConnectionRemAddressType, (u_char *) & mib_idx->tcpConnectionRemAddressType, sizeof(mib_idx->tcpConnectionRemAddressType)); /* * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ snmp_set_var_value(&var_tcpConnectionRemAddress, (u_char *) & mib_idx->tcpConnectionRemAddress, mib_idx->tcpConnectionRemAddress_len * sizeof(mib_idx->tcpConnectionRemAddress[0])); /* * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ snmp_set_var_value(&var_tcpConnectionRemPort, (u_char *) & mib_idx->tcpConnectionRemPort, sizeof(mib_idx->tcpConnectionRemPort)); err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, NULL, 0, &var_tcpConnectionLocalAddressType); if (err) snmp_log(LOG_ERR, "error %d converting index to oid\n", err); /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_tcpConnectionLocalAddressType); return err;} /* tcpConnectionTable_index_to_oid *//** * extract tcpConnectionTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */inttcpConnectionTable_index_from_oid(netsnmp_index * oid_idx, tcpConnectionTable_mib_index * mib_idx){ int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ netsnmp_variable_list var_tcpConnectionLocalAddressType; /* * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_tcpConnectionLocalAddress; /* * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_tcpConnectionLocalPort; /* * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ netsnmp_variable_list var_tcpConnectionRemAddressType; /* * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_tcpConnectionRemAddress; /* * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_tcpConnectionRemPort; /* * set up varbinds */ memset(&var_tcpConnectionLocalAddressType, 0x00, sizeof(var_tcpConnectionLocalAddressType)); var_tcpConnectionLocalAddressType.type = ASN_INTEGER; memset(&var_tcpConnectionLocalAddress, 0x00, sizeof(var_tcpConnectionLocalAddress)); var_tcpConnectionLocalAddress.type = ASN_OCTET_STR; memset(&var_tcpConnectionLocalPort, 0x00, sizeof(var_tcpConnectionLocalPort)); var_tcpConnectionLocalPort.type = ASN_UNSIGNED; memset(&var_tcpConnectionRemAddressType, 0x00, sizeof(var_tcpConnectionRemAddressType)); var_tcpConnectionRemAddressType.type = ASN_INTEGER; memset(&var_tcpConnectionRemAddress, 0x00, sizeof(var_tcpConnectionRemAddress)); var_tcpConnectionRemAddress.type = ASN_OCTET_STR; memset(&var_tcpConnectionRemPort, 0x00, sizeof(var_tcpConnectionRemPort)); var_tcpConnectionRemPort.type = ASN_UNSIGNED; /* * chain temp index varbinds together */ var_tcpConnectionLocalAddressType.next_variable = &var_tcpConnectionLocalAddress; var_tcpConnectionLocalAddress.next_variable = &var_tcpConnectionLocalPort; var_tcpConnectionLocalPort.next_variable = &var_tcpConnectionRemAddressType; var_tcpConnectionRemAddressType.next_variable = &var_tcpConnectionRemAddress; var_tcpConnectionRemAddress.next_variable = &var_tcpConnectionRemPort; var_tcpConnectionRemPort.next_variable = NULL; DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_tcpConnectionLocalAddressType); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ mib_idx->tcpConnectionLocalAddressType = *((u_long *) var_tcpConnectionLocalAddressType.val.string); /* * NOTE: val_len is in bytes, tcpConnectionLocalAddress_len might not be */ if (var_tcpConnectionLocalAddress.val_len > sizeof(mib_idx->tcpConnectionLocalAddress)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->tcpConnectionLocalAddress, var_tcpConnectionLocalAddress.val.string, var_tcpConnectionLocalAddress.val_len); mib_idx->tcpConnectionLocalAddress_len = var_tcpConnectionLocalAddress.val_len / sizeof(mib_idx->tcpConnectionLocalAddress[0]); } mib_idx->tcpConnectionLocalPort = *((u_long *) var_tcpConnectionLocalPort.val.string); mib_idx->tcpConnectionRemAddressType = *((u_long *) var_tcpConnectionRemAddressType.val.string); /* * NOTE: val_len is in bytes, tcpConnectionRemAddress_len might not be */ if (var_tcpConnectionRemAddress.val_len > sizeof(mib_idx->tcpConnectionRemAddress)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->tcpConnectionRemAddress, var_tcpConnectionRemAddress.val.string, var_tcpConnectionRemAddress.val_len); mib_idx->tcpConnectionRemAddress_len = var_tcpConnectionRemAddress.val_len / sizeof(mib_idx->tcpConnectionRemAddress[0]); } mib_idx->tcpConnectionRemPort = *((u_long *) var_tcpConnectionRemPort.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_tcpConnectionLocalAddressType); return err;} /* tcpConnectionTable_index_from_oid *//* ********************************************************************* * @internal * allocate resources for a tcpConnectionTable_rowreq_ctx */tcpConnectionTable_rowreq_ctx *tcpConnectionTable_allocate_rowreq_ctx(tcpConnectionTable_data * data, void *user_init_ctx){ tcpConnectionTable_rowreq_ctx *rowreq_ctx = SNMP_MALLOC_TYPEDEF(tcpConnectionTable_rowreq_ctx); DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_allocate_rowreq_ctx", "called\n")); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "Couldn't allocate memory for a " "tcpConnectionTable_rowreq_ctx.\n"); return NULL; } else { if (NULL != data) { /* * track if we got data from user */ rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; rowreq_ctx->data = data; } else if (NULL == (rowreq_ctx->data = tcpConnectionTable_allocate_data())) { SNMP_FREE(rowreq_ctx); return NULL; } } /* * undo context will be allocated when needed (in *_undo_setup) */ rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; rowreq_ctx->tcpConnectionTable_data_list = NULL; /* * if we allocated data, call init routine */ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { if (SNMPERR_SUCCESS != tcpConnectionTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { tcpConnectionTable_release_rowreq_ctx(rowreq_ctx); rowreq_ctx = NULL; } } return rowreq_ctx;} /* tcpConnectionTable_allocate_rowreq_ctx *//* * @internal * release resources for a tcpConnectionTable_rowreq_ctx */voidtcpConnectionTable_release_rowreq_ctx(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_release_rowreq_ctx", "called\n")); netsnmp_assert(NULL != rowreq_ctx); tcpConnectionTable_rowreq_ctx_cleanup(rowreq_ctx); /* * for non-transient data, don't free data we got from the user */ if ((rowreq_ctx->data) && !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) tcpConnectionTable_release_data(rowreq_ctx->data);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -