static int handle_eamt_config(struct nlmsghdr *nl_hdr, struct request_hdr *jool_hdr, union request_eamt *request) { __u64 count; int error; if (xlat_is_nat64()) { log_err("Stateful NAT64 doesn't have an EAMT."); return -EINVAL; } switch (jool_hdr->operation) { case OP_DISPLAY: return handle_eamt_display(nl_hdr, request); case OP_COUNT: log_debug("Returning EAMT count."); error = eamt_count(&count); if (error) return respond_error(nl_hdr, error); return respond_setcfg(nl_hdr, &count, sizeof(count)); case OP_TEST: return handle_eamt_test(nl_hdr, request); case OP_ADD: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Adding EAMT entry."); return respond_error(nl_hdr, eamt_add(&request->add.prefix6, &request->add.prefix4, request->add.force)); case OP_REMOVE: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Removing EAMT entry."); return respond_error(nl_hdr, eamt_rm( request->rm.prefix6_set ? &request->rm.prefix6 : NULL, request->rm.prefix4_set ? &request->rm.prefix4 : NULL)); case OP_FLUSH: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); eamt_flush(); return respond_error(nl_hdr, 0); default: log_err("Unknown operation: %d", jool_hdr->operation); return respond_error(nl_hdr, -EINVAL); } }
static int handle_eamt_count(struct eam_table *eamt, struct genl_info *info) { __u64 count; int error; log_debug("Returning EAMT count."); error = eamt_count(eamt, &count); if (error) return nlcore_respond(info, error); return nlcore_respond_struct(info, &count, sizeof(count)); }