static int multiplex_request(struct xlator *jool, struct genl_info *info) { struct request_hdr *hdr = get_jool_hdr(info); switch (be16_to_cpu(hdr->mode)) { case MODE_POOL6: return handle_pool6_config(jool, info); case MODE_POOL4: return handle_pool4_config(jool, info); case MODE_BIB: return handle_bib_config(jool, info); case MODE_SESSION: return handle_session_config(jool, info); case MODE_EAMT: return handle_eamt_config(jool, info); case MODE_RFC6791: return handle_pool6791_config(jool, info); case MODE_BLACKLIST: return handle_blacklist_config(jool, info); case MODE_LOGTIME: return handle_logtime_config(info); case MODE_GLOBAL: return handle_global_config(jool, info); case MODE_PARSE_FILE: return handle_atomconfig_request(jool, info); case MODE_JOOLD: return handle_joold_request(jool, info); case MODE_INSTANCE: return handle_instance_request(info); } log_err("Unknown configuration mode: %d", be16_to_cpu(hdr->mode)); return nlcore_respond(info, -EINVAL); }
/** * Gets called by "netlink_rcv_skb" when the userspace application wants to interact with us. * * @param skb packet received from userspace. * @param nlh message's metadata. * @return result status. */ static int handle_netlink_message(struct sk_buff *skb_in, struct nlmsghdr *nl_hdr) { struct request_hdr *jool_hdr; void *request; int error; if (nl_hdr->nlmsg_type != MSG_TYPE_JOOL) { log_debug("Expecting %#x but got %#x.", MSG_TYPE_JOOL, nl_hdr->nlmsg_type); return -EINVAL; } jool_hdr = NLMSG_DATA(nl_hdr); request = jool_hdr + 1; error = validate_version(jool_hdr); if (error) return respond_error(nl_hdr, error); switch (jool_hdr->mode) { case MODE_POOL6: return handle_pool6_config(nl_hdr, jool_hdr, request); break; case MODE_POOL4: return handle_pool4_config(nl_hdr, jool_hdr, request); break; case MODE_BIB: return handle_bib_config(nl_hdr, jool_hdr, request); break; case MODE_SESSION: return handle_session_config(nl_hdr, jool_hdr, request); break; case MODE_EAMT: return handle_eamt_config(nl_hdr, jool_hdr, request); break; case MODE_RFC6791: return handle_rfc6791_config(nl_hdr, jool_hdr, request); break; case MODE_BLACKLIST: return handle_blacklist_config(nl_hdr, jool_hdr, request); break; case MODE_LOGTIME: return handle_logtime_config(nl_hdr, jool_hdr, request); break; case MODE_GLOBAL: return handle_global_config(nl_hdr, jool_hdr, request); break; } log_err("Unknown configuration mode: %d", jool_hdr->mode); return respond_error(nl_hdr, -EINVAL); }