From patchwork Thu Sep 20 11:40:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 972349 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:4864:20::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbo4or3oqkgqeomfzk4i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="Vi32RknI"; dkim-atps=neutral Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42GFCy16hqz9sCR for ; Thu, 20 Sep 2018 21:40:45 +1000 (AEST) Received: by mail-wm1-x33b.google.com with SMTP id j129-v6sf5751916wmj.3 for ; Thu, 20 Sep 2018 04:40:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1537443643; cv=pass; d=google.com; s=arc-20160816; b=OpUDByEcTSww+SINhGM34N+ljH/QXv/obVn4IixIMfAEZxbKqUbjsE4H+P2H5e+P07 bKkAG4moayJ+8yhn2efghdaT6fpUGPmVTFiU6vyBIMmPFHDjMI1PWPa7u9iSI40ZexYd t2k/SqGO8b0IJ9NH531FnRcScs5N8cT4Y9AyEieKFy9mhBWr3MXw9z/fkvV18BNHFWrf nV5TsGkwe/cdXqRir0dUiKdw6pItOqVLnieg5xLVmWk15Wnd3QaBKbKknDVBbGHG0LdF BHBN+LoggFS/zIJakhOj5gqgJ1R/epvdYhRYWyqIdda1P7EmNEsI167zD+uv03lezwg9 60rw== 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:mime-version:sender:dkim-signature; bh=fxh3gSzxW06bx/6bm1jHRre+kN/oMPrjeHTg/o9X2E0=; b=yAXh/DDjAzCST6yVapI2ZMzol+mwZ2HOS1aajjDTmvevwEZ2qfhmtvRB1hlW6s1Plv xGFbQboyYriKs5cBMkFihI9WOgS/2TV2RSxqNNNePPOOUqYACARTMFo+d1/go6v5voOG 0qIeaW2BdPMuwpgbXWqh4ZSzBGdxohogKmqw0oRYeJHK4vemPXbEPsk/cninTG2M5SBQ kYSY4vAn6J78PTR1FloQlVWEsoYA4VfBCzgqyl9QjqQcn/WQZkhQduK0/L5yb5aJfSlE 6xRfn3LG1tfsJxOJjYEIJ+G8Q77gyKXRoCkZ33UmBJ72SFAywU2h6J55vO8Nfh/mFYk7 qAiQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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=fxh3gSzxW06bx/6bm1jHRre+kN/oMPrjeHTg/o9X2E0=; b=Vi32RknIEHy2P1B+3Rxzi4r6lr0+lRfYrGz8ZxBQe19UZK3LUlPssrPs+egFc9SQMC +oQZlBgMeTey5+8t8DeF2Fw2Xsbk++tLzmebIn+xor9pVgoz+GDYy4++ZaGpXQM+N20d e7VKAXmBlNyjyAQwCskDW+uh/3cMM5IuPvK9tc+nBzAKilZQrZyN7rjn8+WQQgbs01gu ppCg8riHLrSZHEEE8+eu8pWxqiFofU0zIHdPIFUqouq/yOvwmFFuL5YATmZXPZfel2fA y9qC9D7qMKRSmOkmbyS86lIq0GDLcbWRWBVvq+m2F1cK2HrG+/WL26EVaXsYkK8h2Hgq PXXA== 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=fxh3gSzxW06bx/6bm1jHRre+kN/oMPrjeHTg/o9X2E0=; b=UUCehTeq/5K7XWqAV8CeiysE3jdZppXssynoF7e2iCjP+++7W9T5hyK1sM+eaK043f lxHjv3rRTT9huJhmNHw7CEq6DHB0FzHN3CIcJB4AF6b9BDthmgvVDZqv6QFWndb3SPbv mQPKILkNjW0N6Apu7dxUTI5WTG5Ov/Ca/FEhRfDpillI/79LSsU8tKju7U0H3okhtj3u 2O+I4PElRWEtOdAYjJ9eKu4MKWzgzvDNh8RFT6fvg89exDN0623VE7W4KYoyYHGXaBMV ESwwUG378di5yEObP5APKUNVgXtfX0mn6xxhiM83tLgFdQy5JIPM2Iw6SAFX4vZ+s6nT atSA== Sender: swupdate@googlegroups.com X-Gm-Message-State: APzg51AS+HhwF9SaG4lxnszcX5VZ2vRTZH207RnZTiGjcrgSY3oAn6Ca FO/c+Zil3IM/IhHrvNmEz5Y= X-Google-Smtp-Source: ANB0VdbiHfoOrAMftEJKUgpHK8cRp5lvFNRr0dO1kPOVfsWG4jjdFwDOA5mKGDWUbGeAy6TlNR8Pcg== X-Received: by 2002:adf:b70a:: with SMTP id l10-v6mr488771wre.1.1537443643263; Thu, 20 Sep 2018 04:40:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:f405:: with SMTP id z5-v6ls562070wma.8.gmail; Thu, 20 Sep 2018 04:40:42 -0700 (PDT) X-Received: by 2002:a1c:7319:: with SMTP id d25-v6mr303417wmb.10.1537443642796; Thu, 20 Sep 2018 04:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537443642; cv=none; d=google.com; s=arc-20160816; b=JsxICilk9625tiDlisRoDiACvGcr6Fksov4pPLvlGzevyUeMcZ+TFbEswmXNcN2nsJ TwURM2pPjPVZxuPtWxvWI85SL5MojyNz40FvqTW+8FHkE5QBsOyS93xmC3eJYw+V0LMO x8lo/9Ltlv79guX9W/hw7iv4/IIceqWuMTRKKk3l214w2TspS6c8n0Lc+//o6PWxdLA7 tC2l6WV2uuk2GPzRGiyYu1LySAe5ZdK4efj1GUSzLhEsbQnRXirn2LYX0KF/1oTGunQk YARRCeGLpt13+ZEziaR6lPKk8QH6FNguX4zB7CJ3xgwATrm63JAq5KBZ8JBx7qSEjjdA 6OHQ== 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; bh=xlLYfiKLyG4LJczhAPynqrKqMAStCiUL4QVifl9MWyE=; b=CbVh3Yt/X2X3p+ql9f6udBGyWKEJ6nFZOhALG11NP/OHoL8iG1z8U+OE6/n+xQyMGQ 908Rt7PK1l0+job3ihDq+5GBHSEBl3urcFugWCOIU0LiVRUA6H4fkHNybQGdOi8TEgrK 6hWNXvMI4B0KRHiqRS2jXhPjTjo0SJTt3Ym7kCfvplD3QNB+59OlSIuU9BxqE4NT8Dcj G6LK1XUT40nqUhFO96lUJ11may6DCB8TgHCXI5D550ughferHoe6sNXzxLSvjizPH9Uy tgJc8lFp56Pnkz1P4vsSYiQgY4iNIQgZGX/mGF5/vIrg1NRz7XgixZr7bG3hidjC1TUI KDWA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id x7-v6si78966wmh.0.2018.09.20.04.40.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 04:40:42 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42GFCt43jwz1qwf8; Thu, 20 Sep 2018 13:40:42 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42GFCt3sgKz1qqlF; Thu, 20 Sep 2018 13:40:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id B-wsal5y3_10; Thu, 20 Sep 2018 13:40:41 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 20 Sep 2018 13:40:41 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 48625454033B; Thu, 20 Sep 2018 13:40:41 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zxb7rXZKpcDY; Thu, 20 Sep 2018 13:40:38 +0200 (CEST) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id 049DB45405E3; Thu, 20 Sep 2018 13:40:36 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/6] suricatta: factorize function for servers Date: Thu, 20 Sep 2018 13:40:31 +0200 Message-Id: <20180920114033.31082-4-sbabic@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180920114033.31082-1-sbabic@denx.de> References: <20180920114033.31082-1-sbabic@denx.de> X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Some function can be shared between the server's implementation. Move them outside the Hawkbit connector to make them available to the rest of the suricatta module. Signed-off-by: Stefano Babic --- suricatta/Makefile | 2 +- suricatta/common.c | 43 +++++++++++++++++++++++++++++++++++ suricatta/server_hawkbit.c | 24 +++---------------- suricatta/suricatta_private.h | 14 ++++++++++++ 4 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 suricatta/common.c create mode 100644 suricatta/suricatta_private.h diff --git a/suricatta/Makefile b/suricatta/Makefile index 3b8dfa7..10d913e 100644 --- a/suricatta/Makefile +++ b/suricatta/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 2014-2018 Stefano Babic # # SPDX-License-Identifier: GPL-2.0-or-later -lib-$(CONFIG_SURICATTA) += suricatta.o +lib-$(CONFIG_SURICATTA) += suricatta.o common.o ifneq ($(CONFIG_SURICATTA_HAWKBIT),) lib-$(CONFIG_SURICATTA) += server_hawkbit.o endif diff --git a/suricatta/common.c b/suricatta/common.c new file mode 100644 index 0000000..a5e5e10 --- /dev/null +++ b/suricatta/common.c @@ -0,0 +1,43 @@ +/* + * (C) Copyright 2018 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include +#include +#include "suricatta/suricatta.h" +#include "suricatta_private.h" + +void suricatta_channel_settings(void *elem, channel_data_t *chan) +{ + char tmp[128]; + + get_field(LIBCFG_PARSER, elem, "retry", + &chan->retries); + + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "retrywait", tmp); + if (strlen(tmp)) + chan->retry_sleep = + (unsigned int)strtoul(tmp, NULL, 10); + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "cafile", tmp); + if (strlen(tmp)) + SETSTRING(chan->cafile, tmp); + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "sslkey", tmp); + if (strlen(tmp)) + SETSTRING(chan->sslkey, tmp); + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "ciphers", tmp); + if (strlen(tmp)) + SETSTRING(chan->ciphers, tmp); + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "sslcert", tmp); + if (strlen(tmp)) + SETSTRING(chan->sslcert, tmp); + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp); + if (strlen(tmp)) + SETSTRING(chan->proxy, tmp); +} diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 357cf0a..b6f0407 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -20,6 +20,7 @@ #include #include #include "suricatta/suricatta.h" +#include "suricatta_private.h" #include "parselib.h" #include "channel.h" #include "channel_curl.h" @@ -1492,34 +1493,15 @@ static int server_hawkbit_settings(void *elem, void __attribute__ ((__unused__) get_field(LIBCFG_PARSER, elem, "polldelay", &server_hawkbit.polling_interval); - get_field(LIBCFG_PARSER, elem, "retry", - &channel_data_defaults.retries); + suricatta_channel_settings(elem, &channel_data_defaults); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "retrywait", tmp); - if (strlen(tmp)) - channel_data_defaults.retry_sleep = - (unsigned int)strtoul(tmp, NULL, 10); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "cafile", tmp); - if (strlen(tmp)) - SETSTRING(channel_data_defaults.cafile, tmp); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "sslkey", tmp); - if (strlen(tmp)) - SETSTRING(channel_data_defaults.sslkey, tmp); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "ciphers", tmp); - if (strlen(tmp)) - SETSTRING(channel_data_defaults.ciphers, tmp); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "sslcert", tmp); - if (strlen(tmp)) - SETSTRING(channel_data_defaults.sslcert, tmp); - GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp); - if (strlen(tmp)) - SETSTRING(channel_data_defaults.proxy, tmp); GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "targettoken", tmp); if (strlen(tmp)) SETSTRING(server_hawkbit.targettoken, tmp); GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "gatewaytoken", tmp); if (strlen(tmp)) SETSTRING(server_hawkbit.gatewaytoken, tmp); + return 0; } diff --git a/suricatta/suricatta_private.h b/suricatta/suricatta_private.h new file mode 100644 index 0000000..32ec2c4 --- /dev/null +++ b/suricatta/suricatta_private.h @@ -0,0 +1,14 @@ +/* + * (C) Copyright 2018 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once +#include +#include +#include +#include + +void suricatta_channel_settings(void *elem, channel_data_t *chan);