From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id UJofN6m0bGQCBwAASxT56A (envelope-from ) for ; Tue, 23 May 2023 14:42:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iKgvNqm0bGSVpgAAG6o9tA (envelope-from ) for ; Tue, 23 May 2023 14:42:17 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id ADFB22DD20 for ; Tue, 23 May 2023 14:42:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1RKO-0001pb-RO; Tue, 23 May 2023 08:41:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RK6-0001gt-Cw for bug-guix@gnu.org; Tue, 23 May 2023 08:41:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1RK4-0003Vy-Sc for bug-guix@gnu.org; Tue, 23 May 2023 08:41:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q1RK4-00035z-OG for bug-guix@gnu.org; Tue, 23 May 2023 08:41:04 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 06/11] link: Extract 'new-link-message->link'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563611767 (code B ref 63516); Tue, 23 May 2023 12:41:04 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:36 +0000 Received: from localhost ([127.0.0.1]:38539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJc-00033i-D8 for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJM-000320-Ho for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:20 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJG-0003E3-AG; Tue, 23 May 2023 08:40:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=nMX11wN6Bmr+rtVcSRbMA+J7MSCCYjT7YP2yT/OwH5s=; b=RRhnKXkOgcWGQbwVkUgC L8wNsTkxq0tPinoPEWbM1mXvud7xvoGqJ4lolllJZeKoaj4BeAoN7Ld1h4C8xwgdWXQZyS08Op/Uc u9VYsOeWWuNK7lPDJbu+QwKxcKsIe4V046bMGDmZ8GIDynnRpih9+tVmPZGBeTtQuZmKbNpLEi8vQ 3J1tkaPE6ICl8ZG5SZFQ9GXSechG8UAZ975dpGPjD07HIEEstaWi76oaPzPQDVDXMCxJn7G7VQGO/ MiN3e/VTAlU4INXE7VringXNlTxESDg5ntj43pzZcllzz4EMLeQqkITcDGhW3i1CGehodAsm2OQhG 5a5QidHAv3Mzeg==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJF-00081G-Rt; Tue, 23 May 2023 08:40:14 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:46 +0200 Message-Id: <20230523123951.6225-7-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684845737; a=rsa-sha256; cv=none; b=bHWVP9eVlNR+F5X6eknsqkK5s5IQ7QEYU/vOD8oIUvUolCesBEdWGvJ8XypOWKAqjS1lIS 5C0eUTHzykUbuoqbElHw7/IUfYSsnCUA8kn+adjnA9ovfb7LjsGsVFUcwY6laTu6xWWrt/ N+JvG4BmS0Q+WaA5BKYt3/k0twIotAPnh2RlXw8UCkFH4DFu0jHSHRK0kUcwOuy36mMVQU yqOr6To0w89qqspbSzLxx4NBhvaXA606/aquElTSx1BI9T536JZ357gGOFEBFoyD9yeFF+ GAogjUTrTA+CwnRP14CB5hKFXawWF/bRD9y4pyUjw82rjBWJ9xJsLbj1lCkBGA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=RRhnKXkO; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1684845737; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=nMX11wN6Bmr+rtVcSRbMA+J7MSCCYjT7YP2yT/OwH5s=; b=YNDBpovXejE9QJLJKj7SFp/F9I9gv8x2H7n+6IpLZIFyW+RwggsbFde6ACAiJenYYQ4oFZ cWn9kFGiI9DNdaoCNbuWDcfp4yTZ9ElYKxO2f+Rn0p5ecX0j7eax4APiSCL6g6pSzxGiD+ EBzlUULgkyJodhS10MNpeug8F1TVbTJwCcCBGolDwgmGhTkDRFzKFpgGnoVCdBUnhUJc/q XYaoXX3cJTWIa31wuCDIL49rlKuvXv6ifG+9DpT3Q3YU86gznxt/OGEttFyfYTtym9jIwm MBO4UCx6SV5vX9HF9PF7rud+KPpoTsDTPfTo16v7g1MDusWfrd/In+MKPDd+5A== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=RRhnKXkO; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.07 X-Spam-Score: -1.07 X-Migadu-Queue-Id: ADFB22DD20 X-TUID: FR0+XXCAiPMX * ip/link.scm (new-link-message->link): New procedure. (get-links): Use it, and use 'filter-map' instead of 'filter' followed by 'map'. --- ip/link.scm | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/ip/link.scm b/ip/link.scm index 814a008..7e0ae6b 100644 --- a/ip/link.scm +++ b/ip/link.scm @@ -59,6 +59,25 @@ (addr link-addr) (brd link-brd)) +(define (new-link-message->link msg) + "If MSG has type 'RTM_NEWLINK', return the corresponding object. +Otherwise return #f." + (and (eqv? (message-kind msg) RTM_NEWLINK) + (let* ((data (message-data msg)) + (attrs (link-message-attrs data))) + (make-link (get-attr attrs IFLA_IFNAME) + (link-message-index data) + (link-message-kind data) + (map int->device-flags (split-flags (link-message-flags data))) + (get-attr attrs IFLA_MTU) + (get-attr attrs IFLA_QDISC) + (get-attr attrs IFLA_OPERSTATE) + (get-attr attrs IFLA_LINKMODE) + (get-attr attrs IFLA_GROUP) + (get-attr attrs IFLA_TXQLEN) + (get-attr attrs IFLA_ADDRESS) + (get-attr attrs IFLA_BROADCAST))))) + (define (get-links) (define request-num (random 65535)) (define message @@ -72,28 +91,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let* ((answer (receive-and-decode-msg sock %default-route-decoder)) - (links (filter - (lambda (msg) (equal? (message-kind msg) RTM_NEWLINK)) - answer)) - (links - (map - (lambda (msg) - (let* ((data (message-data msg)) - (attrs (link-message-attrs data))) - (make-link - (get-attr attrs IFLA_IFNAME) - (link-message-index data) - (link-message-kind data) - (map int->device-flags (split-flags (link-message-flags data))) - (get-attr attrs IFLA_MTU) - (get-attr attrs IFLA_QDISC) - (get-attr attrs IFLA_OPERSTATE) - (get-attr attrs IFLA_LINKMODE) - (get-attr attrs IFLA_GROUP) - (get-attr attrs IFLA_TXQLEN) - (get-attr attrs IFLA_ADDRESS) - (get-attr attrs IFLA_BROADCAST)))) - links))) + (links (filter-map new-link-message->link answer))) (close-port sock) links))) -- 2.40.1