From patchwork Wed Mar 15 13:37:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nick X-Patchwork-Id: 1757365 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nXHaRvXm; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=systemli.org header.i=@systemli.org header.a=rsa-sha256 header.s=default header.b=TqX0qQYI; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 4PcBP732T1z1yWp for ; Thu, 16 Mar 2023 00:40:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UUosLTRSKPUN1XZExcmYqFAoWpKu6sSOnJZH3Wl6Ad8=; b=nXHaRvXmNAAuCH 9MxebvbfRoObCB9rprJp08to7aiU2Pi026HwTWSlpbzuS7gWetZAEknD8KATfZv8VF2EfSBDTMIPv jJCK7UiQD9LtisxZVCe/oFqc2BXiNwPcbNvuK3l8xdIDVtFosCmJuPgU+pLyzdja2hy1WYnLtRpES RJ0R/wveYR/t2E/gJWINvT8fZfH8mroUBms1iJyDb3ft7FppU36uQJ6xS8X0jLwojb212wP/HJZuZ oLDMb7lsfWf6MkUY6sbJQn5SvDY8gLOdcXiTGQSbUFNb+zIL0KazClpyjytzGhOyCdHrOhgnmq4pA 0JfvM9vZci/qmQuTWKUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcRKK-00DT9y-2p; Wed, 15 Mar 2023 13:38:00 +0000 Received: from mail1.systemli.org ([93.190.126.36]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcRKG-00DT7h-1f for openwrt-devel@lists.openwrt.org; Wed, 15 Mar 2023 13:37:58 +0000 From: Nick Hainke DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemli.org; s=default; t=1678887472; bh=Mc79jRKFLmqZP1iyf4DlZdbWHROY+RDPhDHtB9/7qfI=; h=From:To:Cc:Subject:Date:From; b=TqX0qQYIdPcvS96IevhdWFcmukB30WycGpxF/+WLrgaQWON3i4jp+xJPPEQputDfG KCxMKI4VeYt0ueA75su9zFbkfaLsrJz/iU61uwTio9tckIU+7IBdewBRGCrAxSelEr +fVxYFRjNzaY8bg1/6MrEjRt10zw8Zq9hTXFhiMy1Pu7DZ6pdh08M0I5kQ1hfM5Ain SNRn+OyGtMFQVK80j0qCbf8hr3S5YeusT+erZBuLuGoqjuXjw7Niz9PozdgHDjrl4j JJihLyH/lh8ID4sNt3fN7XQaYf9tl7IEUDeCI2Oiemjlbweu5VJDJ/lomRIo8PUSxr zcsglsXstFJmg== To: openwrt-devel@lists.openwrt.org Cc: Nick Hainke Subject: [PATCH] attr: add NLA_S8 Date: Wed, 15 Mar 2023 14:37:43 +0100 Message-Id: <20230315133743.26787-1-vincent@systemli.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_063757_004842_3130B430 X-CRM114-Status: UNSURE ( 7.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: NLA_S8 is used by newer hostapd versions. Signed-off-by: Nick Hainke --- attr.c | 1 + include/netlink/attr.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org NLA_S8 is used by newer hostapd versions. Signed-off-by: Nick Hainke --- attr.c | 1 + include/netlink/attr.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/attr.c b/attr.c index eae91e5..abde67f 100644 --- a/attr.c +++ b/attr.c @@ -437,6 +437,7 @@ static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = { [NLA_U32] = sizeof(uint32_t), [NLA_U64] = sizeof(uint64_t), [NLA_STRING] = 1, + [NLA_S8] = sizeof(int8_t), }; static int validate_nla(struct nlattr *nla, int maxtype, diff --git a/include/netlink/attr.h b/include/netlink/attr.h index 3e3047f..3a5d53d 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -45,6 +45,7 @@ enum { NLA_FLAG, /**< Flag */ NLA_MSECS, /**< Micro seconds (64bit) */ NLA_NESTED, /**< Nested attributes */ + NLA_S8, __NLA_TYPE_MAX, }; @@ -248,6 +249,31 @@ static inline int nla_put_addr(struct nl_msg *msg, int attrtype, struct nl_addr * @name Integer Attributes */ +/** + * Add 8 bit signed integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value to store as payload. + * + * @see nla_put + * @return 0 on success or a negative error code. + */ +static inline int nla_put_s8(struct nl_msg *msg, int attrtype, int8_t value) +{ + return nla_put(msg, attrtype, sizeof(int8_t), &value); +} + +/** + * Return value of 8 bit signed integer attribute. + * @arg nla 8 bit integer attribute + * + * @return Payload as 8 bit integer. + */ +static inline int8_t nla_get_s8(const struct nlattr *nla) +{ + return *(const int8_t *) nla_data(nla); +} + /** * Add 8 bit integer attribute to netlink message. * @arg msg Netlink message. @@ -638,6 +664,15 @@ static inline size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dst NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \ } while(0) +/** + * Add 8 bit signed integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. + */ +#define NLA_PUT_S8(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, int8_t, attrtype, value) + /** * Add 8 bit integer attribute to netlink message. * @arg msg Netlink message.