From patchwork Fri Oct 5 23:25:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Costa Gomes X-Patchwork-Id: 979824 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42Rm8p50R8z9s4s for ; Sat, 6 Oct 2018 09:26:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbeJFG0z (ORCPT ); Sat, 6 Oct 2018 02:26:55 -0400 Received: from mga02.intel.com ([134.134.136.20]:39625 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728088AbeJFG0y (ORCPT ); Sat, 6 Oct 2018 02:26:54 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2018 16:25:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,346,1534834800"; d="scan'208";a="269915144" Received: from ellie.jf.intel.com (HELO localhost.localdomain) ([10.54.70.75]) by fmsmga006.fm.intel.com with ESMTP; 05 Oct 2018 16:25:33 -0700 From: Vinicius Costa Gomes To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, jesus.sanchez-palencia@intel.com, ilias.apalodimas@linaro.org, simon.fok@baesystems.com Subject: [PATCH iproute2 net-next v3 2/6] include: Add helper to retrieve a __s64 from a netlink msg Date: Fri, 5 Oct 2018 16:25:18 -0700 Message-Id: <20181005232522.4848-3-vinicius.gomes@intel.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181005232522.4848-1-vinicius.gomes@intel.com> References: <20181005232522.4848-1-vinicius.gomes@intel.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This allows signed 64-bit integers to be retrieved from a netlink message. Signed-off-by: Vinicius Costa Gomes --- include/libnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/libnetlink.h b/include/libnetlink.h index 9d9249e6..ffc49e56 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -185,6 +185,13 @@ static inline __u64 rta_getattr_u64(const struct rtattr *rta) memcpy(&tmp, RTA_DATA(rta), sizeof(__u64)); return tmp; } +static inline __s64 rta_getattr_s64(const struct rtattr *rta) +{ + __s64 tmp; + + memcpy(&tmp, RTA_DATA(rta), sizeof(tmp)); + return tmp; +} static inline const char *rta_getattr_str(const struct rtattr *rta) { return (const char *)RTA_DATA(rta);