/************************************************************ * Assuming that the RESERVE phases were successful, the next * stage is indicated by the action value ACTION. This is used * to actually implement the set operation. However, this must * either be done into temporary (persistent) storage, or the * previous value stored similarly, in case any of the subsequent * ACTION calls fail. * * In your case, changes should be made to row_ctx. A copy of * the original row is in undo_ctx. */ void saHpiAutoInsertTimeoutTable_set_action( netsnmp_request_group *rg ) { netsnmp_variable_list *var; saHpiAutoInsertTimeoutTable_context *row_ctx = (saHpiAutoInsertTimeoutTable_context *)rg->existing_row; // saHpiAutoInsertTimeoutTable_context *undo_ctx = (saHpiAutoInsertTimeoutTable_context *)rg->undo_info; netsnmp_request_group_item *current; // unsigned char buff[sizeof(SaHpiTimeT)]; //For timeout int row_err = 0; printf("7\n"); /* * TODO: loop through columns, copy varbind values * to context structure for the row. */ for( current = rg->list; current; current = current->next ) { var = current->ri->requestvb; switch(current->tri->colnum) { case COLUMN_SAHPIAUTOINSERTTIMEOUTFORINSERT: /** SafUnsigned64 = ASN_OPAQUE */ assign_timeout(var, row_ctx->saHpiAutoInsertTimeoutForInsert); row_ctx->saHpiAutoInsertTimeoutForInsert_len = var->val_len; row_err = auto_insert_timeout_set(row_ctx); break; default: /** We shouldn't get here */ netsnmp_assert(0); /** why wasn't this caught in reserve1? */ } } /* * done with all the columns. Could check row related * requirements here. */ if(row_err) { netsnmp_request_set_error((netsnmp_request_info*)rg->rg_void, row_err); return; } /* * TODO: if you have dependencies on other tables, this would be * a good place to check those, too. */ }
static int handle_global_update(enum global_type type, size_t size, unsigned char *value) { struct global_config *config; bool timer_needs_update = false; enum session_timer_type timer_type; int error; config = kmalloc(sizeof(*config), GFP_KERNEL); if (!config) return -ENOMEM; config->mtu_plateaus = NULL; error = config_clone(config); if (error) goto fail; switch (type) { #ifdef STATEFUL case MAX_PKTS: if (!ensure_bytes(size, 8)) goto einval; config->max_stored_pkts = *((__u64 *) value); break; case SRC_ICMP6ERRS_BETTER: if (!ensure_bytes(size, 1)) goto einval; config->src_icmp6errs_better = *((__u8 *) value); break; case BIB_LOGGING: if (!ensure_bytes(size, 1)) goto einval; config->bib_logging = *((__u8 *) value); break; case SESSION_LOGGING: if (!ensure_bytes(size, 1)) goto einval; config->session_logging = *((__u8 *) value); break; case UDP_TIMEOUT: if (!ensure_bytes(size, 8)) goto einval; if (!assign_timeout(value, UDP_MIN, &config->ttl.udp)) goto einval; timer_needs_update = true; timer_type = SESSIONTIMER_UDP; break; case ICMP_TIMEOUT: if (!ensure_bytes(size, 8)) goto einval; if (!assign_timeout(value, 0, &config->ttl.icmp)) goto einval; timer_needs_update = true; timer_type = SESSIONTIMER_ICMP; break; case TCP_EST_TIMEOUT: if (!ensure_bytes(size, 8)) goto einval; if (!assign_timeout(value, TCP_EST, &config->ttl.tcp_est)) goto einval; timer_needs_update = true; timer_type = SESSIONTIMER_EST; break; case TCP_TRANS_TIMEOUT: if (!ensure_bytes(size, 8)) goto einval; if (!assign_timeout(value, TCP_TRANS, &config->ttl.tcp_trans)) goto einval; timer_needs_update = true; timer_type = SESSIONTIMER_TRANS; break; case FRAGMENT_TIMEOUT: if (!ensure_bytes(size, 8)) goto einval; if (!assign_timeout(value, FRAGMENT_MIN, &config->ttl.frag)) goto einval; break; case DROP_BY_ADDR: if (!ensure_bytes(size, 1)) goto einval; config->drop_by_addr = *((__u8 *) value); break; case DROP_ICMP6_INFO: if (!ensure_bytes(size, 1)) goto einval; config->drop_icmp6_info = *((__u8 *) value); break; case DROP_EXTERNAL_TCP: if (!ensure_bytes(size, 1)) goto einval; config->drop_external_tcp = *((__u8 *) value); break; #else case COMPUTE_UDP_CSUM_ZERO: if (!ensure_bytes(size, 1)) goto einval; config->compute_udp_csum_zero = *((__u8 *) value); break; case RANDOMIZE_RFC6791: if (!ensure_bytes(size, 1)) goto einval; config->randomize_error_addresses = *((__u8 *) value); break; #endif case RESET_TCLASS: if (!ensure_bytes(size, 1)) goto einval; config->reset_traffic_class = *((__u8 *) value); break; case RESET_TOS: if (!ensure_bytes(size, 1)) goto einval; config->reset_tos = *((__u8 *) value); break; case NEW_TOS: if (!ensure_bytes(size, 1)) goto einval; config->new_tos = *((__u8 *) value); break; case DF_ALWAYS_ON: if (!ensure_bytes(size, 1)) goto einval; config->atomic_frags.df_always_on = *((__u8 *) value); break; case BUILD_IPV6_FH: if (!ensure_bytes(size, 1)) goto einval; config->atomic_frags.build_ipv6_fh = *((__u8 *) value); break; case BUILD_IPV4_ID: if (!ensure_bytes(size, 1)) goto einval; config->atomic_frags.build_ipv4_id = *((__u8 *) value); break; case LOWER_MTU_FAIL: if (!ensure_bytes(size, 1)) goto einval; config->atomic_frags.lower_mtu_fail = *((__u8 *) value); break; case MTU_PLATEAUS: if (is_error(update_plateaus(config, size, value))) goto einval; break; case DISABLE: config->is_disable = (__u8) true; break; case ENABLE: config->is_disable = (__u8) false; break; case ATOMIC_FRAGMENTS: if (!ensure_bytes(size, 1)) goto einval; config->atomic_frags.df_always_on = *((__u8 *) value); config->atomic_frags.build_ipv6_fh = *((__u8 *) value); config->atomic_frags.build_ipv4_id = !(*((__u8 *) value)); config->atomic_frags.lower_mtu_fail = !(*((__u8 *) value)); break; default: log_err("Unknown config type: %u", type); goto einval; } error = config_set(config); if (error) goto fail; if (timer_needs_update) error = sessiondb_update_timer(timer_type); return error; einval: error = -EINVAL; /* Fall through. */ fail: kfree(config->mtu_plateaus); kfree(config); return error; }