From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Getting local IP addresses from emacs Date: Fri, 08 Nov 2019 13:42:57 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="186533"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 08 13:46:16 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iT3eZ-000mQq-9D for ged-emacs-devel@m.gmane.org; Fri, 08 Nov 2019 13:46:15 +0100 Original-Received: from localhost ([::1]:53254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT3eX-000575-AV for ged-emacs-devel@m.gmane.org; Fri, 08 Nov 2019 07:46:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46034) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT3bS-0001pe-No for emacs-devel@gnu.org; Fri, 08 Nov 2019 07:43:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iT3bR-0000aL-Jj for emacs-devel@gnu.org; Fri, 08 Nov 2019 07:43:02 -0500 Original-Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:33434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iT3bR-0000ZX-Dp for emacs-devel@gnu.org; Fri, 08 Nov 2019 07:43:01 -0500 Original-Received: by mail-wr1-x433.google.com with SMTP id w9so104396wrr.0 for ; Fri, 08 Nov 2019 04:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:mail-copies-to:gmane-reply-to-list:date:message-id :mime-version:content-transfer-encoding; bh=uIHtxyuoHIzsjnriUsjh8/8uz0bCJlKYCwCGOwoFldE=; b=QtpdpNA7MZXFxnNHEuw8wIVA7f96RQrucXWR7pnOAPhqfzwjLQ5vvlU3TIv/8jKaB2 ugT6QSsdAOqXaDj8JP+2BLCyFnKJS8ZQghmReVTRnk+T7wikygyoLG8TTk0pLYHnuUyH RSGb1UUY0orUB83UqEbpJXUU/zr2UwOm3CIfOtOPNOqbm1ptn8WGa1QJ1uSLiueU3NlG 5auGXBqK5onUoOu1LXhKCXhMYVw59Gn+LENE00CRZc+Y7WOBhP+4n04tsRSmN9wd4HVr W0Mr+fnDRgZFA4r02f3oHTxYJNi521XhZtJurh7sAGoOsdbmH78F1nBUzuKMg/MAZvFH YoyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:mail-copies-to :gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=uIHtxyuoHIzsjnriUsjh8/8uz0bCJlKYCwCGOwoFldE=; b=rBC7L3mQop/30DEQPWDGIz7L7LGLLOaEmnyUPLFS0c0fBI6poEZhKKkex9XKX5Ey26 TFF5xjYQoYIvggJHjIOofxq3lyGwI3l0I0VZoJMQH4JbtfVCYqvGRUhx8cs+m2GCVjMf 4vbyIbThJaJrPY55nheGkonCHPWssdXFxthigHB5gNwLwVOP2oKSNupEWecxCT+cNioe jW8154sHFPlxQMGqVXxgUSZvBeDjezwI7t2cIFt9md6d3Cl50mKgtaeBRKlMbbb81/Id 79mQtMmzDAP/XpzTfXyeJliI5wrSvmlLKGUmATfX7RbtwxddIi9euclikBk705+NUncC R+HA== X-Gm-Message-State: APjAAAU7Dc70T4Jt3Qt16uO47Vy6fmGit3e//SVecIiuUPmq+j6VS81W sBbp+jybQ9ImcLo4tvNlVAvIFV9S X-Google-Smtp-Source: APXvYqyN6Th/e7GIu6KlzXnmAwBWDA69/4t2Ka2jJi3uVMtKHJmoY9E/P4hDZUFaMx7oxPDtjBl/gw== X-Received: by 2002:adf:b746:: with SMTP id n6mr8071112wre.65.1573216979280; Fri, 08 Nov 2019 04:42:59 -0800 (PST) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id a16sm8754635wmd.11.2019.11.08.04.42.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 04:42:58 -0800 (PST) Mail-Copies-To: never Gmane-Reply-To-List: yes X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:241976 Archived-At: Hi, there=CA=BCs code in nsm.el conditioned on 'nsm-trust-local-network' that depends on knowing what the local IP addresses are. Unfortunately 'network-interface-list' a. Doesn=CA=BCt actually list all the network interfaces b. Only provides IPv4 addresses c. Doesn=CA=BCt return netmask information 'network-interface-info' does provide netmask information, but only for IPv4 (and it uses syscalls that can=CA=BCt be used for IPv6). I was thinking of reworking 'network-interface-list' to use 'getifaddrs' instead of the ioctls it does now, which would get all the interfaces, and (optionally) return the netmask/broadcast info. The only issue there is that the returned interface names would no longer be unique. Of course this is all POSIX-only, MSWindows has similar APIs to getifaddrs, but as far as I can tell they only exist from XP onwards, so I=CA=BCd need someone's help there. Proposed docstring below (the default output would be identical in format to the current one, just with potentially more entries). DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 2, 0, doc: /* Return an alist of all network interfaces and their netw= ork address. Each element is cons of the form (IFNAME . IP) where IFNAME is a string containing the interface name, and IP is the network address in internal format; see the description of ADDRESS in `make-network-process'. The interface name is not guaranteed to be unique. Optional parameter FULL non-nil means return all IP address info for each interface. Each element is then a list of the form (IFNAME IP BCAST MASK) where IFNAME is the interface name, IP the IP address, BCAST the broadcast address, and MASK the network mask. Optional parameter FAMILY controls the type of addresses to return. The default of nil means both IPv4 and IPv6, symbol `ipv4' means IPv4 only, symbol `ipv6' means IPv6 only. See also `network-interface-info', and `network-interface-list', which are limited to IPv4 only. If the information is not available, return nil. */) (Lisp_Object full, Lisp_Object family)