From patchwork Tue May 9 08:07:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1778790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::437; helo=mail-wr1-x437.google.com; envelope-from=swupdate+bncbdd6bwv65qpbby7546ramgqe5of2evy@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20221208 header.b=Rjw9/vju; dkim-atps=neutral Received: from mail-wr1-x437.google.com (mail-wr1-x437.google.com [IPv6:2a00:1450:4864:20::437]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QFrMD2Wnwz214M for ; Tue, 9 May 2023 18:06:00 +1000 (AEST) Received: by mail-wr1-x437.google.com with SMTP id ffacd0b85a97d-30479b764f9sf1885897f8f.0 for ; Tue, 09 May 2023 01:06:00 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1683619556; cv=pass; d=google.com; s=arc-20160816; b=vGQNgYiS5elYJghclYdPv2K+AVQyH1710GISj+ueSfB+WhMZRUelS83DAQh0x8mnM3 kTR3s1gIoBeCFVGWYExV5O3ajEnONq+iCsR2URyZ7bwB+xvT/J/a13nrGOyuS7od1k9A 0EUfm8zBSJ14YBzDiY4QeDv3yD/K1205zDHqYZtnYSMH28k/UnvfxW6wgoIPvfb0ZiLN gD0UZHENh/ZDABZeC9rAu61sbjmwA4kKxQoYj/2Pn0GwesmRK+nx5RW1w77iKKBsoMot xaCZps6n0HVxb58qDZSM532ONbC1qWjYyTYAfzzute/e2HvZjSN7pCPKjfRsUTvuORSA mUQw== ARC-Message-Signature: i=3; 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:reply-to:mime-version:message-id :date:subject:cc:to:from:dkim-signature; bh=MSD63b84yfo0JaUYHZKjThDwixFa5LEal9+LqprHVCE=; b=vZWxj8RTtQnEX56ajJAAwv4/lxuksjmg7oqBPFY8OCBUSgl1KX6+HMYdmo3NtLOK5t Dy6OS2XEexbfUXO5EKIatG94o7j+WfOBcyK2F3ehUiHwA+MNS0Osc2Ld92+I43kx9qjj FkYDMQ21bDYpxn49Q2a4sRRBQOpHW1azwe9ADzsGe9JrM8TBT8d4ysXBMdCGsCvBW4dK vqlL7W3oeiGT6K/73ycFmtfLTSWYuSE8CoyHugFMm1eRXR0qj5fJbgusebZ84i8bAvqa sTTxenku1e4j/RA3xq4L1m31FcxcR3wju7/9M++xLEozDKHkLSwnAWvsn5MYaoY9jkvU RQSg== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=AoJibvZE; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:fe0c::620 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683619556; x=1686211556; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MSD63b84yfo0JaUYHZKjThDwixFa5LEal9+LqprHVCE=; b=Rjw9/vjubYh345SNQejm1fRz9CAlwK6OgOtuMWZWVpde5ilaSuyQjkHQEW6A3bLvMx cRj/6ON0DoXgDz5jfodoDQnSb2TNr9XWuQZM5YE3vKVxANFYofMeZOx0fxj3C7DQRDZG 0bteGyhMytFE+tTVSYU6VTW9obWFWrcz+c4xueip0n55oXh91fIYBs5cSSr5CKc0xNnQ ISFwgudx082S+oZxEdSRdKDhXaBnq9EuBjRK39bLzrA4JtYDdWc2BsNjtTYqbwm1CTVs Uj0nfnz8NjzqgJBCecmnzJtDsYUj7/HBVenxReNI2jY5jYlUOLLxNxqT0S5KWZerCKQj GtCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683619556; x=1686211556; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MSD63b84yfo0JaUYHZKjThDwixFa5LEal9+LqprHVCE=; b=CpguRtt6P8g9i7WoSBZtaeQlOPBXIExo8cNmSRS8P0tExX3oaM6APliwmqSACX+AFs cv1/x2bq+ihlu8SF6sfmK7EGqba/1PlPp7elL67dU+XiQ+z9wS4j35JqrpzJ0EuPRFL6 k7L3gpkds2qzLsjJMmmAKHqenlJyKbCxwfTi+ZL8237Bj0m6sJJPRD1OmF9vnKVo5OGk yFyK+NpFuzgYuIGiOB9VA3HdlFmRC8haHa9YhbJ40I9EZjR0OHTHgM3L/mWyyN+p1bwQ 6irb4zBVp6SG0SMG5Uf1Q+Dh7FXS1hX3Uz/aTs44DkL9tfgWC2Y6CBemDuf003QVeein ZX/w== X-Gm-Message-State: AC+VfDw9MltJbbZOeVTtiXzeIzfE6dW3ov5GjN3FtF8HmIG+xS2n8Mll yO46r9t2EBT8pXr/0eVl4w0= X-Google-Smtp-Source: ACHHUZ5B2ckXqFls2cOa0xtnGTOlU42vV6LsJrSMrqdC1VtUPqTmW4cX830rpZ5GIu4RNAjjjYIjjg== X-Received: by 2002:adf:e552:0:b0:2e4:c9ac:c49d with SMTP id z18-20020adfe552000000b002e4c9acc49dmr1714240wrm.8.1683619556397; Tue, 09 May 2023 01:05:56 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:4445:b0:3f1:68f0:7451 with SMTP id v5-20020a05600c444500b003f168f07451ls5655833wmn.3.-pod-canary-gmail; Tue, 09 May 2023 01:05:54 -0700 (PDT) X-Received: by 2002:a1c:7703:0:b0:3f4:2c8f:d2d3 with SMTP id t3-20020a1c7703000000b003f42c8fd2d3mr520185wmi.20.1683619554848; Tue, 09 May 2023 01:05:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683619554; cv=pass; d=google.com; s=arc-20160816; b=V5MrYyx4N9EbqUPLLumfHbgbfMuNfuN59Py8b0itjBYYqtoXyYEe9hv1p+Zobot1nU NAkQmEUKbNc3F2148HfJMx2mrLRvAQ45273N3ud8bzpb+75gxhDDS901Z6YTOAoFyjv5 5+hn95kVYEuojEG1TjOcW+dEnB9JV8meymMcrmTB9uKfpprdhmbHEM7HlTUCH0u6bmiX erTonT8hIGqaKZ0ihfYnLB6cGQSoJ4ffujlGrBxsfzLtonJjpyxGl4HU6Hka2Tp/h+ey iI3dIYPId8nDnFwy+m45mCOcDiVzcBvJcDdmTjVADsSnUNyl2fEcrk0mngtvodoTUpJ/ VbUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:message-id:date:subject:cc :to:from:dkim-signature; bh=oePFkrLhLQ4nHosYjm6ksYTo+rt7Vt+FMY9HR0hBSqA=; b=WSxteKLPEIWa9xlKc4g9yyY7zVV5VlNE9QPjVehXCDz6B+Aenoktt+EB8eU0KJy5KQ 62bwmUucl5szu7E2N32NRuyLJBTvBXL0D6oyH/lWIT4AZvL3t/4k2EBWuw7VIzsWJFyj TM4u2aueMiHKGY1cqG/CKyYoO6+Wxvpstz/tjHc6v/Z5apBk1L18oBsqcn7md8T/2x+q vTBJutpet66TldgYOGkN4Sp47PzAPcEEyqAlsJwpxMRjeE3kUVSbBrTpvm/KsaaFPH4i BamNPERMJGbzXZHVgesW6CJJiUjPQ6XMzcYoc+DhWvQAGUZQ5hltFwlv2ZiVrl85Ed9A H51A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=AoJibvZE; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:fe0c::620 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0620.outbound.protection.outlook.com. [2a01:111:f400:fe0c::620]) by gmr-mx.google.com with ESMTPS id j15-20020a05600c1c0f00b003f4226e1b16si35251wms.1.2023.05.09.01.05.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2023 01:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:fe0c::620 as permitted sender) client-ip=2a01:111:f400:fe0c::620; ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m+c+3fm8XiQl56efktZMOqkroGKaPU5gTjV8C/vntdg9rxjdo8OBBtQNNKKHN2+PQiVW5q/eOVYyMSlj04CcBSXfVnOSYbt+Yg8RLzJAbQhZw3wCSnH/T9zP6IHmcOn6GyL1QpMJaxT5G28os33H8qhaApUVF5MZU/dXJZKAEH0kfF/w5RoPau5QKDrYA7R2DYqQzmO2oeVZVWDnqKe2H+MUSaxefkdMzryw0QKK0e9CEmvgHiyzSZUvKmQ8ZF1kWRbVG14M8Yn6q0MP+4AUWBVnHz7CAls6Vwqjt1w+qhAZ7oh9zDuPlIqVVO8B5mzcJCV6E7yFr5WgIQUyStSBjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oePFkrLhLQ4nHosYjm6ksYTo+rt7Vt+FMY9HR0hBSqA=; b=aKzxlI/762LiKviLHQf5NJo2lUp38HdWm02mr+oVWJFkbcE7ldls457F5O2IXyovgwAIje5B1CBBcbMuIopQKabcxZ6+pkM06SOqSDUcFOp8HOT6rT6wWwIiQoIukKl616WCW8OmKNXaZmsdYxqeAuJQQ09m+1obeNfhnI+Ye+OYlP7Glh1nUnVK3vYLTumM9Svm1ETUwpueszOMaoigZe1jzKXfVhodgy9EMNKlsKoIbplFxxBQZ2n5rvjGiT5xuAn+p0pXvDhlGgZVLHOFpts+chS4I0+jBA6YmczP78dBBsuf9OtzUENzNLcRbzeD1IuCSKIR1do9gk8BnBd0OA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none Received: from DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:333::17) by AM7PR10MB3685.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:13d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 08:05:53 +0000 Received: from DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::c971:b72f:7778:559]) by DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::c971:b72f:7778:559%7]) with mapi id 15.20.6363.033; Tue, 9 May 2023 08:05:53 +0000 X-Patchwork-Original-From: "'Christian Storm' via swupdate" From: "Storm, Christian" To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 1/3] suricatta: Suricatta module run-time selection Date: Tue, 9 May 2023 10:07:24 +0200 Message-Id: <20230509080726.23738-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: CH2PR02CA0013.namprd02.prod.outlook.com (2603:10b6:610:4e::23) To DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:333::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB5404:EE_|AM7PR10MB3685:EE_ X-MS-Office365-Filtering-Correlation-Id: c3af354a-e363-465a-a158-08db506435a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jLFb09NGB5IkTqBctPXZ8/yKJhDn+qTHzkIL2m4XzXBBI3Cufd0CMRm5PYRJvGuq2kSFgM5S4D7uCH7pM1jJYyS3J95ADXu3088WLJblZm7cknJbyKxNfCMqCeqOZuO7L7fz4l0RUjuL0fIBES4fxc36TNMSVKcQhN9M9VL+/6fWxUfYGheFNoUE9F0BCqsBWZTwjzCaDJJPghoatho0ETRI7bB9zgZ0jwFbQzJRPc1Ig0ZZL5IQiol2AH5os4jmFoSKxnJwqyhvI6M8P+ID2NL0e+eIFiD1yLFmjQA/3YKx7Gq24v0jngKN/OpMHKtulSQpSp/ANtrz645tKG/JuCmT2QIugxg/vgQYQmSQ6e3NuyuPVx2wCOyv/jWE/HIuLrCMBdPm0XGz7wyjQj28lMPUCUoT1f/rafslNCculg6TCds2B/QoBK7y6Q2aexmNk/zFkLtOcdti9MDbSl6yRCwS+6ddU5Z2jV/8JNVxWZmjFB5Ic05EJNFVTvvDCQtca+43hz3wTG3bGOCDwLoOlOS+WzEv/vMBZvWzC4TZ8eE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199021)(6486002)(83380400001)(316002)(66946007)(6916009)(66476007)(66556008)(4326008)(478600001)(2616005)(6666004)(6506007)(1076003)(26005)(107886003)(186003)(6512007)(30864003)(2906002)(86362001)(36756003)(41300700001)(82960400001)(5660300002)(8676002)(8936002)(38100700002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G0tNmCzGc61r/hnpHobLUSV55YaAQg1R0pswF5jO/mUGRnQCwGd0SQohIY9pDUkwF+ouQf1yOXwCMdievqMJo5o3bvWRlD6p+cW9ieKHDj0Dp1rLYPNqz8DsJ2I4grXVjyv1shOdgRTRfvJY60xqcTyi1BObAm3CUp1e/mHghYSH+qsOxwUc9aCiear0hGVCraY496bYf0XzF2ezlRB/fqNNX3oDwMCC2kaepzNy12Q3+p1KNTRhdOX4psf9/PsGyzXISG5bBsx3qjsck1Y4yXzC4Ki+loXc7M3S2m3x9HhlwzzBoFubpELDS1NCGuw+nMowCTKFoR7T1p3HOj5dzujP6gEYvqavCyMO4q5/q9JJgtpXWH00ut4iq2kExWGeHRTE3M2BjQHgoNbSj2vLIgo//YskFFb2gAs+9xbOxsDqmuArT/EP5SFoQuQULED2BNY/XRaPJSgC7gis0bZuFu9WYuhvk/g2aiF6U6veptuKDdbAv+UDDdfcjHXSKse0glyRocVhdJPB8FD+Wr2QZmCtLmZpLHz61OB5kSGs5E17RTO8WefVKX1OafjhBqskRGVx2IiHKmrindIQG8IQdivA25BCPwcRXBYKuHgPKG1Smk099xVIDGzZTT8TloxoUNkBH7trPYW6OiEy9LJNtruq4lbTxW0WO43BhTUSw9BnzveGSYTmb6uYuMFygQa7cBRqpHtE/mpmUeDObi/CukaiNVOJFWNs5NahF8eOnH1VORbOXzgQVVLgopEZza9iCma31B4oPE/jNbl54eadzrk2AReo9N+6J0/20Fk5PuUsnHTeDSdNyYA3/YeSynxON7eQBjl8B7c4XxIzaYdOtpBqWfmXIXcyH+15AvqfsO68KApVND/5ER6s1VDKhWgL6nyk0fbCpGkuL3Q0vCYNDqMSQXa5m7wpTrCXjcDmFLT8EdoURH/mIq+RaUt1+VaPo6rWTtnc86urYcVeuz2nZSrLArSzMk9s/k/OvgXBZLjM2szqllFzE46749XWUZey0GaXyf7lExpwPrWP5AAzyNKC2KvplQ07bwS6021Gqojca19IK4cZIivmoZo8wn+yN4Qj4WVYMZs5h9CJP7ztbvLRc8whlWUtD3WS6vtDUBob4VvpX6UjSsU5f7zYsbli5uOzHu7NpIawkTqc+ZwJiFp7Ha2U3hKhMfDkFeN6h/l3j/jiUS2hFSGmWHHgas5aaPSwMsGqhcEz3SA6K0cd20aD4fw+jg6SpoJ+Pl0l9uvcoWPeM0MSuyApPSVeTW6NfJsu0ruRZVdzHnuiWfJHSGYt9/WC2H0dPY1s37n4dvhhp6Bka4ay8WBlv+xbqkL+GQicpdeDQIuYF53MWF5z3a5X1w1ZcfweqlvIyxsi/6vtFm013khaiOv/hA/yZg/vZDiLKYFeXQ/ELHUPKb/TZTjWX/BlvMXJnNsSyVcMG89loZvBLWRWHzJ7vtyY8hlNl0asiNBtpHp5sHJ48Rqh8VmABvYDpAO/opIQI22F/tvZe7UCKehI5ASR6ZflLmZ800HbBkKxJa3jIM2C+GFY9rx4vSl+76nH6o5V0b6P7BL4ST4KZiOdhfb6IHh+CFg6BtesQMjCewck4g8sumi1Qg== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3af354a-e363-465a-a158-08db506435a4 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 08:05:53.2907 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IXpDwTO+l7JmaeYEKRNEgSClE2Pfp49+atGaqfrnPPPK760t0DVMu0l737X+cqJffaS8YYMELp/cX66mhQmCqVba5L/VyhIHwr8kmjMCSkQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR10MB3685 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=AoJibvZE; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:fe0c::620 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Christian Storm Reply-To: Christian Storm Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Allow to compile-in multiple suricatta modules and choose one at run-time with sane fallback to a single compiled-in one. Defaults to hawkBit for backwards compatibility. This feature enables distributions to ship SWUpdate with multiple suricatta modules enabled, shifting the selection to run-time rather than compile-time. Signed-off-by: Christian Storm --- Makefile | 4 +- include/suricatta/server.h | 24 ++-------- suricatta/Config.in | 30 +++++-------- suricatta/Makefile | 11 +++-- suricatta/suricatta.c | 89 ++++++++++++++++++++++++++++++++++---- 5 files changed, 104 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index 9f6a33a6..41abd303 100644 --- a/Makefile +++ b/Makefile @@ -362,8 +362,8 @@ include $(srctree)/Makefile.flags # This allow a user to issue only 'make' to build a kernel including modules # Defaults to vmlinux, but the arch makefile usually adds further targets -objs-y := core handlers bootloader -libs-y := corelib mongoose parser suricatta fs +objs-y := core handlers bootloader suricatta +libs-y := corelib mongoose parser fs bindings-y := bindings tools-y := tools diff --git a/include/suricatta/server.h b/include/suricatta/server.h index 07981df6..451211e9 100644 --- a/include/suricatta/server.h +++ b/include/suricatta/server.h @@ -16,17 +16,7 @@ * Cf. `server_hawkbit.c` for an example implementation targeted towards the * [hawkBit](https://projects.eclipse.org/projects/iot.hawkbit) server. */ - -extern server_op_res_t server_has_pending_action(int *action_id); -extern server_op_res_t server_install_update(void); -extern server_op_res_t server_send_target_data(void); -extern unsigned int server_get_polling_interval(void); -extern server_op_res_t server_start(const char *cfgfname, int argc, char *argv[]); -extern server_op_res_t server_stop(void); -extern server_op_res_t server_ipc(ipc_message *msg); -extern void server_print_help(void); - -static struct server_t { +typedef struct { server_op_res_t (*has_pending_action)(int *action_id); server_op_res_t (*install_update)(void); server_op_res_t (*send_target_data)(void); @@ -35,12 +25,6 @@ static struct server_t { server_op_res_t (*stop)(void); server_op_res_t (*ipc)(ipc_message *msg); void (*help)(void); -} server = {.has_pending_action = &server_has_pending_action, - .install_update = &server_install_update, - .send_target_data = &server_send_target_data, - .get_polling_interval = &server_get_polling_interval, - .start = &server_start, - .stop = &server_stop, - .ipc = &server_ipc, - .help = &server_print_help, -}; +} server_t; + +bool register_server(const char *name, server_t *server); diff --git a/suricatta/Config.in b/suricatta/Config.in index 29dc7386..0fde4401 100644 --- a/suricatta/Config.in +++ b/suricatta/Config.in @@ -5,6 +5,7 @@ menuconfig SURICATTA bool "Suricatta" depends on HAVE_LIBCURL + select CHANNEL_CURL help Suricatta is a daemon mode of SWUpdate. @@ -34,17 +35,10 @@ endmenu menu "Server" -choice - prompt "Server Type" - default SURICATTA_HAWKBIT - help - Choose the server type. Currently, just hawkBit is - supported. - config SURICATTA_HAWKBIT bool "hawkBit support" + default y depends on HAVE_JSON_C - select CHANNEL_CURL select JSON help Support for hawkBit server. @@ -55,9 +49,10 @@ comment "hawkBit support needs json-c" config SURICATTA_LUA bool "Suricatta Lua module" - depends on HAVE_LIBCURL depends on HAVE_LUA - select CHANNEL_CURL + depends on HAVE_JSON_C + select LUA + select JSON help Support for Suricatta modules in Lua. @@ -65,7 +60,10 @@ config SURICATTA_LUA provides JSON as Lua Tables to the Lua realm and enables channel result parsing to JSON per default. To enable, select 'libjson' in 'Parser Features'. - + +comment "Suricatta Lua module support needs Lua and json-c" + depends on !HAVE_LUA || !HAVE_JSON_C + config EMBEDDED_SURICATTA_LUA bool "Embed Suricatta Lua module in SWUpdate binary" depends on SURICATTA_LUA @@ -90,23 +88,17 @@ config EMBEDDED_SURICATTA_LUA_SOURCE Path to the Suricatta Lua module source code file to be embedded into the SWUpdate binary. -comment "Suricatta Lua module support needs libcurl and Lua" - depends on !HAVE_LIBCURL || !HAVE_LUA - -comment "Suricatta Lua module JSON support needs json-c" - depends on SURICATTA_LUA && !JSON - config SURICATTA_GENERAL bool "General HTTP support" depends on HAVE_JSON_C - select CHANNEL_CURL select JSON help Support for Simple HTTP coded server The server uses HTTP return codes to detect if an update is available. See documentation for more details. -endchoice +comment "General HTTP support needs json-c" + depends on !HAVE_JSON_C endmenu diff --git a/suricatta/Makefile b/suricatta/Makefile index 8fbb1ce9..f5b2bbdf 100644 --- a/suricatta/Makefile +++ b/suricatta/Makefile @@ -1,11 +1,14 @@ # Copyright (C) 2014-2018 Stefano Babic # # SPDX-License-Identifier: GPL-2.0-only -lib-$(CONFIG_SURICATTA) += suricatta.o common.o +obj-$(CONFIG_SURICATTA) += suricatta.o common.o ifneq ($(CONFIG_SURICATTA_HAWKBIT),) -lib-$(CONFIG_SURICATTA) += server_hawkbit.o +obj-$(CONFIG_SURICATTA) += server_hawkbit.o endif ifneq ($(CONFIG_SURICATTA_LUA),) -lib-$(CONFIG_SURICATTA) += server_lua.o +obj-$(CONFIG_SURICATTA) += server_lua.o endif -lib-$(CONFIG_SURICATTA_GENERAL) += server_general.o +ifneq ($(CONFIG_SURICATTA_GENERAL),) +obj-$(CONFIG_SURICATTA_GENERAL) += server_general.o +endif + diff --git a/suricatta/suricatta.c b/suricatta/suricatta.c index b10da933..394019f3 100644 --- a/suricatta/suricatta.c +++ b/suricatta/suricatta.c @@ -30,9 +30,44 @@ static bool trigger = false; static struct option long_options[] = { {"enable", no_argument, NULL, 'e'}, {"disable", no_argument, NULL, 'd'}, + {"server", required_argument, NULL, 'S'}, {NULL, 0, NULL, 0}}; static sem_t suricatta_enable_sema; +typedef struct { + const char *name; + server_t *funcs; +} server_entry; + +static int servers_count = 0; +static server_entry *servers = NULL; +static server_t *server = NULL; + +bool register_server(const char *name, server_t *srv) +{ + server_entry *tmp = realloc(servers, + (servers_count + 1) * sizeof(server_entry)); + if (!tmp) { + return false; + } + tmp[servers_count].name = name; + tmp[servers_count].funcs = srv; + servers_count++; + servers = tmp; + return true; +} + +static bool set_server(const char *name) +{ + for (unsigned int i = 0; i < servers_count; i++) { + if (strcmp(name, servers[i].name) == 0) { + server = servers[i].funcs; + return true; + } + } + return false; +} + void suricatta_print_help(void) { fprintf( @@ -40,8 +75,17 @@ void suricatta_print_help(void) "\tsuricatta arguments (mandatory arguments are marked with '*'):\n" "\t -e, --enable Daemon enabled at startup (default).\n" "\t -d, --disable Daemon disabled at startup.\n" + "\t -S, --server Suricatta module to run.\n" ); - server.help(); + if (servers_count == 0) { + fprintf(stdout, "\tNo compiled-in suricatta modules!\n"); + return; + } + for (unsigned int i = 0; i < servers_count; i++) { + fprintf(stdout, "\tOptions for suricatta module '%s':\n", + servers[i].name); + (servers[i].funcs)->help(); + } } static server_op_res_t suricatta_enable(ipc_message *msg) @@ -103,7 +147,7 @@ static server_op_res_t suricatta_ipc(int fd) result = suricatta_enable(&msg); break; default: - result = server.ipc(&msg); + result = server->ipc(&msg); break; } @@ -120,6 +164,12 @@ static int suricatta_settings(void *elem, void __attribute__ ((__unused__)) *da get_field(LIBCFG_PARSER, elem, "enable", &enable); + char cfg_server[128]; + GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "server", cfg_server); + if (strlen(cfg_server) && set_server(cfg_server)) { + TRACE("Suricatta module '%s' selected by configuration file.", cfg_server); + } + return 0; } @@ -227,9 +277,16 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) optind = 1; opterr = 0; - while ((choice = getopt_long(argc, argv, "de", + while ((choice = getopt_long(argc, argv, "deS:", long_options, NULL)) != -1) { switch (choice) { + case 'S': + if (!set_server(optarg)) { + ERROR("Suricatta module '%s' not registered.", optarg); + exit(EXIT_FAILURE); + } + TRACE("Suricatta module '%s' selected by command line option.", optarg); + break; case 'e': enable = true; break; @@ -240,6 +297,20 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) break; } } + if (!server) { + if (servers_count == 0) { + ERROR("No compiled-in suricatta modules!"); + exit(EXIT_FAILURE); + } + if (servers_count == 1) { + (void)set_server(servers[0].name); + TRACE("Default suricatta module '%s' selected.", servers[0].name); + + } else { + ERROR("Multiple suricatta modules available but none selected."); + exit(EXIT_FAILURE); + } + } if (sem_init(&suricatta_enable_sema, 0, 0)) { ERROR("Initialising suricatta enable semaphore failed"); @@ -254,7 +325,7 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) /* * Now start a specific implementation of the server */ - if (server.start(cfgfname, argc, serverargv) != SERVER_OK) { + if (server->start(cfgfname, argc, serverargv) != SERVER_OK) { exit(EXIT_FAILURE); } free(serverargv); @@ -263,13 +334,13 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) while (true) { if (enable || trigger) { trigger = false; - switch (server.has_pending_action(&action_id)) { + switch (server->has_pending_action(&action_id)) { case SERVER_UPDATE_AVAILABLE: DEBUG("About to process available update."); - server.install_update(); + server->install_update(); break; case SERVER_ID_REQUESTED: - server.send_target_data(); + server->send_target_data(); trigger = true; break; case SERVER_EINIT: @@ -281,9 +352,9 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) } } - for (int wait_seconds = server.get_polling_interval(); + for (int wait_seconds = server->get_polling_interval(); wait_seconds > 0; - wait_seconds = min(wait_seconds, (int)server.get_polling_interval())) { + wait_seconds = min(wait_seconds, (int)server->get_polling_interval())) { wait_seconds = suricatta_wait(wait_seconds); }