From patchwork Mon Mar 5 15:39:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::23b; helo=mail-wr0-x23b.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbkok6xkakgqeuwojdfy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="WfxubnIa"; dkim-atps=neutral Received: from mail-wr0-x23b.google.com (mail-wr0-x23b.google.com [IPv6:2a00:1450:400c:c0c::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw3zc5lS8z9s3p for ; Tue, 6 Mar 2018 02:41:31 +1100 (AEDT) Received: by mail-wr0-x23b.google.com with SMTP id q15sf11372735wra.22 for ; Mon, 05 Mar 2018 07:41:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264489; cv=pass; d=google.com; s=arc-20160816; b=ZP2IJWXGNN3TXh+fkARiAA5mIVuQvC44zSqszoeWGRWxJHrD7whSTieekGToOSZlZI ypODGqdZWasSkgpQdeO38ffiKN6poIvelNrq9IGDc4hm8Yg6i1lb9rcrBSrzAj59XRZO npCdTT8SawqRJJyfjyxCDdwdMbvouq8Kk7wMv8xYpVur/zB3VFfrZqbfxK99b2zihiMN fS8w13rRdfqWNwj3BoIwyjR7Z/wHh5ArDvhPU6khVdqENdMj1vEXJOYVY5Pq/9yLhCnq VodVKWcznY9QzyUUMQhf35l550GDs33F5Xmd4qp8Mhn+58m3dTlp3B6d2FusbnyzltPJ iMpw== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=LwD4Y/CGP3SRGnsfj2N+R4VXoR7RigQ/ga+VhvVlY+0=; b=0jOVHR3G8cxycoFXE4SijAPb71XSH9ADGnUDTATNDUdUEJo9i/+moRA7MnkmA15WUp SA4Fu7iLarJ1pH0EmIwddtd+pHWcLCxX48YfTZELGHt/1z2JGmWS0jNZSQKEdzrdXnUf kOd/ZWGhqCyo1kvtU5X8f2IDQWqJ7RhHMzutTuo1xOtGDdo0I5uLwskFsbc1JOGv892Z 7efsNy//kWCo/NxeSIAUtMPidOd78vpCVAj8HNLHlG8IBsBEGqkx59UlR9jXAsIWHhm4 qHIQvfnGJoB17DdSenTmLI2f3gxQFZD2rzLdEkLWOkexhjnEsMNC11V1XNZpL6doa4Qt XIPg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=LwD4Y/CGP3SRGnsfj2N+R4VXoR7RigQ/ga+VhvVlY+0=; b=WfxubnIaF+2158w092+2W46mFSuuOfYcraC6MDzTfFHaJCFBzLKinnqPCiixr83P4C JHj5duaCGJT6q3TkGckclnlABOTQf0ueKcXWYaKSbTgqUFvVDZ37Wsdt0weSFDRyfwFa kDJrieGIKpJ3FrvGfuAj7dcrt/H1VWMFhe4+rkMSddvYuWGEQviRjY3l30oUySY/Y+4W Z6QGsvJ68fYPTAlUNypLLJGvDR31bWvis+8SxdS353Os+j+jCQijyO/PsFd6M6K11c/T H5bVOyENm5Xp4kwvE469CX41pJwD3v5d7vkGcAUB0xB/nx3KnDvf21eBKDq7Qeu9Hk8r Lqjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=LwD4Y/CGP3SRGnsfj2N+R4VXoR7RigQ/ga+VhvVlY+0=; b=BkT7dxrnsPwmneydFIzGP3mhl6H4dfrOICyXQBy4lyeDuWyfZdaMwbQtLWvqyNl9ye rO+vTiUZ3Za8nuyxSmKy/Nz4nF17fyOvEwLsKwwNHmq8hkU1Xbhe5KGt4J2l1ijZBRc1 mq40BnPx2+nvRKdU6Yt3660FTYiVo+4rg5WbAtvaNG0tDjaSs9VYYnNOvZsSxmuM/72y y77JOMXDxFRE4ElRylJE5RwNw3eW3hAKHilEdb5dIn3m3vrHVjU2LoOmEJWniQ9rN10Z zYuxVi/ER88+EdCIrrQoRf3j855cgN9UNf8VeXiLVSfWCLGmzq08DNhMMmXXiKqUBwdr lcjQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7FZ/19GAKbACHIqeD9ySOnTWBmrJ/7LxEM5rHiXBDlxt32Mgblg XPjx/nyt+v/ZjKqreTYwrMs= X-Google-Smtp-Source: AG47ELt7DJqXZUZUJTZoo1FZv+w9n6zjHzDVNiQHCP3ytm8aJfR5gBUmyTSs+bX3ETkZ/6BD5lPxnw== X-Received: by 10.28.15.138 with SMTP id 132mr38222wmp.4.1520264489507; Mon, 05 Mar 2018 07:41:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.80.133.197 with SMTP id q5ls8110461edh.1.gmail; Mon, 05 Mar 2018 07:41:28 -0800 (PST) X-Received: by 10.80.141.16 with SMTP id s16mr4448951eds.7.1520264488696; Mon, 05 Mar 2018 07:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264488; cv=none; d=google.com; s=arc-20160816; b=PxXBcH8GWej1W/3fR6gEFzrhqp0MMfrX0o9QFOZ4wk4/OHfgxKsN98/sIBrb3i/DSI ZPo3IlmWWVJHXd7XXqYn4632n7GsO71p6RWDIvigixElA8ohxx3Tv0dDM8DUh0Y7gklI 3NyXGEK68Cl7AkcxH/qbcUp7E8/Fab1QgrBM6bKti4objtSVd8U8ybPtZmRuEBvuM+WU BG5dTBnFJj2Zu2sjVYRNR0ejoIUWmyHe90dtK8yjN/m05DfZSuE8UcCa5ZZm3i6vzVYX 7envzzja8O20w8tvKozuRGwLHF3oHv9zmtAyQvKblyzfvc3X6MTtbuuVOmuPpiEip9/i miHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=UgAf3bZo2SMiNCISmw4eXQgDpxnULf5Bncw6lHPkF8M=; b=NyMbgRTKLoZFWY7lCu4mCEOHAOp9DXeGqIEUXZgsnwEfpv9ZYhgo4PrWYFzvbv53R0 IWeAEQWk4zRgxVlnESdnwPy+zZGZ13kjY13xEqE6xAFrM1Vsla/tcEOSAnNX11DNoZRo Oc49WbIoGgILe9HrkZgoCNwHzADF27IUHpi5Dz145gD3ngbg3Vr1v8ZsmLoEPsyfYFR/ WMfDM1vIrzEQFpcqgmpOWa0DvahCgkWnTmgURJOU5K5PmMjJZLC92KwulrLe4ZPOW8SN b5HwPkZszGEF3oxjHEnVfcGbH2uyXGZ/OaFcRSWUETejEb35il+gdGTf5FGZuVtjfrcq +nKA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id g21si193169edj.5.2018.03.05.07.41.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:28 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w25FfS63002461 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:28 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYG022466; Mon, 5 Mar 2018 16:41:27 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 1/8] channel_curl: add support for Basic Auth credentials Date: Mon, 5 Mar 2018 16:39:59 +0100 Message-Id: <20180305154006.18122-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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 Basic Auth credentials support in channel_curl like commit 1243723 has done for the downloader only, in preparation to make the downloader use channel_curl. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 9 +++++++++ include/channel_curl.h | 1 + 2 files changed, 10 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 0dec551..a94243d 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -454,6 +454,15 @@ channel_op_res_t channel_set_options(channel_t *this, } } + if (channel_data->auth) { + if (curl_easy_setopt(channel_curl->handle, CURLOPT_USERPWD, + channel_data->auth) != CURLE_OK) { + ERROR("Basic Auth credentials could not be set."); + result = CHANNEL_EINIT; + goto cleanup; + } + } + cleanup: return result; } diff --git a/include/channel_curl.h b/include/channel_curl.h index 2133744..3af470a 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -30,6 +30,7 @@ typedef enum { typedef struct { char *url; + char *auth; char *json_string; json_object *json_reply; char *cafile; From patchwork Mon Mar 5 15:40:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c09::23d; helo=mail-wm0-x23d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbl6k6xkakgqevso4ccy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="aMgN8THF"; dkim-atps=neutral Received: from mail-wm0-x23d.google.com (mail-wm0-x23d.google.com [IPv6:2a00:1450:400c:c09::23d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw3zk3VfSz9sZc for ; Tue, 6 Mar 2018 02:41:38 +1100 (AEDT) Received: by mail-wm0-x23d.google.com with SMTP id d23sf4319179wmd.1 for ; Mon, 05 Mar 2018 07:41:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264495; cv=pass; d=google.com; s=arc-20160816; b=oaqj+0qZDyf9TK6pM6DnPNHCBSBjpvDIxEUGRX2JVK9f+SXltgjjgePJ7lIkuDf0sS rS9kmLZvxkW5om3FqVLV3/9UwHERnffFv5ekVOF4vXPbefpEJzI43PifLpPrLJVWzFhe qbfhqdS7YfUHJYUDYJZd1RcrR9O6mq9S7FdriI/3aFF9Vd7FxjDuo1Ci6r78gxGf8hoW X6TfELIQTDzSJ/Gq9FNZY8JjMV8/a7srV6IiXxskD0EdesikHZn1KsR5hWg6TIMT7yUA m1L10Z9IfvLtwuv+NCErmHN638rLlMlnAjUNmB+cifBDudN1WVsi6j6P8xhxBEaLxoQG S0Hg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=lECH2ZTHxFYR7aiCj/5Di1ovqemJdLGlKOrcNJNBLX0=; b=YKdUSOA6pHrc+40HuWw9guUeEg4iiBdStzjypDl5vzWnPn6eeqVBG1y1sKCmH1wNwH PPcbbgD6vSiLiqsfKqJ+mz23++lzADbhGGx/l3HouQN3CrwsWL0vbJ1gqmqUYdlDylYr pMNj+cdSnXkLXbnVMw1OileYOZsisvCuJyP9x9j3tGchNIYgFu3gzPYLNLnJTeKyE4/s qiFSps/BAZPhSfYjFrCjtxoi51T6VO6yptfrMAaDIGBjuzWRfA6P4ioTOd1u//htVHpi ZeNdfPkUWeBBxK1+OoCY073DrTDEeA9RE+J4b7sN4mtzksY1SQ2BDF7AssZbFXOSkKE7 HlQg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=lECH2ZTHxFYR7aiCj/5Di1ovqemJdLGlKOrcNJNBLX0=; b=aMgN8THFfKx+6+SZ+9IlvLHtDVF8w90HRxhp0akla/3yz5Cr0iGkm4keiaZHXlIANo YDW53RoIQEGbzg0VP8f7oLRnhYBmGKCOJWElIrabdzekbHVJ3EPV9gIXAw4fg5V7KDVO vs8HGQgcI+RCwbPh9s8Vip9CfBOV7CNVyv18s+xgLX2sGpNhE1U70ly/wJSUccpqtuoZ aGUauYweP1AyuvhfbrKFH1/5eaiqKxYSyiwRGM1rkrZn9VvCL0euhL85mgldfLJT04Fg 86fc3b55zSmgF4fu44iJ8WGVAQUTILEOjz1HPj8vvtmceiD9xPQSflGE69DBqlI6Bqrs b//A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=lECH2ZTHxFYR7aiCj/5Di1ovqemJdLGlKOrcNJNBLX0=; b=RHJbrQWzYJQyCIYXDlPhmJrGqh0YFnMtl6+xYkHLl5a5rIDpOReYR8PRkZ/xAVdzAV PTxj0fXMQ42s45Gou2fwxpPdb9T776HC4SOJ2IZoQFymgCB61VfQslUD88qaXnF2wZvK wdBx+Jz5bh4/S4OXkTdRpVBoHpn44ZB2orgRSfk3LzXwwgLcNN2wCHg8WssUt6kCASgG Syz58ykJDA/4iPoX5Mwbwnk/4XWUAsIksQFfjKOOdzEVsuRzjrT2815lTqa9Z07Wquiq 8a0zy2dnF/prWFhyOEu6BNMmxs2BEaKnNbEa3O0C1DJswX098PfVbpPRZaJyprZqu0pK CuhA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7FFWTp0PBRdvajMYcZ8hl4YEFET/TllKOAekC8NFa6wQbm+Qhnl CNFlpqqvupKpfSJRAP2CCms= X-Google-Smtp-Source: AG47ELv7LDm/uTu0PxXInetaUEE+kVHLZBwDN+SS9suOkszhCRGuZx2t9wU7AsDAgyPBOV0vlcr34Q== X-Received: by 10.28.15.138 with SMTP id 132mr38229wmp.4.1520264495871; Mon, 05 Mar 2018 07:41:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.229.3 with SMTP id c3ls1567053wmh.9.gmail; Mon, 05 Mar 2018 07:41:35 -0800 (PST) X-Received: by 10.28.12.137 with SMTP id 131mr1098294wmm.18.1520264495397; Mon, 05 Mar 2018 07:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264495; cv=none; d=google.com; s=arc-20160816; b=DGCx2IEnuxnWK8V3eu3YS2/0nGzz0mKee8ctfQ99qYoLQ4rz0yf04vjGOeFNfIRLLe kwsXXIzhNWRWwlPGqTiQFPka3l2hzqG7o0z3dnbv+awY0VXjHJdtazouhAI/h5Twn++V Ik0Agwe3/uN4ZHYK2O7ZQuIf45OOu5iaXdtHzBD7bHIpXqDA2X+GfAjutjUKvj3SLRBh M+TnUtOMh59n4KO7NqtQU6Lbj7EuXs25lTN4W7m0K67+f5WIKgKZmHvdhm8EYXt+J6jT FTIBslgZRaXGSeG/PPjASfdapGosSnFq9j6Sw1I2DnF2F5Khtcas9noUBSiQbY87/j4r +1vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8ePFjAmNmOeuAdGdU6gQ83fmhPYlyPgTM3vEIHQADkE=; b=J0FqZUR3R2n/62KjhJ3opyyi6dhsshY3w7oEHl1vDZwx72QpClMp7VRzRXNXi4NDvp eTNBlOUNFF8SUDXcohnqABFgiP4+fgXAcbWig1v8Imx/a0SGRiwJi7+lB/KTv5JKOHTE ipmyEPDCWp4uH/stpyRlvWlKJT+mmKTt9VJtmIKyoU5gVTopvB9gL/Xv+DbMSbz0T5FU xi87bJ+ifUHgcyHQsT27V/UHVYM48Ohw8fWB2SwWfVWbufi5gQIu4F7rDa5aQ334pvfl X0ZikY9HUdHel8Q9fMn0lufaeKXJzER84RDmhWNgY93x8Fmr95Kbl6gvhf8FyNtq5IdQ rk/g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id d12si321733wre.4.2018.03.05.07.41.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:35 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w25FfZrq008656 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:35 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYH022466; Mon, 5 Mar 2018 16:41:34 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 2/8] channel_curl: add missing stdbool include Date: Mon, 5 Mar 2018 16:40:00 +0100 Message-Id: <20180305154006.18122-2-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , channel_data_t uses various boolean variables, hence include stdbool.h explicitly. Signed-off-by: Christian Storm --- include/channel_curl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/channel_curl.h b/include/channel_curl.h index 3af470a..5afb66f 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -8,6 +8,7 @@ #pragma once #include #include +#include #include "sslapi.h" #include "swupdate_status.h" From patchwork Mon Mar 5 15:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::239; helo=mail-wr0-x239.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbnok6xkakgqef63bwda@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="COEfQKYH"; dkim-atps=neutral Received: from mail-wr0-x239.google.com (mail-wr0-x239.google.com [IPv6:2a00:1450:400c:c0c::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw3zr0gMvz9s3p for ; Tue, 6 Mar 2018 02:41:43 +1100 (AEDT) Received: by mail-wr0-x239.google.com with SMTP id v16sf11588910wrv.14 for ; Mon, 05 Mar 2018 07:41:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264501; cv=pass; d=google.com; s=arc-20160816; b=X7imTJNBUNQcIPGRy+6f0oiIi2leLGFweZP0fYS7OjHgIeBRsCDfESiuWvGuGC7Wcx ZJ5AF1hEimUKLgKXsEzJ96IP9jNnfz/uRVHgY92R/jwsa8cG+CZ7UR3EiaRYAcDSxoQa OJXj1t1HTfUtYzD4s7FbYfv0CnA7SEhLW5BjdkeJ/RGk5Ya7P/zLlkv+BDFwAzEdlzSA 5vLXyfStI41C25xXb9W/rewvnTs23mEWIg88P2NqvlKwURjfPluVdnfbS7nqbswY0RSj V7HAITJp7Ej5XkbppuXM0EJi0SsLuZNrGNOF7KAvKewCMM6CA7DhGU66mhrxKFEYfTsq JVgw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=bvO+bWWYu2DoXLfTMtcnuve/vJCZxDU5JUaQBI4qKmE=; b=bneLYhjUx+28iZLjBJ38sJaDhe8Vg5u87r5fZ5OWOQYCis/tZXWXKr56TyhVYV7Mef 1wbFoc6qqON/PDS9yM9yajMwLVq8vdLjLJToI4jS/Zo/WtcT31TWGTkMDMO0xYcYoiTe AKOJK2Xoc9X5CIFxzKrGQKiHZ/bv8sg36wrUvUtfRLaKQOdjbnssWqLBVi7K1Xbu1/4l 8qnYjUPRugcI3mU+ViF5gyIR2IfpSySAoyApT+umP5gtq1ZSjHxWb8YlARinolK9eorB jLq+gBf8sKiYzOArieYDwKZiJ7rrdySlApxRy43rWCl6yOKek0clyqID1dAA1zBHxPba kAvg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=bvO+bWWYu2DoXLfTMtcnuve/vJCZxDU5JUaQBI4qKmE=; b=COEfQKYHdbXk5eYY6ATAebGISeeKJuJr9U28r976vSuqaUfkB96fj8qXheCE3tkJIA EEc8HL8C38sejQFAr8AlSanmxR9cjsrbCe26RyPg+O0EBaIovq1XbhwiO67RmM/UKecv h0pF6G732/ukL/g7YDovtWcVuNE87Oo7saSiwVAjFo9u0mRZca5aEJIUXKbpVTvJiw0p Cmx0k0oHCNI3f8PD33RsIFtuTE09rEBKLHvFgRm5odTp6p9UmZXcZCfaBi2+qP75X+do i0kxwUNwJK/rOCtzKnSGf/4eYHYf5I5LaaMQ1j81gcdGWv8/ScoDXTivNPjpbtw2chuE 9H7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=bvO+bWWYu2DoXLfTMtcnuve/vJCZxDU5JUaQBI4qKmE=; b=gz6dh9y/hAMiDZv93lAn6nTdFLPbj8Iu1hMlaCdYBvVbehCnQTNC7AHp9LFXpt6ksh 11VOtYD/iNOo2w7vWF6dcwMx/2i/Y8Cdc7C7/7STpcPgup9bqqKHnYWenKvrqa3++S3k Ob/s9KgGjmm2YnqznKtMLmZXK0sY7LPkmvmncE2JgPU2WpX0jLe39kiayOE4CzVDZSlh nXTgxBrH4PIgUmn5eJCf+UqbRU9G3NU7v42K3z/YZXQDDF4dtaq0G0AQkjykWOPZvdY1 ByKIEPO1Gqo9lczyZwgi3KcIMhvc6RLAGniqRI8CqlWjPY4II2+or35nJ0RkM48BZSR+ qmpw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7ExTurP7kOUzGnPNhToNf0WoABByhBH6mqLglKMsoIXVxAUviEX sZfP0gt3h1pyR4pNEYo1N8s= X-Google-Smtp-Source: AG47ELvy/JyOMUZ2O35h0KX+cQnGj3stOFuNzk+Frg5wFOfeZdTmpB0XLZhQTNOCMH8Klud6mzswAA== X-Received: by 10.28.122.20 with SMTP id v20mr63125wmc.7.1520264501513; Mon, 05 Mar 2018 07:41:41 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.80.190.10 with SMTP id a10ls8104861edi.6.gmail; Mon, 05 Mar 2018 07:41:41 -0800 (PST) X-Received: by 10.80.202.199 with SMTP id f7mr4455934edi.12.1520264500984; Mon, 05 Mar 2018 07:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264500; cv=none; d=google.com; s=arc-20160816; b=Q/edTHXjOWozX3wckttwEk0z8m3UOSzxsftfIeyDcpUHFfgJ3migsJZg3Sadhb3wlp IWNT6gSt73mfna3rSpwWj0s6QBHRw7/Rj1sxypGBlUP6SFdJzQoRcJI7dc9Yi+TpFsAn otx1MDMSFzBivhJtRItS7D2aUnDa/xItFFCMUZ5lTlYxpwjYQ/5vwbi1Rx2TY2xGIw1B oxQAo9yuhh8WxfNNSFYzxia3hPvTzrKl7pfXEmttafPKVy/0/IRUtEwOuqpT2Hd/1FYd IhfKOJzOYjTLX8jWrcxkPcwUX5Kn7fK7VTYYtp9saXGYSN7De1ZYnpxr8bleekE4eXTi e3RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UWnObXEzlRP5njY+GpOLG4YVYNqiZdElw/SkJJsUVpg=; b=fokuo3a83yg/1l9XuIx8/jlJC6ws8Airaugs4ZwOvVMrY2C7fUQ5WyG9f57s24ZWN9 MxWZ0JkDhBpEwCYRfX48R3Wrp84XLtp21AEME+S6RPIJB/GNJY4eCL9uCKx/JZoefNCW VozfSoJ6cDE5uXPN/zu4XCvtOb9hnNM4H8L2FXF6MOPuMkFEn8HMzDHID50r9s5KDZNy hO/d7VwywvVL28Oak+li0YN1eX5L91I4c+eP3pRHB4MnKJnPwMsGPfOQbAEPGBBQfIfn uuNeZlyWAyaprh62Eav6lwVr0aKmph35VBfEo3df0CF6dOfTpsFVa6HMGEoK02Gid7bV z4Ow== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id g21si193190edj.5.2018.03.05.07.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:40 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w25Ffe2X008922 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:40 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYI022466; Mon, 5 Mar 2018 16:41:40 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 3/8] channel_curl: make low_speed_timeout configurable Date: Mon, 5 Mar 2018 16:40:01 +0100 Message-Id: <20180305154006.18122-3-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , downloader.c has a command line flag '--timeout' setting cURL's low speed limit time period. Make this setting configurable for channel_curl in preparation to make the downloader use channel_curl. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- corelib/channel_curl.c | 8 +++++++- include/channel_curl.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a94243d..ea23f61 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -331,6 +331,12 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data, channel_method_t method) { + if (channel_data->low_speed_timeout == 0) { + channel_data->low_speed_timeout = SPEED_LOW_TIME_SEC; + DEBUG("cURL's low download speed timeout is disabled, " + "this is most probably not what you want. " + "Adapted it to %us instead.\n", SPEED_LOW_TIME_SEC); + } channel_curl_t *channel_curl = this->priv; channel_op_res_t result = CHANNEL_OK; if ((curl_easy_setopt(channel_curl->handle, CURLOPT_URL, @@ -340,7 +346,7 @@ channel_op_res_t channel_set_options(channel_t *this, (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_LIMIT, SPEED_LOW_BYTES_SEC) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_TIME, - SPEED_LOW_TIME_SEC) != CURLE_OK) || + channel_data->low_speed_timeout) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_HTTPHEADER, channel_curl->header) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_MAXREDIRS, -1) != diff --git a/include/channel_curl.h b/include/channel_curl.h index 5afb66f..eec071e 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -43,6 +43,7 @@ typedef struct { unsigned int offs; unsigned int method; unsigned int retries; + unsigned int low_speed_timeout; bool debug; bool usessl; bool strictssl; From patchwork Mon Mar 5 15:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::23e; helo=mail-wr0-x23e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbook6xkakgqev52emsq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="XdzTyF3J"; dkim-atps=neutral Received: from mail-wr0-x23e.google.com (mail-wr0-x23e.google.com [IPv6:2a00:1450:400c:c0c::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw3zw4hGZz9s3p for ; Tue, 6 Mar 2018 02:41:48 +1100 (AEDT) Received: by mail-wr0-x23e.google.com with SMTP id q15sf11373194wra.22 for ; Mon, 05 Mar 2018 07:41:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264506; cv=pass; d=google.com; s=arc-20160816; b=P5Jn1Kjf54okCkULi7xBI9P+QSlQpTG81hPX/MOBHujeAmyErSXh/k/J5im3/25uv/ L8Z8zGm1wkU0/JY+ROcw8N1l5/Hq+7C75kA4znlujPbQfgXgeu+MmHF816HDiWm6T7vb zbMJH6DcMsZICdmeSoqbKJP/wIl9NjD4zVVlz+qshtFVZ4vprxHJL+iPD0CKWvrarUfa V/rgEpwXaKkjvwuyteqb8um4TnzncZpU4AgBkgFM3orx3Jfbx0oklc1q/d45AXUQkSD7 uUDJ2pzwpyxook7Hp+RYmvTNSwvTJlxoQUjfOmHJ29fY/U5rREpI5dLtPb9aHVIlk41d ww8A== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=i8z5xX6dSVTrPp8sP7/xU6jITknP5bndGhP1Gw5083A=; b=J04LHwn/GK3X4nMyhf7aVEyWjqgxObjxfaNvsw3fo6nDgS1SOfxTI9YY94q3zcze9E Xp0vd7sOtb63CE2mn/ZogfAfIP+V1uWvIwhgoTbk0R/VGZcY0syNbCAKBh1MldQAPVam cMRGdH/mFk/OLWoa5RiK+WEbirluo31/uTSoOHqoAkwBSzDRL38/IuzDj9IrYRI5Qrz0 5EJT4SJ2Hoqk3H9sKyCSituwSI30C7HD3VA9ALrbSc5CpE+nsC47RfmLWqSBXOC8/ed/ yzhXFPK1cM88oMYfv/X0fc7gqurJo4HK2C/L5i8ZUs6qcfjQ9/Q5KgL4mYzZ4fG5l92J yD+w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=i8z5xX6dSVTrPp8sP7/xU6jITknP5bndGhP1Gw5083A=; b=XdzTyF3JSBphHsQ1UzQRi8k7oTlOyrYazXDACSztYfqsku4zpv0C0zZSbU0wtnjX1p mvFAs0a2ZrJEZ3n9UrieOatC+t52V5xDEH0Jw7tbM+qvxe709r0qhIheoZKAtWV7tAQk /ciUDFQeD57YttiG5kyqC7wGk+/gw1OnwLk/Z/Jb6AenKP3wCZ+1QBCbEShbCTKl5XuM nz6eMP5tTD5xaFMydmboDNQlTfXHAcH0vk0/RnbUSOrGWNO26GO5vRAt8fXMvVgagZ02 AfT4712+hMSIiUkj3s0D+t2InBgXR/vQatUm3DciU2JkD2s/vyKghgNmaFoGXZrPBqf/ yUBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=i8z5xX6dSVTrPp8sP7/xU6jITknP5bndGhP1Gw5083A=; b=eURansn6Fx5OT8AO+HlyFAgxgDWRqrm3PYfFBzFQYYOmwIhFQX2ymKtKTgCgmZwGD6 J/QHA14fEvpTSvpXNLOV3eoO98KUXdkBTV9xRppN6ZDl5YjRDuuJVSBsB4tQBvrab8LX GnX2eyS270sWJ0HaYpNB6a4lLQD5ZV4S8PJSmrZGdSd8JTgZPAvwPco7MndZ62YU9K9u F4DM/yJeWGNxyYgX9JudK+jq0PSyo8sO8T6B+8UsVvF9WhFEBGHh7/u3PUr9RDs606xc J38VmCKoEP1lxc4roqu8g9B+cO1drcqc1CqfVooYnBDIWqBB4MDKJ2Mw0xCEifHPxsz6 4N0w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7GZ1nDPOyqyvtONaQqrzA4gg8mEblnWDNxjdhc+KUSaFCFgtyAx 3ey0Yo4ChMpwbzLWgeuBycQ= X-Google-Smtp-Source: AG47ELtRokcqVm/FibhrA8v6gY3d0+ojFG0vTRHxIKCS86lwJb4q5gUIsuHqZu8DQJEJBlJz88Cayg== X-Received: by 10.28.199.66 with SMTP id x63mr146410wmf.2.1520264506082; Mon, 05 Mar 2018 07:41:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.170.1 with SMTP id t1ls1561058wme.7.gmail; Mon, 05 Mar 2018 07:41:45 -0800 (PST) X-Received: by 10.28.116.17 with SMTP id p17mr1101659wmc.29.1520264505232; Mon, 05 Mar 2018 07:41:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264505; cv=none; d=google.com; s=arc-20160816; b=s8YR7aeImsm322guVFGXDJyXGC0cB63DQU5/kohIBu0e6IjQNCES6hwsv3CPePCbhn hfhJc3pin5ta3GKhz6k3y3Xki7daGNOWZVStkSth4rjgsJbrjw31ndB+6Cc8L2VH/U4q TAh0R5hTzXT1vWeAjIjvyy1ZsVun6Wz+fnxhxL/7lb9yAIWrZxVHRt0m1SM7yHEAyOgN a1TGkv23XGFmxKK7+VTOuHH49XW2ZlLLHhR/mNFE2VBrSI7oU4cA/rpsX3J16g+YNe2O 2fqr3WkS6sl2PTfK17uuG7adXmz5bY188/r20AUjCWAvpRB0kez2818Xhe7EDIOMSnyb 7pUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cNwTQH6nY3j3s3rrlngxLqqPPGCWpEc+LSodzsNwPmo=; b=TDU8UL+N//4OTKoFcVD/D8IKGDL8GbEAXRhU/kpHXEfVrPeKQ3CXcadREBtYYBvGwD qER3JLERhCD/y/1p8jJuAO6zfyk/oBOm8spT2MoMmQvicbFTER8p/6FE+4cOTWjEQJj0 qKHnGgr4PugarY+ARI2v+/EHy6I8axIbt2v/p01z/SXHRj6bUQiblRPdyz8Sg9soFoP1 1A48kxl74dbOzHIYJ5TsLNkz2PBLdZaeNO3fGE0S1TOYV3uDcEnp5J2wAR9sgaNhmMlz /4iyI0Ynuce3KopqUrVwjqfBO8BQQIFe9jR4mBjdqxe/fANVHpj6dVnGaLBNI8ws+ZVu gTZA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id t15si296267wmh.1.2018.03.05.07.41.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:45 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w25FfiXn003161 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:44 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYJ022466; Mon, 5 Mar 2018 16:41:44 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 4/8] channel_curl: emit download progress Date: Mon, 5 Mar 2018 16:40:02 +0100 Message-Id: <20180305154006.18122-4-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , Emit the download progress via the notification system as SUBPROCESS, so that it also gets forwarded to the progress interface, in preparation to make the downloader process use channel_curl and be able to report progress over the progress interface. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index ea23f61..1bac778 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -327,6 +328,37 @@ channel_op_res_t channel_map_curl_error(CURLcode res) } } +static int channel_callback_xferinfo(void *p, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t __attribute__((__unused__)) ultotal, + curl_off_t __attribute__((__unused__)) ulnow) +{ + if ((dltotal <= 0) || (dlnow > dltotal)) { + return 0; + } + double percent = 100.0 * (dlnow/1024.0) / (dltotal/1024.0); + double *last_percent = (double*)p; + if ((int)*last_percent == (int)percent) { + return 0; + } + *last_percent = percent; + char *info; + if (asprintf(&info, + "{\"percent\": %d, \"msg\":\"Received %" CURL_FORMAT_CURL_OFF_T "B " + "of %" CURL_FORMAT_CURL_OFF_T "B\"}", + (int)percent, dlnow, dltotal) != ENOMEM_ASPRINTF) { + notify(SUBPROCESS, RECOVERY_NO_ERROR, TRACELEVEL, info); + free(info); + } + return 0; +} + +static int channel_callback_xferinfo_legacy(void *p, double dltotal, double dlnow, + double ultotal, double ulnow) +{ + return channel_callback_xferinfo(p, (curl_off_t)dltotal, (curl_off_t)dlnow, + (curl_off_t)ultotal, (curl_off_t)ulnow); +} + channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data, channel_method_t method) @@ -368,6 +400,28 @@ channel_op_res_t channel_set_options(channel_t *this, goto cleanup; } + double percent = -INFINITY; + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_PROGRESSFUNCTION, + channel_callback_xferinfo_legacy) != CURLE_OK) || + (curl_easy_setopt(channel_curl->handle, CURLOPT_PROGRESSDATA, + &percent) != CURLE_OK)) { + result = CHANNEL_EINIT; + goto cleanup; + } +#if LIBCURL_VERSION_NUM >= 0x072000 + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_XFERINFOFUNCTION, + channel_callback_xferinfo) != CURLE_OK) || + (curl_easy_setopt(channel_curl->handle, CURLOPT_XFERINFODATA, + &percent) != CURLE_OK)) { + result = CHANNEL_EINIT; + goto cleanup; + } +#endif + if (curl_easy_setopt(channel_curl->handle, CURLOPT_NOPROGRESS, 0L) != CURLE_OK) { + result = CHANNEL_EINIT; + goto cleanup; + } + if (channel_data->strictssl == true) { if ((curl_easy_setopt(channel_curl->handle, CURLOPT_SSL_VERIFYHOST, From patchwork Mon Mar 5 15:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::23f; helo=mail-wr0-x23f.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbqgk6xkakgqe33yc62i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="FJp+4z3N"; dkim-atps=neutral Received: from mail-wr0-x23f.google.com (mail-wr0-x23f.google.com [IPv6:2a00:1450:400c:c0c::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw4024mTkz9sZf for ; Tue, 6 Mar 2018 02:41:54 +1100 (AEDT) Received: by mail-wr0-x23f.google.com with SMTP id q15sf11373329wra.22 for ; Mon, 05 Mar 2018 07:41:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264512; cv=pass; d=google.com; s=arc-20160816; b=YGGzeHCwpkMlZbRpEqE+fvgnhKYjmXrNSIoIfnciKZCy4lvJyRl4gB9HRlpo9+uAH8 1LzYfErsREQb8OdNDNWvVOBVtZo52EgxraAlAwhTT8iAZ03iPqbZSATrnOirE6Fo1zjC xaTh+8g5YJAdzmiAInVrJZV+nV1xIIBWWHv3nuJD5NfuD8xZI51c+obtlGL7gLKcW3S0 09H+HNTNF/vTJh29yaYQ74nevLYGSX/QcbroAGnBdSMJOs2Z/1PJnC4i8IqaM5hiBPuC fZbEEgxmaj7fM78tXUp8ONB3R0D9g7FIsvU3J3JsX05kepNRNnYLiBDxoqml3UsD4cvM UT6w== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=v8BR/5EyGhjNDhrYZDSLeL7T6fLXhz+cluVELTy85Qk=; b=JDvkkppKgKkoyLoyJVWwDBeeWqTrhj9bhjaKJpY5fnKCqSWek53dThyygcO6PsWgSO E6aLqE5E4fzvYT1uu57AkmPytGI1xfodqxaeJ1JKIzDAO2CWEReHjBnXAHzZMbIES2VP FdKKS7Qhl6MueoIgUqpHA8w97FkC8ez9lYiJ+8KXEUkJwcwi1DIli4vtAkqsl4mfyvpY BiNSR+MFy8WApAHEg77nQz3z/nTuAy1UPndOY/3eDs79r+xRJnfm74Jl60+te4MkOkab 43YETDdkbVIcsuUqpjr0iFlH18HVN2YSOdzuGld2jzNcvasxV7ge8mWw59Xi4gql8pSO zNuw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=v8BR/5EyGhjNDhrYZDSLeL7T6fLXhz+cluVELTy85Qk=; b=FJp+4z3NQnIlVWYxfMUgYt5/0AI5GH9ZkHBs8sYCwq9LgZ6Oc7Ff0GXJDvWcuOASDH G0NCBxH7DJqhMEFBQLY6DMwdjtUGCyqQQp9ibfSzv5hve9a/N31nW0FUxRxb44uSpC88 VUsEYjRyHTTcNSNVzjaBs0aZAJzp6MX0w7DyKBrSAAfR+bZMAexRjsHMyEF9mVdzMJrz 7fGrVTeMp5JBDGkKN9KSM/rutjAu9DFhsu6Fdk3IkwYjJmflGpA5QMw+BWxow/V0rFoH fbyHybqcFHGm7d3jhTg53UDATFsl39H8G6vwkUd5AjHXjz03Oh1sXEwWzG5FEqpyuyQf V37w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=v8BR/5EyGhjNDhrYZDSLeL7T6fLXhz+cluVELTy85Qk=; b=TtsC7qboSlezHWOiDBKP0ZIpOsdE4oB6J9yP8K//B/z29UuHi8qyP6gI3CoLUxNWqq EWkgfWB4jrvVVGSI/CbjR9Wa2JX/cKI9+A6csed2BPZvJR28XW5ci7/BBPPnyFDPE7LM Mr2+zv3pTp+m/G32DYQcCEQ1gKqySFTh33NvYy4TBPFhtKS3KyCB51cch9UQsdoi3Wux 3Ad48BNeN3OgIVIvKMKcIotl6kq5S2stOcBvaH3bAGcjCOCS2J5Nn6hOLRRj2ux6Tuev nDmazUX4Xk5d24uC++Kwvvnf86qyDHWSoJFos2trPuiIdId9nlEiyrMRblEIxJrPirBD daiQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7EhAzbmAg4vpipyn+Ki2VHY5Q8eNZgNIi9JPo1ptFNI48l8haal +iAl46GohPxy0esAqTl7K/E= X-Google-Smtp-Source: AG47ELv4Pd4tWrO4zPP3lUhW2v2zqVJZ1QmpyVfuxjSuBGdv0cVLWTMzPBr//hdz/Tof+VbKYErMgw== X-Received: by 10.28.63.139 with SMTP id m133mr142635wma.3.1520264512317; Mon, 05 Mar 2018 07:41:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.135.246 with SMTP id c51ls4458251wrc.11.gmail; Mon, 05 Mar 2018 07:41:51 -0800 (PST) X-Received: by 10.223.150.47 with SMTP id b44mr1326151wra.7.1520264511722; Mon, 05 Mar 2018 07:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264511; cv=none; d=google.com; s=arc-20160816; b=dj/LdHfaOK+GSoQ98FBeTL/c9b07Zp1rQWqkPzFWWOe/4npbXPvTyROqRoYgxNu/v7 +KPMmBvRSzuW9ch8sMgIc5q3hXHD34dlusk99s4n3nHQvzDYXG1PBQpaw72DlmAoxfbL NJu7Lz38/6xD3G/M/S7wzoSFiHjBlED70frdCvHmvrrxdkSp8ypEQSo0lkEtuiyqhiac 9TTFaj0l+aZDMuxn7v2rWwuwYNGYzeUQIVEIFyoTMeXBtLG/kqSftiqt7vXYnIM/+7BI JxX9BVksEZsy6mTGx9seNrRZRWXJgyj5VblM9/qZzBBZkuFTwJ0tj86NNkV/b9hTIud5 2Mxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hMDwQlPIaDwaQWJZ5mrhn0cFFhMNUBmIk4yiZ5a9qow=; b=aVcWLvMf0Sb7YYWkhF086cmHuDRs4lOYC8AAgE1cVVGYstZUs+beoVerU2RGMrkooL YSCkcda/6IXP3DAAjgAj7lZqTgPDZ3bm4fIoJlRDTOsWvjKXG3ab9tMJSX+/Dh7eof1l RQBxFidrbpGmWc9xdzSA9vgpVKGCJb7+hNJ3JokoVGDACcpKxrOWNIDkT+/1RWgdqJgs WQkJPHnIgc09kqOqqy6h5j1aBXZ5VFCT0WMAM400i+FLpqs6IHPcI6jYOz4TCXLqIfZs 4JJzEJgciW7RVF6R1Nq+exOo7Ucgy4V3Lq+xFiXVmmGZVxe3rYHnpCeVdyfsX5QzzJj2 PETA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id a138si249965wmd.0.2018.03.05.07.41.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w25Ffphw021116 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:51 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYK022466; Mon, 5 Mar 2018 16:41:51 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 5/8] downloader: make use of channel_curl Date: Mon, 5 Mar 2018 16:40:03 +0100 Message-Id: <20180305154006.18122-5-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , Instead of the downloader having an own cURL binding implementation, make use of the generic channel_curl. Signed-off-by: Christian Storm Reviewed-by: Stefano Babic --- Kconfig | 2 +- corelib/downloader.c | 347 +++++++-------------------------------------------- 2 files changed, 49 insertions(+), 300 deletions(-) diff --git a/Kconfig b/Kconfig index fe2f5ae..ed5559c 100644 --- a/Kconfig +++ b/Kconfig @@ -286,7 +286,7 @@ config DOWNLOAD bool "Enable image downloading" default n depends on HAVE_LIBCURL - select CURL + select CHANNEL_CURL help Enable update from image URL using libcurl. The stream is sent via IPC to the installer as it is done for other interfaces. diff --git a/corelib/downloader.c b/corelib/downloader.c index 108a6f6..23471f1 100644 --- a/corelib/downloader.c +++ b/corelib/downloader.c @@ -5,29 +5,17 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include -#include -#include -#include #include -#include #include -#include -#include -#include -#include - -#include "bsdqueue.h" #include "util.h" -#include "swupdate.h" -#include "installer.h" #include "network_ipc.h" +#include "download_interface.h" +#include "channel.h" +#include "channel_curl.h" #include "parselib.h" -#include "swupdate_status.h" #include "swupdate_settings.h" -#include "download_interface.h" #define SETSTRING(p, v) do { \ if (p) \ @@ -37,30 +25,13 @@ /* * Number of seconds while below low speed - * limit before aborting - * it can be overwritten by -t + * limit before aborting. It can be overwritten + * by -t command line flag. */ #define DL_LOWSPEED_TIME 300 #define DL_DEFAULT_RETRIES 3 -static int cnt = 0; - -struct dwl_options { - char *url; - unsigned int retries; - unsigned int timeout; - char *auth; -}; - -/* notify download progress each second */ -#define MINIMAL_PROGRESS_INTERVAL 1 - -struct dlprogress { - double lastruntime; - CURL *curl; -}; - static struct option long_options[] = { {"url", required_argument, NULL, 'u'}, {"retries", required_argument, NULL, 'r'}, @@ -68,242 +39,37 @@ static struct option long_options[] = { {"authentification", required_argument, NULL, 'a'}, {NULL, 0, NULL, 0}}; - -/* - * Callback from the libcurl API to progress meter function - * This function gets called by libcurl instead of its internal equivalent. - */ -static int download_info(void *p, - curl_off_t dltotal, curl_off_t dlnow, - curl_off_t __attribute__ ((__unused__)) ultotal, - curl_off_t __attribute__ ((__unused__)) ulnow) -{ - struct dlprogress *dlp = (struct dlprogress *)p; - CURL *curl = dlp->curl; - double curtime = 0; - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &curtime); - - if ((curtime - dlp->lastruntime) >= MINIMAL_PROGRESS_INTERVAL) { - dlp->lastruntime = curtime; - INFO("Received : %" CURL_FORMAT_CURL_OFF_T " / %" - CURL_FORMAT_CURL_OFF_T, dlnow, dltotal); - } - - return 0; -} - -/* for libcurl older than 7.32.0 (CURLOPT_PROGRESSFUNCTION) */ -static int legacy_download_info(void *p, - double dltotal, double dlnow, - double ultotal, double ulnow) -{ - return download_info(p, - (curl_off_t)dltotal, - (curl_off_t)dlnow, - (curl_off_t)ultotal, - (curl_off_t)ulnow); -} - -/* - * Callback from the libcurl API - * It is called any time a chunk of data is received - * to transfer it via IPC to the installer - */ -static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp) -{ - int ret; - int fd; - - if (!nmemb) - return 0; - if (!userp) { - ERROR("Failure IPC stream file descriptor \n"); - return -EFAULT; - } - - fd = *(int *)userp; - ret = ipc_send_data(fd, buffer, size * nmemb); - if (ret < 0) { - ERROR("Failure writing into IPC Stream\n"); - return ret; - } - cnt += size * nmemb; - - return nmemb; -} - -/* Minimum bytes/sec, else connection is broken */ -#define DL_LOWSPEED_BYTES 8 - -/* - * libcurl options (see easy interface in libcurl documentation) - * are grouped together into this function - */ -static void set_option_common(CURL *curl_handle, - unsigned long lowspeed_time, - struct dlprogress *prog) -{ - int ret; - - prog->lastruntime = 0; - prog->curl = curl_handle; - - curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "swupdate"); - - curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, legacy_download_info); - curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, prog); -#if LIBCURL_VERSION_NUM >= 0x072000 - /* xferinfo was introduced in 7.32.0, no earlier libcurl versions will - compile as they won't have the symbols around. - - If built with a newer libcurl, but running with an older libcurl: - curl_easy_setopt() will fail in run-time trying to set the new - callback, making the older callback get used. - - New libcurls will prefer the new callback and instead use that one - even if both callbacks are set. */ - curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, download_info); - curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, prog); -#endif - curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 0L); - - curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_LIMIT, DL_LOWSPEED_BYTES); - curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_TIME, lowspeed_time); - - /* enable TCP keep-alive for this transfer */ - ret = curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPALIVE, 1L); - if (ret == CURLE_UNKNOWN_OPTION) { - TRACE("No keep alive (unsupported in curl)"); - return; - } - - /* keep-alive idle time to 240 seconds */ - curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPIDLE, 240L); - - /* interval time between keep-alive probes: 120 seconds */ - curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPINTVL, 120L); -} - /* - * This provide a pull from an external server - * It si not thought to work with local (file://) - * for that, the -i option is used. + * This provides a pull from an external server + * It is not thought to work with local (file://) + * files. For that, the -i option is used. */ -static RECOVERY_STATUS download_from_url(char *image_url, unsigned int retries, - unsigned long lowspeed_time, char *auth) +static RECOVERY_STATUS download_from_url(channel_data_t* channel_data) { - CURL *curl_handle; - CURLcode res = CURLE_GOT_NOTHING; - int fd; - int attempt = 10; - int result; - double dummy; - unsigned long long dwlbytes = 0; - unsigned int i; - struct dlprogress progress; - - - /* - * Maybe daemon is not yet started, - * try several times - */ - while (--attempt) { - fd = ipc_inst_start(); - if (fd > 0) - break; - sleep(1); - } - - if (fd < 0) { - ERROR("Error getting IPC: %s\n", strerror(errno)); + channel_t *channel = channel_new(); + if (channel->open(channel, channel_data) != CHANNEL_OK) { + free(channel); return FAILURE; } - errno = 0; - TRACE("download from url started : %s", image_url); - if (!image_url || !strlen(image_url)) { - ERROR("Image URL not provided... aborting download and update\n"); - return FAILURE; - } - - /* We are starting a download */ + TRACE("Image download started : %s", channel_data->url); notify(DOWNLOAD, 0, INFOLEVEL, NULL); - curl_global_init(CURL_GLOBAL_ALL); - curl_handle = curl_easy_init(); - if (!curl_handle) { - /* something very bad, it should never happen */ - ERROR("FAULT: no handle from libcurl"); - return FAILURE; - } - - /* Set URL */ - if (curl_easy_setopt(curl_handle, CURLOPT_URL, image_url) != CURLE_OK) { - TRACE("Runs out of memory: serious internal error"); - return FAILURE; - } - - /* Set Authentification */ - if (auth && curl_easy_setopt(curl_handle, CURLOPT_USERPWD, auth) != CURLE_OK) { - TRACE("Runs out of memory: serious internal error"); - return FAILURE; - } - - curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); - curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &fd); - set_option_common(curl_handle, lowspeed_time, &progress); - - TRACE("Image download started : %s", image_url); - - for (i = 0; (res != CURLE_OK); i++) { - /* if resume, set the offset */ - if (i) { - TRACE("Connection with server interrupted, try RESUME after %llu", - dwlbytes); - if (curl_easy_setopt(curl_handle,CURLOPT_RESUME_FROM_LARGE, - dwlbytes) != CURLE_OK) { - TRACE("CURLOPT_RESUME_FROM_LARGE not implemented"); - break; - } - - /* motivation: router restart, DNS reconfiguration */ - sleep(20); - } - res = curl_easy_perform(curl_handle); - - /* if size cannot be determined, exit because no resume is possible */ - if (curl_easy_getinfo(curl_handle, - CURLINFO_SIZE_DOWNLOAD, - &dummy) != CURLE_OK) - break; - - dwlbytes += dummy; - - /* Check if max attempts is reached */ - if (retries && (i >= retries)) - break; - - } - - curl_easy_cleanup(curl_handle); - curl_global_cleanup(); - - if (res == CURLE_OK) { - result = ipc_wait_for_complete(NULL); - } else { - INFO("Error : %s", curl_easy_strerror(res)); + RECOVERY_STATUS result = SUCCESS; + channel_op_res_t chanresult = channel->get_file(channel, channel_data, FD_USE_IPC); + if (chanresult != CHANNEL_OK) { result = FAILURE; } - - ipc_end(fd); - + ipc_wait_for_complete(NULL); + channel->close(channel); + free(channel); return result; } static int download_settings(void *elem, void __attribute__ ((__unused__)) *data) { - struct dwl_options *opt = (struct dwl_options *)data; - char tmp[128]; + channel_data_t *opt = (channel_data_t *)data; + char tmp[SWUPDATE_GENERAL_STRING_SIZE]; GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "url", tmp); if (strlen(tmp)) { @@ -320,7 +86,7 @@ static int download_settings(void *elem, void __attribute__ ((__unused__)) *dat get_field(LIBCFG_PARSER, elem, "retries", &opt->retries); get_field(LIBCFG_PARSER, elem, "timeout", - &opt->timeout); + &opt->low_speed_timeout); return 0; } @@ -338,40 +104,36 @@ void download_print_help(void) DL_DEFAULT_RETRIES, DL_LOWSPEED_TIME); } +static channel_data_t channel_options = { + .source = SOURCE_DOWNLOADER, + .debug = false, + .retries = DL_DEFAULT_RETRIES, + .low_speed_timeout = DL_LOWSPEED_TIME +}; + int start_download(const char *fname, int argc, char *argv[]) { - struct dwl_options options; - unsigned int attempt; - int choice = 0; - RECOVERY_STATUS result; - - memset(&options, 0, sizeof(options)); - - options.retries = DL_DEFAULT_RETRIES; - options.timeout = DL_LOWSPEED_TIME; - options.auth = NULL; - if (fname) { - read_module_settings(fname, "download", download_settings, - &options); + read_module_settings(fname, "download", download_settings, &channel_options); } /* reset to optind=1 to parse download's argument vector */ optind = 1; + int choice = 0; while ((choice = getopt_long(argc, argv, "t:u:r:a:", long_options, NULL)) != -1) { switch (choice) { case 't': - options.timeout = strtoul(optarg, NULL, 10); + channel_options.low_speed_timeout = strtoul(optarg, NULL, 10); break; case 'u': - SETSTRING(options.url, optarg); + SETSTRING(channel_options.url, optarg); break; case 'a': - SETSTRING(options.auth, optarg); + SETSTRING(channel_options.auth, optarg); break; case 'r': - options.retries = strtoul(optarg, NULL, 10); + channel_options.retries = strtoul(optarg, NULL, 10); break; case '?': default: @@ -379,34 +141,21 @@ int start_download(const char *fname, int argc, char *argv[]) } } - result = FAILURE; - - /* - * Maybe we need a different option as retries - * to check if an updated must be retried - */ - for (attempt = 0;; attempt++) { - result = download_from_url(options.url, options.retries, - options.timeout, options.auth); - if (result != FAILURE) { - ipc_message msg; - if (ipc_postupdate(&msg) != 0) { - result = FAILURE; - } else { - result = msg.type == ACK ? result : FAILURE; - } - break; + RECOVERY_STATUS result = download_from_url(&channel_options); + if (result != FAILURE) { + ipc_message msg; + if (ipc_postupdate(&msg) != 0) { + result = FAILURE; + } else { + result = msg.type == ACK ? result : FAILURE; } + } - if (options.retries > 0 && attempt >= options.retries) - break; - - /* - * motivation: slow connection, download_from_url fetched half the - * image, then aborted due to lowspeed_timeout, if we retry immediately - * we would just waste our bandwidth. Useful for A/B images. - */ - sleep(60); + if (channel_options.url != NULL) { + free(channel_options.url); + } + if (channel_options.auth != NULL) { + free(channel_options.auth); } exit(result == SUCCESS ? EXIT_SUCCESS : result); From patchwork Mon Mar 5 15:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::239; helo=mail-wr0-x239.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbq6k6xkakgqevvq52qy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="L4b7vgsv"; dkim-atps=neutral Received: from mail-wr0-x239.google.com (mail-wr0-x239.google.com [IPv6:2a00:1450:400c:c0c::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw4061VXdz9s3p for ; Tue, 6 Mar 2018 02:41:58 +1100 (AEDT) Received: by mail-wr0-x239.google.com with SMTP id c37sf11606903wra.5 for ; Mon, 05 Mar 2018 07:41:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264516; cv=pass; d=google.com; s=arc-20160816; b=FHBgwKUyCVP+VwZTGj3msYrhpMce3m7TAVruXgFu1GlA9lGklB+O1aG6ACu3/cdvFx Odw5mrLf7o0Sv2rLcBCWQ7kpOtfAMj2WVayYBpYzKJ1XoSO8pzT9NwzyoVL29NFCRFEy 6i5nMK8CQJqrbBmxRcp99KCUF5vbZEL9Zp+T4ma8skouAtD66cfC61MWW0Hn0FGggF3L UGJfCco3Kcu53zz69iGDE5j1wXLYUOzz2auAPHl6dflhL5RYs9aZ73RtGPBU4ZsxnMJP Sep5VfB3qeXojfcjZutosWWalC00V/eH0VK+pHubeMZCQlZ4lqnkjuymKpApXVH6SGpO q0Zw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=gwHOah6UyHEhJ1g6Ubxls2fzjVH0aTCmrcsyrLZ+0YU=; b=MMok78q4C1/HM24nuEoA7ISceKXHcC6qsfE0D4b7QPv5RBFxu9yxO/TL0bjAbpD85t KmrvtVYIpHiwKYSI9frTtTI1bRSbtmLZwVv4MG9usPyxHATrte/x5ZSRRa0p3qmI7Alu a9jsCHlMtkw42Nb3SFEN143mrzgNg9lIR1AcwspAnm7w09Qm2glMa11R9SrO5+U/rH0x l2hsXjO/w/QuO9qPxJM6SG2IQSvcfvdL9D/0AvOMissE+y+XTGts7QSbXKDJb2d83Uv5 8G2jRqhFM6sUdIVA5PrqT0O/QUeWdqrHsG3+o+DzKBhigATuCXAdcOCMh4M1ee8kY32h eEFw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=gwHOah6UyHEhJ1g6Ubxls2fzjVH0aTCmrcsyrLZ+0YU=; b=L4b7vgsv/OBYyyVON1oRrWnjv/DC55fBwWuZcsWxafjqyAdbuJI8jvAQ5ktMJElLsh mQQwppOL+80PeXEZJlQbEX3C9QZIU0L0Tant8/Q6BhBGh2VqBwzDs+5Ifb6S0Y3S9TJq 5w2fvR4/+SIqqqv0H0k9X0VAiek23kDfqC8dSPyLhgiaVKTss7qGLqX4faIQ78GkQfA6 mJ9f/m8grZ0AC4Ilr/kXuAfpX0B1X4QKv/0ugVafkGwcJrnoIjHf+XG9rniqdKrfekXP mseecAGWErfpOEfnMZF0b4UbSqR5iVN8PuqCnZzOSwhjNTfS4sfrVaNuVu1jGYea4W+i wPPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=gwHOah6UyHEhJ1g6Ubxls2fzjVH0aTCmrcsyrLZ+0YU=; b=itxTk3tDFoS8OroJlstZfdGWArHqRpbUY0XUKBF4dpHIMHhtS90WyiYvPZDIWZYi+S tTpeK58LFn+4JFba/ndKErVUXrvaLEoHkitcwrficUufiUvBX7hz/JnTggu0wE/L3W+7 BnpJ1Sx9XwmYQsRtMeRoCNbVD3BeBJdXMn8r/kItgb2GoY6rAOJdw+3vkxANTOU7w9TN lGjQSwfnELBp4qRKduvp8OcrSJk6zvYPhRDmNyR5QzHwU3qTsCg9d7sEb0RuWSk7Ae38 RluchY9REIx2J7PgdcY1oPof1Kt6WllKrqm9GImzKsG0eKdWXLiocZbwVRsK73jRSQuK z/gw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7GaWvgmPDhBBBBnoxHXu8iJMo69oqq2XNQfT+fEfqOtbs5o7F7Y BSB+wy+gG5baHuOyY6mzcRI= X-Google-Smtp-Source: AG47ELv1iHzj+OnT+iPs5k3tBHfG9q28sIebs4LK9zoGZ9suf6iHul3WM2W0LzTg/9uAJhFB/SvRpQ== X-Received: by 10.28.114.25 with SMTP id n25mr142116wmc.5.1520264515996; Mon, 05 Mar 2018 07:41:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.197.200 with SMTP id v191ls1591741wmf.1.canary-gmail; Mon, 05 Mar 2018 07:41:55 -0800 (PST) X-Received: by 10.28.126.193 with SMTP id z184mr506478wmc.14.1520264515456; Mon, 05 Mar 2018 07:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264515; cv=none; d=google.com; s=arc-20160816; b=UsXBt+sw5/ODtLKvj6SpLzjJplBb/7XFAPzFNzV7ICuu7h/ei5wy15TUZVK1frucIc AIknbf4n9r1qykpqrJfcQ8uKFfofOQxKIO5rwaF5uVq37P0MtwIzaeHBi3Atb53KrZrw OP9j9MZ4s8xLqYXEPEXXIm6b0ZpEFN6lPQC43tJRhoOGT+ekSxChCJRg3CVvTpAd2Y4q dDdAmV61j6JMVDyWaqPUnDI3gKUIjUinW8Jg98XRp49K/5ZxFMS7/qYsOfApIt7gtHie lL7vCOxGaHet3A43nq742vWyXz0ewWpeO+xyB8aFe0bw7z7W/xNB1DqEiL7BQESMWiOp mcgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Tb6cAFFbJnTg7gyFtFMFTd9LeqY3mgXeVEyDGkm8XIM=; b=tjJHVza7WjKOlL+aLqP0pINgL6GGhBJZ+kNoOg5+dpxqgd4Xkrh382FqsEX+c+gEDB Uc3X/RrmDJzakdNpXKc9MNALK2xczTxmCFgV5GWsNESIYeik3jDrbh0Yvik8l0p1H7Dv corm0B3M8dLttIv2R5280DA+V3FHvXvrCpLEGyZl4DfCVc0H6TiYs/bAeYzHuJDuGFHR ECPcIuTKkJ8rCQL+ZK4Es3KF+OeAE0UtWXBt2DogRMQPIQIZkSF+uc4AycxN0e4zt2le FR/u/oqkUUSG+mihF3XQjEaIT154/tCIfZ3uZ8XJCyISs8egpAtYc8tCb8S+mX2uOXXK bucw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id a72si211362wme.1.2018.03.05.07.41.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:55 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w25Ffthq021175 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:55 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYL022466; Mon, 5 Mar 2018 16:41:54 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 6/8] channel_curl: remove hard dependency on JSON Date: Mon, 5 Mar 2018 16:40:04 +0100 Message-Id: <20180305154006.18122-6-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , Currently, channel_curl relies on CONFIG_JSON. However, this is mostly only required for preparing channel_get()'s return value as proper json_object to be consumed further. If used for, e.g., the dowloader, such preparation is not necessary. Hence, enclose JSON-specifics in #ifdef's. Signed-off-by: Christian Storm --- Kconfig | 2 -- corelib/channel_curl.c | 7 ++++++- handlers/Config.in | 1 + include/channel_curl.h | 4 ++++ suricatta/Config.in | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Kconfig b/Kconfig index ed5559c..1ac2b81 100644 --- a/Kconfig +++ b/Kconfig @@ -297,9 +297,7 @@ comment "Image downloading support needs libcurl" config CHANNEL_CURL bool depends on HAVE_LIBCURL - depends on HAVE_JSON_C select CURL - select JSON config HASH_VERIFY bool "Allow to add sha256 hash to each image" diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 1bac778..a6e0284 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -21,6 +21,9 @@ #include "sslapi.h" #include "channel.h" #include "channel_curl.h" +#ifdef CONFIG_JSON +#include +#endif #define SPEED_LOW_BYTES_SEC 8 #define SPEED_LOW_TIME_SEC 300 @@ -979,6 +982,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) http_response_code); } +#ifdef CONFIG_JSON assert(channel_data->json_reply == NULL); enum json_tokener_error json_res; struct json_tokener *json_tokenizer = json_tokener_new(); @@ -999,6 +1003,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) cleanup_json_tokenizer: json_tokener_free(json_tokenizer); +#endif cleanup_chunk: chunk.memory != NULL ? free(chunk.memory) : (void)0; cleanup_header: diff --git a/handlers/Config.in b/handlers/Config.in index 6226b59..da1110f 100644 --- a/handlers/Config.in +++ b/handlers/Config.in @@ -165,6 +165,7 @@ config SWUFORWARDER_HANDLER depends on HAVE_LIBCURL depends on HAVE_JSON_C select CHANNEL_CURL + select JSON default n help This allows to build a chain of updater. A diff --git a/include/channel_curl.h b/include/channel_curl.h index eec071e..13988fa 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -6,7 +6,9 @@ */ #pragma once +#ifdef CONFIG_JSON #include +#endif #include #include #include "sslapi.h" @@ -33,7 +35,9 @@ typedef struct { char *url; char *auth; char *json_string; +#ifdef CONFIG_JSON json_object *json_reply; +#endif char *cafile; char *sslkey; char *sslcert; diff --git a/suricatta/Config.in b/suricatta/Config.in index 2586169..55943c8 100644 --- a/suricatta/Config.in +++ b/suricatta/Config.in @@ -72,6 +72,7 @@ config SURICATTA_HAWKBIT depends on HAVE_LIBCURL depends on HAVE_JSON_C select CHANNEL_CURL + select JSON help Support for hawkBit server. https://projects.eclipse.org/projects/iot.hawkbit From patchwork Mon Mar 5 15:40:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c09::238; helo=mail-wm0-x238.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbsgk6xkakgqeu5dedxi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="NXZHErJl"; dkim-atps=neutral Received: from mail-wm0-x238.google.com (mail-wm0-x238.google.com [IPv6:2a00:1450:400c:c09::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw40B5jlkz9s3p for ; Tue, 6 Mar 2018 02:42:02 +1100 (AEDT) Received: by mail-wm0-x238.google.com with SMTP id u83sf4804964wmb.3 for ; Mon, 05 Mar 2018 07:42:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264520; cv=pass; d=google.com; s=arc-20160816; b=cP8XD81nQBRSI72UQt/di3r6G2XBoYfrrlgDiLkpgK8TIB7doFDuEWe9DZmxtp/99R 69noOg0fQUcQhyXI6qHfEf6HHyPuf4wDSf5mTN0EFGEjHokNKDrg6ns9KQpTwEZO3SsA 6KdB0C4/JXIT93yMJoiLm1D+brGZLBIgMBqTVj/S4Y+ZZDBabAxii4tXjAvs6hUnOigo drtG04YXAtDDdD721TiMDrianlThZZ3q2Jg+GIp5L719b6sOyqqgVkXXfV83hykSHxwo tQb4EDM3D6TNq0uo9Vo41sXjVqAnSjHbLNcUmgQvNnSazBPnRMp2IlXhk6BGI9jmV4Qj /eSg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=M/srug0zobH1kGcP3HvBD/mblHdFHYWA5wdOtJNQAkk=; b=cdcHcwciX+upuB8gakS8oE7Mr+FibR7i3fOdGI6WAdLlac5dDQKVsYjythtikgAQr5 ji0vFWeonThEJycsJfJWjfepdNBSBMYbIHYw6HTKyvRxZlC9MxkAyIR3msQAXCb4GL9q m8f2N6Rgkrm6vXU63zoUaHTHNI12cnEd0q6BThY1osQG0Sb7DOOlglIzG6GYQG34Suuc ViGp9bQcSLuojeh/w0Rj08p6CC51aqKloE0S7FrtMIoRBGqH8asgW6auU5vs2K8yAHC1 IGrJAkgx+jjqFBraYTQGIS67Ll7AElYyl5eIxVMPapl0HjNOyTmuNDsXwqBIkuUd3S5R DkvA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=M/srug0zobH1kGcP3HvBD/mblHdFHYWA5wdOtJNQAkk=; b=NXZHErJlfyezETooAdIwkujzTWwyvedaQqiHI/6BUyPx/FrRkd7NQGDWQOsNST17xB ZMGIMMi5SkL9JFvWh4URoPapFL7qbDmKiD6luyT8EUKNlI1J2c33M9dqzUsgKAKrAMrv G3tqfqUxqPD0fY0p2UknV+R26L6QP32ix8BkodmsVjJf2ge7AgZAIfyTNtzK/D9Jq1RT go/nmuoYHB699pd1ghLWUcHonS8aqBM/NpkNK6xy882w3pt3BEzBtG1mGsRAcJvV/rg0 QxzJjKaUvsqn0TGimWOG+HKYw4zfWNglR4qKGR63KiLxxtR8N3MmNCZREXXnNaZeN4BD nDpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=M/srug0zobH1kGcP3HvBD/mblHdFHYWA5wdOtJNQAkk=; b=OW9GTuFQKB/ZH7Y/JQBaNzU+vQgfND/AIMDmIeBylBL1SrioAIWDOpak8pdVXjF79f 7FVRvOvfWlqNPbxgfBpTyo1B6JmhOWhjTsoIH96HLYyLXkxZZv+WjHlbkUi7iID2ouvr zE/ZdSMlv7Im92GOCLh/QLneKyMK7U8yil79KYVFZXQl40Xqw39nP3YQpU6QC0MIyxfQ Bg/tVipdw6HfhC0YR+eXb1Vvl/1ZiY6OdzNPW7OQKiOTNCnTtpFN5w49bWHObOry0lJq sSFpFY1kbuNC19aukbSj/6p/oldZaPJ1rYk79xziqqY09W+TIZlmVlc7kpwZSuZflwvY NePQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7HUypxJwNv5dH7moR6UwVk4s1pDzNFu+LwYor+IhK9HLehXLnm9 2yNBUkfxsfnx2IKQ30alDT0= X-Google-Smtp-Source: AG47ELuNcKydNjxCEvQ4Cvfb2/aDDZuL0jjAGNAmxppw2dlhZc5nXpy5+mxfcqDD1FReqUuBzBZAJQ== X-Received: by 10.28.11.76 with SMTP id 73mr145871wml.1.1520264520203; Mon, 05 Mar 2018 07:42:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.124.15 with SMTP id x15ls1574657wmc.4.canary-gmail; Mon, 05 Mar 2018 07:41:59 -0800 (PST) X-Received: by 10.28.128.141 with SMTP id b135mr1142497wmd.15.1520264519175; Mon, 05 Mar 2018 07:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264519; cv=none; d=google.com; s=arc-20160816; b=1H2DzAl4P5IRc2k83BO6CoZ0NpAzRZTM73miGGgPBG+sVcjNOh5cELmH6HSD3KYfts zC0pBVfudwqLcrElnqf8sxa9l2TbL/Q7QdhdB5DfSB4fkrwdAxmFTErT8lJtwkDQJ4zc NKnJTRKzu5+QRk5jT4+5+PxlsaqgfNLFFh/aK6nFmj4dDhRae6JatKsvDX0ESMAnQMYj V0NIgl1Co36SCe7bPooi98NuvZP259BJs08NNNjWdyTpzdL2vFiw+MAdngwi93k5HJDl dFA56L9iS8t9a6lyfmXYIC7dJCCsBm7wSG33XuDH16kh2eZS8DtFLRkry896UpuA+yiP p9mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OMuV72DUMayCxxuQmOLrWwGFkU3uzIvJz1JzuBRrI78=; b=QYHJFm1OqGgyaNLSPXsWc7XGEgVcxcY2Bo/PlBZkVH/c2V875679deJ8ACWY2c78S4 ehNm3ONr/MJNyZAQhjE2QLhrGOFgtu3ugNYcqmpRyOynoea+pNW+E5RGGBTKGdZj3u7p iQmonjo8kg0qpaMN+K9ptXyXMZqgJnhMrbfZW5+0d/aVi5ZiQRHZxTlyrJvxdLoadxtq SAeRAlFS9fNymHzgp4lzPuTCXmac+VLEwpFFX4LhpOV0ZzCAIarZ0hTqdWhBsfrQlsbU SKqbD98MO90pfb+0VmI4gtEn3M/WxMRU+SNjclFs60k+HdVJ/XgVuS7mqTwkaCFgxDhk tpKA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id a139si226216wma.4.2018.03.05.07.41.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w25FfwpX003916 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:41:58 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYM022466; Mon, 5 Mar 2018 16:41:58 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 7/8] channel_curl: rename json_string -> request_body Date: Mon, 5 Mar 2018 16:40:05 +0100 Message-Id: <20180305154006.18122-7-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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: , As channel_curl should not be bound to be used exclusively with JSON, channel_data_t's json_string field is renamed to a more generic name request_body. Signed-off-by: Christian Storm --- corelib/channel_curl.c | 10 +++++----- include/channel_curl.h | 2 +- suricatta/server_hawkbit.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a6e0284..1340850 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -469,12 +469,12 @@ channel_op_res_t channel_set_options(channel_t *this, if ((curl_easy_setopt(channel_curl->handle, CURLOPT_POST, 1L) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_POSTFIELDS, - channel_data->json_string) != CURLE_OK)) { + channel_data->request_body) != CURLE_OK)) { result = CHANNEL_EINIT; goto cleanup; } if (channel_data->debug) { - TRACE("Post JSON: %s\n", channel_data->json_string); + TRACE("Posted: %s\n", channel_data->request_body); } break; } @@ -537,14 +537,14 @@ static size_t put_read_callback(void *ptr, size_t size, size_t nmemb, void *data size_t n; /* Check data to be sent */ - bytes = strlen(channel_data->json_string) - channel_data->offs; + bytes = strlen(channel_data->request_body) - channel_data->offs; if (!bytes) return 0; n = min(bytes, size * nmemb); - memcpy(ptr, &channel_data->json_string[channel_data->offs], n); + memcpy(ptr, &channel_data->request_body[channel_data->offs], n); channel_data->offs += n; return n; @@ -646,7 +646,7 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data) if ((curl_easy_setopt(channel_curl->handle, CURLOPT_READFUNCTION, put_read_callback) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)strlen(channel_data->json_string)) != CURLE_OK) || + (curl_off_t)strlen(channel_data->request_body)) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_READDATA, channel_data) != CURLE_OK)) { ERROR("Set channel option failed.\n"); diff --git a/include/channel_curl.h b/include/channel_curl.h index 13988fa..a1f9240 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -34,7 +34,7 @@ typedef enum { typedef struct { char *url; char *auth; - char *json_string; + char *request_body; #ifdef CONFIG_JSON json_object *json_reply; #endif diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 02ffb3a..a487354 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -325,7 +325,7 @@ server_op_res_t server_send_cancel_reply(channel_t *channel, const int action_id goto cleanup; } channel_data_reply.url = url; - channel_data_reply.json_string = json_reply_string; + channel_data_reply.request_body = json_reply_string; channel_data_reply.method = CHANNEL_POST; result = map_channel_retcode(channel->put(channel, (void *)&channel_data_reply)); @@ -443,8 +443,8 @@ server_send_deployment_reply(const int action_id, const int job_cnt_max, goto cleanup; } channel_data.url = url; - channel_data.json_string = json_reply_string; - TRACE("PUTing to %s: %s\n", channel_data.url, channel_data.json_string); + channel_data.request_body = json_reply_string; + TRACE("PUTing to %s: %s\n", channel_data.url, channel_data.request_body); channel_data.method = CHANNEL_POST; result = map_channel_retcode(channel->put(channel, (void *)&channel_data)); @@ -1434,8 +1434,8 @@ server_op_res_t server_send_target_data(void) } channel_data_reply.url = url; - channel_data_reply.json_string = json_reply_string; - TRACE("URL=%s JSON=%s", channel_data_reply.url, channel_data_reply.json_string); + channel_data_reply.request_body = json_reply_string; + TRACE("URL=%s JSON=%s", channel_data_reply.url, channel_data_reply.request_body); channel_data_reply.method = CHANNEL_PUT; result = map_channel_retcode(channel->put(channel, (void *)&channel_data_reply)); From patchwork Mon Mar 5 15:40:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 881554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c09::23f; helo=mail-wm0-x23f.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbs6k6xkakgqek7j7ryq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="QGIAeIsd"; dkim-atps=neutral Received: from mail-wm0-x23f.google.com (mail-wm0-x23f.google.com [IPv6:2a00:1450:400c:c09::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw40F6rgmz9sZc for ; Tue, 6 Mar 2018 02:42:05 +1100 (AEDT) Received: by mail-wm0-x23f.google.com with SMTP id p14sf3954979wmc.0 for ; Mon, 05 Mar 2018 07:42:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1520264523; cv=pass; d=google.com; s=arc-20160816; b=PolQA5DVBeUjDHJQUfXndOGU5Wre3udSS9Qb+yPwri7fC8L3sb+3GllN5LPBKN4tHJ AbulqtqbCzCIJ9LTm2hgTQ20zmpWFqOlQqiicMfroVKUa6z2zxuA+p28dGCztY0j/9dn NNkJJpZ6bqX90UA+k7VW+R6DL4ZXri0mM21/q7l554C5KNAcFTJ9hmeKTGREGh6QH+sq h+OevDWo8Rt7CaSbuIVas95JMhXP4lvqbHHVPIPo6IC+kqw3Bf9nrO1Ty+883ItmZwAH RZXOF/clMyY6kGbU7QJeS0X6vPlhin+qITKRNiXsvflckWuESdHWlw/b2+amlS555DnG 0r3A== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=hYzlCvUX5eunuWXe6syF5ze+7mREgvazAbC5PrKlKcw=; b=Py6EWdh6J4jKCCNIDMPzOZ0a2syyoQQxmDnIb5fVZqkIeyaaUXtj1wYpJ1aAKdxi5X FN22ja5OkqGEG2qagL//kQ4wEBzCCWbA51h6NvzT7onykbHESg7Q+kyPjh7oB5imykSz +fJdGpqy2MmeIVfQ2DRNE9fwQNZRzeJUccjuOkKMC/lZdPccp+efHK3O2gH8VuGqp9of ymP/78hbk3r8OYq3xm0K3wQsTu88tAuDCmN7CkIxeQTrrZr/e1zBv1A1nHiFEIjys2cy ddFlPbtrJqK+ckQjVPMdGkSXpzmUqUndWZRTAjkZtmY87me4ZOxxtUIHvRGOieTIEn8b 1T5A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=hYzlCvUX5eunuWXe6syF5ze+7mREgvazAbC5PrKlKcw=; b=QGIAeIsdwGhJj83o5uk7Rz4kQa8oVDSkqpNuc0IHyEtY5SnygwQoSrJsJrgHLrm75S 8PaaFnUA0FJV0QMRa60Gd1vkNVZxAxpVDaapvaH/8IKUIU1KOSQ1wnl73J+ZF2qKadqs Gaq8ufpG4RhAv4G/EmZnPzbd8up6XUj4K+MNlcPW+DK2v9iY/Q7HImm9rrcz816pAGIY IdRD9fLwSJXoWQ5ovSMqS//h9jrrbcDYqk3nsq7Wl/kBnRy4Y12lXq2KILPK+p5Dpo1b H39xp9XAxKrRXhRvbcAeb2ZuGXJNgohmbgf+XI+dvkKVXtq5v4ollXTlExs3uTBfyXs4 Obbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=hYzlCvUX5eunuWXe6syF5ze+7mREgvazAbC5PrKlKcw=; b=poJtVIcDbUDWtkzMMcne5qu2RXBaqoI3A2QnDNnamIDaND9ZkTvKF2/2m2F7t/5+9N Br1qrKwQDlhDTwd+mHdD0b38ncAlxbf9IZQpXPyO65ZElxIcD5tFhJAQdSQvpjxMf29t w6kVPxUh4JlfsycfFA2+uF9YBkVaj946wIou8Ys7ASKMO82JU8T7M7zm1tOIY+O3La4F f2ZBLft3QLnNaRWORbBNZKHDkXG+J6kop+f6OMzV65oQiGoNLxIa3hyTv/DDsRo5X5RE xErL5eI9XaRoonwIR8EWGG+vtTbN6g3MVIvG+c8WXaAi4hpYYthce1J5vwNtD5v541eh Xj9A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7F6pgaaGzz+Oi8s7hsRTBylhBZ2IQx/UMSB3YkL+peK1KBgqBl8 fb+kLOcRkK1IJFQFrs4fE+k= X-Google-Smtp-Source: AG47ELtWatMmh2HaEGq+7snwY3qQnnJMsTvEz2Vp7tCIsTv2VaAyHal/n8aFqJwwIrQ8JYvZTR7Dfw== X-Received: by 10.28.106.24 with SMTP id f24mr79184wmc.0.1520264523568; Mon, 05 Mar 2018 07:42:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.193.69 with SMTP id r66ls1525763wmf.10.gmail; Mon, 05 Mar 2018 07:42:02 -0800 (PST) X-Received: by 10.28.11.65 with SMTP id 62mr1032317wml.19.1520264522981; Mon, 05 Mar 2018 07:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520264522; cv=none; d=google.com; s=arc-20160816; b=rRevscc9vc4S8aTqIA69OL5U5iQTAc4OAKmpimI8yaDywxUA6v6107iYvnYRI7JhOJ 1yI4SRkkk9l7LC7F4egW4wtBjsvFy+/oK2jhR2iL+ei+7Z5NyKsGIRECkyrkzZs8ugeH G3JhtINftuzOggpsaiL0e+fADY6krlGp17cCfOMhcfMl3PYE8cWbLQiGgMVp2Lz1cXyj kKJKjsAq49Q9D1lzKHbtvyjeVGQC4svK8sMcmwWfO/U+TIhM2OQbgH/mT/T5a1urFpwp glXZ/t3Vdk9z6/6XkKZVjZy+vzCm0L8AYEhFaGyUxO8nujdG/trZIRUu9PEdVVBSap+7 g56w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=T2awIEcrButSiEhjr6hS2WALfehy8DQR0I1OWvUt1Tc=; b=T42Xa1tf8HQyFL9T8DK6bNmnHL+MJ/yredVRT0sSVPvo+TbQizWO8smoFdGW18+qbd lKYbW5s3df0cDRLC7uCENJLorrEzOtC2xHGrebhn6vSHMfllW06VNXzCfxtVBCSdT3gx OH7ySIUcKCe9DFXTG5EQaJx9l1NwzgeWsdox08WZdA7L0K8wD5DU4fAsCEPM1c8f8p9B TcFl2FOpC7wI9at979Uxd+dGLcphKDkKo79CPR5fXkFQPWiLcU5AISnZ98OJ2Qfvhvut Z2gch7giW7mayPqcHrZwsH6myOYzV96tnXw8qprBvQnghjNshUekBdscwvhIkJKsL4/S LnWw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id s81si342349wmd.2.2018.03.05.07.42.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 07:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w25Fg2oj004125 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 5 Mar 2018 16:42:02 +0100 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.202]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w25FfRYN022466; Mon, 5 Mar 2018 16:42:02 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 8/8] channel_curl: enable SSL support Date: Mon, 5 Mar 2018 16:40:06 +0100 Message-Id: <20180305154006.18122-8-christian.storm@siemens.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180305154006.18122-1-christian.storm@siemens.com> References: <20180305154006.18122-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=christian.storm@siemens.com 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 order be able to initialize channel_curl with SSL support when !CONFIG_SURICATTA_SSL, introduce a cURL SSL support option and an according KConfig option. Signed-off-by: Christian Storm --- Kconfig | 22 ++++++++++++++++++++++ Makefile.flags | 7 +++++++ corelib/channel_curl.c | 2 +- include/sslapi.h | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Kconfig b/Kconfig index 1ac2b81..1bce6d4 100644 --- a/Kconfig +++ b/Kconfig @@ -69,6 +69,10 @@ config CURL bool default n +config CURL_SSL + bool + default n + config SYSTEMD bool "enable systemd support" default n @@ -294,11 +298,29 @@ config DOWNLOAD comment "Image downloading support needs libcurl" depends on !HAVE_LIBCURL +config DOWNLOAD_SSL + bool "Enable SSL support for image downloading" + default n + depends on DOWNLOAD + depends on HAVE_LIBSSL + depends on HAVE_LIBCRYPTO + select CHANNEL_CURL_SSL + help + Enable SSL and checksum verification support in channels + using libcurl. + config CHANNEL_CURL bool depends on HAVE_LIBCURL select CURL +config CHANNEL_CURL_SSL + bool + depends on CHANNEL_CURL + depends on HAVE_LIBSSL + depends on HAVE_LIBCRYPTO + select CURL_SSL + config HASH_VERIFY bool "Allow to add sha256 hash to each image" depends on HAVE_LIBSSL diff --git a/Makefile.flags b/Makefile.flags index b6c2859..dac790f 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -177,6 +177,13 @@ ifeq ($(CONFIG_BOOTLOADER_EBG),y) LDLIBS += ebgenv z endif +# channel_curl +ifneq ($(CONFIG_CHANNEL_CURL_SSL),) +ifeq ($(strip $(findstring crypto,$(LDLIBS))),) +LDLIBS += crypto ssl +endif +endif + # suricatta ifneq ($(CONFIG_SURICATTA),) ifneq ($(CONFIG_SURICATTA_SSL),) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 1340850..caa5c4f 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -73,7 +73,7 @@ channel_t *channel_new(void); channel_op_res_t channel_curl_init(void) { -#ifdef CONFIG_SURICATTA_SSL +#if defined(CONFIG_SURICATTA_SSL) || defined(CONFIG_CHANNEL_CURL_SSL) #define CURL_FLAGS CURL_GLOBAL_SSL #else #define CURL_FLAGS CURL_GLOBAL_NOTHING diff --git a/include/sslapi.h b/include/sslapi.h index ca27f42..213478e 100644 --- a/include/sslapi.h +++ b/include/sslapi.h @@ -15,7 +15,7 @@ * Let compile when openSSL is not activated */ #if defined(CONFIG_HASH_VERIFY) || defined(CONFIG_ENCRYPTED_IMAGES) || \ - defined(CONFIG_SURICATTA_SSL) + defined(CONFIG_SURICATTA_SSL) || defined(CONFIG_CHANNEL_CURL_SSL) #include #include #include