From patchwork Wed May 17 15:35:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1782743 X-Patchwork-Delegate: sbabic@denx.de 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::439; helo=mail-wr1-x439.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbt7isorqmgqexybla4y@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=IGDFQIPE; dkim-atps=neutral Received: from mail-wr1-x439.google.com (mail-wr1-x439.google.com [IPv6:2a00:1450:4864:20::439]) (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 4QLxyb0yZRz20KF for ; Thu, 18 May 2023 01:35:49 +1000 (AEST) Received: by mail-wr1-x439.google.com with SMTP id ffacd0b85a97d-3079c6648e3sf575476f8f.2 for ; Wed, 17 May 2023 08:35:49 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1684337744; cv=pass; d=google.com; s=arc-20160816; b=nN1f+OGKEDlZ86MwqLjpPug18Rj/qVXgw4c34dZ+hX/Cr2qgslwMTnqJgyOmH60IbT 9D2Fv9TuBNxjcXwhWCvCYJzX/0ddEM/e9flBX6kwN6FR4MQ58LiywQAHizw8MODMlgW4 AaJxpYNouw4VjmyCV6RPEXBUXXaSXmsP+d5ZHbqh1VmxzIatXoz/j8fzpZPaLlFtA5uZ mRM37BQZ2uldlkljlBL7daHs+US9iwkkm7GAZEoX1i/hw9JVWz3sPATRM5jtGk1+Nty0 POrdfYMuBtBi2ic8epVcI8rQfr5Ny721hJ7BCiAseExeigh3QY+Wdsu+4hsfLwjQn8+t U0CQ== 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=GXNLWp7xwrg0amqY3wckP2GIOi6CzTwODZpb4V+HjhY=; b=uKKtfysuYAdRqNNXFKZ9X16CmtH4AtSza6kJ5A0VkuR7uNOgdML3cqxZjZdKpbxBoB 69IX0qoJm4dvyNhBBbTeA+dBBbIVUMAsc13WDRzbVlcOMjSs4wn1c8AT6RupVPV6ZuYU /Xe7nHrdPvIoJnqysOc9QGPkPrfITX+K7ZGLfOly+FPhXTDHF7NeYg/r9whiWq8oOOSK y/aaYMmVaVCrTaGdikiCDe2ePz6n6o80FV0MEiwwGFAfkXi8n8vPrn+1FyRdgnrRh6FF GbLtSIqjkU+Sa63KOuvoBA+q1CCFb6LwKxkbPeClkvmf6v6649CM6R9wUdGYplmc/dv9 xIrQ== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=q4cykKnR; 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:7e1b::614 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=1684337744; x=1686929744; 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=GXNLWp7xwrg0amqY3wckP2GIOi6CzTwODZpb4V+HjhY=; b=IGDFQIPEqoH0ckiv2fknge1FhO1WNBZYmhR+/+XfqXcBMyZqDujH5mXWEemKu/sAHG YIKfP2TfV+TGJqIJ5xypYBhsyevEHVm0FY87CTgr5+g2nmWgyxOhUmNJ9yQRqx32M5ll V3H/BZSbgKo08S/RhLa7qebvvPF00fTWkTH+AvaRaT4r6C4j8o6NxELblg4GfOWwe2LO ljUQvLp8PWAA0FHRuhF104mJUD6GDyroA2WKG+63ItmMkOletJ+gimuki4CkOyulKnjA XLbBIFqilMBNptLI6bzmhB+d3qGXjqxg0AuGidSl0UwoOCzRdbGl2nMjWItVJ1TjJgzo PvWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684337744; x=1686929744; 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=GXNLWp7xwrg0amqY3wckP2GIOi6CzTwODZpb4V+HjhY=; b=FI/xObfbeAsBubq5WT6GX2pCWTbb3H+VxCRnllhB4oskS8muVmBF+EVEoCPN4TFSbP 022AI7bwltKxIlGXW4E7wTMbjWMF+XyPEygn2jNuFR4YNRjokfQSDeOWb4knwTX/5LIj VxF31rN3l+JJacJXux6sm64cmbNbSNfkulxGaBVJbXDGdmbAMW35kreVKglaei6jB0h+ I8BcBe3tOOI79b5B1uAIjHza5HgiUKoEpGu6VPD2mxiUP+37Ci8It8JT6mhQuW9pSOoY 95xgnX1ucs9ADqbtCPdu+l/f0JITMU2sukeqyBY6aSrw02cPZRiUZUXA8oa2kCzgrkeA +AaA== X-Gm-Message-State: AC+VfDznrDly3LiTKT6lqq35XBRWtwMAPrypqapL6OcYSz2FC0uo7I4v ISgaFTI/0a/LNTL91lJjkcY= X-Google-Smtp-Source: ACHHUZ56Fq1U26qvDZXTCzz2EivvRR6XSoR0l6q9PR88tenxd2QnxGIlDJYLES57QJZluhMCNYZaiA== X-Received: by 2002:adf:ea51:0:b0:307:a4ee:4a29 with SMTP id j17-20020adfea51000000b00307a4ee4a29mr240254wrn.2.1684337743900; Wed, 17 May 2023 08:35:43 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:4445:b0:3f1:68f0:7451 with SMTP id v5-20020a05600c444500b003f168f07451ls1583976wmn.3.-pod-canary-gmail; Wed, 17 May 2023 08:35:42 -0700 (PDT) X-Received: by 2002:a05:600c:20f:b0:3f4:2267:10c0 with SMTP id 15-20020a05600c020f00b003f4226710c0mr25639477wmi.28.1684337742215; Wed, 17 May 2023 08:35:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684337742; cv=pass; d=google.com; s=arc-20160816; b=i4ieT+oowj4oRqXUbr4p4ApHO3l8g3pCBQqNF3umZFQbW4/d4xEE6xTLzLvRS1QxEs 28/yhT+2rEG5hxKrl4BP3NOKbNWrmh/LZHvu0JBIG4zRsukjnBXcdegpGWlSKLXLuNP+ 0qfQH/kAUY/2GsvqjEvt8wZehA0HF1R98WdA51FNzHnLu8iQf0NhVeGY8zESnVkpn7Qx kfslBY5gGD1UVssfO2PqZQfw/ZzQS/iEATliLhD4rI+yJ5w8AagHPHvU9i/YCbVv2S3t LUP7aoysyuEaJVrbJBXONMwob4ZMGLe8jCwdNIFNEh9c9wQUjjxIE8NFFDrKcohJvgnb eO9Q== 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=3/G9wk37yO7eDMrcFYJkjsA8mpSG2VRUwCMdCECCknE=; b=tMenYDmFI55yVH8nTNk6gbIP/6myOW4Zu6+Inwut8nC0Q+cYW90BJyRrwqoxCiqh4b vSgADivR8qp7JDOenK5tf8+xbz3/jwWiYdbT7GjdXZ3RS4qIeZY7KAUxXe/9O9dlIj9f fIhrMofLed7vsa/AUXUGu+BclFV4brYGHo3x7EPTTxCKeh6u4x6rbJRyUEzGWKouQBNs k9uiikxaz6/M/7LjhGfAwPntCffHde5M3lERGXGLSlGGc89n6qAXrkr2j6+nG/2ZWYrz RpysJmOIhOG1j7z73xu+nOpvpt/N80sVNAzd2rpGd7FsCvILdhi/d/a5ZFi8RbfCkuCS NqjA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=q4cykKnR; 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:7e1b::614 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20614.outbound.protection.outlook.com. [2a01:111:f400:7e1b::614]) by gmr-mx.google.com with ESMTPS id fm27-20020a05600c0c1b00b003f4241e235esi180864wmb.0.2023.05.17.08.35.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2023 08:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:7e1b::614 as permitted sender) client-ip=2a01:111:f400:7e1b::614; ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/KFm+Fn14aJG2gqee96A60AQGTfOdoavhRRmcy7d5c9NdkRtszi7pDHCZTJywVKU81iCm/9AUpKUs/3H1fsTh0z4UJoM+7V/wMu+whqs9p/GkEYTXiCmTdigstNB/PjR87DDJG15QG5GxeUANNkq7hkXQdywmhmk0OnxbJlw0DJYfJ0Q710swEXYvczlx5QQ7AIEmi10WRPAQ5xxoAuvuAT0EI+HTWzMZBkY9ZiUycAnHoepWX81JQ04ejJdN14piT9XqZQs+k0gImao/BAawH8LxG4KpZbYnc1IF/WgBXAfxAXlM7XHUi3d5SXXaz/O7HxqI0xwnDUYoy4L3NQbg== 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=3/G9wk37yO7eDMrcFYJkjsA8mpSG2VRUwCMdCECCknE=; b=UrIZxS4Nzpn/+XZT9TQFQAVi176Mvpc/PP0IK9Z9mpJUri3ggd9L1HrOZNjjZjHm/Z4KCQJJbUZYYKW9ZhzPk7E4XNhQ8LlGB6qmoUs2mRKj9MOblM1TlhzHrdWcTzjZ1fdmMZc2EUq5+puoaXIiksElibQx/YpYPRax2hjCq7pOuAkknFr3cN1+aqKq+M5Lw+zKF8qAzWTVNjClXYoOgyLQ2MrQAlsQnU1uff7WdUrrI80CW4K9UR2Kr1nUpAuVCSU4lQH/06UUCL/CqUInfZH/l3r7j3QWwr45CHdlqHop0zUqmJIHvsLsF4iZq44ROF5t0adhuqq8NEG7auedFA== 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 AS8PR10MB7972.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:567::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Wed, 17 May 2023 15:35:40 +0000 Received: from DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3]) by DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3%5]) with mapi id 15.20.6387.032; Wed, 17 May 2023 15:35:40 +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/lua: Add IPC types / definitions to spec Date: Wed, 17 May 2023 17:35:48 +0200 Message-Id: <20230517153550.262808-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: FR0P281CA0171.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b4::12) To DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:333::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB5404:EE_|AS8PR10MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 953dea8a-7f65-4a2f-cf34-08db56ec5eaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wyr6AbgbwqJjYdGncvcBnXI2BglMrES4vba7/fwWK2ez5CO4T8zEaFI0VuZAgGpiRlw3LsxY1JBsgG3/4+0+IC0Xyj/HChfkKqSiBwlWKFGiVrxspOdOq/XhVXApZR7neqdE4U4U7Qxq8/JF5PI0wnlDte/OswdSd2YIOYAK/yjLuETjMJPKb8apsFRrs+9Wth7v6NUQC7q6yykS2BNllNZGZgDaoQzMmu0lm1TeEXVxTCocUXtxNT6kaAW2zzPkkRPzoPzvHDbD/VMnsxIDgLHaHIcuGXpLPgyIlRw42AqY7Gtn38b5Ryq97vYT2lMafkwmoHq/BOCzZIh9iVQhF1dA9QHiNzkEGsFU+1N3Nos9Xr1Nrb578J/gTMbhq6EX5wImJqoStRaR/gBTXf4+aTppWYKu2Sph5mO8FnfUL56Io5S0q4zE0PqBMv3TW0O860sKhuWiHg5AhB8xEhPgYzsvs5XaB2JqEPIhMNfyBCLeaJ6E0E9Neo6YcTBWajKYql2mGtTM0i87mQB95aawgNhxpBVzF3HfdRvPwkx9ljDnC2cJl2jquAr2bUY+5bW9 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)(136003)(366004)(39860400002)(376002)(346002)(396003)(451199021)(86362001)(36756003)(6486002)(4326008)(478600001)(66946007)(66476007)(66556008)(6916009)(316002)(5660300002)(2906002)(8936002)(41300700001)(8676002)(44832011)(38100700002)(82960400001)(6506007)(1076003)(6512007)(186003)(2616005)(107886003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eQOw5aVNXdXujLu0y64IBASYQtirch8+dzY7YOLR+AFTSnkPAYA6YS0MUhu07uZ7m0NPbBgAZwHn7eo9HubRw0BN6PX2zwPLWVRq9XIO4RK8uUgOFvbL1ahqfdQ/63QWkVOSwu8MA1F+5MPHRVobcq9lOG8n+EV5KM2dkQ7Bhr4h7irfSZ9SE/Hgh2NfDuoMcbvUSXHmvio0H52TP8qm1mQR9C7Zcs1nlmeC0Kt012u9CXmP8dDw+clmzxAGoubEgLv29ZvUmez872wfAxpULv8ToRDPjijlcvUowmLpHChiBQ6Xx6T/lp2rXJW8QmG7JO4yOHhuFgskw6FuvAh2BL3fUfN/o9gvLRq22LDSGl9+6mAcWm1W20ODtCPzzFM4tPiXiPky6sQF4x2Og19QnDEhpgVuj86ktFDulh0jH9pKPVRrS/BWSMnFNBIqmPsa7gtuLfAh88sfWs/BcSSakb7c1gox09wn+f+y5yybID2q83jjtnOCzWZJ4bO9g0861oFUapnb3oXOPNW7ffUUSQcZ8kTqzWoNN1mfW9MRDpuZ8xxoAemfeVYGyHUJfYERjr1fdMrxKYZGIz+5tjUKJ9iqcCFS9Ws6MhE5a8/uyTarvP11vC8aRIuDWMCCJgqUNq+EiNC70ul3btND0lviWGQzo0wLOZTfkFUcGEfp76Y3HgY09yEhH4Flg81a9AXPGdsLYrYbvruBekJPe9eMZnHezDSKwKi7p1wLFNlNJ8zc7Vpc4KyAD7CNT4DnFdvxcAXbXtrz3bGbFf9zKvNRZ/HKTDTzfHlOl4dSz8FtRln26QN4U5UQSvihP6x+fRJOX8kA4qJi57A1npwFmvegxLw8BXpWUjPV0AYXBgTnDRXpsKeeGDHoX5Q6hRsIN+KjQbvcW5eVb0RlKPzl/uJF0GvIbSCFMPC3cZIc/tCsNrU/d6ZAnhngzpQ1y8asWvbozGvufLKlZd3AFMz7OT3rMa0fLB2r+N/GNg00c0a/dhYlsgx2PA7o33f32rudAo2o5ggqbJQjQJqn7QjX4pxIswGwaVqFjPp3GKN74u1u+fCR6ktrTxgjkNDotjFLOlf5rUQ6c1qsQxYeQx5dfSLk9QNNg35na87k1CE9vAZ4ML1XrOjTupUNsU/YOMFqP9gxjYezbk2CZ9SKbxaI7gDoVIN9zRKSQhGsH0bt1L7QbEUJQxhgqRw2VGbhb71bBmi76LL70aaac5q68/4G8NdHX3Npu3DaPUP5OJr6JP+S6R/rUnC3+sS44/+V8cgYGEvD26hdCsPcf4WQVFMMs32gqiNLeMT5mqVDvmPL+HYhnL3TzEW/hLR0gjJWiUGWvrBO3In7aOgrPjR7hboOsweWX696sx+WizqiYYf8sc+WySIndJX0XMMIKNkrzzmCpzqerJm8dzQnB/moVqgTPtTuTFXzt1+tSKrGAUgRCgDgDpEFfBbXIADT+VqoPAj82qFPpcdZuMtw7LAmZoUAegNlZy90OqeabWcLSXmJMXmSfVlwiiZrdCWvFUXDx+18TFyALIuIGJhbtcv6nwj1hDITvBYmOSH+M3P+f1uIjNrn4OPVqeSaEP96k/M0A/p2Go1KRTYIOePIG2kiSeTV/JFNyqXlJQUNM3gA1KNFLbh+8uV349z6f+q/AmEc/XhYFdfLWKrNo14bjkClCW8wyjIR/w== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 953dea8a-7f65-4a2f-cf34-08db56ec5eaf X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:35:40.7410 (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: 2M/xNFR7apTD6gDMlenzVCghzBZgqulZSnrSuzyAjV0kXZ0HrJPwpHg3XAUCaipS8yDF3mSPHYalSv9ZYZNGviShUYkTaVxPiglMg/c+wno= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB7972 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=q4cykKnR; 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:7e1b::614 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: , Move SWUpdate IPC types and definitions from the 'General Purpose HTTP Server' example to the Lua interface specification as it's generally useful for Suricatta Lua Modules. Signed-off-by: Christian Storm --- examples/suricatta/swupdate_suricatta.lua | 80 ++--------------------- suricatta/server_lua.c | 24 +++++++ suricatta/suricatta.lua | 72 ++++++++++++++++++++ 3 files changed, 101 insertions(+), 75 deletions(-) diff --git a/examples/suricatta/swupdate_suricatta.lua b/examples/suricatta/swupdate_suricatta.lua index f1d2da60..3f01b0ce 100644 --- a/examples/suricatta/swupdate_suricatta.lua +++ b/examples/suricatta/swupdate_suricatta.lua @@ -252,49 +252,6 @@ end -- suricatta.server.register(check_cancel_callback, suricatta.server.CALLBACK_CHECK_CANCEL) ---- Lua equivalent of `sourcetype` as in `include/swupdate_status.h`. --- ---- @type table ---- @class sourcetype ---- @field SOURCE_UNKNOWN number 0 ---- @field SOURCE_WEBSERVER number 1 ---- @field SOURCE_SURICATTA number 2 ---- @field SOURCE_DOWNLOADER number 3 ---- @field SOURCE_LOCAL number 4 ---- @field SOURCE_CHUNKS_DOWNLOADER number 5 - - ---- Lua equivalent of `RECOVERY_STATUS` as in `include/swupdate_status.h`. --- ---- @type table ---- @class RECOVERY_STATUS ---- @field IDLE number 0 ---- @field START number 1 ---- @field RUN number 2 ---- @field SUCCESS number 3 ---- @field FAILURE number 4 ---- @field DOWNLOAD number 5 ---- @field DONE number 6 ---- @field SUBPROCESS number 7 ---- @field PROGRESS number 8 - - ---- Lua equivalent of `progress_msg` as in `include/progress_ipc.h`. --- ---- @class progress_msg ---- @field magic number SWUpdate IPC magic number ---- @field status RECOVERY_STATUS Update status ---- @field dwl_percent number Percent of downloaded data ---- @field nsteps number Total steps count ---- @field cur_step number Current step ---- @field cur_percent number Percent in current step ---- @field cur_image string Name of the current image to be installed ---- @field hnd_name string Name of the running handler ---- @field source sourcetype The source that has triggered the update ---- @field info string Additional information about the installation ---- @field jsoninfo table If `info` is JSON, according Lua Table - - --- Progress thread callback handling progress reporting to remote. -- -- Deliberately just uploading the JSON content while not respecting @@ -306,8 +263,8 @@ end -- is suspended in the call to suricatta.{install,download}(). While this is -- safe, both callback functions should take care not to starve each other. -- ---- @param message progress_msg The progress message ---- @return suricatta.status # Suricatta return code +--- @param message suricatta.ipc.progress_msg The progress message +--- @return suricatta.status # Suricatta return code function progress_callback(message) if not gs.channel.progress then return suricatta.status.OK @@ -560,40 +517,13 @@ end suricatta.server.register(send_target_data, suricatta.server.SEND_TARGET_DATA) ---- Lua "enum" of IPC commands as in `include/network_ipc.h` --- --- `CMD_ENABLE` is not passed through and hence not in `ipc_commands` as --- it's handled directly in `suricatta/suricatta.c`. --- ---- @type table ---- @class ipc_commands ---- @field ACTIVATION number 0 ---- @field CONFIG number 1 ---- @field GET_STATUS number 3 - ---- Lua-alike of `ipc_message` as in `include/network_ipc.h` --- --- Note: Some members are deliberately not passed through to the Lua realm --- such as `ipc_message.data.len` as that's handled by the C-to-Lua bridge --- transparently. --- Also, this is not a direct equivalent as, e.g., the `json` field is not --- present in `struct ipc_message`, but rather it's a "sensible" selection. --- ---- @class ipc_message ---- @field magic number SWUpdate IPC magic number ---- @field commands ipc_commands IPC commands ---- @field cmd number Command number, one of `ipc_commands`'s values ---- @field msg string String data sent via IPC ---- @field json table If `msg` is JSON, JSON as Lua Table - - --- Handle IPC messages sent to Suricatta Lua module. -- -- Lua counterpart of `server_op_res_t server_ipc(ipc_message *msg)`. -- ---- @param message ipc_message The IPC message sent ---- @return string # IPC reply string ---- @return suricatta.status # Suricatta return code +--- @param message suricatta.ipc.ipc_message The IPC message sent +--- @return string # IPC JSON reply string +--- @return suricatta.status # Suricatta return code function ipc(message) if not (message or {}).json then return escape([[{ "request": "IPC requests must be JSON formatted" }]], { ['"'] = '"' }), diff --git a/suricatta/server_lua.c b/suricatta/server_lua.c index bdf34084..60133a80 100644 --- a/suricatta/server_lua.c +++ b/suricatta/server_lua.c @@ -1569,7 +1569,31 @@ static int suricatta_lua_module(lua_State *L) lua_newtable(L); luaL_setfuncs(L, lua_funcs_bootloader_env, 0); lua_settable(L, -3); + lua_settable(L, -3); + lua_pushstring(L, "ipc"); + lua_newtable(L); + lua_pushstring(L, "sourcetype"); + lua_newtable(L); + push_to_table(L, "SOURCE_UNKNOWN", SOURCE_UNKNOWN); + push_to_table(L, "SOURCE_WEBSERVER", SOURCE_WEBSERVER); + push_to_table(L, "SOURCE_SURICATTA", SOURCE_SURICATTA); + push_to_table(L, "SOURCE_DOWNLOADER", SOURCE_DOWNLOADER); + push_to_table(L, "SOURCE_LOCAL", SOURCE_LOCAL); + push_to_table(L, "SOURCE_CHUNKS_DOWNLOADER", SOURCE_CHUNKS_DOWNLOADER); + lua_settable(L, -3); + lua_pushstring(L, "RECOVERY_STATUS"); + lua_newtable(L); + push_to_table(L, "IDLE", IDLE); + push_to_table(L, "START", START); + push_to_table(L, "RUN", RUN); + push_to_table(L, "SUCCESS", SUCCESS); + push_to_table(L, "FAILURE", FAILURE); + push_to_table(L, "DOWNLOAD", DOWNLOAD); + push_to_table(L, "DONE", SUBPROCESS); + push_to_table(L, "SUBPROCESS", SUBPROCESS); + push_to_table(L, "PROGRESS", PROGRESS); + lua_settable(L, -3); lua_settable(L, -3); lua_pushstring(L, "status"); diff --git a/suricatta/suricatta.lua b/suricatta/suricatta.lua index bfcb3be5..c61d483f 100644 --- a/suricatta/suricatta.lua +++ b/suricatta/suricatta.lua @@ -386,4 +386,76 @@ suricatta.get_tmpdir = function() end suricatta.getversion = function() end +--- SWUpdate IPC types and definitions. +-- +--- @class suricatta.ipc +suricatta.ipc = {} + +--- @enum suricatta.ipc.sourcetype +--- Lua equivalent of `sourcetype` as in `include/swupdate_status.h`. +suricatta.ipc.sourcetype = { + SOURCE_UNKNOWN = 0, + SOURCE_WEBSERVER = 1, + SOURCE_SURICATTA = 2, + SOURCE_DOWNLOADER = 3, + SOURCE_LOCAL = 4, + SOURCE_CHUNKS_DOWNLOADER = 5 +} + +--- @enum suricatta.ipc.RECOVERY_STATUS +--- Lua equivalent of `RECOVERY_STATUS` as in `include/swupdate_status.h`. +suricatta.ipc.RECOVERY_STATUS = { + IDLE = 0, + START = 1, + RUN = 2, + SUCCESS = 3, + FAILURE = 4, + DOWNLOAD = 5, + DONE = 6, + SUBPROCESS = 7, + PROGRESS = 8 +} + +--- Lua-alike of `progress_msg` as in `include/progress_ipc.h`. +-- +--- @class suricatta.ipc.progress_msg +--- @field magic number SWUpdate IPC magic number +--- @field status suricatta.ipc.RECOVERY_STATUS Update status +--- @field dwl_percent number Percent of downloaded data +--- @field nsteps number Total steps count +--- @field cur_step number Current step +--- @field cur_percent number Percent in current step +--- @field cur_image string Name of the current image to be installed (max: 256 chars) +--- @field hnd_name string Name of the running handler (max: 64 chars) +--- @field source suricatta.ipc.sourcetype The source that has triggered the update +--- @field info string Additional information about the installation (max: 2048 chars) +--- @field jsoninfo table If `info` is JSON, according Lua Table + +--- Lua enum of IPC commands as in `include/network_ipc.h`. +-- +-- `CMD_ENABLE` is not passed through and hence not in `ipc_commands` +-- as it's handled directly in `suricatta/suricatta.c`. +-- +--- @type {[string]: number} +--- @class suricatta.ipc.ipc_commands +--- @field ACTIVATION number 0 +--- @field CONFIG number 1 +--- @field GET_STATUS number 3 + +--- Lua-alike of `ipc_message` as in `include/network_ipc.h`. +-- +-- Note: Some members are deliberately not passed through to the Lua +-- realm such as `ipc_message.data.len` since that's transparently +-- handled by the C-to-Lua bridge. +-- Note: This is not a direct equivalent but rather a "sensible" selection +-- as, e.g., the `json` field is not present in `struct ipc_message`. +-- +--- @class suricatta.ipc.ipc_message +--- @field magic number SWUpdate IPC magic number +--- @field commands suricatta.ipc.ipc_commands IPC commands +--- @field cmd number Command number, one of `ipc_commands`'s values +--- @field msg string String data sent via IPC +--- @field json table If `msg` is JSON, JSON as Lua Table + + return suricatta From patchwork Wed May 17 15:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1782744 X-Patchwork-Delegate: sbabic@denx.de 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::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbvpisorqmgqeh36pcqi@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=mPwErNEP; dkim-atps=neutral Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (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 4QLxyf10f1z20KF for ; Thu, 18 May 2023 01:35:53 +1000 (AEST) Received: by mail-lj1-x23b.google.com with SMTP id 38308e7fff4ca-2ac8e10abafsf3996161fa.2 for ; Wed, 17 May 2023 08:35:53 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1684337750; cv=pass; d=google.com; s=arc-20160816; b=KVNd9e7sMbvrBgXLXsmGvoEs7qHS7Dem3UeANwUA4Cg6JdnID9OzPVpn/un5DJOyie /7TpPgq6vpqY7ymYVKZhqjyqOEHuiImHqzygYS+zaIgCEErnDOP8pk4iECvJzSI97APM XGeb975XkXAhtY7CjhuR3dCsLZ7KWsUOuiqiYfNnOnEDNRKLzZLjW2RyVc40S99R08Y4 rFz6KFp69Jv9IMNjh63eiouSdkptxD3jIpgvCZtWsOP/IiszCfcwRdEcxE2xHYTCpyVZ d7tUydmlBRRa4D3QgXJ6DjHNA33n9+VriLafPwu2K9+gqGirLmbgBKeGuYMsUWWbAU9V 5buQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=+hljQ0Z10yvloWiFqd6+rUdaq2KX/L7LsrKcYI6uXyY=; b=H0htA4kP84HVcVWhlpcdfr52WFynfFumjpp9crjppf90E/YeatVx8RWjceyADMahkH tqHWILONj9R+3VZzO33vCYXhQ21p/3eQL/qXQm8oDSIlha8hTKkzDeC2aOLrAnMJHvfC xVTSSmtvZYD9es4lPVSlkMaOc0YUvhdRTzsLmCSSIAaOvQkwGIeKt0CPAoyj6Iuk/Z3e EBZRxxV8NcJNA06zBPbzO0eYxI3/2M0P4Y5cmopUO7xuW8d5F4kyI3rIl0RrUKEc4sX6 sQTMwfZadcaGO0lC99CnqZVZdVjll3B0T+aH5RRrX7g8NvIgQhO19Xak7SbxYJ4cK0FC smsg== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=B0bGouPU; 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:fe12::623 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=1684337750; x=1686929750; 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 :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=+hljQ0Z10yvloWiFqd6+rUdaq2KX/L7LsrKcYI6uXyY=; b=mPwErNEPlWRXDs1AWDUFW7NP+rv6ILLpQg0mKX9C4j1vXkYmpJtWIKDkPoSyGFnf7i zTVr/EEngkzXeCM877mSZ4+il9b863DodHCsZ+g3Zn+yaJK6/7P0mS08MdpUbEiq+cSq bcC1Wx3F81ZF+U+oDSjIZWCMtt7vi5yDAP71R+zqLKOJ3SBuzB/N39Qy4sbiBYL8eCAf lQ4/Jvj6YO8Q7LyZ8bmhVpXSAEVIEtVBiq1ej/eig5KvMHXIoLf4d2Hl2zn+f7BzOyPj bpseM+n0FogDtkQ8olivh77iK0knwg6VryTrivRr8QqTIHZC19Y5J1TAf8C6Fw/rguoO sMKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684337750; x=1686929750; 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 :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+hljQ0Z10yvloWiFqd6+rUdaq2KX/L7LsrKcYI6uXyY=; b=KTPg9Jf/1iHA3vqJwjnn1RjDSzLj6zcZ6iZTWw6oBtkoAnYAwom3J8isstTIKoXFmP Qmj6jWE/SaK74CQO+ElbyNutl7GdLXN2KZwkdM1kENGbsp6BEmqbY0qV7iwQAQf3Vmtu eTiDPEzz1sK1y7tbbA/WaYUJoBMzooda/cIVqi4eg1QxhoURuyd2Gm32xpw/7DSxClbp joCcndSju8WxgtR5VtPwpA4ts1bfG4602a0fCahMJXy6ONDJ1+Vdnp4hZf3kn+ac2JV+ ML8+au3wbnRf5G2XP2Dq4J0N06BCQg7uzzrmN/D1nmfw2QK5AsKGdEMFoNz862ALh6jj R9HA== X-Gm-Message-State: AC+VfDzLYTOEfQ9o//UNLuZNoEs0WpWv2AEpAW5LhnF9DoJuPV/nuc25 q9wagCPUrOdRI3C2vjvN0NU= X-Google-Smtp-Source: ACHHUZ7yF28NiIojtT4xAnzdRegeK4JH07V290tiOaIG1ZHEl6kyLhvaUZHZ38Ar+f4MU+ctEhcfmw== X-Received: by 2002:a2e:9c86:0:b0:2ad:9149:272c with SMTP id x6-20020a2e9c86000000b002ad9149272cmr7582543lji.2.1684337750201; Wed, 17 May 2023 08:35:50 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:9945:0:b0:2ad:a1e5:c894 with SMTP id r5-20020a2e9945000000b002ada1e5c894ls176384ljj.1.-pod-prod-06-eu; Wed, 17 May 2023 08:35:48 -0700 (PDT) X-Received: by 2002:a2e:8755:0:b0:2ac:98ba:a52e with SMTP id q21-20020a2e8755000000b002ac98baa52emr9261005ljj.44.1684337748540; Wed, 17 May 2023 08:35:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684337748; cv=pass; d=google.com; s=arc-20160816; b=XxW5nuTQ24jemoUodNFA02dZI81NGaIQDBjf7MaHV8bq4fRb8pOeyXMgK879BlPgzg Nm1dhcd0GyVdo+AM0Nlz6eF1L+Q2mQb9C8y4TzbVPUiXKZfVh5vJdxk4d+1oBHftDAjl NfDFj754Jo89K6IQyALrUHs+IPU86d3ziS8bKYTDz+Z9aNZzbFjH1gHEUvXnCPGhexHR ENWCTwnkhCmK3AtLPI6txDJCpEfox4wqIQw60wjQbphCZcZ0bRRSlyJUBa3SuZ0E7RC2 ezmBzaB/lK80vE0JSqZ4oEHBpzAj+rHU/9X0V6iMNfQTcooBKtItca2A8TlPJ+pXY7bJ yz+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kDb6xZbega5Jh81fByqCTDESw5pL+GAwCtVPCZNBabo=; b=pwVBAvMK4segcV0SjxxOiKaI3u/n++sOBJTtZGsUij9ShTjd3BtfLwcZa8bs8w0PhX NMBQNxsMes7dzohtuHd8YLhCeaLcZVGePeo7jfUiWAj8McIhRD5YDaV7A5xz0vvkbeDj qe8+ZalwKMXbX0vl9U70opfxj2/VWir8V0EmDAR7iHOEiUYmEplMi6uDg5QhWamDxK6Q Aq1pgToT5IT6Ao4QASoonNvMOseibpSs+qpmxY3fvL4SuFcAal8e1amYvxTayr/2dMK3 ZDonEmyUfcw6zGto0tMiz4s0BJDCppn1T6G1LdF4hKeSSaYV0yW8K3TkA9OF3523+V4D 7Vjg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=B0bGouPU; 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:fe12::623 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on20623.outbound.protection.outlook.com. [2a01:111:f400:fe12::623]) by gmr-mx.google.com with ESMTPS id bx43-20020a05651c19ab00b002ac75541fd4si1955085ljb.0.2023.05.17.08.35.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2023 08:35:48 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:fe12::623 as permitted sender) client-ip=2a01:111:f400:fe12::623; ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOvJ6zFALGcIDy/78G5QhNSCyx4Mrsd+n63UseSYsl7ofAUKpZX8UY2kRIAaqqCyrZCsxOKVAO3vrRRtRUbW06Y1yGefQFduvowaLKUblUY4SEwnn7N2LyZdwYiJOk+mekwGEwvhMm6ZeeE65tB8+b/ySyYJiXAXFyz7TG6Lv82oS+B9kn3Vc8wnfzfkD9V0Zv/C3cvGMJZSezmOnJMW3lgeIMQ9agbvTDU/PxReBw4JB+dowRkRu4iCRiYm2QChncvQR74dOcKLbiyszkKlW1DbRXsnRQcYB9j8mnDuu+baJcC8HGGv88VsR+6kGW3aRRqRhLzqJ79lQMA+miDPvQ== 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=kDb6xZbega5Jh81fByqCTDESw5pL+GAwCtVPCZNBabo=; b=doXb3dSBMxy8ehytWOJtYR8b4jTxGlegA7kZmZku1138dr5AVXSxcL5NnKYVF6e3VjWYgzoyOqRnXvtpAZZFkxkg3rFzlKuQt3JmbkPUs3HoBfe8jUqNGz/Rj+Y8lrR6cTo/DlWguqfw4Sf3G3t7hrwNFQ78pGcHR/p186h+MqarCfp0mc3lsXUtFLsGK8fr5qFdOTHcSHutG24ZH5+9zV5f0GUhGsw+O3DHYBqP1FnvgmtBkkMPc/AQzDgMyWUijXN3yC4uzVRCOB7hZzuAs+X966s88s1SAMHcIfkTHwTj0nmvKCp2MPDaxiDhveWNUNczAxx2kXk6s10eFfTb1Q== 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 AS8PR10MB7972.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:567::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Wed, 17 May 2023 15:35:46 +0000 Received: from DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3]) by DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3%5]) with mapi id 15.20.6387.032; Wed, 17 May 2023 15:35:46 +0000 X-Patchwork-Original-From: "'Christian Storm' via swupdate" From: "Storm, Christian" To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 2/3] suricatta/lua: Properly type integer values Date: Wed, 17 May 2023 17:35:49 +0200 Message-Id: <20230517153550.262808-2-christian.storm@siemens.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517153550.262808-1-christian.storm@siemens.com> References: <20230517153550.262808-1-christian.storm@siemens.com> X-ClientProxiedBy: FR0P281CA0168.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b4::17) To DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:333::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB5404:EE_|AS8PR10MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f7a61b9-88b8-4e6e-772e-08db56ec6251 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QI8lbATG04ZxjSx90+n4V+4vKSEpTQnOtN7uOMBRof65yJh4T5bY6pxQLDx6TT3ZjkkA07PU9tOTMjQMU5+o8gdytlFZDYWw2mIPwVq/rJn3MWyBhSkC9hp2orNDdn74RpErJyYhORlv+ihCuIMHXXMkyV8fWTqkSb0L1tM4gBvw2iq9bTFXnx56jYf/0tMH3/ZlwWjTOayuHRVYJ8vtTmjsxdsB1nRcxvF5QvRooiYqK1ghC31t9UHCtColmnAzVo7AK0c2c0WwDTunfu080I5hXz6WZ27MAXzFmOEjEspoJU/iL/frFvHvPOMSg5zcC9JXJpp9oM1tAljfV2kMHY3pkWVPLbrZuzIh2lhs0/k1W65u8w4qYFxG8AcPk2lDZkV78WMoOWNhPrmfPrcrtP5Xhu08hmVR6VJNvu9JA+7BRVYPNmwlL4GSZMxO8e/cZ9smOgS+h9+n1rJHU2cbJiM9178Xuc1UVu/ruDo4hEwSIYH+F1At1ixnAmAJJg3Em19QP4+1ovffIIkpw5UbnQFp5FJZBOs8ma/hPHACrzc= 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)(136003)(366004)(39860400002)(376002)(346002)(396003)(451199021)(86362001)(36756003)(6486002)(966005)(4326008)(478600001)(66946007)(66476007)(66556008)(6916009)(316002)(5660300002)(2906002)(8936002)(41300700001)(8676002)(44832011)(38100700002)(82960400001)(6506007)(1076003)(6512007)(186003)(2616005)(107886003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ow7yV4sgzIjBi9EXOZu8xCETx7O2bineEoFGggBEbT/n1K9wgrQ/wbHM5QjrQ3d2aSFM4Qmm9CYRvklX84XlRNtHEYxVAT+CXqJ4/x8m9krhjbSCEIEif4N2XfOvc1d17QUjm64h4351pk3zd9UppJUnZ3rr1Tk0OvLvZUsA4qo6Sy6xPL8lZUQh3vWHHXhA1GRKlK4b+Lde1pGjKXzOBEvLP0hwBLjMol1I/o5BApAiDPVLT5TI4DcE6Hs/zSFC9Ip/8Ka+SskpXZk+rlFjGsGa+yCbdN6+7l4TaIF1Pcn2XhqbCRWSISyU/FJ22zKLE/Zjaf4TG6U8fUrj8XE0NbVnhDa0YJfl12Rc+IP10xG/QfPETb8ltCbrdc82Vt4dfSVDCN8Ya8gX2dYfFmiu2itp+ZgwNt7M7lkFx7EGmUuO90+ndez/irPPmKHyFs0BzVfWK4OC4uUrzxfcH6tyNCLwB22aLhFXeaaSR4eVTmxQEiPELxg/e4aGFr/Z5vQaXNReg91BcdeS7g5z6AVtiQ0ozv7VR8NDTMD7fiNtbzRPZUizjrmmdvwbazORvBGk+sLnvpQ0BicErzsOt4Ang+wxuOD1nmJX17Klu87z4UWivjD1HTP6+WSBrz+1lD3vpxx+yt1WjA9l2tdgb2KtJsOMkHYXG6otIGLlEZ3qx4dDw2fX8sH3qzYXzFSer8gelnBnj+NL25v+pTndTXYsLzKA7wDDsymkO+kh6suD/TCQAEMCKIalWgEUAg/asCfpPQvA3XQAPf3rFsdfmATO6nlkXZGReyOXVrrhUltBxVj8kr10Z+Jrx8pPHNUyt84RvteGevMMSnXXq9WYcJfD4KnfqY2A7Yd68dlhW0oNpXPteLHi8KvPDcPnGju3jmR5u0sqBKwyQT/Fq3RlzDfPgORwqO438C2iX/P3lhOXiizN6ZCvrBv9Epf6ILKc4f2x+0C+JNtbUvDahaoCv0BkFIAV9Dnd8KgfyHrJPZYpT4E7eEBA9DsTXxxXSe7Hnu9KwLAQQfghssclWdqMe19Vmba5f3CIAJB6Ww4ReBjwNM9T92qKVEWDjDc3GoiTYy5d7RBZCx+pHJHh+IoKRZ6Y6EJePGje0xoglgVFYyZihxsXfdlTvDeoSTpohy/I3jKVRAxxCo/kGYsHfEDRw1X4sUSdB327j9h44PbLdiNA+zJWr0f2UyqjQ0RXMHG5YoBDfRyRPn4gRYMHqDiICRgmz4ExaTJHf1qwixQnpdL+dT60pPIrzP+rH+eNEri0B5uYkgTeNprga+Z7VxYchB5LbX91wKdypbr7ldYE6g/zN6kUve5rwewsM5t7rn2JTd949sLHBCopedob+lsWaMu2UxeN9sSJytzpY6jHuUUoMOU7JA7Pb27ZodA9fMhnDtvJ4mzaxxGrqzvQNQA+amqWadBRy+bupnBOpLrnEHlhRJCAS7iFbjNKOsauUnCh+n5a2vzQ+k60Z7WlmO/KStMcceQQB9CGOkD0Uvp1sIV554Czkvd8+bA1SZYzwta8Pkmgxh5q+R7AKJS37icZUTReCh6OWkOn8Eg/htfJbQL4ByPA+Jj12qCKocA5z0yChv0moF8n3KAKIpNkGwJSkdhrH6rGtpeCnuXCVZ49DOORz4uhdaw+EQ5enZsCWJ834XUhmoSunb7o17YWJZjh1UaTXA== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f7a61b9-88b8-4e6e-772e-08db56ec6251 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:35:46.8154 (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: gikCB47781vWxkMMApG0F3ol1sVEL9HQrBvfViVEU6nGFP3XaY612Ma8Bhb2e8luD56WAULO7s9a2Bmkdza1+GgDl8FzOj5GhZSjxLsmbLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB7972 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=B0bGouPU; 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:fe12::623 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: , Since Lua 5.3, the conversion of a number to a string adds a .0 suffix to the result if it looks like an integer so that, e.g., 2.0 is printed as such and not as 2 which was the case in Lua versions prior to 5.3 (see https://www.lua.org/manual/5.3/manual.html#8, Section 8.1). Hence, fix this purely cosmetic glitch by explicitly using lua_pushnumber() or lua_pushinteger() depending on the type. Signed-off-by: Christian Storm --- suricatta/server_lua.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/suricatta/server_lua.c b/suricatta/server_lua.c index 60133a80..37e4950b 100644 --- a/suricatta/server_lua.c +++ b/suricatta/server_lua.c @@ -167,23 +167,23 @@ typedef struct { __builtin_choose_expr(__builtin_types_compatible_p( \ typeof(name), char* ), lua_pushstring, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(name), int ), lua_pushnumber, \ + typeof(name), int ), lua_pushinteger, \ (void)0)))(L, name) \ ); \ (__builtin_choose_expr(__builtin_types_compatible_p( \ typeof(value), bool ), lua_pushboolean, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(value), unsigned int ), lua_pushnumber, \ + typeof(value), unsigned int ), lua_pushinteger, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(value), int ), lua_pushnumber, \ + typeof(value), int ), lua_pushinteger, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(value), long long ), lua_pushnumber, \ + typeof(value), long long ), lua_pushinteger, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(value), long ), lua_pushnumber, \ + typeof(value), long ), lua_pushinteger, \ __builtin_choose_expr(__builtin_types_compatible_p( \ typeof(value), double ), lua_pushnumber, \ __builtin_choose_expr(__builtin_types_compatible_p( \ - typeof(value), channel_body_t), lua_pushnumber, \ + typeof(value), channel_body_t), lua_pushinteger, \ __builtin_choose_expr(__builtin_types_compatible_p( \ typeof(value), char[] ), lua_pushstring, \ __builtin_choose_expr(__builtin_types_compatible_p( \ @@ -299,9 +299,11 @@ static int json_push_to_table(lua_State *L, json_object *jsobj) lua_pushboolean(L, json_object_get_boolean(jsobj)); break; case json_type_double: - case json_type_int: lua_pushnumber(L, json_object_get_int(jsobj)); break; + case json_type_int: + lua_pushinteger(L, json_object_get_int(jsobj)); + break; case json_type_null: /* Lua has no notion of 'null', mimic it by an empty Table. */ lua_createtable(L, 0, 0); @@ -348,7 +350,7 @@ static int json_to_table_callback(json_object *jsobj, int flags, } if (jsobj_index && !jsobj_key) { /* Visiting array element: push to Lua "Array" Table part. */ - lua_pushnumber(L, (int)*jsobj_index + 1); + lua_pushinteger(L, (int)*jsobj_index + 1); } else { /* Visiting object element: push to Lua "Dict" Table part. */ lua_pushstring(L, jsobj_key); @@ -675,7 +677,7 @@ static int channel_do_operation(lua_State *L, channel_method_t op) if (!udc->channel) { ERROR("Called GET/PUT channel operation on a closed channel."); lua_pushnil(L); - lua_pushnumber(L, SERVER_EINIT); + lua_pushinteger(L, SERVER_EINIT); lua_newtable(L); return 3; } @@ -715,7 +717,7 @@ static int channel_do_operation(lua_State *L, channel_method_t op) /* Assemble result for passing back to the Lua realm. */ push_result(L, result); - lua_pushnumber(L, result); + lua_pushinteger(L, result); lua_newtable(L); push_to_table(L, "http_response_code", channel_data.http_response_code); push_to_table(L, "format", channel_data.format); @@ -1146,7 +1148,7 @@ static void do_install(lua_State *L, int fdout) result = iresult == FAILURE ? SERVER_EERR : SERVER_OK; } push_result(L, result); - lua_pushnumber(L, result); + lua_pushinteger(L, result); lua_newtable(L); if (ipc_journal) { const char **iter = ipc_journal; @@ -1162,7 +1164,7 @@ static void do_install(lua_State *L, int fdout) goto done; error: lua_pushnil(L); - lua_pushnumber(L, SERVER_EINIT); + lua_pushinteger(L, SERVER_EINIT); lua_newtable(L); done: if (callback_data.progress_msgq_lock) { @@ -1219,7 +1221,7 @@ static int lua_suricatta_download(lua_State *L) ERROR("Cannot open %s for writing.", luaL_checkstring(L, -1)); lua_pop(L, 2); lua_pushnil(L); - lua_pushnumber(L, SERVER_EINIT); + lua_pushinteger(L, SERVER_EINIT); lua_newtable(L); return 3; } @@ -1464,7 +1466,7 @@ static int lua_pstate_get(lua_State *L) update_state_t state = get_state(); if (is_valid_state(state)) { lua_pushboolean(L, true); - lua_pushnumber(L, (int)state); + lua_pushinteger(L, (int)state); } else { lua_pushnil(L); lua_pushnil(L); @@ -1933,7 +1935,7 @@ static unsigned int server_get_polling_interval(void) */ static server_op_res_t server_has_pending_action(int *action_id) { - lua_pushnumber(gL, *action_id); + lua_pushinteger(gL, *action_id); server_op_res_t result = map_lua_result( call_lua_func(gL, SURICATTA_FUNC_HAS_PENDING_ACTION, 1)); if ((lua_gettop(gL) > 0) && (lua_isnumber(gL, -1))) { From patchwork Wed May 17 15:35:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1782745 X-Patchwork-Delegate: sbabic@denx.de 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::43e; helo=mail-wr1-x43e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbwxisorqmgqeufww4ba@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=aWjwaXhU; dkim-atps=neutral Received: from mail-wr1-x43e.google.com (mail-wr1-x43e.google.com [IPv6:2a00:1450:4864:20::43e]) (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 4QLxyk28Khz20KF for ; Thu, 18 May 2023 01:35:58 +1000 (AEST) Received: by mail-wr1-x43e.google.com with SMTP id ffacd0b85a97d-30641258c9esf382304f8f.2 for ; Wed, 17 May 2023 08:35:57 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1684337755; cv=pass; d=google.com; s=arc-20160816; b=dPlp/PaD8DbxnZRfPP9s3+t0iv5p0rTj/ksgQqz1ITHYNPWIECZ7Zlr15GJWgIi/X+ OLVFpSWQS63Apw498Ei9nPY+YoN19hoNBUqaM5aGUhg8hO6f9+DTn1C9N+N1J1aUVW1b r89LxqiZvIBW01xZJSRNyzY7JDJzNetdhHTj+m2aWg8CpRHLmDOqSVRgfkwOuYz1xRgq U/idH5tfQUuzJD8zcV4C7SxK++ZZE4StrMiaxOcgv9rZgdIVeB98jZDJ0oJASchINvEM 1havTAfloPOoLAwJQy5/XsxzCsNrDW5rMMVZXfnRy2mqN3MYsK+wpTIWlzFZZjMMcvgB nVDQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=MM2bNNlcAmjYcc2lBUFwOHQ2Mr2rTbZ93o4dsDWGrs8=; b=EziUreAvFQshNmDaglfwzQmZDMjf2conSPZk5abk4vL8hfV7qVI8efDAbatZuzFc/h MEHWL1HWjW67BQtBa+Pq53eqeso3B7+jKDY9/MGlV0RD4zMWpSAwRmqB0jS4X7xTOXuv Aamo63EhGpXaxMYFn6uLdI04v2NsM0Zy+XW5oVKdaW1AyHf0WAQ4UDo+cL+wpsuEwS4W Lh0g2SnxI/yJcNnM41256fmfZr+mwbbkd3wxIw6c9zgHVQL/htd9Kx+eE6k8APqUuGAF a8KhObSadB+qD7pO3RYutToid1ZBj0Wy8y6XDKe6I5mB1FCGL76WDSigwpWLR4lYl7zK vO2Q== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=QMn5EkJf; 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:7e1b::626 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=1684337755; x=1686929755; 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 :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=MM2bNNlcAmjYcc2lBUFwOHQ2Mr2rTbZ93o4dsDWGrs8=; b=aWjwaXhU//j2SQw3C7gX/edhqGz1I9BkiRHtiqs+MwR4QHJAEVsQ2dPB2NippRhhS3 IyMR8t1LXQAcdeJdogI4r9fVcamof79nr8tNnZW4qLVhZvesmJ0h1qQSmrFOB5/tNA4p HAN++Lr2LjO82Zj17HEPHQJQRWArvF6xS+6wKnW+/3QWH5xoZiyT62ruKlfiykABtfAb pTI4jF63/0EiipMa5dRqLiXBOYcvXA3B7R0fdVcHXsX0EtF9v3ZYHGQUgQf3scTBBoL1 +2xbgDGH8dc5Y+XcEV3J8UEmr5J/CzOQ7kn70OIVtPTHleR8G7CmonYI2XywF5gcts+M Mkpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684337755; x=1686929755; 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 :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MM2bNNlcAmjYcc2lBUFwOHQ2Mr2rTbZ93o4dsDWGrs8=; b=U7B1wwkKxvoBkKpgUPIC068vw2BddO24wQx/wnR130qDVjLsm87IjnpAW4rU3Y8iQ5 TwmyIu0qE9srHZiCBeAuBKCVhjrdFylH6SwWav/I5PlWtxNPxeHY20PAOX0xi496Fc6T KfqYOXpeLwmN4PFEQZdf8p/RThWs7eTMz1Blbro/oxBDc++SifeMopv+ViuJPcGnMPms g94O7WWAfPAu41lRRM0mgmKYFYN9tuDw4BdS1vU2A3wZAjP0TPLOHq+XuxKFfosOSPxd Hx4hgljnkfZHDYcD4sQ36CowM85pPP4SK+E/Qh8QtlmoAw8mrh6ZgityGWtGmWVeYzIk q6gg== X-Gm-Message-State: AC+VfDyL3NKnWtUSmXYjAgWwnCsGXHeSbj9P1ZDepQ36jKhDGQMFQuat hYXKgymPPaBixOD+HxhhehQ= X-Google-Smtp-Source: ACHHUZ4nJRGvt4RvALMb2JcG/kTZ/DtRDMTraBdNGBFpfLp3a8G4FybVYTA8wmS7VD1wqOTwdFUSSA== X-Received: by 2002:adf:eec5:0:b0:309:38af:91c4 with SMTP id a5-20020adfeec5000000b0030938af91c4mr198209wrp.6.1684337754912; Wed, 17 May 2023 08:35:54 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:45c4:b0:3f0:b128:14c0 with SMTP id s4-20020a05600c45c400b003f0b12814c0ls1586262wmo.2.-pod-control-gmail; Wed, 17 May 2023 08:35:53 -0700 (PDT) X-Received: by 2002:a1c:f209:0:b0:3f1:92aa:4eb8 with SMTP id s9-20020a1cf209000000b003f192aa4eb8mr27304883wmc.16.1684337753301; Wed, 17 May 2023 08:35:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684337753; cv=pass; d=google.com; s=arc-20160816; b=jjbKo9GlV2mPV8nrzoob16IAN8zMEEk8PPXvlqQgegT+qYwo5haKPSJcCDighYZEjt 9SfAVcXhvWIjQMmDRHmPfU8SmSaSfVRuI4wuotY3brsQq9xgIK93Wec2GMwMJbOXC6cj GI0I9JLB4SCyQ94t+L9Zc0Auf21pyL/gHMDwGllUThp6bPboZLBfrq3h5UH7iIzCNF60 NWUsou6jTFLBbpRVV1At57wDRxfzX/2O+o5JvmElBwS+LXqI8Q0Gfk42j01ThBXUpO0y MvvcVUv47q91Uw5wP20+LHz4jLHQKJvLEqbMXro4dtPXOTVNyPC9sSjXoRJTAHhHtLaG ZmDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=yi4ILqWLdvdWZKVqGlWD99EEqIgfMpvM/tmCeSeXCOE=; b=FOgzbHtPvBHoo2qi8Q5/YDtVaUnXJb90/z6RCe/aIL0YJ39VDfS6ClJN3QBnEf55yP 3v6/vb0a7Iy6jLNuoop/1FU/Wu7PyhsJbvLBI9kmoPHM4dBxK5XqRxgB8KiAbmWe+uEP jIuoeVkPdK3abqKyoKjHFTHpZQOz8nZFAA1cWTVHuayNUnmQRBpi+XJquXqF1DCg3dBt eh3ywQBueuJQaNkNE6BtF/2t+ZPdL47WMQsRlDUYAJwrNhx2tW4s6uodsjvibkLJy77+ 8jc6G00KPylsZjY9o/qqig6+r+QAgy1CysjyvZcxHFV6bAo/KOZ+7JPSrUTsSN6ammtn 8VVQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=QMn5EkJf; 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:7e1b::626 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20626.outbound.protection.outlook.com. [2a01:111:f400:7e1b::626]) by gmr-mx.google.com with ESMTPS id e11-20020a05600c4e4b00b003f4276a712bsi119890wmq.1.2023.05.17.08.35.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2023 08:35:53 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 2a01:111:f400:7e1b::626 as permitted sender) client-ip=2a01:111:f400:7e1b::626; ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kDSsebB/pvRGpb/kba5R/jSdjQZ+q5igZ7KXhGCV10K5YwrSw/sn63gdVslYjRzI+9z7seWMvRxCk/rg8dKCD4iU9ZSHJfsAm4pEpgh5NwT4i3+YQ+kXkaUWHZztw2ewQ0q2pG8AVK94dLhSph2p/MkSINirj2kmLzHm4ZdHdvTAj85ZNYmQEcAs49ZbhH+q5lNOmA0nKHMuCIMcw4ytdnRawT21Lxlo0jVKm5GaztMUcjpOcrNk+7nvX4QkPcUUXNG5Rki+Z70po70HgM1tqkn1eNuHSItKLnlOBsaln8XqYlUjHoHhQIhsWj5uNYKrC4VwFVElkZEA4pVNx9Vssw== 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=yi4ILqWLdvdWZKVqGlWD99EEqIgfMpvM/tmCeSeXCOE=; b=k7FNn4vGl5cly3Pp6c63roz9fl4hb4lVUyLJf3ar4WgrcvuB/V1LFkirmsgBMsjoTk2Fq6hnMoFszL6NoEJ+FMywo8LAqoF3wSuRwDq9+MKgwC1M9tyrWoQh1fPhcFq51/ARzdjjQvoV1FXmaY8ikdi392H0IugeeDYg4AOkVrZCvzEwhxlcTUhM1pWqeEPpcXC17oym2DUX0DUNRI81QqgEeIquJ+0UQEt8m6TuC2znA3KyqgAfQrMPa2sJY75W/QH6boJiW2PWpiQvoKU21+rTJ9HJ78jiGR4AYoOan3e+dAFLVMHn+glW9WYj12ppQyfIyW5vCCBXcg/8G9yCGw== 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 AS8PR10MB7972.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:567::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Wed, 17 May 2023 15:35:52 +0000 Received: from DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3]) by DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM ([fe80::6bed:3b93:4756:c9f3%5]) with mapi id 15.20.6387.032; Wed, 17 May 2023 15:35:52 +0000 X-Patchwork-Original-From: "'Christian Storm' via swupdate" From: "Storm, Christian" To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 3/3] suricatta/lua: Return STATE_ERROR instead of nil on !pstate.get() Date: Wed, 17 May 2023 17:35:50 +0200 Message-Id: <20230517153550.262808-3-christian.storm@siemens.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517153550.262808-1-christian.storm@siemens.com> References: <20230517153550.262808-1-christian.storm@siemens.com> X-ClientProxiedBy: FR0P281CA0231.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b2::11) To DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:333::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB5404:EE_|AS8PR10MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 82b84571-5f16-47d7-6389-08db56ec6591 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VToMLttWO5XL7VtwCu8Ah7A+3znKe+dRrczkTeeruj1upoN/vISxK/00JrwxH0YOnq+8huA8oR9RiabwRDfjQTqBqZqtC9BDA0WiZnoZs+KFUaNqSVWlCVOvkAJtZ2bQS8hrR0ZF84JOwPtX6Bc5R1ovDsAzWta5JvMIFy6m3pSx2U7bb+OaeBmAHEdnzDoMIJ7toX+NG/VtYHtIp60S2JdYfZYodJapVhtN3N6J5HxNYoh7jZuNQMZOpv2/nvusofuMLYmITAwUPKifW4xVRqaePkHIijQWdeTMAO0MsgTpL0+iLJIlUJco9H9OiT0C3MotmqxuNNZ56M4KsfsjVdaiHoUs8CVSaI/ySRaabp8HgPOOtCYQhHwynGm6tg+h3ge9WpjJGsqEyHlM8BGm2qDx7K7bp3Te2dt7Zoiq+WlqacPHD+Ou0IcskBRAGvNP25cc1p0VmD8FvYODl9mziyB0M5sfLfVh8KSmDnhhzf5bioEgkWk6shCMXRlvLMnXY2V+apNf81/5Dfzu3KZYrDArLUKeIegl5tBIDICj75Caqk0/BpObV7mdDVUUQ8mU 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)(136003)(366004)(39860400002)(376002)(346002)(396003)(451199021)(86362001)(36756003)(6486002)(4326008)(478600001)(66946007)(66476007)(66556008)(6916009)(316002)(5660300002)(2906002)(8936002)(41300700001)(8676002)(44832011)(38100700002)(82960400001)(6506007)(1076003)(6512007)(186003)(2616005)(107886003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WSYhS9VLLLWJZS4ESxeucx+f2X1/sgN/jmrxGa2SgQfuLPUOhTZq4nsPHrhLJZQMf0WWQk64JppG2A1Ry80zViXWJseLWylBSWTufsFipAenuy7lb+xkUmTiOwZQRYx2SnSqOd5YHnnFJs7nbeq1m7b+1mMbJWPU8cpGypIIrX+O9rcxbEGDCAl7r1NAx3jUDl9o9otuBEYwRZhNb3Ov6T9/9h0IAvmNr7Ldj/NGqte/vC2z2VkJtxK/h3lw5tL7IWTtKe+RbnMpRbpFQkeMSUj91ToPpqUDhlHd3CAFXXG8tTfoEwYbEiVSrbCw/JLeRVynPJzk/UPzKqT6W9wtCYUry8BQ987tbHM3cbLvrdWpY4yVhajqxEMqB5A1tEu/qfEPoRLfaVsbsUtzU9OsavJGvSdqpTg2P/OSuVOnEAjBfX4C5l1SvZq50QHVhrW/cME4Qo9Uq7S/+IAoLuPCn+iKtvs2YJbR05lU2C+XHGHhGCzseVWqXHOI/Wbfg9ijlCSfKyyT6iA46A906O1BIPjDlFDvzBdJQy+cJM8X91mzDRQgJUvwCHUVr4wjUfIzBhkHkTOHc4jL18GjDYfON2YaH8ZfPMHRattPQfATxy2PtjnYo8UCBjjZDormJ0aLDKZZcYwiA8bs7hwMiOeaMvYVyPvgAojccTQjiL7qhZHYnO5umJQ5kFqONvAvq5J9hjlkaKea5GSW7cxyvc4ne0o7eGbEv9YjArRkcKBtK/tKUnKgo3X3DTCuRfcgIKg/QGtgSzGwQTTPByaF2w9MUYpqQVo/lMXTVjlz0iP0YYZRiBUkJBkajyIbUoyIQyj4pEtdaTGy4atdv6u29kenf3xnvS4QTUPbZ+RSNZVdRVAET8P/48KwwyEnzd3mmI57M7DBUXOB/Dj76gw1AzTzpfMYxoWdGxb5qV5HA6Ykp7uFjEsc2IGvo+tDOva9OnKhmlWjSDUM8PzUfi/qoiphs3Tg3DZWDUyLsw2ccL1m57eMvTNExhwqMLxJy4QEXfgMJoEOt2Y4jG2+82un0KguAig59eQst1jmUK6M/2d5vzA0f3V5XGIp7UXcQs8+S0aremtG0ewHrIEigbw2lpZeUWoVPDk/IYk4F7GLhPolU4kD5cdwbwNHf2cL4TuquVIithxAgNNIO3arq2lnDQGNGzSOWH4I/caazcPidE4CjDe5wJWX8yX+nGnfBW1C8B3woU8T2y1HQVAN0ODV3+QZ3+pQyXDBxwrXfMVwnaYWLHhGL/Yx3lI2M69sPHgvwAtv6t36o6aytlVHOf6vAXUlv8oYLQsHMlJI3oQ3DRQqse+LtwcUEIJoOd4l1l6NFkYx+RwVaf56hP/YuPMzI3p++L8ZceRDEaYp8YpgUQoSHl2i+oc+2XAMpBsm7yL0eRZ9px1Cn2+4bLl6N/K8CQhyaaZMRCYC7HaN/PCULY/OtJz4gN77MCYSJKWvgaP6i7Ggg11okJ0MVBCmOOy91rkmu3dvr6xFbysB9QgjuPZyAfQN8+fsF4SSZgSAcV1XJMtvSzNpxF4CQzYUbkk4GK0OMiVrB48OMwvv7WqbB3hi5dMnmS/xbyCH7QH0BAvG7UznyH85woZ33Lr6m8nkr4zpUqtdcXzzHwKPBeTR12CN8KkY8yqWh7ku+gyd/hNDb4VIA5b1X7LbgljVYJbZTJPkMw== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82b84571-5f16-47d7-6389-08db56ec6591 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB5404.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:35:52.2568 (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: myRK8HwEVmq3azBLRhIRcIf3J0isHgOCiQgEabwEYH0qI082J8teqg//VaSdPouMogFwsd+pq91WgCbHETV1+cSclEDLvcFvXwY3qfeTNTg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB7972 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=QMn5EkJf; 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:7e1b::626 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: , As nil is not of type number and STATE_ERROR is semantically equivalent, return STATE_ERROR upon error in suricatta.pstate.get(). This change also makes it unnecessary to return a success indicator boolean as first return value. Signed-off-by: Christian Storm --- doc/source/suricatta.rst | 4 ++-- examples/suricatta/swupdate_suricatta.lua | 3 +-- suricatta/server_lua.c | 13 +++---------- suricatta/suricatta.lua | 3 +-- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/doc/source/suricatta.rst b/doc/source/suricatta.rst index 01102c3f..9782e591 100644 --- a/doc/source/suricatta.rst +++ b/doc/source/suricatta.rst @@ -397,8 +397,8 @@ defaulting to ``ustate``. In addition, it captures the ``update_state_t`` enum v The function ``suricatta.pstate.save(state)`` requires one of ``suricatta.pstate``'s "enum" values as parameter and returns ``true``, or, in case of error, ``nil``. -The function ``suricatta.pstate.get()`` returns ``true``, or, in case of error, ``nil``, -plus one of ``suricatta.pstate``'s "enum" values in the former case. +The function ``suricatta.pstate.get()`` returns one of ``suricatta.pstate``'s +"enum" values or, in case of error, ``STATE_ERROR``. `suricatta.server` diff --git a/examples/suricatta/swupdate_suricatta.lua b/examples/suricatta/swupdate_suricatta.lua index 3f01b0ce..dffc2909 100644 --- a/examples/suricatta/swupdate_suricatta.lua +++ b/examples/suricatta/swupdate_suricatta.lua @@ -171,8 +171,7 @@ gs = { function has_pending_action(action_id) action_id = action_id gs.polldelay.current = gs.polldelay.default - local _, pstate = suricatta.pstate.get() - if pstate == suricatta.pstate.INSTALLED then + if suricatta.pstate.get() == suricatta.pstate.INSTALLED then suricatta.notify.warn("An installed update is pending testing, not querying server.") return action_id, suricatta.status.NO_UPDATE_AVAILABLE end diff --git a/suricatta/server_lua.c b/suricatta/server_lua.c index 37e4950b..14167fe6 100644 --- a/suricatta/server_lua.c +++ b/suricatta/server_lua.c @@ -1458,20 +1458,13 @@ static int lua_bootloader_env_apply(lua_State *L) /** * @brief Get update state from persistent storage (bootloader). * - * @return [Lua] True, or, in case of error, nil. - * [Lua] One of pstate's enum values. + * @return [Lua] One of pstate's enum values. */ static int lua_pstate_get(lua_State *L) { update_state_t state = get_state(); - if (is_valid_state(state)) { - lua_pushboolean(L, true); - lua_pushinteger(L, (int)state); - } else { - lua_pushnil(L); - lua_pushnil(L); - } - return 2; + lua_pushinteger(L, is_valid_state(state) ? (int)state : STATE_ERROR); + return 1; } diff --git a/suricatta/suricatta.lua b/suricatta/suricatta.lua index c61d483f..9dc1bcfe 100644 --- a/suricatta/suricatta.lua +++ b/suricatta/suricatta.lua @@ -130,8 +130,7 @@ suricatta.pstate = { --- Get the current stored persistent state. -- ---- @return boolean # Whether operation was successful or not ---- @return suricatta.pstate # Persistent state ID number +--- @return number # Persistent state ID number, suricatta.pstate.ERROR if unsuccessful suricatta.pstate.get = function() end --- Save persistent state information.