From patchwork Mon Nov 20 15:54:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=OzIa1jie; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33a; helo=mail-wm1-x33a.google.com; envelope-from=swupdate+bncbaabbwec52vamgqec43cghy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33a.google.com (mail-wm1-x33a.google.com [IPv6:2a00:1450:4864:20::33a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY4xFFz1ySR for ; Tue, 21 Nov 2023 02:55:08 +1100 (AEDT) Received: by mail-wm1-x33a.google.com with SMTP id 5b1f17b1804b1-408597a1ae3sf14281415e9.0 for ; Mon, 20 Nov 2023 07:55:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495705; cv=pass; d=google.com; s=arc-20160816; b=buo9uFS5q0JEA6TR7hkKjh6HUr8P8qvvecCF/xBdoNZsCQGAgi1UtA//zGxzBHGy83 UzdFzpBXCl3S1rLzK5I3uGebgkP5lRnMN0bxTFQmOkmihGGs41HhGOuPyn8qW7pLzS6V qd7Y+E+s5XJeWfPBuGDkNRC+TeVRb2NW8szzg/iRXAaH7ZXyhcvk6CiuCJuqWxPuXx3g vQ9GX1cjhqpuFBT1TxSiyEjY6uVP2YbYT+T4UFVQfP4IEhXBnQZp9GD1EYpf9VVYdwQ9 LR7yio4kpYF+Il9pAmKl2BWonlx4o5MKXq5m7kecHWrcS1fiQUIyrWQAqul8rmlcLLtb Gapg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=2K7So9w+GxUaZjlvcfTyPKQRHmdQSL4U+cuCNgWBvME=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Il8iMfCIHJI4GHpwDMoozJ0IJ/xjhtLqLXffbwFuuDLEnfN2ebTDehfa4X6/qMdEfS 9qrP5INPx1X4uCO+jTDGD4JUrSpKMrcSd6iT1pgBtSMGGwg/rFtMI5nzLUNTNTipR6ig 2yI9c1C0JJxkU0BOfWGJ2BL1c6iTCc7qMnD0wKCLv3uTMvqYaxKWDLal0TgYuK7WZdcZ I5jeyMPwuJnOf9oTSiVIS5oX3nMEIQqRDdKpOeu0blgHJ//EWXXCNz2bxwydfgDSI61A hAHQEG1eQpGX9hcHOi6C5YCSucyJAjKWa+9Ppf77Z+HU70itgty28mGUxxlrysm34dhL zo0w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495705; x=1701100505; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=2K7So9w+GxUaZjlvcfTyPKQRHmdQSL4U+cuCNgWBvME=; b=OzIa1jieF7c44LXZXfaQKZmxeh3y//PhDzKm9AUe33gp9YqrLtSNSTMoUJ/2L428e4 Akeogj2fEzdNvcVklnCpmEpQjDy9Pbik+DiJuWaA9QRK77gUvSG86ZJWTTF8MXxAIIyR 8eitCHpzPSq6WkO3CJwTTN3tAOazdbPWOkz8OYLc/xtiRcA7GD/tvsR1w5eJSn3Sci56 BIYj8k8xJrFitn3NqOggEFTo2KVa320H1wJUiN73JzN/chTR46v85DCguhryhID0yHMx wz6C+IeWJ3tDdH6AtSlSjlEbzEFl+fWv0lIMN1aq92Y9T6QVLE7brGrzfRBitWlyeZuf lPYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495705; x=1701100505; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=2K7So9w+GxUaZjlvcfTyPKQRHmdQSL4U+cuCNgWBvME=; b=M5XsnMWmqs/NRo/DzJVh9UTDotaM5x1pbv+4QBf1U3M4ISeku4R0YXrAzAPpjD69M1 evgVSZhLAV7i8Tl7FO2QuuK01vJH5N/34C5jREHOXBrkQP/IkZDZvYME9cLOsrO9WFC9 6SNlNVAnSeId0F9zFeCiqoExaJK6HmKfygkn5JSOjE2pUJRn1TmYi5iHL/y5FWW2F5nU pLmNSFHNLcXDzaVU0XovFzblCSo9ZRsbthjkKrV4kVAZwk5gPOXcMgzamTYfncREEPoA gaiHG8sECHNJhK2GVvjUd+dRWRQXYBOXq/WoRp6a8saPgGv9vQKKmO5ye17QloyFkL3s qFjQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yx8ocq0R8IBSD5VqXXAtvJSNVKrSbFFzZPPmCpqCAnFA3hWgOm0 tqpaea2OHffFUyFMg2ariGo= X-Google-Smtp-Source: AGHT+IEiorisbOhJgJPhzQdutHWPav7aqH8gdrPw003kUMGARJcqApOjlBokqF6mjIcaiBRmwsSQjQ== X-Received: by 2002:a05:600c:4f14:b0:406:f833:d853 with SMTP id l20-20020a05600c4f1400b00406f833d853mr5017626wmq.15.1700495705050; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:3ac6:b0:40a:4830:8045 with SMTP id d6-20020a05600c3ac600b0040a48308045ls1007475wms.1.-pod-prod-06-eu; Mon, 20 Nov 2023 07:55:02 -0800 (PST) X-Received: by 2002:a05:600c:1d28:b0:407:3630:f35 with SMTP id l40-20020a05600c1d2800b0040736300f35mr5126911wms.9.1700495702336; Mon, 20 Nov 2023 07:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495702; cv=none; d=google.com; s=arc-20160816; b=K0BlsQw2+/vs9LjJf4l1TiPXGlCTtI7xEL/rJlCdJiOte73Hwia5bom1COaY3qf6BD 5iQsIsxMIQmb1U0LsapxrJsyH3CCjqBT9Aw1q89eg0Nwe2G8ju5g7mAmt3JGDYoavxyQ NvqFtS+W0TTKEDqpEMdFtqhRE0donPqHLfI2t0MBdjmvTMRpY10Qsaa04JYebDMoVIeF KKGPGBcdB2mVib6biAOpn4cZgPGIrHyJE2ls+9tFdE/jLgQLHhEG0rwqWt5PmHDJRywm NeJ9njmCf2E7bpD+iCScpIIjORlyfefTB3yE5NpmZCVTtj6kvtLQPYV3TV3j3B6jM0Ns z0FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=YVNtL+pUJ6dYJem9s4vrppUgXXZSb3A6rNDxXFlGB8o=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Urm7vVaTPUV2oZo7Gf3HxmbapyZoxsXfiVqv4lpTpbNt/0saTBaik0H+kqVxiQkEBo WRdvNNjSZCOiIqrc6TklrKYiD60iE4fwLssG0R8HjrJYWKwQFdqdVPhNwRVr8CqQC3Bc yTG3S/bi1K1LvMwRuGDFIuh+2vUCxUyDNAbb3lQyTlr3fmuDBMMM1iOQmgxOkTDAMvr3 HTKZ/L0nEjrUHWvZbkK6k1ebfYTnUhH65pBT+v4pwKF924vMsi0aVXueaBu/38zQf0yI ewOx/gxR9IABZiKv/mF0K3fubCBtqXNJTupKc4+IuYvIrxtdY0FGaDLaDSirWruZiANj 8meA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.75]) by gmr-mx.google.com with ESMTPS id c6-20020a05600c0a4600b0040a441dd5e1si682206wmq.1.2023.11.20.07.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:02 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) client-ip=217.72.192.75; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MAfQk-1rBkSb3iIq-00B03E; Mon, 20 Nov 2023 16:55:01 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 01/13] curl: add support for Unix Domain Socket Date: Mon, 20 Nov 2023 16:54:47 +0100 Message-Id: <20231120155459.45188-2-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:wvpQW6c7eGi/6+IpWWFnbYqBPYYMpqH3F/viQJPjpFf5zgVTomY JwB/y/ptPgyssRWY9+capnOeNwSUQFqCcGhWPIZ6/qWYB+C5JL/I8FhX2SalauaTmRSbUQu TfFoRsl4/urNXPkH8ZzlY9ow3XBpRxLZzFgdZ4zX+WoC7XlMLaFa7estEguV7aMrNHE0GvN gOLfWfokElwSeIuR12AWA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:1uZr+OrAE0c=;+vcPH92FLh3e1OiTwwQ6Zplc11Z wC9rVu1tqFfwAqR8LjUtkwkEhZ/pCP3N91vc5MI3JicTcV9HRiMsPFgR0nq235tZ8I+ZBmWB/ LxlHBfOv8N7myP6U/isdj+frfPebTcQ99hP2AfJ+SFkJO2eAl+98qnWhyBuUG8tNr/DbaOnb6 ieFHM66Vw4XcNZIyxe40H12z067E520lY+Fo9zW+kHrZArZqrpFr6DUlrNd2dJxksQrEY5/lD RlHhERjnoHLq5mImfMehRqPl8ek1GSE72kzH5uOaHukz+0aePGZ/Ofz9edC8idzbvCZBzFV7T 2cfY+IIN96NJFcKZaVZWS/Cx8EfnnECmaf5aKh+TUut2Dfv+gGrRXebiw4Znb4wRnhVLZc9qC EeiatZ/iyvCoPm++P/kIzL00kcBf6wmoyEZNcvSF2k6mwbYtx16OHSQ3lMNC4OwhWfC+zir/z TaHmp/VVXX9/EfI+D5w2ZF6qNQOQo2KVSDo/hFSJJWOnhGc+S+nAfVz7zNXdJ3WQzAyI2lqFC /89fZXZnjaV49LsWaYiY2JLrr85PH5e+GcPXXnFQlyuPy2zvHvHHmx/pQkMdpPRjc296apDMB cLMVutfEg91qs+9v/gpeJq7do8ZJkwgl7mVv3arSKcGHdvg5bJcSksdg2bbfFnUXY3GkDNmga 3WPfCXiKyc7jOnXwsbRNtdcNCMIUJs0iVHBi05PxHkeR2YJpB+9VekRulucaSASZ6nU4s0QbA oxPkg4ECJeDJcoU0rWKXcV9GSpC1oIgR3YyHgb8jbZJryr9Tu3nsRvJMN7X427f8LR2Qy//xr VZsrA8HGrMz2jVPZaTbXRgtiQcfMq7mOJUOMSDyv7fDOCZ/+U9DzPjFacHMwvl3fRTbrpWYMW syOOp6giSNImyRrBBE0O6bBWEXlsxmKaP0Qk= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Set configuration for communication via Unix Domain Socket (UDS). This can be used for many communications running locally on the target device. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 10 ++++++++++ include/channel_curl.h | 1 + 2 files changed, 11 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index c411aa8a..8ab0eca3 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -605,6 +605,16 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da goto cleanup; } + /* + * If connection is via unix socket, set it + */ + if (channel_data->unix_socket && + (curl_easy_setopt(channel_curl->handle, CURLOPT_UNIX_SOCKET_PATH, + channel_data->unix_socket) != CURLE_OK)) { + result = CHANNEL_EINIT; + goto cleanup; + } + /* Check if sslkey or sslcert strings contains a pkcs11 URI * and set curl engine and types accordingly */ diff --git a/include/channel_curl.h b/include/channel_curl.h index 643082b1..1eefbb1c 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -36,6 +36,7 @@ typedef enum { typedef struct { char *url; + char *unix_socket; char *cached_file; char *auth; char *request_body; From patchwork Mon Nov 20 15:54:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=r4r2/kJK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbaabbwec52vamgqec43cghy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY4zSHz1ySV for ; Tue, 21 Nov 2023 02:55:08 +1100 (AEDT) Received: by mail-lj1-x237.google.com with SMTP id 38308e7fff4ca-2c50255b905sf43648801fa.0 for ; Mon, 20 Nov 2023 07:55:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495705; cv=pass; d=google.com; s=arc-20160816; b=Hb0COUy+cyzFch15Crggt4uuZ+KzmMevBSXd4rGNyd97bTI0StXlnSGHbPpdAPIFyz s2PrY1dKY+WSNrFWiLDUl1xd5N9r9QY4HJXjbrl20GAW2QAC7fNPn2trm2Xxu6B+E8Fg vojZtGkpJ9TJxUc66bh+9KldryREB2h3UhFXI1BdKlAEocnDeNPgFatxKFuJghvpZ4mR IPtb/EP+iJ4sfI9E//+SNyVZJNcQ1uei7HAlvwGThLCPwsKMSnW/y+gM60RkBZ8N1nVQ 3Cvx7X7mRmESR++Eh80yx6s9uXctr6ju64uU8JcOwHgGqzUPSGGhOOhlC2rsGJ04s+cs ivyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=r5ClAwEkv8YMP58HvrUo9X3vaETe790crrofIkSoO74=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=AazS57H+BuuzstYYm+ed0hgVNusIl+0rJTY5w81XXyIdRafPc3F7/xNQ6UGn5F8YyV qXTtLWAD0yeQMNYmgApxZ6fp9RMazqNsRXju/TwgSB3FJCcYAJz9n9EWN9GigU2Uh5Xc 56oUhCX7hipfEvY5lGYEiMprPqQXJIQjm+snwPgouea/CcIDnDrvMiI6cjXk84JfiKE4 c3KyFG24tGjFS9WyoqHLCab5WGYC6Cc5yg9k3KYnuQIdZ+5GmChLlisueNDWNZ3fIcV7 WRbNhm7MR6hGJcECA9RxKoq7aDvdf39jBUAXPiZdnwrR/H4zTviL33TcpuukU4jbjmhf Qcdw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495705; x=1701100505; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=r5ClAwEkv8YMP58HvrUo9X3vaETe790crrofIkSoO74=; b=r4r2/kJKcRiLbcKfo0ordlGOWdeN1oMnPTZjeLgMmG/XQbBsWxiFbK/o5KtGGDOGOv W6xc3oZBEXU7qsr9pfi6O14rZoAVFnvqQalgsBj0Ki/EUl863ADYeW130iZPYorC6JBi ioko5VpLAPVeiRzcmpFSs5KE7MNCXbBatmoNmxmoWqhzHyFYcPoKPnrqG3wYvAvNXGoG izJaxNSVCOJqV0/nEqX//aqhjb1/5t/rYKcx5frITAcNx3OZgpcW2Gl7V99F0d+KgCii 42xNBCGiRwZlBzTEuhQkELlWI6lrvPlb8XTqTY5nDCGu32iOwTb2oF66VbqgEZVetGif yjbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495705; x=1701100505; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=r5ClAwEkv8YMP58HvrUo9X3vaETe790crrofIkSoO74=; b=Sj+KFrMIJQ94/V99HJxjaB2lx3bsvExiifpCxhQKyWU+qXp9RhDwiXj2//4YSsJZD/ NYvQLgaeatjjKmGzCw1HaxGQJtBasLqYcXfd0lsJtdBBw/QhR7p4/jlJR99OuSAWYgQ6 woSTLHN4NsNYS2lFaGHeiaZXTX9cCU3E3LdHgQHsn/iz2kfDsL6HOF5aZW5QgI7tfr4L ZoT+G57ImT30OYhRprUfnqVfzfTlc0uZ6quwo6KamzO0xRLOcPbG8IXB1KYiF2Iv/2Wu X6/PAvR095rJ3KTDfnU3KqnFQbP2brod3vUgHKOK6KulUKNjIvO8D36VhQhEIJBBZ+vt cLvw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YySxvx0m9EYJaYjLwLgHIbv9T6QOT0RDsfRPe/4qWxcCvBX8eVG RVkC6D9BriD0VEfl1EClBgs= X-Google-Smtp-Source: AGHT+IHX8V+HBkFCT6IiiC3gMiozI/fys1M6G2IctG5MAHj+RJ1avYBWQb3Q2dnyXEYic8LGBu1W/w== X-Received: by 2002:a19:7018:0:b0:507:bb8e:b644 with SMTP id h24-20020a197018000000b00507bb8eb644mr5349236lfc.12.1700495705322; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aa7:c705:0:b0:543:7afc:7035 with SMTP id i5-20020aa7c705000000b005437afc7035ls87606edq.0.-pod-prod-07-eu; Mon, 20 Nov 2023 07:55:03 -0800 (PST) X-Received: by 2002:a05:6402:70e:b0:540:77f8:240 with SMTP id w14-20020a056402070e00b0054077f80240mr5086214edx.14.1700495702758; Mon, 20 Nov 2023 07:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495702; cv=none; d=google.com; s=arc-20160816; b=EurNXfU82KZ70La30getwi2/ZjcMV0rIaRN4lQDkjaK08QejN0EX8YV9NYWA6jn8Dj d7dYy0VAfxRMPACGebBGRsFJwjTmNv8dvCNsSzyBfMEMq9GL7pbhV0AEuuUv1g/n9h1v Lus4BfAjVO0vQrJ4WSsaiZRu0QB4F+Wm9PF9qErjRo0m/v3yM9s2BA/byO5mDFOhKyj2 Iw+80qOmM9qFDz35XoSMLt6q5cORTluyhILdcBtpp2q9Mn1k9m9Q8sw5fUNq/lEmNYWy otVhDVKpQDQWckD8IdZjpt22NcudNplCMPeB5Vnr7HK7D1C9MEGMF1+6aIOhYE+zm8Ws mdDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=i0TZLEHPcCjlA/pG7s0HUWwLs1MYlqLHvXLC0Jky9mE=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=j2hbiJfZqLU6+kYhjXe8VsNZxSWp8wM5ziI9O4Yzh2UGFUBbogs15TK52HnWOmqdB+ ekoYA8kFKu8VFsnh2esMQz+o8pZmQCO994gMT2EYJc1jKXZY0YFniv7t+DcuKVLXu0US Mn1ofHKMM2CTGTRvZj6/m5x4B7DeF2GQCq7ZI6ufSeB2AxKM3WL/583GUguXWJ5BWPJg yMTC/ghSEQb1Lg+zin/dGqgaS79rKMIAOifbtc6rchEBLhgDAVAZqBR4nxGg94Aqv+Da a5hxIggIXXhB0SmgUzOTemVMGdtnel+vfj98MiPEVjaa3xAsCkn+me8G/NFi7Ptxj7Lw 7FMA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.74]) by gmr-mx.google.com with ESMTPS id f8-20020a056402194800b0054359279646si337736edz.3.2023.11.20.07.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:02 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) client-ip=217.72.192.74; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MGi6m-1r90dA1HOc-00DmGo; Mon, 20 Nov 2023 16:55:02 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 03/13] channel_curl: rename put_read_callback to read_callback Date: Mon, 20 Nov 2023 16:54:49 +0100 Message-Id: <20231120155459.45188-4-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:QRGZFcDyFJpzePlyHK5YNhV5b6DX5XF42BrQidcFg1zE/decRgb 3siQa0efxMsSpIRFjHB/lGzavYnN9LHdrLzWroiN2zYJ2oMN7O0GtkWd8WUb2F9iWf5036X 52I9IRLz2KasF5MGGhOjs+CO9XoxghuUzmzDrfz/7irKYci+6cr7Tq7qpRU0w9JOjH789oE D640mNu6zDpRMJGug3GAw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:zb/oDlXj4hQ=;YDcWdHBFBKJmisLG4uoYi+XsozY GFtCunD8GFu5U/MiohaCrpyhRCcZaJGvQaI7W0wGTmId+3sUVDBYnFKjEejV2qJv81DvEd83u VKCHTWmW8L0XcdX4y9GsEGmlUzDlN4mWQ0q1uMf6FfRnRYEKAV21sJ8YXOuEqC57lf5VNS0SG bsZTiHAFQZXsvqcHUydEvIFk6ihtoZpWxqnd8EBwC36s9JVxbRHVt/fe7zH5Z1dG5OcidOBTh XA8IkEFehgaTvvZ7U4yPvCnz0mu6kThAV3VQkvKWaWWEjqbDlBdrr4HlM4q7nmZb7mtQ9a+ER mBTpsY4Fgfi8XC6r8WLvNcwlQqZkjmpnXi2wVe/bLo6yIHtFk3BSjLEKssq31Qu+M9MSkCYnO BPBbMd2aJ38N99hP4tMrlDE/YtBQ1EQpOyqZPGitzqurkpxSDKmdyih5hi2BOkKIH/HQXzZnN mlHQpZsj7ghtKokJtlD2mEhGz/7takO+h1Bp6AuOVpDpFYC7QLfoQUZZNv60YtNPyqJBJUOjb tirix0DHXY3Tgla5KfNeAVZVgODacWQyvnnEZElLFeaof9ex3DAEU3/oNGJ2ZHULq9Rxmt/eq Brcp59C2M45ytqS8PHZt8Y6rI+tW7pmK3+O9zHiLirYBteGx4IA6fwyMy7oBgxc9nxvPmvLX+ 4d7NdAAFauOUJn9Ab2O+VW5ZPWlt4jiz5DgI1DsCa4wT3VAiHQePpI9jioWhNLC+e2XZ/uDJ/ vGAabyX57oNyj6W642MDOH7PFaLEzjZCPBbWoF4DiIDvlMYvAnQyFzUpSNhqbLxAmsgIhFS9f whVGd/pQ6oh4ce7TAhEw8+uMBwgdFyxSdoBYGfFlorurOoWzWmWn+fPyLt5HrPNxTNKO42wfX +9YWGqOoQkhUcwLTzoJJu5nG8oWKVVeQtL9I= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The callback should be generic because it could be called even by other methods and not just in case of "PUT". Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 9842d7a5..2da49ce3 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -888,7 +888,7 @@ cleanup: return result; } -static size_t put_read_callback(void *ptr, size_t size, size_t nmemb, void *data) +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *data) { channel_data_t *channel_data = (channel_data_t *)data; unsigned int bytes; @@ -1041,7 +1041,7 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data, int met CURLOPT_PUT, #endif 1L) || - curl_easy_setopt(channel_curl->handle, CURLOPT_READFUNCTION, put_read_callback) || + curl_easy_setopt(channel_curl->handle, CURLOPT_READFUNCTION, read_callback) || curl_easy_setopt(channel_curl->handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)strlen(channel_data->request_body)) || curl_easy_setopt(channel_curl->handle, CURLOPT_READDATA, channel_data); From patchwork Mon Nov 20 15:54:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=wDdqB3ZN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbaabbwec52vamgqec43cghy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY4z6Jz1yST for ; Tue, 21 Nov 2023 02:55:08 +1100 (AEDT) Received: by mail-wm1-x33b.google.com with SMTP id 5b1f17b1804b1-408374a3d6bsf12893335e9.0 for ; Mon, 20 Nov 2023 07:55:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495705; cv=pass; d=google.com; s=arc-20160816; b=dZ3vHA0XtNS5EILuNtzua/vYiNB9vJB0a7L3RoXDbYhgj7oplRoEcny/I0KQeoHqV1 wWdxU+dnvLANLeLTRzwn4lZPw7ReNlenPewkB4gljvI9LkGFQ5vjzPCBMlz9HSDyou/w p7XcOhDWIWD5uThH6sn4eSpVBUqNwsyssUUoIjaxYJgIGmbQgyW5NmFGf+ExOXcu4auy lPVkEtvYYCw1Ye4aXd/o0mQ1ld1c4seOe6jWC8+T+UI3nIIv3YjvYPKPeanMMs1ax+EG tqXDf29D8gPKSy0Vw0qosN/WZpDIOCrNsh18+5yEhlS10vGIgE7DN7023+25/13vC7AJ 5eTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=X81UBqQGJSg7WsQXGjvO4rKw4mRl/BSWyG8YS3MwOUc=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=BTB04kw/rrlkT37UZdIox1fAhdzgm2a1/7rwTNcBdHQIArbFLXlP1IydzMGOsC5Zm2 pknm/yDPFp5s+l/+hf7mdc1dU63BVm8xtdmagnEdPJj7canSUhhB54exN3jAwU/SOGst 82WREK6umbXONju+gvlYT0XoefGl2K3B2VR6mY3HAKOgDQh5+7bcNzTQc/9UHI6BNLTU u49DBZUatRk/t2y8i/1pke8JA+FPOPKVD1lMxaykDTmAVaO4XuJ+/VMoAt50wCufew0H nqwzk/HY3GxLt4F7IDnAgpq2EPjGJ3//M2jaXjKHD8WnOqi9xJEz0hTzH1TzSUaA1gr3 mBZw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495705; x=1701100505; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=X81UBqQGJSg7WsQXGjvO4rKw4mRl/BSWyG8YS3MwOUc=; b=wDdqB3ZNIGqaO43eSbH9vmu9E4pR+zkGCk+fxbwJhy2Yc448P1HYIn8aVft/Smj7l6 K+1Tcc1N98/v4OSIMT4aMlP8XxhKBB0hxSBDXmq2rXMQccSLkn2gSwVEw63iM77japfz Y43XN+IZ7oWoBZcyfyDViJsw69wid5Mer5H13LpQ3EXOkzt5cpDuCGp5Y4ojdFLB8Rur WBNcHO87yRXj4sWAK03BCJmY2DGuzt1bkWGkNKxZAkka+c70i4ZDoGH7pJv4yPXxmSGM mcn+x8aAyFCEYmjvooOpENEHAxvYixpw40eegcV4aKCO9zAvsJq8j1vAfC1Sd/y3DKKf 2ASQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495705; x=1701100505; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=X81UBqQGJSg7WsQXGjvO4rKw4mRl/BSWyG8YS3MwOUc=; b=NB5IwwVDD9YoNN7ZdFQI+FC4ZThPlivjj1YsGhdpKC+smxQ5sgV4QoAkjaaBrf0V3J vyb1f0Dc6IjQv1s37XNTTU2vEhTru1ZuVEHcKlvODsScy7fzk96yb5AineFMWnLkt20A Gopu6kgGwuFDh8HSvIP5xwilDro8MpPwyUgJys2bmo5q1rXexaljiaB0rb2EuYljBEfZ zpkrejgR1XYEIqNRm35YZe4UYco1EBfhlwPErUozpJ7WRH6NAMqpHRXdAH+MYoUw8qkT Bxifv8TFKHOn692SwFi5t3nHrpZBIYcWnhWxfLWbUNwCRrZuHGh2ou9tU+KWaPLaqKCw OH/g== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YzAe5XkQULrAxnIreoHIe7BFkh4ZAd10B4y8QIlllXCEBj4dyRo ypctbTDWE0O4eXfA/jrf81U= X-Google-Smtp-Source: AGHT+IELdxTpQmQNISwLp6z4CGxUDpXRmbRjzX61V7HYPyYbep46nC4gfHdkypu2WbEwAwfpFU3JbA== X-Received: by 2002:a05:600c:1c0a:b0:408:59d4:f3c4 with SMTP id j10-20020a05600c1c0a00b0040859d4f3c4mr7403895wms.10.1700495704687; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:3147:b0:40a:7784:bcd1 with SMTP id h7-20020a05600c314700b0040a7784bcd1ls202595wmo.0.-pod-prod-05-eu; Mon, 20 Nov 2023 07:55:03 -0800 (PST) X-Received: by 2002:adf:cd91:0:b0:32d:a495:a9b7 with SMTP id q17-20020adfcd91000000b0032da495a9b7mr4207282wrj.61.1700495703114; Mon, 20 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495703; cv=none; d=google.com; s=arc-20160816; b=qD/9UkaQL+qlrCQ1BJjE05jPESRdl6VDZJ8B6Gtkpiv+Fq8nl+TfKKjPaMO0sb6VBE 90MbTLQ7TYNoUmBk0OxW0HOuXSebAsDsvR0S2F0LJ9LioPQzgbfqyHBQtS/pDvGqgFjS vQFZWdNOjEE+P7eftU5sP1ENMDXbqISlml0ycZgwyoF1tkzzvXNJrats9EX/ae0pzrlJ svl5RtQ7a4wCkUxOXOSVv7iLyxl6KvONewzVuMH2s/kFu7nB+R61FJbgLJsHSlo9t9IJ SsxQGx9ZGg3NDNQgesVOi+nwdxzB1W8CkktBCzCS/qusrAxlAVJi/6NDYyyYYyC3/kaB qt3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=InRETLdaQ/PX5ezYwJS65Da4eWdxNMsUtRPNDJQWeo0=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=NW7AWJWOC7xzvAFuDN88C/fHlA/r2qW11ogJbwomzWGyGsSMIOT6IM5l/xNp9NaXtn ZCd2ymWaYEBZbQ8o4jN40fSNgAmw6TsSmNO9q1ufeibMMGBy6KM6YM8uGkoQKekk+uq0 H7PTZkZ1AihfuAxBF/vQpNMvX8/G2CIz3E1DTclYaeBhERMZoMBRLwBXKuzri+uWwwpr 2BZaEPMYYaL7GGM0whkFEE0J+0fnb2B4MvrX2OoFFbfqEW8M+rBBOEFUzsXYqQM9P4KI FwBMG1Zx8Ng5ssIu1uw6ibguuva94LPoN0CiFg8yfm47Y2RB2fDDlor4Vli9kSRlF/nI xu7w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.73]) by gmr-mx.google.com with ESMTPS id p2-20020a5d68c2000000b00332cc5c485csi16799wrw.3.2023.11.20.07.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) client-ip=217.72.192.73; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MUokB-1qw8Jj2ZKD-00QkYL; Mon, 20 Nov 2023 16:55:02 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 05/13] channel_curl: add fifo to read callback Date: Mon, 20 Nov 2023 16:54:51 +0100 Message-Id: <20231120155459.45188-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:NARbalNmrk8JjgccRQ8/6luMhmVZeSQXteDr+tYWkn0SMDl3geV eAuw4/jJy092Jii1bSiVKo2qIdlOcuhu5A5s1Bvn30eodyZvLkGNAjC8N1OxcuLxu8q2BLe M68pZF7sKWc6igj0K3UI4BA7AEWT0CSTMSWrXTaksOnvHSIKNLoD/NSFYiQ0ZplfFcKqa43 qx8uL7B6SLYpp6aol1ivQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:sTVYXWLUzSQ=;Zk7slkQvZ7LWrrJJngkFGgRJvEg k+1dmfhdryrVsGLSNYpm8IUG/5aJsy0Qiu1sMLdgVJrfFHWz1GIcYXGqlCEMlGGd8jU86fmhR KvjxQT4FMyWMqWXeWasYbNZdxtaDvwQqttS4xnqkOZoZb7CuU4FYpwX/5OQ8Sj1EpWvzJd2MD c1JJWnToV3XatSvQraHLgYa5BE+ExmVkyZdDV31J3W0aPPrsV8b1BWj+KclJiTJQecwBYbOFy Kt49l907ngoKFiOS5HEhlLxh0dqOZOjs6F4o4mp1OXXbVKIyB1VTZKZyOUd2GVt8g8J23p/0v zaOU755iuqsSRoL7/CIl35MILPx/erlIclF2bASXxZEiLMpjsyLj1OMOLc2moCz6E5CzWtTVe Wdl280UI/r0nnT/Ld/EytKr5/9I5VM9wZqk99jdLlMmW0Wnvij76YXDxSJax+rtzYExCaTBtq z14eOA0bQVcn3jB4V+KUtSl4jRfnZy1AVIq01+me0V9vWy2r3QiI1q2ld4Ka6P9TCzeJBMqR3 9HP39oe01r64/3iEUrAtb4C/bdyQcqvBdvjCoei4yBY+8P0quSaxPrqgsLpw0DRZ+cFYNP5La D2mOJQ00ruDVq+vXGBQ6kBga9xYNdUfk1nUZ5UG+0Jh8AaKWZv70XWSlZaWjb6RdGHqfk2ntD /DJyF7KnSsASfge6TCyxkhcVPKi0WeEcG0x3xfM8+iWRQGb9tYq18nyq7OFz8P1iYxR91xOPp ftWQZp9ITsQSRwXIgGvxtjDNl/aHY0r7ooviPKsThoyba+1y0fhm8ZFs68HTZZ5aqn0QxZ7gl ad14dMCPKkfPXv+TsvY5Dila+rePUqaFyw+lO2Z+ik0+zvA0Go4+rVf4FnXEhGQntZUwt1DPh Xh9/5weBkqzl9q3+nD2zrB+ptEex1qMCipgo= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , In case of upload, the data is read from a buffer that must be allocated and filled by the caller (request_body field in channel_data_t). This is not suitable in case a large amount of data should be upload, for example in case a big image should be transferred. Let the callback to read from a fifo that must be created by the caller. The caller writes then into the FIFO, and the callback consumes the data by reading from the FIFO. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 58 ++++++++++++++++++++++++++++++++---------- include/channel_curl.h | 5 ++++ 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 2da49ce3..4a209bcd 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -891,19 +891,41 @@ cleanup: static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *data) { channel_data_t *channel_data = (channel_data_t *)data; - unsigned int bytes; - size_t n; + ssize_t bytes; + size_t n = 0; + int ret; - /* Check data to be sent */ - bytes = strlen(channel_data->request_body) - channel_data->offs; + /* + * Check if data is stored in a buffer or should be read + * form the input pipe + */ + if (channel_data->request_body) { + /* Check data to be sent */ + bytes = strlen(channel_data->request_body) - channel_data->offs; - if (!bytes) - return 0; + if (!bytes) + return 0; + + n = min(bytes, size * nmemb); - n = min(bytes, size * nmemb); + memcpy(ptr, &channel_data->request_body[channel_data->offs], n); + channel_data->offs += n; + } else { + bytes = nmemb * size; + ret = read(channel_data->read_fifo, ptr, bytes); + if (ret < 0) { + if (errno == EAGAIN) { + TRACE("READ EAGAIN"); + bytes = 0; + } else { + ERROR("Cannot read from FIFO"); + return CURL_READFUNC_ABORT; + } + } else + bytes = ret; - memcpy(ptr, &channel_data->request_body[channel_data->offs], n); - channel_data->offs += n; + n = bytes / nmemb; + } return n; } @@ -992,6 +1014,16 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t return CHANNEL_OK; } +static CURLcode channel_set_read_callback(channel_curl_t *handle, channel_data_t *channel_data) +{ + + return curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_callback) || + (channel_data->request_body ? + curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, + (curl_off_t)strlen(channel_data->request_body)) : 0) || + curl_easy_setopt(handle, CURLOPT_READDATA, channel_data); +} + static channel_op_res_t channel_post_method(channel_t *this, void *data, int method) { channel_curl_t *channel_curl = this->priv; @@ -1031,6 +1063,8 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data, int met curl_result |= curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, channel_data->request_body); + if (channel_data->read_fifo) + curl_result |= channel_set_read_callback(channel_curl->handle, channel_data); break; case CHANNEL_PUT: @@ -1040,11 +1074,7 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data, int met #else CURLOPT_PUT, #endif - 1L) || - curl_easy_setopt(channel_curl->handle, CURLOPT_READFUNCTION, read_callback) || - curl_easy_setopt(channel_curl->handle, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)strlen(channel_data->request_body)) || - curl_easy_setopt(channel_curl->handle, CURLOPT_READDATA, channel_data); + 1L) || channel_set_read_callback(channel_curl->handle, channel_data); break; } diff --git a/include/channel_curl.h b/include/channel_curl.h index 1eefbb1c..bf7a508f 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -68,6 +68,11 @@ typedef struct { bool nofollow; size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb, void *data); + /* + * read_fifo is used as alternative to request_body buffer to push data + * in case of large data. This lets push a stream instead of a buffer. + */ + int read_fifo; size_t (*headers)(char *streamdata, size_t size, size_t nmemb, void *data); struct swupdate_digest *dgst; From patchwork Mon Nov 20 15:54:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=vui+bZK0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::138; helo=mail-lf1-x138.google.com; envelope-from=swupdate+bncbaabbwec52vamgqec43cghy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x138.google.com (mail-lf1-x138.google.com [IPv6:2a00:1450:4864:20::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY5ML0z1ySW for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x138.google.com with SMTP id 2adb3069b0e04-50aa8d9a1a1sf1862151e87.0 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495705; cv=pass; d=google.com; s=arc-20160816; b=cH6TsCtcGsozY9Uiuuvs6Rat3ZD4BLuQiqBX0ZXCFrrL3EXAKUUM63w74Kq1WawtKn k1CG4t0kXfdUZ1T6URZA2B/3JFhkAV1VcpgZm9LqIDwYoE554y87gtMlmXdthZ4ruKFR OQIHhk3dNzwIZ4m9BUOhR/dODT4Arls7qQrV89Q9y7+Pwzbi0wJ4H8aCYDlWfQ8fWmkQ opd9QD+H//tp/s60MYkwN6RQVTQE4A4TG0ZA++nNz+ycgsv0ZrGqa9nknm7zDsw+w45i BUFv8TxyY8YIog8uoH5RiDZM/XFksYUGQ0N40pyjX3qyfgIEHtOiNiGre1RMCbuZvTXf +3vA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=7zjDQtqeVQzCoyKdazcZYy4qeINty3U9SvFqU5krVwk=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=uo2y50zFxfzAGJ1sMC5AiZiCUpIf6HKj4XqfoE8G8S//L+7fNrWmhygSOCJOS5lYBT AsJFvy3C96yEk2dKZsxErWTACf2QWYuqGK0BWcLeVgY3jx5Z2cv2vsI6fmh1JAKu3eGJ Th9MTH8kd19BqZHgd4EYnHGp4UoE5iykHGJmtDVsKerfQfYNVFUAu/wLe8lPhgA6hvvl AXWvrzHUS0u2isE1gIpVR5o7XpQJYkE4HosxL0ZBxiZGve8gik+8IhzYe04rlt3wUudP X/PovasH3K/YybPPa+7J1sMpmgNygbGH+nJu+1NM8S6TNupXGP9AHZx80wgWpPxGCPpi fPgQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495705; x=1701100505; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=7zjDQtqeVQzCoyKdazcZYy4qeINty3U9SvFqU5krVwk=; b=vui+bZK0Cxd/0Y7353k76opn+iOq/gFgVvGYIslUdQdPchzxPq/AFhs3z03Ejdyaqe cAiezUf9MkvbwWuFGQsHcWQIMkw7TmNvI+XJlxNJdLvJG0iDUh15OmYRgbClt+Pt/YYF vgzX+LYeDTosebDG2vW5DTGjieJPRWs5ebxYvuXPR3DgdoBCfG2oOQNu1Q8lLECwbaNo hEijFZr/HQ+33svBcQOlWAsrG0QvY2JlC4KOGsPKSkaYMN9WSFYUD5b7H5B/EWtVvGfK LaDPn+IaEXCQLQ758LwkE54AmqSCJ6yCZHHHdotFIwCmg8O45OjfO6fKdcXNS2PS/+z7 uOYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495705; x=1701100505; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=7zjDQtqeVQzCoyKdazcZYy4qeINty3U9SvFqU5krVwk=; b=mwUFnVgENhdJmff428n6PSEMJv9EdqmzSAGrnkWCmQAq0pW6YAXrD7E+RlyTAe+uRu qVAuZJxXDP3MOjZLMzpGRfYSi6bahpSJcczgWBasacenKIT8aklikpZ9QazB2SYYoT7j /MiYOTech5bOEkvkPeLNNf0q8Xd9BTWO2sWoOtu2Mjo3FmLn7JyStphvnsAK4Y8EEq/b nkavQfgjisdL/vm3dipXQQilR+G6cTK7Y/WZhXhU2BmncNwEYwtSkvF59SXg84/ymo9J YloWdZYT/FHMyLP2cxc0PNmKFOz0JVE+4wzlyxnqfuAAuVgB0gxU2wAxleenpLJfPDAi RH7A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YzRFh5IG6hiDUqxltIxB+Zt+Q+BFCzEXOi89Q9sAhERnKMCHrXk 6k05jwMLeWuVlU/R+ASLvXE= X-Google-Smtp-Source: AGHT+IGzEKuHaDtrgprFi4cw0BBSuyKlwkuhxPaj30NLaA5/7FIkzl4tp91YRM9xgiHlMVhas9GVfA== X-Received: by 2002:a05:6512:1252:b0:50a:a720:141b with SMTP id fb18-20020a056512125200b0050aa720141bmr5994671lfb.31.1700495705376; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3d09:b0:50a:aa99:28a6 with SMTP id d9-20020a0565123d0900b0050aaa9928a6ls251679lfv.0.-pod-prod-09-eu; Mon, 20 Nov 2023 07:55:03 -0800 (PST) X-Received: by 2002:a19:f010:0:b0:505:8075:7c10 with SMTP id p16-20020a19f010000000b0050580757c10mr5703093lfc.25.1700495703576; Mon, 20 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495703; cv=none; d=google.com; s=arc-20160816; b=AHzgJ7AYrX4D9vtKGMJ/oGUTXLX7OGXS90c++SMpwcc44QRX1V0qQ4iIjlDAHgX0Lk H+W1quGvRlKZr8zTzjMyX23b+58FOYJmtFe2QGzQFVs47oIuzhIilSHsyQUJIMopt59j jJZQzG/6dO3dCOAPsk1wD3cYPn14hG9Bf+yHkXO/X7BqAyIMnz755u7raua1MPk26r6L uFHpSz1N4yPIpVZB+1aOpBO0I3AKsbwWQL/tURDfHIwGw9CaRIevb1YwOZN+sP6bzJQr 656Hwc3FP35S22rkyx6DAi9a5gsrjZfoxnbQV/VHt9aIEyaPSEczLu/4aLgliBgBpR3i 36xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=6R2RmOGTtv2vFpvIcTWoC3QtbTR/aly0bGUDXLPlFCA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=kVfS77azRlS4tB3lTICPKxRXv60bZsgQaU3WbFXVEJalEzyJBdcMK/jhSUV8Rmz9gK alpJHpLfAuaC5PCBLpC1IaR/NqUKEGVqqBrG4eIdH2ROif2I28vYIh9193179WJj2eme QX4FqwKnBiYpsHNN2YIOBwC9gxouR/GMlELzGyENqFXJlrOYBHCZJy3Pp7lBFFtvCNX1 M51T5L7iU8FgBmktQO/5M2L4T8BquPRZ+gkeOQPUpR9HGcARLv6VVshAddihNbGbWfYy bCVD+77PtzABUKuRuiCNaUGHdvsAwP2Yt7yb97K5/9grIxSC8ZMlGSFNyBuzmU9TivHA ODcQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.75]) by gmr-mx.google.com with ESMTPS id o12-20020ac24c4c000000b005056618eed7si282686lfk.4.2023.11.20.07.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) client-ip=217.72.192.75; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MQ5nK-1qjC0U385I-00M7yK; Mon, 20 Nov 2023 16:55:02 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 06/13] channel_curl: add DELETE method Date: Mon, 20 Nov 2023 16:54:52 +0100 Message-Id: <20231120155459.45188-7-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:tIjXdTgUwbg7qNGBSfzUMdlAdhH8TqOuGC5Yb2SvmnmBdO+okTD FxiR7EXO5O1HwGRefdwHNU/+VdQfe0nIvAQAmEWxdzYanCEY5CksNj7GHAl46PLObp3t5H9 7Wh195qd9QxEUEjXn1gYfUHbV1qRZKMGI/YXYykbLVN43olRiIARiypOaVZZxP27WJd18YZ mPOI5qcmUFJfRqSIzxh1w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:KtkGs0SH6K8=;8j2HvbOXOizzuH8ktPYTjlHEW59 /LJ6o1M7qLHHDY8aSHMjMvWiUwi3FrRGM5YIQPQMaz2xz/ARRSKl5V6p4kSXGvW0dqavDXkPJ p9WZGif0jG6F7VXToGmi0zdYEbI2xHBK80U63k98qq9lnqK6OY8jQqjQJsqggaduFjfmtiWPJ /tUf+lltJdsrC4HYTt11wjUUMlLsvG7Z+tzKJ3Qqv3RSdKdEGbAg/XAcO4FB1GNvsM82xuioL Ala8rzEIYkwsLMz6TICyppH/m4luNpGSz2IaUYjwi95600Wgbqn9B8E3DuMei+0B138Lu4eqs IQHDAri6nY3bhJQwzNt7yjcIo4eDj6FwdklZvm+T2DITm20ogR7PJEz9IYp3xN3ugq2OR6VyE 07WNx0/e8OvLcEWdTIroKMzZNv4AyZeraqXs1i+34VNMszBgHd/NJc6sJULRKGb708m519g8d hpgNDppv7kg4g6lv0FGf+DZMX0CI0wIncrxh24qjnN42d1O5ErCWgDKxM5gMfSywEBaaD1fDM q2JL09zm7UT2HoNZf8UcZ2Ww+TimNFKCE1EbZzjsT1Mc5gI1LBD4fWGWsu5CNHtguzxUXSReY Cc3vl6PlnkRPkRfhvKNoKTtnguNNLaX7dzFTtTdoLIWkhP9jKCQnHEZnQi6NCHn3bjZAFlSRw HhAx1jQug/rzUSUe8poM23e1EuG41GmLhByh0wfz4uEDEvQOyHTOBSUXq3mXBeUZi1pIrjkc0 AeqcXn5aZkgOBpuBa9MuYJ1yctmtzt3sxrbzGF/DjLVw+IBzOd5JRFzZJtj3IyP/PUCBpDe6s wyz2cwXzYiMIhfjtgjc7vjhyE1FRk7fI6Lax4AV+K3mPHnY7rehlMReceBDM3DlJ90gQ17Udt 0oHXSDez25a+B60vBoKPcrZ5FLqDepJq5bv0= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- include/channel_curl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/channel_curl.h b/include/channel_curl.h index bf7a508f..25d3602d 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -24,6 +24,7 @@ typedef enum { CHANNEL_POST, CHANNEL_PUT, CHANNEL_PATCH, + CHANNEL_DELETE, } channel_method_t; typedef enum { From patchwork Mon Nov 20 15:54:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=HmhegWgK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13a; helo=mail-lf1-x13a.google.com; envelope-from=swupdate+bncbaabbwmc52vamgqexodzwrq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13a.google.com (mail-lf1-x13a.google.com [IPv6:2a00:1450:4864:20::13a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY6NHPz1ySZ for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x13a.google.com with SMTP id 2adb3069b0e04-5079a8c68c6sf4163720e87.1 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495706; cv=pass; d=google.com; s=arc-20160816; b=O+tH2GljkIcMaZAJxNcdtQpe/6F2kYSgS1OfIM9uCj3/uKCnqZ9W33yCUMH34vAgt2 1TOBsJ+QPzlH7pqBC4OjeB/Sy/mkc+5iGQIQVFVPhciR/tIRoVn4Ko4oLayyhV722pbt 3onVlX8cPtWnHLse61I1o/eFHCFq7XP2Up9WoTsRdaZNVux07TIQ9EHNraQt/l7WzBNW YemH0DZ0nWx+4KBSjA1qZxo5F3nGPmxXp1VbJYYEMWKQhR1k0K1ZyZEKzkrR7T6UNZai HODkYkibBggeXoq/C9OSX43I0KMiyx+IdcG2ZTXNXYymfu0xi3CbmoE9gt53JM3dMImc 2Jdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=bwK5MbS2BkVP5+tuA9jkSl6IebTx5X5XFTcLYUvqexM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=FyL9z6gosbP2xb5+EZS70Oie1TiTbnCBVpeYw1wxT2nd3zSZ9lRpDO2K2d6RvUML8I cbf1Xdj9T49vS9iBtco/8PaQgSezRfyTNHsHf5Zb7X4sKM+A9UXX/+Edelb0Kl0hAfuO Dn14HQB3sRKXrLHHD1YL9cur6j0EiO2uEnpcsyB8X+vxvrAdXBuYdhhcAGHJxZOir397 f4Lhncwkjs++iFBXUBdnnwT8PG9KsDa2XIFdwS/XPX6oDqvrNaP+HJLqe6G5fZLfu5qj fi5ZaXN8rZ9E5GmSbuz3uSaVYSix48jHXTzhXEamx20jtSp7nS0Gs74slCl+/cRJ3BTY LIOw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495706; x=1701100506; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=bwK5MbS2BkVP5+tuA9jkSl6IebTx5X5XFTcLYUvqexM=; b=HmhegWgKQx2GNeut9vHZyOArU8gGqoJMH4JZtqm/raQs6sSbu3YUcH6qDSpXHAztDu 58bZ6dAQEowp/F0rtWX/k4nP3HSif07v97rooVK9Y8pG9+Ul4CZgJt4yRSPy+wXoQGP/ 5E+TAJnPPK+ObfW+TFmoyLyZCCQRDB98UMjp0fJAa83qrwvyqDiAfk7I6Dgonz9+ivma GfLnwpnryNC2jBdfB/EDmjN3/5IqsBGVjcTztAWts52iemsCi5RuojC5g36YiopCPBgw 29sKXmxM247NX7bGMxF/26RKKOYdboXNsQYDSS+03YzqElh/JMlyiUGYt7W2Hza+PVcj 1sfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495706; x=1701100506; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=bwK5MbS2BkVP5+tuA9jkSl6IebTx5X5XFTcLYUvqexM=; b=nuo14Xk/d5t+jE8Uq0+CoY7JuJB0VLIIPYD9KIUT6SfSzcgIZjKOM4FPuhnIBUKtkc FBEmQjfKl5UKg6IMsdAZNkyZFXYf2XZH797Q8U2mPAK8cWwCKUZ9AHEV5Aa977F8kbMY /5yJkMFsV3xjxDRkd+4mDNMx1qgk55fQsY/+b3nj3xNFaBRaeFSXg35agBgX3pOyIAKd dJ4NlPoOweicj+yIEA8herqLCi0SJ+KBzZdzIWqSg5URLcImdqgEbUBDkYUDqWrL+xOO RKbmH0bdQ1n1iNrdDUmooOQ2n13NulXeAMYx9siXVwLGKWusFjcixvOXfAmmFft0XKek Qbug== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YwMGHkdVrcHogZ+BVnv0m2IzwjOseq0SbeFlBsrgCI64iKxoDEy gQYZKwa2YvFqMcYiuyJTRcE= X-Google-Smtp-Source: AGHT+IFt4cS6V7IitG3a8H9vpD/Y5v2rzMqhC2gxA8b3Z+J1q9Kgc9YVKoJqhna93yZdM1InWN4RFQ== X-Received: by 2002:a19:ae11:0:b0:50a:9f28:5efe with SMTP id f17-20020a19ae11000000b0050a9f285efemr6084734lfc.19.1700495705772; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:23a7:b0:50a:a6b2:1d1e with SMTP id c39-20020a05651223a700b0050aa6b21d1els247821lfv.2.-pod-prod-01-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a05:6512:312a:b0:500:99a9:bc40 with SMTP id p10-20020a056512312a00b0050099a9bc40mr5598214lfd.69.1700495703764; Mon, 20 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495703; cv=none; d=google.com; s=arc-20160816; b=R1cmGN5VCz5E++hV6w7HZ5WOk/VkESIeRagRn3mKt15Qap7eHVjwkGz0kSFkmh7p8B MkEyaCVixDurynqtUFbPGU4g63KfgfTYntoo1uOa7wS/dWvMgTmK/aclq/LfA0MwCTUZ bzQkAMTEeNh412u+of6wRFVWZ7xa/qgs6q39zINbKQti5ZPdHmbMmuGnK5hFE5jT5rR1 qYxllLtJQ2MONCnI5UdwQ8X9iGjfhX8VF3qawgvpxA9ypq3eKhs2+ES7szXG/kVl1EjV m4qXEIWNH6d6KA5e2KU5ZYniPUjUBfVq/DjjArtEeflwCkPN39IfrZdjRZ4f1yj829dj EUNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=nWsp7YCL8nvaKFFLXUTSUwYTiN9y1BkkYF/YyamV5W0=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=aAmrpbCvuoTquY4Dl/rXHRSdYQYdlBP97dz2ITMMK4LtbXfUfn2zy/D5084MbO8Ywv 1T05J2wgLST0PtyuItjRD0YLgwVi/clUsv2dWu3MECOSMkh6k+N8Ued6bZ9npNQ6oLEK dX5gz8+Wb1OLE9laRbLwyuPKLQsZX9HdN6zIhUEYaQ2bteZUGIstFqbw1JKn+1uYkmnd rFnIyaHNda50Ts7dkHXWNxukBZ7s0I7HWD+6YC0bHwhV+6xQv8G5Noi96AIAp/MBsNTX ZLaX5xYWbYZMqqA4hXgzCE0arg5e+31td+Fu4ZzbSLy/BLIBWle5WeZc1qKgm0uraUAb ooyQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id br35-20020a056512402300b0050aa8602e82si200873lfb.10.2023.11.20.07.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MRCFu-1qkIT43sVI-00NER2; Mon, 20 Nov 2023 16:55:02 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 07/13] Improve comments in the channel_curl Date: Mon, 20 Nov 2023 16:54:53 +0100 Message-Id: <20231120155459.45188-8-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:ioTl6LFDwcuz/JPE/UOnu1XmlOSD094UE9idZcSFDhnYsFh4Flq UcSoCu7WtdLbZm9zISvV8T7f9SUF++tZSGM7H14T92NkX9lnAhrB5rLBlBXswqoQJwqyUm9 CeJkoyq4Ca0dEedhLkg7c+mgtNVuvACjbUBMS2lyatpnp76ATUzJxNCvzsPYIAHpRLkpL1O Il/Mm9X2YXCK2RmRdIHkg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:AWfsZc6eKEs=;/q4zsdJKzpeS3pVUZipRcVifU3Y //35exo3yeu1SsE28eeHOz1mm3lVho+pa/TmXsz5Q3MFpVHE8hv7SHrtc6IUtbPHVTTcZWg7d bQKYGjr5tCx0y8ypbrmW1H4u1fd2EK+s9Ii68XAQquw6X7h+FLbPMHhi7BgZGPJxirrLV+/zq Iy+2hpHQ/mgyQmyEXvC8rWe6fPcYt0MvpQ+2z9xwMtrFEPCunZ4MpYTdMwpU5sQwVfPpvHwXM XFSmu3fCI2arKAkDMQwVihEGmGlh2lGZZM8bkkutjw9cuugUwHOlMuhIics9QoNgpcyccX4Q3 0qhhov7PQ69XdDdo8n/h+MZHkDeYlyiLZKEJvUR+Y41RBOm02aZEmC+dSD92fJZGhKZlvmmDb +WWPha7k8VbNmK8BbERKbsk7ErqF+dfYzV0zpUQsbB6vT7WmQv2zwJkqHgicpIw0o9umqcupY vUVtshhiIs4whKifebBchYuoyXDRh0USjKjcPB4+ijpq72kHKPx6+pL5DOPEUuJ5vwy6G0tnK BZqjRqZhnlAR/SIRXpsqdtnHiAPp5Geogber2M7oUPJji6tnTAaeiMiY+gU4WwfVAg4XKDDhM nibfIHRgiYHXBLqpo2aGcIAzLeoXX5D0KiME9vwlGTRfRShdaDoeczlf12+QJU6Jf6qqWnXUh h3k/qRQpdUxPtcxjnHx3Su1IT10/nDi/ojURzRCx5Y4brxCgiP4JuNtqYPPlqc/FEDB8dJFFi aKpJJtH69+tNFUPYKW2hEfw1xcu0lZkMNdPa4ZDJOENQZMWLa9OXI949X1qfnUchvt2eJNFT2 n8akpOV+30YV+zYuyniszEffcz66NDHb29I3jjdF95w4pVzY3wWLX8YlV43hTP3cIwwCQewqL KOOD3+cDqLfArD1dkcrgBRmhQP2hNCTpJ+l8= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- include/channel_curl.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/include/channel_curl.h b/include/channel_curl.h index 25d3602d..b1fc65c2 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -12,11 +12,9 @@ #include #include "swupdate_status.h" -/* Curl Channel Implementation Private Header File. +/** Curl Channel Implementation Header File. * - * This is a "private" header for testability, i.e., the declarations and - * definitions herein should be used by code employing the curl channel - * (e.g. server_hawkbit.c) and unit tests only. + * This is the specific channel implementation using libcurl. */ typedef enum { @@ -27,6 +25,10 @@ typedef enum { CHANNEL_DELETE, } channel_method_t; +/* + * format for a response: the channel can just transfer + * or try to parse the answer with a specific format + */ typedef enum { CHANNEL_PARSE_NONE, CHANNEL_PARSE_JSON, @@ -35,13 +37,19 @@ typedef enum { #define USE_PROXY_ENV (char *)0x11 +/* + * Structure to configure the connection and to + * exchange data. + * This is passed to the channel methods (defined in channel.h) + * to set up the connection. + */ typedef struct { - char *url; - char *unix_socket; - char *cached_file; + char *url; /* URL for connection */ + char *unix_socket; /* if set, the UNIX Socket is taken for local connection */ + char *cached_file; /* Retrieve file from cached file before getting from network */ char *auth; - char *request_body; - char *iface; + char *request_body; /* Buffer for the answer */ + char *iface; /* Set a specific interface */ json_object *json_reply; char *raw_reply; bool dry_run; From patchwork Mon Nov 20 15:54:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=jJ6vmIQG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::139; helo=mail-lf1-x139.google.com; envelope-from=swupdate+bncbaabbwmc52vamgqexodzwrq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x139.google.com (mail-lf1-x139.google.com [IPv6:2a00:1450:4864:20::139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY61QDz1ySX for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x139.google.com with SMTP id 2adb3069b0e04-50aa8d9a1a1sf1862170e87.0 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495706; cv=pass; d=google.com; s=arc-20160816; b=ZQO8LEdsYZRGUZEPsiQuRKiss8i4urSqgWtyAj/fK32EwNrO6vw1wrqx56myziXWVz P5AqroNCMwsy6WILfilEi/X5GJgakTOyF/OpoAQMaaU/xETvtDRMzwByN+9q2cjxYn8y iP4mDotaOBDYdsnp76kYCg4H7RO4Ox9AWFj8o360fHId8F2QXV5AQNdFAYVNSlWhn+Jz 6Oqk0U5/olx54bav5qX3c2AYQTwCixC1n/BNZ1dJQu7T0b9igkFnXHTRxqbJ+b4j1dUt rUTDTfShX866qi8q7pseBjhIc6mxZKHU6gflF8CxjGw2pcxhBstaOuSKqEFlkprgY5QO Zp/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=K0edQc6oNw864YfOGZXko2EX8OwBoZJRd92cL4LH1mo=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=GP1SqZjCeb9Kzss0l9c2AiblmkC8fGNuu9Vn5TrSm5ngy8Ck+7mzWnnt8O//lFxs3X HHlE+0JLoZVl8rbFPhOkoQgDNQxvxZqCkiwUr6HuwQWEmElrCibdK7beHFPmQ8W81nNA 3L6n9gOVolISkQu+jTJTnt5w50xgs7n8esAxbP80heJySOj4zHhEDeWojY6G0yCpskYN dkoGlpbq71UbA5okZh2c4R/c37Okx5YXTdb4FbiFTFaj4OhXJ5UU3e0Eo7A+TylnC0lZ SqptOwAOGqVyyZm0zrYU0KgKCR5wbu4DRMDgyGESS8c6cAhOK8OiEfmjZ9n50ZdLnHbZ lJcQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495706; x=1701100506; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=K0edQc6oNw864YfOGZXko2EX8OwBoZJRd92cL4LH1mo=; b=jJ6vmIQG2R3HH5C5o4i0FR8samDAL3pW1ove7fKv/UDLad9kffoD+Ogox+YzYjVdCj 6VOh7hSm4DW82JQ9cZIr/Qbapica9ntS4+TqpSkxmklirGsoxnBE4YYfI26wBS2+1yRK 6T/CoR0TdlHHOEzAVLLTqXzYXPSD9MdkOGIUnjNhXfVzHodFjNp1wF7LjPkHs8UuUPj7 ulGb2PQrCt+VLA0r6zE9+mvYrIf8U9SWnq358ISJAms2UHaOceBTngQAymgM22pGLiBl i6bgrM+bsslxXMDVGvNYWYi6ewWwgYylbisgwX0m1AZFfYm26rrpNIXJGuHU94qdgV9a E+3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495706; x=1701100506; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=K0edQc6oNw864YfOGZXko2EX8OwBoZJRd92cL4LH1mo=; b=wNdIft4/3BKB5ufitd0HKaOpIE1CJgZr8+OtpXyUGJ4slw1kLBHu7Gk7yIhadScI61 int2u4S03xseNu0LJJI2Tw/9lVCrx6ALewm8tvn8bMqtJ9Yi6v9It5dNM6gNcDKcUbpM uE+rWufhiwA/3e024H3o9Wr/fCja+1y4QtncyaKB/rPPN9YfMEFqUnZPm8WoI39Vjotl qP2jhf02G3dRYdIdt4a02YjuEowsFwjHA10Rj34g44mMAIsNBK1YWDuxklXSUGzNK33p hWpUP4ad3RGcUTHRXbmLYu+i0RSUhBkQqbbSXJV7qMounn22fZm5gebzGZxpW3RBuaI1 0CWg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yyb/2vune+YOL81uM9WMdIwTbHbKQvTeP+3LiKmhDK4MRBhwNgM LDgc5Mtw/tlw+yDGHq9l6js= X-Google-Smtp-Source: AGHT+IFEBH3NADrEc5NJhjZTndvoUWjUcDT/pzvFMoIzxi71T8Pmhe0jHyVgSXK+hp7TDikz363esA== X-Received: by 2002:ac2:5a48:0:b0:50a:6f95:3b50 with SMTP id r8-20020ac25a48000000b0050a6f953b50mr5279241lfn.16.1700495705578; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:5290:b0:548:49cf:8459 with SMTP id en16-20020a056402529000b0054849cf8459ls128862edb.0.-pod-prod-09-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a17:906:c791:b0:9fe:42aa:425d with SMTP id cw17-20020a170906c79100b009fe42aa425dmr2622330ejb.76.1700495703671; Mon, 20 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495703; cv=none; d=google.com; s=arc-20160816; b=dLfkw36OCzVf48f+bUQpRPVxe20ZTCt2i0TUOh0BDUUqNHyWiGaAL4JjuMYN7Lrs9F /vHIawZZjBjciXHt+fubCQ/uSp+bc4yzHEElpZF+yVSOF1Q4npIWjV5AMBDUQZr5mS5E 93uIHoZZ1r713KZfW7FLSwxpUQtIfbCj4GDiPbADBkY4w9iCGUpe/P1kEmvgBybDxGV4 O5U/dubt8iP9RiB319E54h1WOFAqkLfE6baxH/cJGI5LW9AJkFPokG9bHtp9q9ILll9a C2jygQ0vfbbU+279l98uS/7gDQkyziCc46X/3otXmdnXsw0fZCVK8VpLDT5c0kXcYaYF WKPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=B/y04mw8nmRXlGmDBM7G9MF/K4gxkeK97an9d4ovR/Y=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=xQu09+UvhZJCPyJ641mzDzZwI7tebudVAc3shZD4oVvhFQD/IB0iNdw5SdBm9GPd9A drcy4BRmeVIVDBlA0DDbLPK8gq/JyO6h8xksSs5gP26EVESVQCcgvhv0Kmft73omJNwt iEVlf044UB+vl/q7pr6GYGgAyxyqB7IPFpRAfJWz3WIKkBhJj6S8tiliq91DWgvGDE03 MCijcwf/4ddVmpUA7yMjh3XFqAWkwj8O6B4PV2QihtMd4GtvzSuU+gD2U0DLVjUUJHWG RYVo8rT6qUIP+mov68b/jEy1YKggG6/aKtH0RnEbsWnnGzocED5ws3GnpehQjJm3vWBS ITmQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.73]) by gmr-mx.google.com with ESMTPS id st1-20020a170907c08100b009f0ec8d7ff6si441377ejc.1.2023.11.20.07.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) client-ip=217.72.192.73; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MFsd7-1r7e7U0GOl-00HLZX; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 08/13] channel API: add a put_file entry point Date: Mon, 20 Nov 2023 16:54:54 +0100 Message-Id: <20231120155459.45188-9-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:n6ZJHlEGY1d5a/K4Bbdj7DA+UOAkpslAuAxNGwMEJE7X/E1ynEv sW/rdPVSFekU5ZKyxuLgEHF6PofyleL+AfHt3u+NjwMUK3GXyqgdigilSeQPups2edx1NEa 3IaKa/70S9V9vTmHPKIbTb/eVWTuIej5eTAiqzdqwdM0xUTued26vMCyfXP46hB1WwA0ZvF zBsMp86YClL3XQJko+Ltw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:JnGh5aIIW0Y=;Y8b0Zsm+KgJO768dm21BwJBuPaN vupgPVT5FTgmhrxdtSkND9/Ac5A29hP0Xz/qZp/Co/JDjly1FZI8EeMZEJPRSDa+8Eb6do9VZ XH27F5e6fU7KXOUbs70ElOawiDcuwNGcIbw0tvXffo7kYvyFL9bID1lt+JzhGpKrPnKozE65z rH1lycTVrsFfDcqoSxNBWMwWryl+eOI/YTLLSd3o5/9xjsJBfmpnmHW54prvyG6wZ08PNi9oz /b5g+Pupbm5KfNOXOjqOn/gMLXiNH4ME/3e2vY21Yyv/pGbKPGQxB5pUHU08S1rSgIssslV+O L2NhPdz7N6THQVWEdVRXVBCIuNhV+K9Wi8W1ZtGC74V008XrpOKuepfRgqydnl1ORVErw6iPk 0chmMLVHHu9odj4kUqPEIZdxnWHZpw1n72QBjcAXtHCMjRRXGhvs8G7L1DI8V8E6MlP0ayGrJ MrqvEQzbuVN+vvsNIlbQfVghbuVNNUDa51nV5CDFVUkuKp1Bp68dN1K+ShXR/9B1Z0j3/3m1x 3sgK4XZk5fwQDaoRXLMc/Ln3u6eTYhVNyLFiTZwxbiiDqTCF5RACO2hoZ3zmuqwGFsMtjJQ7u urfPGwZ+XVXquYyG2hwuc3Ug9K2e3lgE9KiNhme0+5bFZao6iuhZXnlhWZ4Jf9BWxrJkgOXRJ R3Edoml0bNZnKcovYws/2KLYRGg+wJ1tvQ8iChVhUmE+GrS5i/tBJWPtc76IM29ZHw7iIqHeS wxfar91SwEKdwqDWHr13UVIALDMES3mxZu+FDgEvq01wAtICvGLekr3YE1j8PY06PQi6fqYXo wwNX0/gXefhRUGzFVT7R5XgEvQ3lmSxVFAGcJDnNs38lTdkRG1KhVQ7rEIu1oj/FnG76TARE8 VZUgnhJIZD8gQ331v4epauljazSpQNGq4LuA= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add an own entry point to upload large files, letting put to run POST query or to upload just small amount of data. Signed-off-by: Stefano Babic --- include/channel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/channel.h b/include/channel.h index d44b810a..50237d17 100644 --- a/include/channel.h +++ b/include/channel.h @@ -25,6 +25,7 @@ struct channel { channel_op_res_t (*get)(channel_t *this, void *data); channel_op_res_t (*get_file)(channel_t *this, void *data); channel_op_res_t (*put)(channel_t *this, void *data); + channel_op_res_t (*put_file)(channel_t *this, void *data); char *(*get_redirect_url)(channel_t *this); void *priv; }; From patchwork Mon Nov 20 15:54:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=aUROld8E; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13c; helo=mail-lf1-x13c.google.com; envelope-from=swupdate+bncbaabbwmc52vamgqexodzwrq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13c.google.com (mail-lf1-x13c.google.com [IPv6:2a00:1450:4864:20::13c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY61lfz1ySY for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x13c.google.com with SMTP id 2adb3069b0e04-50aa95b5f99sf1993186e87.2 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495706; cv=pass; d=google.com; s=arc-20160816; b=tKJkWGoQqXmWaSvLOGXvh+D3Rj73qfODl37Yn3r+vT/viyBrZwJUA5ewpEQDPQNtni GNkC5NDH6EZWxSOs8j0pwHnst4IsKVeen6QdYHMF7O3H8XdXvuJ5qCuhD2l5KdqV2RG4 iOSoXDOl+baxeo5cXegZHX06yTks3Aan0wFqFSz64dhyc/RXj9qw3VXS4x5/ywp18kFu 7N3t5WlUy56xgKwXZyIIfA4RnU3tI7qz9WXnl6PbLzmnggj1Lb7ry/ijHrv4YNXDY/WE tn8okUVKZGjnXCUzCcP1G7NVOeTSMgL31nDkfQ/cuL6ZPW9Y3ENhIFUevkvSV/GQ3obn YQCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=/Js1CJ/DxlVFwCdT+9bfGKx4ONFJ7k/+leuEBeEIjxw=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=j/a4sU/09E5c1SRJNWvtvDsjwXUPWBwir2dI/nJY0QlGYt/JrwA73H3qv4ncuXJ6Bt xu0DHpnoCuMRuFRykMse8wrwpJocBrsgc7HL/3jZWc0fe7puUn/Qq+X/ktDuS7f5KclU SbblR3izeSad0vdrltWqfxf8gMIYydHfDfz3CwqubiRu6ojJclhGLgZHOQ3Q0+47S74d vSbi9ZckwkeoXK/+Hbzle5hhW4iCCI0Yxs4JjzworOBGRQ88YkcvBYWwd4JvCPeuZ6Io 3FLCTwQm0SL3dQ9BZO0VrWKocJTQa/cVnXZQx/iIsyTCxTS+Dv4vd8aMQ98pH77DerqN 7O6g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495706; x=1701100506; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=/Js1CJ/DxlVFwCdT+9bfGKx4ONFJ7k/+leuEBeEIjxw=; b=aUROld8E14mbQtgVYC+4MdYpUygyYUO2UPXhsysjT1ReFBxM0NbYhPewI263vexyS8 lJ8ScFQUFvJHW8pQL2hEUlN3+Pywl2t1AmmEUzgcEH0wD35Mhf+9l2CJLZoYn0fHlm2Q CxAmIatdR+E49zAVKAUGf88rG3+CpwxTnpOJ7oXpIG2BUCqu+DI5AzT3f7Jb7GsWBFFG g8cZBSITV9mECc3gk2CxUI9sbVxW6CFcSX4ljAP18ShDlDO+0ShDJ+1fJ2eDVbsbF/0S G9PKdWD75rtQShTt7NFOK2y1C+KnK60A44iQL+0PTX96E/hwikeatEOoxJNpqah9v9Oo s+og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495706; x=1701100506; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=/Js1CJ/DxlVFwCdT+9bfGKx4ONFJ7k/+leuEBeEIjxw=; b=Htz8g//taIVIgCQRt2ekNSb29+6dLTNvv/1iT7TG2GFO6L5/2svgyGQUzzA1Qz+qr2 kYuYA9cB6OVJxEUVr3oR1U5/Bl0ErND8wEyZRAMmrTj96DTdWh7HulkXStGncLG0+/gU BFquPcGqmorhrpURMtdKCaaZRy/JATTYGpuVlSTI/w+xGUu3r7+w8Kn5exdw5yZO3eqR tR60LTfUYMTekkvw0x2p6xjE9jvTf7b88qphpFdEqjrQLKLw8O7odaAediuaGai3BzYu elaHCgXd1Ec1rhgT3gyE8His2gtvTMXvp7NDY8shSszvsQSIzJTO4DIORpzlYTKbgCHq 0L0A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YzY09LU33I7pZ81/Fc6mv5Bhu2e/z6N/KYAob2kaoCjKjePi4uL MCIB+q430clcCQ8w2mzA/Pc= X-Google-Smtp-Source: AGHT+IGKniiAJBd9+HeHI7a6mVBaJErxMyNzk1JUzweG9KfokbNTiOA13ZQXH62aB8LCOELqwdPpLA== X-Received: by 2002:ac2:4423:0:b0:502:9fce:b6da with SMTP id w3-20020ac24423000000b005029fceb6damr4995964lfl.21.1700495705939; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:b16:b0:4f9:5599:26a with SMTP id w22-20020a0565120b1600b004f95599026als996299lfu.2.-pod-prod-08-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a05:6512:41e:b0:509:31e6:1de5 with SMTP id u30-20020a056512041e00b0050931e61de5mr5171059lfk.47.1700495703933; Mon, 20 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495703; cv=none; d=google.com; s=arc-20160816; b=iUdFCpNTkYAkT2a3peI9lcM5jmHQXPJXRk6kfN+M4Vrso9D4RxN/X/TpCPSx7Y1Vne Tq4M/twGulsiC8Mye3zgJqIXflq3eETxWDzkBhxmeS7Jz/C74BNAWIKcIPmAW6Wq4vci a7/P+Ug/fC98ymIwLkMWZAW9xoqZr4hyD3d6sGDH7jBmMQCkh+DNLUUzYQF8hRry6owr CWfGe8PX5wUkelfLvBWCIkwHOcIaEkcunh143jazzn4vAFEX2RwvRaY3Nc8Ico+YVcvn gW6rUY5WN9gQmGR8FydBUilms/nn2lIcxTdJqY0aMSMSSHM8FT0I3tHDF3Siq7NRcpVS T+6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=HFuI6g6Vi3xp013LBIDZ7viy7AXQiOwTRCSjNFSWWiM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=pO4q0y9C5giMnFtWyZWj8MUqz/srGRNuYTP/auA45uAnKhL5x1ogr4wzK+jouxsehz r/YogIkf5PWBVtE0c2/uCRve2VY1wGHOUwy2uoO8cZSHwGjGtxdb2tMJniJ6Ky3xGloQ hnFXON6gCJrEZp8gz2UZFQUJPg5/59wOksB5O8dxiH93sOWRzoGlkF/O4Z+uszYOkDds nEaMzWT+Zr2VmqAoXKx4VvwUzJs2Yk5/cDnBPgtoXwcm2sRwh/9/cUIqlFvY70oWc+Oa KFyuo4r1CmRl+o0/2uShCY3r7KfhXLbMC1S22gq3yW5hXPD4J7S4laIWJH06BnyaRmSU LEwA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id f7-20020a05651232c700b005008765a16fsi297489lfg.13.2023.11.20.07.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MGQax-1r8C5K10wv-00GnLB; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 09/13] channel_curl: implement put_file entry point Date: Mon, 20 Nov 2023 16:54:55 +0100 Message-Id: <20231120155459.45188-10-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:iZ79sa1ueT2vrHkJ/Hp1i4bG3AkYDqSP8bQSw8WYHZz4L1FMEko 9xoQYNBdrywLnQushFyQTE+/pz5jQnOQORYJp24DQSzNITGMELu+ABitUjFViN4VyuIOO+g KM1XHJQqauuqvIv1xt1vnLquzRRN3ektV58rVN8tH28U6UwHl/4s60Gm8pJLUfpjNC/mSmN McCcQe/JyKu+UparMndjA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:BfGelg/QMlY=;UuEbM0kzi1sSGjmj/z3h2CWzm0s fioFZcUErLTxaJn9IyIyqOoFMnmuvNll9Nb80QJtirbJxRXi6kEMWH0rtzH8nK/x0PexNdLXY RjfR6U/qr8eGp1Y/MomtflGpj8yms6094+EkjZxXwYMGC9yWWKePyEL6sFiLxDgtaohFPJ4KB zcLyWh7GvDQ8n/CobM+RCtusWxmBFFLXc7128R0RR1lISiDbC92+xxrdTBLGnX1QSB2LsT+vO 7eNgUYA72NsnYlDFq9LvNeR2dDyC8CYR8A1H+uMbVSPynMySFy/2j3F+ivUY7LI/kxG/2yxlD Z9FP2f75OHHc00hwcDrEkWhFvGLyf8dFA+Lt5b17Guip+DHHAfAx93F2TuId5mtd6QXb5nHcb jOEcUao8pgNqHqtQ5hH2jRFtH1AwsbUi836pnxusW09/87VFfJamSoRMrGoOGDPsHvfCzpJ9W TIEw2ds5SGPvHn4sFETo7lg1rqfo09+tOkNp/PXwad79jaZ/hPMwDzP10rWG+bZW/nXa9i/F3 zuFesfE+ywGY2shaVBfZ+VQSLolRSHoM7H5086e/ouDi3MvgmGDnOUpwLQ0/fFLwNvYQ1G/Mv x+Do8v1cLdLKEl6O2zIJTdsstDgor8nqaLPoLn9GWysKSiv+XYsFeKd/stqo4CxgZ/Jo9fa3k TZ7OAGmghPlRs1FVt/JnI80Osl9QltVv9RCR9bFybaBlUcKIk0E4xriTOg/EtGcVnv5jr3ou3 Qi08dX+0bImMTMgUnYH0PAG0SWSmsjUOFWBk3SP0kQuRIPxZpGr5H9ZlUOiBatH1OtsbyfgVW QosX9w7l8uRqWIUlNjtu3KkGZOnXr7Rs7aayGcF4TbYvtTYm5cLi7bjQ7powzeAqJH0KwN03V QX2Q1SS71pPf5UxUznOTKIS5mwuUDU859az0= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Use put_file to upload a file from a stream. Data is read from a fd that must be set by the caller into channel_data_t structure. Caller must set the total amoun t of data that must be uploaded, else libcurl cannot know. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 125 +++++++++++++++++++++++++++++++++++------ include/channel_curl.h | 1 + 2 files changed, 110 insertions(+), 16 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4a209bcd..27b31247 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -86,6 +86,7 @@ static channel_op_res_t channel_open(channel_t *this, void *cfg); static channel_op_res_t channel_get(channel_t *this, void *data); static channel_op_res_t channel_get_file(channel_t *this, void *data); static channel_op_res_t channel_put(channel_t *this, void *data); +static channel_op_res_t channel_put_file(channel_t *this, void *data); channel_op_res_t channel_curl_init(void); channel_t *channel_new(void); @@ -119,6 +120,7 @@ channel_t *channel_new(void) newchan->get = &channel_get; newchan->get_file = &channel_get_file; newchan->put = &channel_put; + newchan->put_file = &channel_put_file; newchan->get_redirect_url = &channel_get_redirect_url; } @@ -888,12 +890,11 @@ cleanup: return result; } -static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *data) +static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *data) { channel_data_t *channel_data = (channel_data_t *)data; - ssize_t bytes; + ssize_t nbytes; size_t n = 0; - int ret; /* * Check if data is stored in a buffer or should be read @@ -901,30 +902,34 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *data) */ if (channel_data->request_body) { /* Check data to be sent */ - bytes = strlen(channel_data->request_body) - channel_data->offs; + nbytes = strlen(channel_data->request_body) - channel_data->offs; - if (!bytes) + if (!nbytes) return 0; - n = min(bytes, size * nmemb); + n = min(nbytes, size * nmemb); memcpy(ptr, &channel_data->request_body[channel_data->offs], n); channel_data->offs += n; } else { - bytes = nmemb * size; - ret = read(channel_data->read_fifo, ptr, bytes); - if (ret < 0) { + if (nmemb * size > channel_data->upload_filesize) + nbytes = channel_data->upload_filesize; + else + nbytes = nmemb * size; + + nbytes = read(channel_data->read_fifo, ptr, nbytes); + if (nbytes < 0) { if (errno == EAGAIN) { TRACE("READ EAGAIN"); - bytes = 0; + nbytes = 0; } else { ERROR("Cannot read from FIFO"); return CURL_READFUNC_ABORT; } - } else - bytes = ret; + } - n = bytes / nmemb; + n = nbytes / size; + channel_data->upload_filesize -= nbytes; } return n; @@ -1018,9 +1023,8 @@ static CURLcode channel_set_read_callback(channel_curl_t *handle, channel_data_t { return curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_callback) || - (channel_data->request_body ? - curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)strlen(channel_data->request_body)) : 0) || + curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, + channel_data->request_body ? (curl_off_t)strlen(channel_data->request_body) : (curl_off_t)channel_data->upload_filesize) || curl_easy_setopt(handle, CURLOPT_READDATA, channel_data); } @@ -1136,6 +1140,95 @@ channel_op_res_t channel_put(channel_t *this, void *data) } } +channel_op_res_t channel_put_file(channel_t *this, void *data) +{ + CURLcode curl_result = CURLE_OK; + channel_curl_t *channel_curl = this->priv; + assert(data != NULL); + assert(channel_curl->handle != NULL); + + channel_op_res_t result = CHANNEL_OK; + channel_data_t *channel_data = (channel_data_t *)data; + channel_data->offs = 0; + output_data_t outdata = {}; + write_callback_t wrdata = { .this = this, .channel_data = channel_data, .outdata = &outdata }; + + if ((result = channel_set_content_type(this, channel_data)) != + CHANNEL_OK) { + ERROR("Set content-type option failed."); + goto cleanup_header; + } + + if ((result = channel_set_options(this, channel_data)) != CHANNEL_OK) { + ERROR("Set channel option failed."); + goto cleanup_header; + } + + if ((result = setup_reply_buffer(channel_curl->handle, &wrdata)) != CHANNEL_OK) { + goto cleanup_header; + } + + if (!channel_data->method) + channel_data->method = CHANNEL_POST; + + switch (channel_data->method) { + case CHANNEL_PATCH: + case CHANNEL_POST: + if (channel_data->method == CHANNEL_PATCH) + curl_result |= curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "PATCH"); + else + curl_result |= curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L); + + break; + + case CHANNEL_PUT: + curl_result |= curl_easy_setopt(channel_curl->handle, + #if LIBCURL_VERSION_NUM >= 0x70C01 + CURLOPT_UPLOAD, + #else + CURLOPT_PUT, + #endif + 1L); + break; + } + + curl_result |= channel_set_read_callback(channel_curl->handle, channel_data); + if (curl_result != CURLE_OK) { + result = CHANNEL_EINIT; + ERROR("Set %s channel method option failed.", method_desc[channel_data->method]); + goto cleanup_header; + } + + CURLcode curlrc = curl_easy_perform(channel_curl->handle); + if (curlrc != CURLE_OK) { + ERROR("Channel %s operation failed (%d): '%s'", method_desc[channel_data->method], curlrc, + curl_easy_strerror(curlrc)); + result = channel_map_curl_error(curlrc); + goto cleanup_header; + } + + channel_log_effective_url(this); + + result = channel_map_http_code(this, &channel_data->http_response_code); + + if (channel_data->nocheckanswer) + goto cleanup_header; + + channel_log_reply(result, channel_data, &outdata); + + if (result == CHANNEL_OK) { + result = parse_reply(channel_data, &outdata); + } + +cleanup_header: + outdata.memory != NULL ? free(outdata.memory) : (void)0; + curl_easy_reset(channel_curl->handle); + curl_slist_free_all(channel_curl->header); + channel_curl->header = NULL; + + return result; +} + channel_op_res_t channel_get_file(channel_t *this, void *data) { channel_curl_t *channel_curl = this->priv; diff --git a/include/channel_curl.h b/include/channel_curl.h index b1fc65c2..b3b51e85 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -90,6 +90,7 @@ typedef struct { struct dict *headers_to_send; struct dict *received_headers; unsigned int max_download_speed; + size_t upload_filesize; char *range; /* Range request for get_file in any */ void *user; } channel_data_t; From patchwork Mon Nov 20 15:54:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=hZ6tehaf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13f; helo=mail-lf1-x13f.google.com; envelope-from=swupdate+bncbaabbwmc52vamgqexodzwrq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13f.google.com (mail-lf1-x13f.google.com [IPv6:2a00:1450:4864:20::13f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXY4xPQz1ySS for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x13f.google.com with SMTP id 2adb3069b0e04-50798a259c7sf4568379e87.1 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495706; cv=pass; d=google.com; s=arc-20160816; b=ez91zDcJkF8wb2XAilg2DTziue0celmMzlhPOixBCKvGBKW4v7XyC3uJxJn9Kk7oiA appZ3l3n2hnrNQZJHc5Sr+rXRJJtwjK69FitS90A8sjRNKqE7skcvZKuhHGAbZtcGlTc Ny3v6RxuD2ZHBEiTFDq0e+Mr0mS3v+G6bKgkpiP1ydofk4K0MaajA8w9wi6KnuftOMMj bQRidffxaSAoqbIKHcRSoBPRDUuiMcf8SXFYEwMN6Y7WpypalelmvbRTmrDaw23zsO6W jMuXfhVLna9HlNNw1c0/vs+WlkbsqJC9arPZGPiZ5omP7xB28mAteh24me/ziKPYD94b 4kPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=pt532cLTZTRu88b5mmPasybRngzlE8St2HKmGmlG7dY=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=qZhac5DEmSqKTqLBi5bhzZ4Wk/bD2JLAS+PfbvS73m8qDwMsL+7cXTmBQCIDh7pVXI 1+xPpJsORr4hL7zSuwBecpLHb13qIZUlGRs6Aur+WwCFj82j51p3MyRGDdQGf8aDMub9 2o22E1uPvfE1f4UJgMKQNkJMGyYNOw/+p2R7HHbwexqV8t7wYIohBdoQX+ILOGnAnR7F Wn8lor4E5RHi5Rddt2jkBH45gutn6rOcwe2wwYEH14rLnhDxx+J/hpTX5nNLq5lGiTD0 VWyRmFHMDrbZfsLeCb51g2TaH1mqsct7QTIQUjLNZBqrUTGOawkORCmsasZeMOGz4Ub8 PZFQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495706; x=1701100506; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=pt532cLTZTRu88b5mmPasybRngzlE8St2HKmGmlG7dY=; b=hZ6tehafUh0tlFUogQSqjuiHvBvv0f0uoCW1cqnagGlpiENqiglun+na1/CkNlwOh3 7FfjCHX52QcNnR/ozNnkoj+XU764bWfuShsm2BRjaNCNAYfHhHA09khh/mauSJkqxuzS YxDPVlvEVSH08RKc/HgiGIAkuEFOt+pv3n7n7lAftPg7JvaRNvTzKKsKzO7xa4BzVW7b +zeHYfDadge34EoXjvISbo0n7NsJyh47nzuTw7TJ5RIHMMJhAmfASsR7qB4N4c59nqlh 7L6c2h2EAqUcrzQPC2aRnfJI1BubK1VI9UaIdrgf+bvyKHsPbLYM0NV5LJM7ChFxoaIx 93Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495706; x=1701100506; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=pt532cLTZTRu88b5mmPasybRngzlE8St2HKmGmlG7dY=; b=Y/Xl2IlVrGjuJvgJKJgiIq1x4a/X34XACZ4Bvsc+BehRrHFKXPrOaCvw/yfyjyvwwY Hhvf9Ni6Svi+o47RN3ec6e60uyoya+55KZEVLgr5l7p6mVZ5rylRVDjr5m7LF0xmPTA/ WvqsANHknTT3elkeEXPoTrjTZ4g5k2dwVClj3LpWXy+Sxg4kLEuaa8TJOguVCFqCHdo0 dMNiZoz0beOyNV94sDcQmZSjfjDC+Szc3yAsPhgH8+T5eX159y1f36wq953OAJYdX+IK IU/RPO55gbrtDuKkZWFRZGOlhw5QBj1g1p+vQ6vBpWaUxkC6uQMJQLfNiH/+wdY2n80I yAxw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YwAfKEpq7QslPDrqrEi7h41WqPg2c2A7fY1+9W+cKTvxin+DlRY sIyURc3AV63YsP/y09n2r7A= X-Google-Smtp-Source: AGHT+IHCBjUJfwWeGgbmFUHtDFWpkR7UWHTW/WRS9soUe29sLX4KtirRSbDlWlTpsEGD3zK2oBmpwA== X-Received: by 2002:ac2:52a4:0:b0:503:26bc:b08f with SMTP id r4-20020ac252a4000000b0050326bcb08fmr5501186lfm.24.1700495705761; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:104c:b0:503:7ac:19f3 with SMTP id c12-20020a056512104c00b0050307ac19f3ls174722lfb.0.-pod-prod-07-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a19:c511:0:b0:50a:2720:eac2 with SMTP id w17-20020a19c511000000b0050a2720eac2mr5795096lfe.4.1700495704109; Mon, 20 Nov 2023 07:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495704; cv=none; d=google.com; s=arc-20160816; b=b6U1slHkVJnZG3jtl4HyEt7m6H4WYq0sWxqzs0zWXwGgrJncy0GZ5uRAO/TYMWJEyJ U7gb/bg1L/Grg0UkfMtwv6e6NgYXTbmqWrfoIN37ekDwqe6NtOnQNblQAxVQF90ZH4i8 s9JXxeZfLxAl39xVE794f9oHBxlG8g0OI9sPEv6XWoenRFsxpmtsYMCv8OrN6wW6y6/Y TqOJjB3xJh6TF8daVZkFntFVFfCElIpzbz0i8JqRHE2ODLIs3OJN6QzSuiPriQZ7QBw3 Gn03v93T/szifEgduI7+7x/a3a8ZMybai12mh959QOMhEUvn+4Dcvmgo0AVrBhTQ8u7f G8mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=F0IibJoGfiGx2ml21Dh86y8XBgm0rpPLEDwUJ6FFd9c=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=nlfVAHTbHTemyTa30JPk6fg90RQM9VbK0txjjiVHB5Dw4Os3aYZcVBLzZS4yv77dT2 i0qP7JMuOun3fbp7Kn9h2ES2RtIF0V0dWM7dEY8po1+YmKTk9WS6fl71QtfGYHOVLWHA x3yJO7bOLZFS+aMA9gMwUp2HICNBDxwRpasNYit8NKhZm2VvRGAU1F90aJpy21/fKLuK 8s8MFUh7Ac/wEiK5Aj55CF1xDS1Cw0x0frjaQbP6067KtqthRq3r97eHAR3jNuQqmNvk GM/jRQ/IwqdtIimvcRFqBQ+iTB1dqppyuubNCdoJj10hTRmDXcl562i2oQqhp48vKfyh qnZw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id fb13-20020a056512124d00b0050a72e696casi308634lfb.6.2023.11.20.07.55.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M6lxY-1qz5Wz1a6Y-008J9C; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 10/13] channel_curl: allow different content-type for send and receive Date: Mon, 20 Nov 2023 16:54:56 +0100 Message-Id: <20231120155459.45188-11-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:gaOz7wQ8PBZD1kvXaes1MKzCP/5COFN6G/z6emFFWjeX+tdQ2TA sn/45/1DBfTBI9VTg5lDw/KAXeHzxXUTopK3bjsZ2i9P59d7+2p2O3KBTzHyct8S4vpd+JP d61a+9IthgiGR1GCkQusVQmqnE2HcR5J6MR3KSPNborWmEGAC2pI1fTOzTbwlnW92gl7Ejt AUOaia23dVByD8nrT24ww== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ImVCYQej3Kc=;VlCMW0H0AeVRkz9HEhhZb/9YaKw 5nXwawPq1tVr8if3aZ06AmUBf+/KnndQ/7ufP5W2WC0i3bAjnOb/m7DDybfS8K0tgWsPzRPLI 4MZMzk+nGrLRFadnQ6YNLtUL2WM+ksZfczMrUKbN1rYDT3JAI6Xc1sre+Y1maQlXGszmRhY04 9pqNj3ZyAur0G6xQg+KwlnXWUR5/aOSM5OhTwC7Ic0OHLZ7N+QLyvbbgfRjUOsRXmVKAdv/OU mfng3CNvyRv1h1il+bsK7c7tgnUA8NzRQ6looV7wkzjWjSOyHs03m29zRpP0macXi+7yZIOwE U6AbN6uiuwpFIKy7mkebjaSk0j0JQH57rZDn3FGOUc/zSKOvj2B2kX6O9/7WRbYUVv3rwXE42 oDCImJ6RWI8S18w3+X+EmoT+2Dr0+3OHT8tCVIf0OiYpl8ajhnuhxoBlP0VcUrFYhM69XuZzk QHX7yRtK5T7yWoBIkq6Frgp83CJuaV8SKYAhz/ALJA22YGdojlmuiaELwVSZ5OT49/e+NgmeY 0tEOJ+RThh/bSbgtnqtE7DOrjLY8eslJ/bDeOhiB6vYIcRFh7pGY/mCcoy1gKBWOoplohuNfp E929azu4IXbQyChLzfXEUWVxMkt9wWMbM5kF6/X20dOEb9I4nak84BG4NglmKcnuyEGy8UGL5 WCN8qTvzFGcUS36S8PHNQh/sVRvAA3ut6CAQTDxY0Z4wJ5NwRZsqi1lNU2ym6AOHDXtUV6U9F 5voPxJmTa6kbBrfFs7OTsv5G3PVcoLqMMBAWpqVst0MiTY7CnhYymHnk7k/a+ZfhbzkcaXxFm 6UJcHY+3C+OHIWBzPh4eMSIaH5oeee5nfup4QptOuye9uq6tKKaV3Cm1ZhI9GPX0Nq2Go/VSj yWV84Dv5rGoyP8CdcAV+J0PuCIUPm7moNugE= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Allow to have different content-type. This can happen when a file is uploaded, and the server answers with a message about the status. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 2 ++ include/channel_curl.h | 1 + 2 files changed, 3 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 27b31247..4ac089b8 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -547,6 +547,8 @@ static channel_op_res_t channel_set_content_type(channel_t *this, } } + if (channel_data->accept_content_type) + content = channel_data->accept_content_type; if (ENOMEM_ASPRINTF == asprintf(&accept, "Accept: %s", content)) { ERROR("OOM when setting Accept."); result = CHANNEL_EINIT; diff --git a/include/channel_curl.h b/include/channel_curl.h index b3b51e85..b346a6c5 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -61,6 +61,7 @@ typedef struct { char *info; char *auth_token; const char *content_type; + const char *accept_content_type; unsigned int retry_sleep; unsigned int offs; unsigned int method; From patchwork Mon Nov 20 15:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=iitIrhIn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbaabbwmc52vamgqexodzwrq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXZ3tC2z1ySc for ; Tue, 21 Nov 2023 02:55:10 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id 38308e7fff4ca-2c871ce22cbsf22333801fa.1 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495706; cv=pass; d=google.com; s=arc-20160816; b=hYQp0E4mvV//pR3Z46V8Ua88YXkN+Gb4PrHmHvfuEUtkmYQHlXLBM5PPvVYSrVIE/e N1xSt27mVkq2BaX84knSJgj4Jqqm4LUZ53rh5piRNE9KqyBeSM1nrcpZjPq6LX5hyrY0 4Ijz4iH7HVUbpB3dwQRv9si36ChjMrqkLzTD4FK54y3JsUC1tjJLkASt63SFFndah2h9 ef7QZOn53gssEZbqVAIsYEN5l2DkoVj0g8IfqM/4odSKL9z9V5nIkGE+VkT+oBIFwdag ijwEd68bbsRMOQy4AZ5vJxfkmianJVhvMOHZ8BT14WuzJluB7+4A3QM8Fyu4Y/kfVs3X 7icw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=4vb+8XWjzGBCCabNpdOhy8kWpJTVyBjLHOpAdvf04hQ=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=JOlarRj6+c5pcqQTu0MilH0pmrHtIo6j0IMt9H1mHZUFMGU9TicnMG4h3illZac87h yvIq1YYhKwRm9tVtpWkdBUfrOSOw/jLBWyLC4UHRp/5gdu8iUKbq8+L3JHhSTIQkqPKf 6IhXKju07AFr3JSGCcuj19+JaRjnfq0W5J51+fWLrmKaZcclQPG43VX49wGl1hiYl99V 5IbiwH+HwKkAcmTo0o/m4BfnBdWsD9gdEgSvaI2dkR8USuiJ3hZzHh+VuAYbeASYT4CB iit01+XHZeHcW9SnTTQz23Lx+icCHwPOhAIHqp4TejUChuIlC5Km70Me5D8IloNWBHpJ Vi8A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495706; x=1701100506; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=4vb+8XWjzGBCCabNpdOhy8kWpJTVyBjLHOpAdvf04hQ=; b=iitIrhInmsTwT8eBBki7Jz/nyMkEkEF5KTFwq2cz9ko/OiJvz0JWNExXN6KkI/Fcb3 kFhLmAFGbBWl/WHVI9+TM+KL9aS/5WD6WV8opCh/4Y/zUBLb5NBdNSAN6jYsnJrccODN x8TGkXdR68bzSpsKEviDT6OY0utCEhwfjhkFMSLGovMwMFbUa4bZaj+d82f3vBoDZ7Mi 8KX/B3PLYMJK1VD3pwOSwHjDpmZb6EvgvCtlotUijgRs9QeF5FulC7gTqLd2nTlpNS3W hkaB4ZIs7133pAjcOY6mJNBwuxWnUsLomc21BybHtObwhXeNM3A5biCl+kG2cO7ONWXb qPKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495706; x=1701100506; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=4vb+8XWjzGBCCabNpdOhy8kWpJTVyBjLHOpAdvf04hQ=; b=FihUk1r6FILEQ+gEatpR6yhTPRNJCo4lHfbHbQVO5C3dD/S6eILJ8opKcwTtf25kko 535sqCQjFxu3jQ9JhVBT1kU1IT/iHKzfjVVEvlE8Hmx4Y6hfMZWz3BeSCvnV80uBreKi 8u4A4CdgbEWBuTHIaaMdXJFPkFPrhLuKurTBn2X8w/rsmJd/zMOIyTRuPC3nxMEMTeOX dcuQuOxEPdzOZvyMnnCU78/7jEMFL3pVV4U4DF4kCWcChus48/k4Qx2ir9CNzTzNiwMV d1218trLFDVIIHeUxYyTFpV4yW7UrKPt6jd7E4CUeA+viY/1ddvx1rEcGIXzjGMKF1x9 5RmQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YwVVOXklpD3dPJVRmqJEIvtLYsnWk82u44/vR5Oann2jAUoZ6eJ 7hWegMC7zmGK51b8UpqFNR8= X-Google-Smtp-Source: AGHT+IHgcUc8cddOLqcNg9iJqnuEM4oW3N5dAgIOuBGC0nLx8jXufCGJ06xpIvjvV9zS7YcyDMJHHA== X-Received: by 2002:a2e:5314:0:b0:2c5:106f:5416 with SMTP id h20-20020a2e5314000000b002c5106f5416mr4427909ljb.53.1700495706314; Mon, 20 Nov 2023 07:55:06 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:b554:0:b0:2c8:7654:1e42 with SMTP id a20-20020a2eb554000000b002c876541e42ls32243ljn.1.-pod-prod-05-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a05:651c:311:b0:2c5:5926:de4c with SMTP id a17-20020a05651c031100b002c55926de4cmr4800275ljp.32.1700495704231; Mon, 20 Nov 2023 07:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495704; cv=none; d=google.com; s=arc-20160816; b=nKQ+j5/Pl7yYW/Igyh3LQNimpv/lVAlFJVpMiA95m9+BE/rnim6fNOwXILPGvU+JCJ 0dsl7qDNeQMxcQ+F7cdQMebIhVq5FG5T4qwzc+pOqD4dv/Bo3uhQhuLRMZfmWCKEr6q9 /Vznxiu2bpxGT9iTK1sKch1kzezwoRy8DEqokYG8PlfXWf1XmnZap8FIn9xWEukEOHiB jpkVpN2JF/XrRVDO1n++hYd503AgjDgN+4wVlorl3UxSTZLI8InVrfAMoRkN8AI5DdwR 8peHpXejwMxHywDqT+1nnGyWyQmfuwVdGmpYT/3WWG18fsBql54r92zGZCmTwUwpLz96 lOKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=WauT0gt4QCYJYbLao+0kT14oOoodRjvqFgFmJNKJCEc=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=B9l3AcX+0kkxnefOgGcNjoMNaR37raHoDpMsGuPi490HlhMb+OTKWw4hBDmgTn0xsr iHNlfUBAxYyYinFD0XU3t3FC0auA7xRphpzb4SoqUXcn62El8WWVU4g9FaVXp0D+PyPb NxnDVrbHmAe1hlWhWdzBP3lfE84X5LYUN0G6DMZXDHRAMLSeoqVS720zS0HwPB8AztpF nk0M40R+9WEGUcMbwbZb9PvPi3JF7xMMeiREMZF1KlWOgoxbysUYAFBIAFxQ5s/Zx16A PtuOgCadaXrXSp/dgPmkwDzWQNdzTAPXZSJJPpaFLKWt5PfUb5E9Z185cTLKeF6LnZ18 jEfw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.75]) by gmr-mx.google.com with ESMTPS id e16-20020a05651c151000b002c820f71e0bsi56775ljf.5.2023.11.20.07.55.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) client-ip=217.72.192.75; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N7iKq-1rQXW12Dic-014mSo; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 11/13] channel_curl: implement DELETE as part of put Date: Mon, 20 Nov 2023 16:54:57 +0100 Message-Id: <20231120155459.45188-12-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:nsfH7DitYSBmRaqo2evOIuLglgCiAEyjlP5b/O4FHl3xGiouUv9 Xtj1YptLJ1LkUiGSdz/m8/mio3/63MPfoK+lUUFAco88LjKdhTQuqnS4Ge1mb20OhiQ6Qo2 RzCFKUSulq5Efbi3nKX2adF86KXzJtnqKDfBo7xF7HK+J3fdsnunMmifNFjupY3/LckytfR ctFLXcZjJxWwJ4eh06rXQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:MFDY8jEhsGo=;tfRy5oSdOoO2gmomzeEZE46e+ws bw6/P1ln57EFM9eaBc2CpxQ0Ru8QpnhuwCg5TVfMUZwqN9biJDFaP9OpIkNXE1xoXrMSVJQ0C 4cg1hanMigCeWDlvcLiHY6YBaZ8kANnGpDwVojCRsQxFa2Ii/7A2DkmYoCV9bAkb9LTTORYPe QMwzTi1SYH0z7JcYMd/32YxTPEYNuaghtltZMOaKakf/NvQuuhsAO/9/szboXcIRWfF/d45sN qyFa3d5f3EOkJbGsq2IPzqWgSVfPrV+omHh5xleL+sHD0RFAeJxHgmUnBCacyZSTGy7R9wRiR tWtht/ccBOIio5dtuIQ3Z3I7RVn2jrE4mTdjZyx4msuEc51CbZlbE7dxRj5+Vwojvy6wDurWh jI7QbBFM7KD5ZgBE5kiGwjWsvB+IPjqz8ylSmyLPCvaVjIfEqePy7D+43xzW4AVXWrrsw/qBy DbAG3TKlbYrqahWJeFu5RshQUe1/e0lJVcJ26bzvB41FGFOs3VHkigesamvcZZDT5XNdQVTRJ RQmHZ1dslZObdbivhbNBhe+5KUNVGATIEZF6dtPqCClRdscAqkXq1+PMQ/+BQsHcReRRVsJkT KBHfNUTDBElqkIDR+ERxUqeOYevWeEmxpFiC0VItlr4Zm0Iyf+A+ebrySRPouwKi+o5alA08M AIqoS2PJ1LcFWNqeyZpkeT3fYhhIikwandx2i+0c2ziqt2P11Mny92GTm0RH40MWovC3ND8RI 8Bz2cqa4qnUWk473cFF7g0IVOwFmPf3anE12M6sgXZ5xE4TDLZ1sWdnap7W1iyKsxINCwJcNU POh6s7gHMc7FXIp3VmXJgG62P56ioBndgKeICam1LOIZ8/uA7v3DZAkkrgtsvAKerIrhL6k8/ +iGbfmGDAxiXN9g== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Implement the DELETE API and reuse the put entry point by changing the HTTP request. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4ac089b8..c498c666 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1073,6 +1073,10 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data, int met curl_result |= channel_set_read_callback(channel_curl->handle, channel_data); break; + case CHANNEL_DELETE: + curl_result = curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "DELETE"); + break; + case CHANNEL_PUT: curl_result = curl_easy_setopt(channel_curl->handle, #if LIBCURL_VERSION_NUM >= 0x70C01 @@ -1135,6 +1139,7 @@ channel_op_res_t channel_put(channel_t *this, void *data) case CHANNEL_PUT: case CHANNEL_POST: case CHANNEL_PATCH: + case CHANNEL_DELETE: return channel_post_method(this, data, channel_data->method); default: TRACE("Channel method (POST, PUT, PATCH) is not set !"); From patchwork Mon Nov 20 15:54:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866128 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=vx+ZywjO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbaabbwuc52vamgqeirvszjy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXb70T7z1yRg for ; Tue, 21 Nov 2023 02:55:11 +1100 (AEDT) Received: by mail-lj1-x23d.google.com with SMTP id 38308e7fff4ca-2c506abc320sf37161321fa.2 for ; Mon, 20 Nov 2023 07:55:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495708; cv=pass; d=google.com; s=arc-20160816; b=sNRxe1u03p+zkWjvH7zETsAAmJQrQtKEfx8fO7jFC9KYVlXlSFHKKILnAACu5tTd+I Z1CXkeYhY+zZSzmzslVsj3l73XbxekMzhhILo5pQtio6/L93Fz2/i2JRbFfD1O7C9z7I zUtzW4Ym1Y2Teoz+6yhfu1c7THrZ+1la3ulIAoXqq86Hr4RZ9m0oBd2uwQ0Wv9odOIZp f2Xjbrepn0zQJSNYDM22a7XAuBspWTnvbZbYq0ACN53QS6Gq1cr9q1FEcMCS7CNOqECp TOLxBmv2+cpM4BJmWJb68VyhEeEYfc+zwTDrvAQHNzkdzbz6o0d+ckQh0U/t8n/v3Fti XP9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=3cknw1GRLlcnS/eG3Qgso5IPfoehqIB+Fvzil9cDo6g=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=HMbquWrL9KQ2bm3UdQ4+uT4pQV72xSv7FeoJQLADxY45JzS4TcX9Dwr7qLsze0inm+ oiJaiTTJjP7P8Z5QmrZ6TCNeHRyXCaxQPQdNmJsKk5vHRPkjrOiPYZxT0N6x1KBA5EJf BlkqSrdfVMkjqBMOD+XIx3snGTvFOIf0B1BfMpibnRxQ+bwdQq8sxnmLoZNatEhRNr6S Al7Ld+/CUN0NgL7CZzyBNq5rjNW+aSQEStBkrWALRBM1t4mEDHNv7qT7s8qPQNAKyzP2 cgabxq/7XhVuG3D/Et8Q5sAgvzylCfPd+De133UKoITszoMOoRamHZQvSi8+bTmFnjvU vxNw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495708; x=1701100508; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=3cknw1GRLlcnS/eG3Qgso5IPfoehqIB+Fvzil9cDo6g=; b=vx+ZywjO3wMsjeY0IvEqZdevGjak46zlHjomZFmTLgEFr9zdNY2WAM3EiVF9lwRIbT wZxZIg5AVv8wlgJWuA+n380iIrza6UHk3UE4fEHX99Eb+/6l7XeH42UjDHYqBsQHhi+k EMcu2dylQSX55nRoLZNzCM77wF9iqP7MSEorMeXc+YKWg/+bGbbTjPdyuJ3T4UPg00W2 LxR36iPmcaC71nJKPtwZe8Rw2ARl2YV3S98xtC/6Ga9mC+NdXwRp3y0xJkjNopz/z9G2 vVA5VKUZeJK8Xm8D8Z9zZxYeIExVrRnoyTWdM2nk/uuBAcFWbQi+KrrkasnqD3uHTXoQ 9l0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495708; x=1701100508; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=3cknw1GRLlcnS/eG3Qgso5IPfoehqIB+Fvzil9cDo6g=; b=UC2kOWEF80k+IgBM7kApbZ7TLWMC+tXJqWf8LO1J0635aKqQ36d9h/e5cnb15w1TZY VlGPXcRoLuUYqnWTjMSGqds3alwvba9Qxw2ulgUWlmK3KkAx/H2IIFos8ZBgzGDDTEel 3B6ycsoBhUgbS2QSM1ssNx9soCDd+nDyJneqnPOUen6ZehZzIvrWdC7Mrk7GiAr7BLbE w2K2W1PIVpud2Gdvz7oR7EdhXRoxX2tZ5LrUtQTRvf7DMk+eFhl2FnF06U7USfif/4Jb o8vH/MatzLKbuTprb2w6fcNSoTIzzsSq7mzDgA40a2csBBO0DYjbb9ld0nLC1zmlYJBJ 4FFw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yxbs4rh//hmHdalG0681rstMNZlqxI6sm806v34ZAp0zQnIy4ER N0dbWPIrgFxHbxEIb4tWrss= X-Google-Smtp-Source: AGHT+IF3DaV8/r6s06TUaAuHWDyv1s2DD1Vyy4davDgK1LYVmmmf7w35c5WEsOX9WMGYCfK8h8un1Q== X-Received: by 2002:a2e:5013:0:b0:2c5:b583:f167 with SMTP id e19-20020a2e5013000000b002c5b583f167mr5787224ljb.34.1700495707817; Mon, 20 Nov 2023 07:55:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:1181:b0:2c5:12ac:1bb2 with SMTP id w1-20020a05651c118100b002c512ac1bb2ls13630ljo.1.-pod-prod-02-eu; Mon, 20 Nov 2023 07:55:04 -0800 (PST) X-Received: by 2002:a2e:8e32:0:b0:2c8:7665:9ede with SMTP id r18-20020a2e8e32000000b002c876659edemr4084872ljk.19.1700495704330; Mon, 20 Nov 2023 07:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495704; cv=none; d=google.com; s=arc-20160816; b=kAuZyz+7tc0ZVJSALJLgrAKrvmwOBE8o7grgTn1114JGhpf0pXWInwHXqP/n4Ue39K 1gcCE/J/7SG110DRV3GdrKdDKdW6J+KFXLHqwfUrz7xq4Env+wDURhyfpmM93gwoCDaW +/fNi+9lkgoLxKDeoi6jfByyET3ZCKPpon7+0gKqmVQ/yRySidmPiq4e3Tv0tKCHGgix 5hHvqSyap9hW3RHAP95yNUqHmccZgMt9rpCKqfCs9IlknDi2EmYWVJJIpsfynCoUs+8z Y82jJVcne3OK/cwBWaTz+UcBqMDYCcbWNgfeC0zj0L6xj3h3LoT1YJgzPXiNLB60BxhK /4lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=JrM53N56sSyQS5KlyG8U7MizuHWFrdHi6o4aDA5X5RA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=DBQQbredSf8j8bLWgqvOUDIc3wPfC7Ixsdo7kdQzDo5pOm8iqk9/ZFILo0A6XeaUQP PhHfioigAvh5x9vkPBrcXGjEscrSi+JkrpGcVPJBjkMNep9oXtXysk4N5BB5VMIHUKRu wymKA0DD/aXseSPLRaSb79FJgXLn9ncaOcvpsjcXu6lYXNnxWj4QLehvWh8eyZiPD8kg 5hQ7OwoY+xsAl+Ik7EH517oambWAey6Uu9S1eS4k134mNeWIV/OJg+YRfJZIVxfMuWLN eVrE/Aom7mTGccEjPSO87tC0/qZD2URzICrlVFlk6eny1RHxMIkGk5H9zPYga+wp/0io s1JA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id e16-20020a05651c151000b002c820f71e0bsi56776ljf.5.2023.11.20.07.55.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N336J-1rU6gs2nDJ-013Ngr; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 12/13] channel_curl: BUG: endloop if no answer is returned Date: Mon, 20 Nov 2023 16:54:58 +0100 Message-Id: <20231120155459.45188-13-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:O50hTK0RNgdarYbF5hDBgbVF8co90ImCFJwHeOvrfa5KPOq3XkH v74wUgxMpqV20LW+beUm9knYqBMichskjdPAV1uWnjeWwPeHXIy8oX4WXB3l6fg0EELXbzG ++fQGp7uxBge+oiHeN6O513pi+xgO7e3Q9dj82WZRicdFTDj7hV8rKX4ktYW/1Osioza9Jo xc7GOGiAUSkdku0EbPKvQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Mi7BWGQzDP4=;ufs3Vuv4LT18Ju2Oxh/UBmJW0Ax 1SZgaHmfQlFb+8ysWoS5fKoQc5xr43IfhbC4Ol9aA0cXvRdrjNwl3UNl9TlDQXvLwmOyr1lF4 vlJ/VJVwDsA9fqxK3+0UAVUwGCMLJQq+z8o3Tybm30g57Zi9OaKg1PV9mkyXjRBVzZQetJ3/h hWuBRTXWRxFmZELShvpnZxnAJPHZDHhjTTC0rLeGb4yrtUg9ov5nEeIq+Z2a9DIKaG+JtN04b xfLvc2YAZIXMKYkfvCteGdB6jYVuBrqqCqY28aSDmtOuPqWliO7v+/EtFg6Uzvp626ool7hN/ FQZLP2+pvy3rPeVDQn0h3lBMLwarggbP+yAAgI6KdWCb9uvzsguo51SVo2pgkYQ7aGxTTzO1J LWHQ681yqFy9g7zRtLvi4/spfjXl+NoviWFem7Kw6OXUT6Wo6/RaF3w7xo3auSW1/lUOwZc72 fChczbQ8vtzAK/bG5K3qRAwltquXHkJiwIRMAdMdvCcmcWfto82R7RhFbeMMPZI8ZlEaEc31R jGXimqWg3nsOry1NHobVJDDuS7C9Tc2DX6OJI8NrFm66N/XtKwWYHAwVdL80E0hCJUnhdTXfl mBe1T7IsNZmT7Sub23ghjDKdF/mKKNMvhQWTGL3VnfW+LgJHajLvwto3oGLXpVqtWmwXOamlW nl8mUy80ptxpTLa/MLhD6KFXbBJZYrGqcXcAcjjYT1Gwmj9cFAaVpto6elMqlrgoyD2hkaFXm OH5JWaoIso38zGCAJoyOPCm8equzOR3w+UwFuVdh7wCXrIF4Ky5Nbag4T7hCRWSQ59qlPosRb 2tVjHgyZOP5fMKyP+dNuz9vGb3OCGIr7e8uTN3Qfz1SHVN7OB+Shyw+HZqdyRRNtC76Iw7NgK ebw4IEI1VhYu27hcHe/isHhpNZ4jj3BWMl34= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , If there is no answer and the reply is parsed for a JSON message, system remains in an endloop because no JSON error is generated for exiting. Check if there is an answer, and exit from parse_reply in case the buffer is empty. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index c498c666..422109a0 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -988,6 +988,9 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t return CHANNEL_ENOMEM; } + if (!chunk->size) + return CHANNEL_OK; + if (channel_data->format == CHANNEL_PARSE_JSON) { assert(channel_data->json_reply == NULL); enum json_tokener_error json_res; From patchwork Mon Nov 20 15:54:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1866126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=TnyljS+o; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::137; helo=mail-lf1-x137.google.com; envelope-from=swupdate+bncbaabbwuc52vamgqeirvszjy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x137.google.com (mail-lf1-x137.google.com [IPv6:2a00:1450:4864:20::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SYsXZ1r3yz1ySb for ; Tue, 21 Nov 2023 02:55:09 +1100 (AEDT) Received: by mail-lf1-x137.google.com with SMTP id 2adb3069b0e04-50aa6b1bea6sf2249641e87.1 for ; Mon, 20 Nov 2023 07:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700495707; cv=pass; d=google.com; s=arc-20160816; b=fbHiDygfgcDAYKAF1oYA+Bb5joK8+/4fg9f9GCv/VwmZbvXj7vAG+iPoulCgJ5idnx wjRzcm2t+A4Pco4BebJs9hRnGehXW/kSI3mghLDaSeujM03M4xrvqH/NL0EkuERjNyXN EbUYfl4xq/VdBAZ60aV9hYIBk6LR6YDsAA1BkVjUb/RGFDlUNMdGc0sE8qPx5Zrb3s1a iROy2sOkcMwwxibQwF21IIkbczxL9JbInPMgrHQ12dddGjcfb723qzIoy3j3A5uOYFCp zG9uzwHBnbrLECKTo1brI46LAqyb/fYImY7nTJ5StIViqn90PeE72xD0tOVlXylnDI2J BdBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=bsPx/F7wdtUFzX0mwlbJfOthNn74nIkxdpynKHzmK+o=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=kbKbeCqdNHspwIbXwGYB23wGrj8CM7rVMTS3rUp0xygqggEsHtsuDYYNfeorcSgFD1 /bqivo2D8aszmHGB2Duv2zOfJ/Vy9vAkqMBMgANNNvGBnMtvuc0Qyrq1MEhyRmZqkNMg ur8+1/emw8pGINj3KtseLhHAqYbnhkXbUct1Z8JTDLw3LsuxkBB4GakceezXpdXKczX9 6aOoPwnacX3nH9UlMZ9GQsDAtKDj1ii3EYAiAo4rrEzjYl4ZK+3yVdRw5G39njkMA5Xe 2f4a1TDAfGKTUzqr1RJiWPXKMf8ktyLzxLuF/0/8Y9uIxDaEyVPtvBPrqBO1aviDsks6 eRvg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1700495707; x=1701100507; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=bsPx/F7wdtUFzX0mwlbJfOthNn74nIkxdpynKHzmK+o=; b=TnyljS+ogdnp3IDw+j+R31/8iEk4ff0kEoOdJK6RCU0kqrv7OWWgFuxaxB8UzNEQ0c uoh81nCIM/gpdsxhjS/vNzSgQSUsW0YhAsfDRBVKRabf3HgSuLnvTbD1THcmdvZ8BLpe 4x1gXnSeW2CD5KcfZGLod3ELUmPNO8OdjJgiR+tGa4LzxBOYurXauYA7FsVIEfJBuVAS TnsQNpc6zJZI0lA4Fa9rvn9Fp+xaV5Uo22BACw4q0AzqhskVWJ9rFx1zk0uIAVLEbyLf zy/iPJgIuf/q6FnazEvXle4obmZ5EEw4Cq5i30Ps8D2ZucG5oPmmc6onIuL2gUZ+lS18 z0VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700495707; x=1701100507; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=bsPx/F7wdtUFzX0mwlbJfOthNn74nIkxdpynKHzmK+o=; b=A3aJTT42qhNYOGPD0+KdctacsiYi9U+FkS865FuZA+ERRixYUQhcnasSd8Cq37gP0S 9GbFlozUC9qmmiexv56Ct9CjGDVXJK2aBem4HBLp7ZnGAmGGTYnRqS3V1nY3MSlGX8z2 L7QVY1MM5lE5zZhhG2YkVjRpVL0yffe92zlclIhdF9apiQcxRLH9uWWkagqycwXMxr73 6W523K4WijRHi1xvXi2P3UJOjrpp6P/UNTP57vKZxOllciMHnat1l/jRL41NYz2ZVDdZ u6qbGUBwn8gc6q+MVNAXkxCEuCnyA0QL6qTBlMU4LrS8Zyr4UTLR8lQk96ezVDioEpdN +Grg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YxWi+4us2V6nYSwv2fPM7oYqo5qqJ3dNEDzTXvuh0P4n9pS2asF xzG49/HxmZa+Z/HFBZxfIjs= X-Google-Smtp-Source: AGHT+IET9+hNAcg1+yk+IxLjMpzcSuQujEwg3DR6ayAOgjn748oFB/uqYCzJf49iHxZqHVre1nTmFg== X-Received: by 2002:a05:6512:3e1d:b0:500:b2f6:592 with SMTP id i29-20020a0565123e1d00b00500b2f60592mr5862882lfv.50.1700495706658; Mon, 20 Nov 2023 07:55:06 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac2:4c42:0:b0:506:8b0b:f8bb with SMTP id o2-20020ac24c42000000b005068b0bf8bbls995619lfk.0.-pod-prod-08-eu; Mon, 20 Nov 2023 07:55:05 -0800 (PST) X-Received: by 2002:ac2:4f89:0:b0:508:e4b1:a785 with SMTP id z9-20020ac24f89000000b00508e4b1a785mr5318074lfs.62.1700495704628; Mon, 20 Nov 2023 07:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700495704; cv=none; d=google.com; s=arc-20160816; b=ZzkI6eBIHZkP3DzjT8fxsW8YBHKguMTD1XlKTF0xSaIsf7252wJenT081NjwydP0QT Dis+VObWRzg9qxAtuegXG0jAjBYRjm0lI1MXc2LNIol5nQxbd24fPQC+5N21X8dEw6JH 4FkQ9MCTxlRyjJ+ljaX9MXb1kRRPhP1tCECYem5orgYWNaRq1EOELlizJxazivtYsvPV 6agOC1H5tt6JCAyYYK2rDiAV8zkp5ZcMJJyX3TB9IzqN7wr0jejS9wTA1iqmdbVllbp8 PiI0MjW5HSlhnhHOj/3Pa1qaPRRDyHb1pENvyxwUZNCksg9daBWPfJZ3sUms9wWjEXKt +LMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=JDeLlJO5tgJY7MF5dLpl9EMegrrxHcNFMJxWulqbgkA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=E4FiqiSHDC5D2cK7mLnp1l7G7Rs47rNfX5nNfjzvXW2ToW6eaN4DDPIVJw3kkv31lN jIZASmLl+SCX8SHdzeW/22B9G3/dU2cOJx2nvT08T5UwKVtqTHQAEicNB4ezuJbslssr SuXBurEGDck6t1U//qxjAImLKQrRGyZojSh7ipVWBhp96SaHDut//SIla5RuESjxrjx0 z7GD8K+MChFOzeLLL1CHQErWBZ7GhVVdkLPA2BRUod8qVBu1c2GPPwGO1wyJ58lk95bA RSaE4DDOzSiGnhLuUDUByjVi5phNdC8xQcX6LrChSDGpXsFQEuf+uXwdnDvIfTfEJNB5 y37Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id g4-20020a0565123b8400b0050aa77fac93si208953lfv.2.2023.11.20.07.55.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MBltK-1rCqvD3MOS-00C6Vw; Mon, 20 Nov 2023 16:55:03 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 13/13] Add support for docker Date: Mon, 20 Nov 2023 16:54:59 +0100 Message-Id: <20231120155459.45188-14-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120155459.45188-1-stefano.babic@swupdate.org> References: <20231120155459.45188-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:gqSqmk9fS0+Ivfmgm4R2Ek9nDTo7O+ZO42q5GiwfAdI1WSKHAuH ybhqtx7GotlrRVoXIOo5gKbIG3LO0N50KCsqPNCBdsUVNK5sove1IW7M7tkPKelwvrvwQXH GTJNqbpbWlcFuXh+dEGosMK9Ho9qn3NdenmOLjwt0+Plgr8ygXNmVTCKd/te5UFX1nkAgcI u96UULb/X+ANgRmgCSTRw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:20O/hWpKmUI=;xCtm7cwTzWV/q9R4Q3j/u+anyRX BnPmIwyO4qUyqrwIzOBp4ca1u3HlbCWiGpab3Y82uYsqFxbFEro5rJdmx627g/qWH678aEa8W FGi28PB2DhvyucwBhsJpIXLzb2vW4hlDg6E/HxjR8naj/AdBG/J7eErTc3DKPdSaWcGd1eZbL WRFjKxJwlnXBw4+/Zv5au07GzbF4K1HAHYMQEUuHcxxfSky5SnLIm10oGNOH00T4Ar5IE3/Ju uRqJxU/5yZ9seZ+HPddMxlYyTAPMHKekoRBU3unaAiiZliiPP1FaPFdua53IWv/nFgqiGHl2S JinCY/G0PL/tJleZHaq2Tf2BDLkgT57fYdQMIEwEW0DtAha+WM+hmJx2imONKhnsWJrcbaeG4 6Xc5OGV58sK9hdudNB+UVaHYQTvrhQZPZnYaRh+6OUsATEQLukiFVQjrLqT4EI76EENjT2fLj JptgIJ0c0MDupS6RNq3SB0uy++AORDr9Nf+1w65jZj4rAR/+3bSBkXCEGAfe5G0BiHs0zby+G hcCcBIf/5V9d5gio8S6E0kNvqw+cZ8RlOu3AU2f61woz8rCfWqfLR+zVDUjtAyMDnPUZL+qUH uW+TXTL8YGv5fUNKyJEuWEPZ857WH3ItyHmIr9YRDFZLTpi3ncMOQvhmrUdW+eka6YbMXV1tR BM4EDlvaBsaTaILqku76u6U5cQnAbgps0LmpB+QLd9PWeZCIuvE4Ti7RqUHuvXo+NJ8x6bZuK tu2AY6flLIoz/EGaf1xQO03hwZ9htV29i9UuHOMYsy8kHYEzbprM7r+wQKedCro3GHNqYSwTP Tm48vs2ZUeeD35tqhepPeyVNQIws4jRi8L7M/aQI950mY5bhj5YkPVt2Hh4B+qWQ0m3l0lyNs xXL3vN11EhNuxog== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Start to add native support for containers. Implement the docker REST API to load an image via the docker's socket. Add a docker handler that take an image and push to the docker daemon. Following are implemented: - Image load - Image remove . Container create - it takes a JSON configurazion file as input. - Container delete Signed-off-by: Stefano Babic --- Kconfig | 3 + Makefile | 2 +- containers/docker.c | 237 +++++++++++++++++++++++++++++ containers/docker.h | 32 ++++ doc/source/handlers.rst | 132 ++++++++++++++++ handlers/Makefile | 1 + handlers/docker_handler.c | 307 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 713 insertions(+), 1 deletion(-) create mode 100644 containers/docker.c create mode 100644 containers/docker.h create mode 100644 handlers/docker_handler.c diff --git a/Kconfig b/Kconfig index 2ae2e4bc..5a3dc9a4 100644 --- a/Kconfig +++ b/Kconfig @@ -546,3 +546,6 @@ source parser/Config.in comment Handlers source handlers/Config.in + +comment Containers +source containers/Config.in diff --git a/Makefile b/Makefile index c693635c..3940a18b 100644 --- a/Makefile +++ b/Makefile @@ -363,7 +363,7 @@ include $(srctree)/Makefile.flags # Defaults to vmlinux, but the arch makefile usually adds further targets objs-y := core handlers bootloader suricatta -libs-y := corelib mongoose parser fs +libs-y := corelib mongoose parser fs containers bindings-y := bindings tools-y := tools diff --git a/containers/docker.c b/containers/docker.c new file mode 100644 index 00000000..353d4ada --- /dev/null +++ b/containers/docker.c @@ -0,0 +1,237 @@ +/* + * (C) Copyright 2023 + * Stefano Babic + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "parselib.h" +#include "channel.h" +#include "channel_curl.h" +#include "docker.h" +#include "docker_interface.h" +#include "swupdate_dict.h" + +typedef struct { + const char *url; + channel_method_t method; +} docker_api_t; + +docker_api_t docker_api[] = { + [DOCKER_IMAGE_LOAD] = {"/images/load", CHANNEL_POST}, + [DOCKER_IMAGE_DELETE] = {"/images/%s", CHANNEL_DELETE}, + [DOCKER_CONTAINER_CREATE] = {"/containers/create", CHANNEL_POST}, + [DOCKER_CONTAINER_DELETE] = {"/containers/%s", CHANNEL_DELETE}, + [DOCKER_CONTAINER_START] = {"/containers/%s/start", CHANNEL_POST}, + [DOCKER_CONTAINER_STOP] = {"/containers/%s/stop", CHANNEL_POST}, +}; + +static channel_data_t channel_data_defaults = {.debug = true, + .unix_socket =(char *) DOCKER_DEFAULT_SOCKET, + .retries = 1, + .retry_sleep = + CHANNEL_DEFAULT_RESUME_DELAY, + .format = CHANNEL_PARSE_JSON, + .nocheckanswer = false, + .nofollow = false, + .noipc = true, + .range = NULL, + .connection_timeout = 0, + .headers = NULL, + .headers_to_send = NULL, + .received_headers = NULL + }; + + +static const char *docker_base_url(void) +{ + return DOCKER_SOCKET_URL; +} + +static void docker_prepare_url(docker_services_t service, char *buf, size_t size) +{ + snprintf(buf, size, "%s%s", docker_base_url(), docker_api[service].url); +} + +static channel_t *docker_prepare_channel(channel_data_t *channel_data) +{ + channel_t *channel = channel_new(); + if (!channel) { + ERROR("New channel cannot be requested"); + return NULL; + } + + if (channel->open(channel, channel_data) != CHANNEL_OK) { + channel->close(channel); + free(channel); + return NULL; + } + + return channel; +} + +static server_op_res_t evaluate_docker_answer(json_object *json_reply) +{ + if (!json_reply) { + ERROR("No JSON answer from Docker Daemon"); + return SERVER_EBADMSG; + } + + /* + * Check for errors + */ + json_object *json_error = json_get_path_key(json_reply, + (const char *[]){"error", NULL}); + if (json_object_get_type(json_error) == json_type_string) { + ERROR("Image not loaded, daemon reports: %s", + json_object_get_string(json_error)); + return SERVER_EBADMSG; + } + + json_object *json_stream = json_get_path_key(json_reply, + (const char *[]){"stream", NULL}); + if (json_object_get_type(json_stream) == json_type_string) { + INFO("%s", json_object_get_string(json_stream)); + return SERVER_OK; + } + return SERVER_EBADMSG; +} + +server_op_res_t docker_load_image(int fd, size_t len) +{ + channel_t *channel; + channel_op_res_t ch_response; + server_op_res_t result = SERVER_OK; + char dockerurl[1024]; + + channel_data_t channel_data = channel_data_defaults; + struct dict httpheaders_to_send; + + LIST_INIT(&httpheaders_to_send); + if (dict_insert_value(&httpheaders_to_send, "Expect", "")) { + ERROR("Error initializing HTTP Headers"); + return SERVER_EINIT; + } + + docker_prepare_url(DOCKER_IMAGE_LOAD, dockerurl, sizeof(dockerurl)); + channel_data.url = dockerurl; + + channel_data.read_fifo = fd; + channel_data.method = docker_api[DOCKER_IMAGE_LOAD].method; + channel_data.upload_filesize = len; + channel_data.headers_to_send = &httpheaders_to_send; + channel_data.content_type = "application/x-tar"; + channel_data.accept_content_type = "application/json"; + + channel = docker_prepare_channel(&channel_data); + if (!channel) { + return SERVER_EERR; + } + ch_response = channel->put_file(channel, &channel_data); + + if ((result = map_channel_retcode(ch_response)) != + SERVER_OK) { + channel->close(channel); + free(channel); + return SERVER_EERR; + } + + dict_drop_db(&httpheaders_to_send); + + channel->close(channel); + free(channel); + + return evaluate_docker_answer(channel_data.json_reply); +} + +static server_op_res_t docker_send_request(docker_services_t service, char *url, char *setup) +{ + channel_t *channel; + channel_op_res_t ch_response; + server_op_res_t result = SERVER_OK; + channel_data_t channel_data = channel_data_defaults; + + channel_data.url = url; + channel_data.method = docker_api[service].method; + + channel = docker_prepare_channel(&channel_data); + if (!channel) { + return SERVER_EERR; + } + + if (setup) + channel_data.request_body = setup; + + ch_response = channel->put(channel, &channel_data); + + if ((result = map_channel_retcode(ch_response)) != + SERVER_OK) { + channel->close(channel); + free(channel); + return SERVER_EERR; + } + + channel->close(channel); + free(channel); + + return result; +} + +static server_op_res_t docker_simple_post(docker_services_t service, const char *name) +{ + char url[256]; + + docker_prepare_url(service, url, sizeof(url)); + if (name) { + char *tmp=strdup(url); + snprintf(url, sizeof(url), tmp, name); + free(tmp); + } + + return docker_send_request(service, url, NULL); +} + +server_op_res_t docker_container_create(const char *name, char *setup) +{ + char url[256]; + + if (name) { + snprintf(url, sizeof(url), "%s%s?name=%s", + docker_base_url(), docker_api[DOCKER_CONTAINER_CREATE].url, name); + } else + docker_prepare_url(DOCKER_CONTAINER_CREATE, url, sizeof(url)); + + return docker_send_request(DOCKER_CONTAINER_CREATE, url, setup); +} + +server_op_res_t docker_container_remove(const char *name) +{ + return docker_simple_post(DOCKER_CONTAINER_DELETE, name); +} + +server_op_res_t docker_container_start(const char *name) +{ + return docker_simple_post(DOCKER_CONTAINER_START, name); +} + +server_op_res_t docker_container_stop(const char *name) +{ + return docker_simple_post(DOCKER_CONTAINER_STOP, name); +} + +server_op_res_t docker_remove_image(const char *name) +{ + return docker_simple_post(DOCKER_IMAGE_DELETE, name); +} diff --git a/containers/docker.h b/containers/docker.h new file mode 100644 index 00000000..671b1e2c --- /dev/null +++ b/containers/docker.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2023 + * Stefano Babic + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#pragma once + +#include "server_utils.h" + +/* Supported API */ +#define DOCKER_API_VERSION "1.43" + +/* Default socker for docker */ +#define DOCKER_DEFAULT_SOCKET "/run/docker.sock" + +/* For UDS connection, this is the URL */ +#define DOCKER_SOCKET_URL "http://localhost" + +/* Docker base URL */ + +#define DOCKER_BASE_URL DOCKER_SOCKET_URL DOCKER_API_VERSION "/" + +typedef enum { + DOCKER_IMAGE_LOAD, + DOCKER_IMAGE_DELETE, + DOCKER_CONTAINER_CREATE, + DOCKER_CONTAINER_DELETE, + DOCKER_CONTAINER_START, + DOCKER_CONTAINER_STOP +} docker_services_t; diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index e8e2e43f..5bafb558 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -1274,3 +1274,135 @@ Zchunk creates a temporary file with all chunks in /tmp, that is at the end conc header and written to the destination file. This means that an amount of memory equal to the partition (SWUpdate does not compress the chunks) is required. This was solved with later version of Zchunk - check inside zchunk code if ZCK_NO_WRITE is supported. + +Docker handlers +---------------- + +To improve containers update, a docker set of handlers implements part of the API to communicate +with the docker daemon. Podman (another container solution) has a compatibility layer for +docker REST API and could be used as well, but SWUpdate is currently not checking if a podman +daemon must be started. + +Goal of these handlers is just to provice the few API to update images and start containers - it +does not implement the full API. + +Docker Load Image +----------------- + +This handler allow to load an image without copying temporarily and push it to the docker daemon. +It implements the /images/load entry point., and it is implemented as "image" handler. The file +should be in a format accepted by docker. + +:: + + images: ( + filename = "docker-image.tar" + type = "docker_imageload"; + installed-directly = true; + ) + +The handler checks return value (JSON message) from the daemon, and returns with success if the image +is added. + +In case the file must be decompressed, SWUpdate requires the size of the decompressed image to be +passed to the daemon: + + +:: + + images: ( + { + filename = "alpine.tar.gz"; + type = "docker_imageload"; + installed-directly = true; + compressed = "zlib"; + properties: { + decompressed-size = "5069312"; + }; + }); + + +Docker Remove Image +------------------- + +It is implemented as script (post install). +Example: + +:: + + scripts: ( { + type = "docker_imagedelete"; + properties: { + name = "alpine:3.4"; + }; + }); + +Docker: container create +------------------------ + +It is implemented as post-install script. The script itself is the json file passed +to the daemon to configure and set the container. The container is just created, not started. + +For example, having this hello-world.json file: + +:: + + { + "Image": "hello-world", + "HostConfig": { + "RestartPolicy": { + "Name": "always" + }, + "AutoRemove": false + } + } + +Creating the container can be done in sw-description with: + +:: + + scripts: ( { + filename = "hello-world.json"; + type = "docker_containercreate"; + properties: { + name = "helloworld"; /* Name of container */ + } + }); + +Docker Remove Container +----------------------- + +It is implemented as script (post install). +Example: + +:: + + scripts: ( { + type = "docker_containerdelete"; + properties: { + name = "helloworld"; + }; + }); + +Docker : Start / Stop containers +-------------------------------- + +Examples: + +:: + + scripts: ( { + type = "docker_containerstart"; + properties: { + name = "helloworld"; + }; + }); + +:: + + scripts: ( { + type = "docker_containerstop"; + properties: { + name = "helloworld"; + }; + }); diff --git a/handlers/Makefile b/handlers/Makefile index b5203f96..eb24a49c 100644 --- a/handlers/Makefile +++ b/handlers/Makefile @@ -28,3 +28,4 @@ obj-$(CONFIG_SSBLSWITCH) += ssbl_handler.o obj-$(CONFIG_SWUFORWARDER_HANDLER) += swuforward_handler.o swuforward-ws.o obj-$(CONFIG_UBIVOL) += ubivol_handler.o obj-$(CONFIG_UCFWHANDLER) += ucfw_handler.o +obj-$(CONFIG_DOCKER) += docker_handler.o diff --git a/handlers/docker_handler.c b/handlers/docker_handler.c new file mode 100644 index 00000000..9d0aba41 --- /dev/null +++ b/handlers/docker_handler.c @@ -0,0 +1,307 @@ +/* + * (C) Copyright 2017 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +/* + * This handler communicates with the docker socket via REST API + * to install new images and manage containers. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "parselib.h" +#include "swupdate_image.h" +#include "docker_interface.h" + +void docker_loadimage_handler(void); +void docker_deleteimage_handler(void); +void docker_createcontainer_handler(void); +void docker_deletecontainer_handler(void); +void docker_container_start_handler(void); +void docker_container_stop_handler(void); + +typedef server_op_res_t (*docker_fn)(const char *name); + +#define FIFO_THREAD_READ 0 +#define FIFO_HND_WRITE 1 + +struct hnd_load_priv { + int fifo[2]; /* PIPE where to write */ + size_t totalbytes; + int exit_status; +}; + +/* + * This is the copyimage's callback. When called, + * there is a buffer to be passed to curl connections + * This is part of the image load: using copyimage() the image is + * transferred without copy to the daemon. + */ +static int transfer_data(void *data, const void *buf, size_t len) +{ + struct hnd_load_priv *priv = (struct hnd_load_priv *)data; + ssize_t written; + unsigned int nbytes = len; + const void *tmp = buf; + + while (nbytes) { + written = write(priv->fifo[FIFO_HND_WRITE], buf, len); + if (written < 0) { + ERROR ("Cannot write to fifo"); + return -EFAULT; + } + nbytes -= written; + tmp += written; + } + + return 0; +} + +/* + * Background threa dto transfer the image to the daemon. + * main thread ==> run copyimage + * backgound thread ==> push the incoming data to ddaemon + */ +static void *curl_transfer_thread(void *p) +{ + struct hnd_load_priv *hnd = (struct hnd_load_priv *)p; + + hnd->exit_status = docker_load_image(hnd->fifo[FIFO_THREAD_READ], hnd->totalbytes); + + close(hnd->fifo[FIFO_THREAD_READ]); + + pthread_exit(NULL); +} + +/* + * Implementation /images/load + */ +static int docker_install_image(struct img_type *img, + void __attribute__ ((__unused__)) *data) +{ + struct hnd_load_priv priv; + pthread_attr_t attr; + pthread_t transfer_thread; + int thread_ret; + int ret = 0; + ssize_t bytes; + + signal(SIGPIPE, SIG_IGN); + + /* + * Requires the size of file to be transferrred + */ + bytes = get_output_size(img, true); + if (bytes < 0) { + ERROR("Size to be uploaded undefined"); + return -EINVAL; + } + + priv.totalbytes = bytes; + + /* + * Create one FIFO for each connection to be thread safe + */ + if (pipe(priv.fifo) < 0) { + ERROR("Cannot create internal pipes, exit.."); + ret = FAILURE; + goto handler_exit; + } + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + thread_ret = pthread_create(&transfer_thread, &attr, curl_transfer_thread, &priv); + if (thread_ret) { + ERROR("Code from pthread_create() is %d", + thread_ret); + transfer_thread = 0; + ret = FAILURE; + goto handler_exit; + } + + ret = copyimage(&priv, img, transfer_data); + if (ret) { + ERROR("Transferring SWU image was not successful"); + ret = FAILURE; + goto handler_exit; + } + + void *status; + ret = pthread_join(transfer_thread, &status); + + close(priv.fifo[FIFO_HND_WRITE]); + + return priv.exit_status; + +handler_exit: + return ret; +} + +/* + * Implementation POST /container/create + */ +static int docker_create_container(struct img_type *img, + void __attribute__ ((__unused__)) *data) +{ + struct script_handler_data *script_data = data; + char *script = NULL; + char *buf = NULL; + struct stat sb; + int result = 0; + int fd = -1; + + /* + * Call only in case of postinstall + */ + if (!script_data || script_data->scriptfn != POSTINSTALL) + return 0; + + + if (asprintf(&script, "%s%s", get_tmpdirscripts(), img->fname) == ENOMEM_ASPRINTF) { + ERROR("OOM when creating script path"); + return -ENOMEM; + } + + if (stat(script, &sb) == -1) { + ERROR("stat fails on %s", script); + result = -EFAULT; + goto create_container_exit; + } + + fd = open(script, O_RDONLY); + if (fd < 0) { + ERROR("%s cannot be opened, exiting..", script); + result = -EFAULT; + goto create_container_exit; + } + + buf = (char *)malloc(sb.st_size); + if (!buf) { + ERROR("OOM creating buffer for reading %s of %ld bytes", + script, sb.st_size); + result = -ENOMEM; + goto create_container_exit; + } + + ssize_t n = read(fd, buf, sb.st_size); + if (n != sb.st_size) { + ERROR("Script %s cannot be read, return value %ld != %ld", + script, n, sb.st_size); + result = -EFAULT; + goto create_container_exit; + } + + char *name = dict_get_value(&img->properties, "name"); + + TRACE("DOCKER CREATE CONTAINER"); + + result = docker_container_create(name, buf); + +create_container_exit: + free(script); + free(buf); + if (fd > 0) close(fd); + + return result; + +} + +/* + * Implementation DELETE /container/{id} + */ +static int docker_query(struct img_type *img, void *data, docker_fn fn) +{ + struct script_handler_data *script_data = data; + /* + * Call only in case of postinstall + */ + if (!script_data || script_data->scriptfn != POSTINSTALL) + return 0; + + char *name = dict_get_value(&img->properties, "name"); + + if (!name) { + ERROR("DELETE container: name is missing, it is mandatory"); + return -EINVAL; + } + + return fn(name); +} + +static int docker_delete_container(struct img_type *img, void *data) +{ + return docker_query(img, data, docker_container_remove); +} + +static int docker_delete_image(struct img_type *img, void *data) +{ + return docker_query(img, data, docker_remove_image); +} + +static int container_start(struct img_type *img, void *data) +{ + return docker_query(img, data, docker_container_start); +} + + +static int container_stop(struct img_type *img, void *data) +{ + return docker_query(img, data, docker_container_stop); +} + +__attribute__((constructor)) +void docker_loadimage_handler(void) +{ + register_handler("docker_imageload", docker_install_image, + IMAGE_HANDLER, NULL); +} + +__attribute__((constructor)) +void docker_deleteimage_handler(void) +{ + register_handler("docker_imagedelete", docker_delete_image, + SCRIPT_HANDLER | NO_DATA_HANDLER, NULL); +} + +__attribute__((constructor)) +void docker_createcontainer_handler(void) +{ + register_handler("docker_containercreate", docker_create_container, + SCRIPT_HANDLER, NULL); +} + +__attribute__((constructor)) +void docker_deletecontainer_handler(void) +{ + register_handler("docker_containerdelete", docker_delete_container, + SCRIPT_HANDLER | NO_DATA_HANDLER, NULL); +} + +__attribute__((constructor)) +void docker_container_start_handler(void) +{ + register_handler("docker_containerstart", container_start, + SCRIPT_HANDLER | NO_DATA_HANDLER, NULL); +} + +__attribute__((constructor)) +void docker_container_stop_handler(void) +{ + register_handler("docker_containerstart", container_stop, + SCRIPT_HANDLER | NO_DATA_HANDLER, NULL); +}