emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting local IP addresses from emacs


From: Robert Pluim
Subject: Getting local IP addresses from emacs
Date: Fri, 08 Nov 2019 13:42:57 +0100

Hi,

thereʼs 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ʼt actually list all the network interfaces
b. Only provides IPv4 addresses
c. Doesnʼt return netmask information

'network-interface-info' does provide netmask information, but only
for IPv4 (and it uses syscalls that canʼt 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ʼd 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 network 
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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]