From patchwork Wed Aug 5 06:58:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1341109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=1ftsA21U; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dNS+Nx/T; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BM2bh5bhGz9sRN for ; Wed, 5 Aug 2020 17:01:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=y6VL+2ztKlLDr1sYG/IJX8+0MQRZ+EOSZyKj0wbOUQ8=; b=1ftsA21UHJLHgL+R7xwEE/FFsX XizJcMFlvE5BQbTfzESzGgGDPZ0Rpjp3cwJw4N6z/rGZKKa2/tUp+5p9zPpYxumZhVoqX4B5yxpIY TDnit2y/IGMT+eZ9okz5urQXksUQJK1boC50gNYCQAfLi+2VLajf1eaVfbhk/cAxIfa5/wMXKib44 vSRnMdGMf0ZS1zOidQp3HUBoyIoyeK8aviiR+e5JZB5if4v9tHVYdQbHbpavppkBbqSdP4pftqSAR Qv878sizwXh/Y2pIIYXw2ISN7IlRkZriCVJ55HQOj8PlFPj3YnYo2wMQYr3iLdV6UJtRSzjHlN4tS KBqsJb6A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3DOD-0002Cw-N0; Wed, 05 Aug 2020 06:59:05 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3DOA-0002CW-Al for openwrt-devel@lists.openwrt.org; Wed, 05 Aug 2020 06:59:03 +0000 Received: by mail-lj1-x243.google.com with SMTP id g6so33790009ljn.11 for ; Tue, 04 Aug 2020 23:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K324ELS+U0NPHo+PBbu6mrc1yyehUYHOAGZ9L/16Prg=; b=dNS+Nx/TIyYhhbrZOqxKLs65Zaw17wFmw+H3uGrRkbv/zv/5jN3WLUynL48Cb03Yys y/CwWL1frpyvf0Az3eyjUuHHm/hNGXouhMB6HxJkPRIIBFe6AuvAdXsXdO+wytxkvRI6 1t6R89OE9c4BRAWgtZAhr4Kk47aIWzSXZuYfWjAub3xcBS2bgyKcAPFtIIWa7br2hwY0 PNumI7Ux3GzU8KZxq+hlMr9YyCLJSvsIaTH6ovK5u/Zq2R4MatwG8YKJluddzpvqJFmi JlxwcfENM+HcytAyqR9OuCZc6k505D+3lx21qUYmKN0KMhc5cW8ycRBaVD9G96Dz8Zd8 6Ayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K324ELS+U0NPHo+PBbu6mrc1yyehUYHOAGZ9L/16Prg=; b=n55IkN2o0MbOU4C9UZD2VYe+Rzc8uLJkVcsnIm0ec9+oWKhQYlQDTgxjs/eA2IAqh9 zr/MrCZqKPWH40y0BvMnQihNY58WA6aFLSUut0Dg8FAV4B1fJMgIbraK2Wy87D57SsV/ CE8pGQ64L1Eloh8CozbtM6P1YV9hMSPiyq1I14K29cyTIGSfXsAu1ysn9x9ZXrK18HFD Qczxn5ATEqLMlM7NfU0if8fZN5ny3RrY96WZyvwMFef+cBmBF8+IwqxNs2g7Xult8Yjd yZuSgrwDxhWlbVv6s/Y8j0gIYDW1GkV55K5TCmoHUrXDPaWdjMCOuFRMt5g7vPGtJkfJ AGqQ== X-Gm-Message-State: AOAM533lDi1VypAAcAA0n2YxwGmhMC6wwG+wTj5SNKUYFC85fmXLrGkk y/MoC/VlqHBH/tcx3qqkDY7eDcGX X-Google-Smtp-Source: ABdhPJyJUpPS383nasjGFFCNre9qe6D4+YSaFUh4R/hmONWHJLN/BlmTGkn2SkaWtkLU4EYBSUPPXg== X-Received: by 2002:a2e:9643:: with SMTP id z3mr797487ljh.282.1596610739368; Tue, 04 Aug 2020 23:58:59 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id x4sm481695ljd.34.2020.08.04.23.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2020 23:58:58 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH uhttpd] ubus: rename JSON-RPC format related functions Date: Wed, 5 Aug 2020 08:58:45 +0200 Message-Id: <20200805065845.18269-1-zajec5@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_025902_419773_3A09EBE7 X-CRM114-Status: GOOD ( 13.35 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:243 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [zajec5[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [zajec5[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Jo-Philipp Wich Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki Use "_json_rpc_" in their names so it's clear they are related to the JSON-RPC format. This cleans up code a bit and will allow adding more formats in the future. Signed-off-by: Rafał Miłecki Acked-by: Jo-Philipp Wich --- ubus.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ubus.c b/ubus.c index 062e973..c22e07a 100644 --- a/ubus.c +++ b/ubus.c @@ -189,7 +189,7 @@ static void uh_ubus_send_response(struct client *cl) return ops->request_done(cl); } -static void uh_ubus_init_response(struct client *cl) +static void uh_ubus_init_json_rpc_response(struct client *cl) { struct dispatch_ubus *du = &cl->dispatch.ubus; struct json_object *obj = du->jsobj_cur, *obj2 = NULL; @@ -205,11 +205,11 @@ static void uh_ubus_init_response(struct client *cl) blobmsg_add_field(&buf, BLOBMSG_TYPE_UNSPEC, "id", NULL, 0); } -static void uh_ubus_json_error(struct client *cl, enum rpc_error type) +static void uh_ubus_json_rpc_error(struct client *cl, enum rpc_error type) { void *c; - uh_ubus_init_response(cl); + uh_ubus_init_json_rpc_response(cl); c = blobmsg_open_table(&buf, "error"); blobmsg_add_u32(&buf, "code", json_errors[type].code); blobmsg_add_string(&buf, "message", json_errors[type].msg); @@ -235,7 +235,7 @@ uh_ubus_request_cb(struct ubus_request *req, int ret) int rem; uloop_timeout_cancel(&du->timeout); - uh_ubus_init_response(cl); + uh_ubus_init_json_rpc_response(cl); r = blobmsg_open_array(&buf, "result"); blobmsg_add_u32(&buf, "", ret); blob_for_each_attr(cur, du->buf.head, rem) @@ -251,7 +251,7 @@ uh_ubus_timeout_cb(struct uloop_timeout *timeout) struct client *cl = container_of(du, struct client, dispatch.ubus); ubus_abort_request(ctx, &du->req); - uh_ubus_json_error(cl, ERROR_TIMEOUT); + uh_ubus_json_rpc_error(cl, ERROR_TIMEOUT); } static void uh_ubus_close_fds(struct client *cl) @@ -283,7 +283,7 @@ static void uh_ubus_request_free(struct client *cl) static void uh_ubus_single_error(struct client *cl, enum rpc_error type) { uh_ubus_send_header(cl); - uh_ubus_json_error(cl, type); + uh_ubus_json_rpc_error(cl, type); ops->request_done(cl); } @@ -298,7 +298,7 @@ static void uh_ubus_send_request(struct client *cl, const char *sid, struct blob blob_buf_init(&req, 0); blobmsg_for_each_attr(cur, args, rem) { if (!strcmp(blobmsg_name(cur), "ubus_rpc_session")) - return uh_ubus_json_error(cl, ERROR_PARAMS); + return uh_ubus_json_rpc_error(cl, ERROR_PARAMS); blobmsg_add_blob(&req, cur); } @@ -308,7 +308,7 @@ static void uh_ubus_send_request(struct client *cl, const char *sid, struct blob memset(&du->req, 0, sizeof(du->req)); ret = ubus_invoke_async(ctx, du->obj, du->func, req.head, &du->req); if (ret) - return uh_ubus_json_error(cl, ERROR_INTERNAL); + return uh_ubus_json_rpc_error(cl, ERROR_INTERNAL); du->req.data_cb = uh_ubus_request_data_cb; du->req.complete_cb = uh_ubus_request_cb; @@ -401,7 +401,7 @@ static void uh_ubus_send_list(struct client *cl, struct blob_attr *params) uh_client_unref(cl); - uh_ubus_init_response(cl); + uh_ubus_init_json_rpc_response(cl); blobmsg_add_blob(&buf, blob_data(data.buf->head)); uh_ubus_send_response(cl); } @@ -564,7 +564,7 @@ static void uh_ubus_handle_request_object(struct client *cl, struct json_object } error: - uh_ubus_json_error(cl, err); + uh_ubus_json_rpc_error(cl, err); out: if (data.params) free(data.params);