📄 tcpconnectiontable_interface.c
字号:
if (rowreq_ctx->undo) tcpConnectionTable_release_data(rowreq_ctx->undo); /* * free index oid pointer */ if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) free(rowreq_ctx->oid_idx.oids); SNMP_FREE(rowreq_ctx);} /* tcpConnectionTable_release_rowreq_ctx *//** * @internal * wrapper */static int_mfd_tcpConnectionTable_pre_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_pre_request", "called\n")); if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:tcpConnectionTable", "skipping additional pre_request\n")); return SNMP_ERR_NOERROR; } rc = tcpConnectionTable_pre_request(tcpConnectionTable_if_ctx. user_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("tcpConnectionTable", "error %d from " "tcpConnectionTable_pre_request\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR;} /* _mfd_tcpConnectionTable_pre_request *//** * @internal * wrapper */static int_mfd_tcpConnectionTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ tcpConnectionTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc, packet_rc; DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_post_request", "called\n")); /* * release row context, if deleted */ if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) tcpConnectionTable_release_rowreq_ctx(rowreq_ctx); /* * wait for last call before calling user */ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:tcpConnectionTable", "waiting for last post_request\n")); return SNMP_ERR_NOERROR; } packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); if ((MFD_SUCCESS != packet_rc) && tcpConnectionTable_dirty_get()) { /* * we shouldn't get here. the undo steps should also clear * the dirty flags. */ snmp_log(LOG_WARNING, "tcpConnectionTable dirty flag set in post_request " "but status != SUCCESS.\n"); } rc = tcpConnectionTable_post_request(tcpConnectionTable_if_ctx. user_ctx, packet_rc); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("tcpConnectionTable", "error %d from " "tcpConnectionTable_post_request\n", rc)); } return SNMP_ERR_NOERROR;} /* _mfd_tcpConnectionTable_post_request *//** * @internal * wrapper */static int_mfd_tcpConnectionTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc = SNMP_ERR_NOERROR; tcpConnectionTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_object_lookup", "called\n")); /* * get our context from mfd * tcpConnectionTable_interface_ctx *if_ctx = * (tcpConnectionTable_interface_ctx *)reginfo->my_reg_void; */ if (NULL == rowreq_ctx) { rc = SNMP_ERR_NOCREATION; } if (MFD_SUCCESS != rc) netsnmp_request_set_error_all(requests, rc); else tcpConnectionTable_row_prep(rowreq_ctx); return SNMP_VALIDATE_ERR(rc);} /* _mfd_tcpConnectionTable_object_lookup *//*********************************************************************** * * GET processing * ***********************************************************************//* * @internal * Retrieve the value for a particular column */NETSNMP_STATIC_INLINE int_tcpConnectionTable_get_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_get_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_TCPCONNECTIONSTATE: var->val_len = sizeof(u_long); var->type = ASN_INTEGER; rc = tcpConnectionState_get(rowreq_ctx, (u_long *) var->val.string); break; /* * tcpConnectionProcess(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h */ case COLUMN_TCPCONNECTIONPROCESS: var->val_len = sizeof(u_long); var->type = ASN_UNSIGNED; rc = tcpConnectionProcess_get(rowreq_ctx, (u_long *) var->val.string); break; default: snmp_log(LOG_ERR, "unknown column %d in _tcpConnectionTable_get_column\n", column); break; } return rc;} /* _tcpConnectionTable_get_column */int_mfd_tcpConnectionTable_get_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ tcpConnectionTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info *tri; u_char *old_string; void (*dataFreeHook) (void *); int rc; DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_get_values", "called\n")); netsnmp_assert(NULL != rowreq_ctx); for (; requests; requests = requests->next) { /* * save old pointer, so we can free it if replaced */ old_string = requests->requestvb->val.string; dataFreeHook = requests->requestvb->dataFreeHook; if (NULL == requests->requestvb->val.string) { requests->requestvb->val.string = requests->requestvb->buf; requests->requestvb->val_len = sizeof(requests->requestvb->buf); } else if (requests->requestvb->buf == requests->requestvb->val.string) { if (requests->requestvb->val_len != sizeof(requests->requestvb->buf)) requests->requestvb->val_len = sizeof(requests->requestvb->buf); } /* * get column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _tcpConnectionTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); if (rc) { if (MFD_SKIP == rc) { requests->requestvb->type = SNMP_NOSUCHINSTANCE; rc = SNMP_ERR_NOERROR; } } else if (NULL == requests->requestvb->val.string) { snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); rc = SNMP_ERR_GENERR; } if (rc) netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); /* * if the buffer wasn't used previously for the old data (i.e. it * was allcoated memory) and the get routine replaced the pointer, * we need to free the previous pointer. */ if (old_string && (old_string != requests->requestvb->buf) && (requests->requestvb->val.string != old_string)) { if (dataFreeHook) (*dataFreeHook) (old_string); else free(old_string); } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_tcpConnectionTable_get_values *//*********************************************************************** * * SET processing * ***********************************************************************//*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*//* * @internal * Check the syntax for a particular column */NETSNMP_STATIC_INLINE int_tcpConnectionTable_check_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_check_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * (INDEX) tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ case COLUMN_TCPCONNECTIONLOCALADDRESSTYPE: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ case COLUMN_TCPCONNECTIONLOCALADDRESS: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ case COLUMN_TCPCONNECTIONLOCALPORT: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ case COLUMN_TCPCONNECTIONREMADDRESSTYPE: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ case COLUMN_TCPCONNECTIONREMADDRESS: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ case COLUMN_TCPCONNECTIONREMPORT: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_TCPCONNECTIONSTATE: rc = netsnmp_check_vb_type(var, ASN_INTEGER); /* * check that the value is one of defined enums */ if ((SNMPERR_SUCCESS == rc) && (*var->val.integer != TCPCONNECTIONSTATE_CLOSED) && (*var->val.integer != TCPCONNECTIONSTATE_LISTEN) && (*var->val.integer != TCPCONNECTIONSTATE_SYNSENT) && (*var->val.integer != TCPCONNECTIONSTATE_SYNRECEIVED) && (*var->val.integer != TCPCONNECTIONSTATE_ESTABLISHED) && (*var->val.integer != TCPCONNECTIONSTATE_FINWAIT1) && (*var->val.integer != TCPCONNECTIONSTATE_FINWAIT2) && (*var->val.integer != TCPCONNECTIONSTATE_CLOSEWAIT) && (*var->val.integer != TCPCONNECTIONSTATE_LASTACK) && (*var->val.integer != TCPCONNECTIONSTATE_CLOSING) && (*var->val.integer != TCPCONNECTIONSTATE_TIMEWAIT) && (*var->val.integer != TCPCONNECTIONSTATE_DELETETCB) ) { rc = SNMP_ERR_WRONGVALUE; } if (SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("tcpConnectionTable:_tcpConnectionTable_check_column:tcpConnectionState", "varbind validation failed (eg bad type or size)\n")); } else { rc = tcpConnectionState_check_value(rowreq_ctx, *((u_long *) var->val. string));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -