diff options
| author | Robert Pluim <rpluim@gmail.com> | 2019-11-15 11:11:30 +0100 |
|---|---|---|
| committer | Robert Pluim <rpluim@gmail.com> | 2019-11-26 08:46:13 +0100 |
| commit | 650a514e996287106f9a9525b6f27068ec2a0cbf (patch) | |
| tree | 188170aae76f32d894d8df1baa7f435fbfe99d88 /lisp | |
| parent | 5c3d0cf7910afa6b3fbdba24ac5c5817f268eb0e (diff) | |
| download | emacs-650a514e996287106f9a9525b6f27068ec2a0cbf.tar.gz | |
Extend network-interface-list to return IPv6 and network info
Bug#38218
* src/process.c (Fnetwork_interface_list): Extend argument list to
allow requesting full network info and/or IPv4/IPv6 info.
(network_interface_list) [HAVE_GETIFADDRS]: Use getifaddrs to retrieve
interface IP addresses.
* src/process.h: Update prototype of network_interface_list.
* src/w32.c (g_b_init_get_adapters_addresses): New init flag.
(globals_of_w32): Initialize it.
(GetAdaptersAddresses_Proc): New function typedef.
(get_adapters_addresses): New wrapper function.
(init_winsock): Load htonl and ntohl.
(sys_htonl, sys_ntohl): New wrapper functions.
(network_interface_list): Implement in terms of
get_adapters_addresses.
* nt/inc/sys/socket.h: Add sys_htonl and sys_ntohl prototypes.
* etc/NEWS: Announce IPv4/IPv6 changes in network-interface-list.
* doc/lispref/processes.texi (Misc Network): Document updated arglist
and return values for network-interface-list.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/net/nsm.el | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el index 205b7974883..5dc5244e6d5 100644 --- a/lisp/net/nsm.el +++ b/lisp/net/nsm.el @@ -228,21 +228,22 @@ host address is a localhost address, or in the same subnet as one of the local interfaces, this function returns nil. Non-nil otherwise." (let ((addresses (network-lookup-address-info host)) - (network-interface-list (network-interface-list)) + (network-interface-list (network-interface-list t)) (off-net t)) (when (or (and (functionp nsm-trust-local-network) (funcall nsm-trust-local-network)) nsm-trust-local-network) (mapc - (lambda (address) + (lambda (ip) (mapc - (lambda (iface) - (let ((info (network-interface-info (car iface)))) + (lambda (info) + (let ((local-ip (nth 1 info)) + (mask (nth 2 info))) (when - (nsm-network-same-subnet (substring (car info) 0 -1) - (substring (car (cddr info)) 0 -1) - (substring address 0 -1)) + (nsm-network-same-subnet (substring local-ip 0 -1) + (substring mask 0 -1) + (substring ip 0 -1)) (setq off-net nil)))) network-interface-list)) addresses)) |
