diff options
| author | Eli Zaretskii | 2013-10-16 18:44:02 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-10-16 18:44:02 +0300 |
| commit | 3dffe395916c0c075c1609c41e553d9f8e3690ea (patch) | |
| tree | eeaa2e377b897148fee2ed764c9e0fbb786dc9e1 /src/process.c | |
| parent | b911a94d7993508f8a53360a4be4651de30ea301 (diff) | |
| download | emacs-3dffe395916c0c075c1609c41e553d9f8e3690ea.tar.gz emacs-3dffe395916c0c075c1609c41e553d9f8e3690ea.zip | |
Implement network-interface-* functions for MS-Windows (bug #15610).
src/w32.c (network_interface_get_info, network_interface_list)
(network_interface_info): New functions.
(GetAdaptersInfo_Proc): New typedef.
(get_adapters_info): New wrapper function.
(globals_of_w32): Initialize g_b_init_get_adapters_info.
src/process.h (network_interface_list, network_interface_info): New
prototypes.
src/process.c (conv_sockaddr_to_lisp): Now externally-visible.
(Fnetwork_interface_list, Fnetwork_interface_info): Define for
all systems. Return non-nil for systems that HAVE_NET_IF_H and
for WINDOWSNT. Doc fix.
(syms_of_process): Defsubr Snetwork_interface_list and
Snetwork_interface_info unconditionally.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/src/process.c b/src/process.c index 2ed8a690193..cf9d5e265e1 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1958,7 +1958,7 @@ create_pty (Lisp_Object process) | |||
| 1958 | /* Convert an internal struct sockaddr to a lisp object (vector or string). | 1958 | /* Convert an internal struct sockaddr to a lisp object (vector or string). |
| 1959 | The address family of sa is not included in the result. */ | 1959 | The address family of sa is not included in the result. */ |
| 1960 | 1960 | ||
| 1961 | static Lisp_Object | 1961 | Lisp_Object |
| 1962 | conv_sockaddr_to_lisp (struct sockaddr *sa, int len) | 1962 | conv_sockaddr_to_lisp (struct sockaddr *sa, int len) |
| 1963 | { | 1963 | { |
| 1964 | Lisp_Object address; | 1964 | Lisp_Object address; |
| @@ -3504,16 +3504,45 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3504 | } | 3504 | } |
| 3505 | 3505 | ||
| 3506 | 3506 | ||
| 3507 | #if defined (HAVE_NET_IF_H) | ||
| 3508 | |||
| 3509 | #ifdef SIOCGIFCONF | ||
| 3510 | DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, | 3507 | DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, |
| 3511 | doc: /* Return an alist of all network interfaces and their network address. | 3508 | doc: /* Return an alist of all network interfaces and their network address. |
| 3512 | Each element is a cons, the car of which is a string containing the | 3509 | Each element is a cons, the car of which is a string containing the |
| 3513 | interface name, and the cdr is the network address in internal | 3510 | interface name, and the cdr is the network address in internal |
| 3514 | format; see the description of ADDRESS in `make-network-process'. */) | 3511 | format; see the description of ADDRESS in `make-network-process'. |
| 3512 | |||
| 3513 | If the information is not available, return nil. */) | ||
| 3515 | (void) | 3514 | (void) |
| 3516 | { | 3515 | { |
| 3516 | #if (defined (HAVE_NET_IF_H) && defined (SIOCGIFCONF)) || defined (WINDOWSNT) | ||
| 3517 | return network_interface_list (); | ||
| 3518 | #else | ||
| 3519 | return Qnil; | ||
| 3520 | #endif | ||
| 3521 | } | ||
| 3522 | |||
| 3523 | DEFUN ("network-interface-info", Fnetwork_interface_info, Snetwork_interface_info, 1, 1, 0, | ||
| 3524 | doc: /* Return information about network interface named IFNAME. | ||
| 3525 | The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS), | ||
| 3526 | where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address, | ||
| 3527 | NETMASK is the layer 3 network mask, HWADDR is the layer 2 address, and | ||
| 3528 | FLAGS is the current flags of the interface. | ||
| 3529 | |||
| 3530 | Data that is unavailable is returned as nil. */) | ||
| 3531 | (Lisp_Object ifname) | ||
| 3532 | { | ||
| 3533 | #if (defined (HAVE_NET_IF_H) && (defined (SIOCGIFADDR) || defined (SIOCGIFHWADDR) || defined (SIOCGIFFLAGS))) || defined (WINDOWSNT) | ||
| 3534 | return network_interface_info (ifname); | ||
| 3535 | #else | ||
| 3536 | return Qnil; | ||
| 3537 | #endif | ||
| 3538 | } | ||
| 3539 | |||
| 3540 | #if defined (HAVE_NET_IF_H) | ||
| 3541 | |||
| 3542 | #ifdef SIOCGIFCONF | ||
| 3543 | Lisp_Object | ||
| 3544 | network_interface_list (void) | ||
| 3545 | { | ||
| 3517 | struct ifconf ifconf; | 3546 | struct ifconf ifconf; |
| 3518 | struct ifreq *ifreq; | 3547 | struct ifreq *ifreq; |
| 3519 | void *buf = NULL; | 3548 | void *buf = NULL; |
| @@ -3654,13 +3683,8 @@ static const struct ifflag_def ifflag_table[] = { | |||
| 3654 | { 0, 0 } | 3683 | { 0, 0 } |
| 3655 | }; | 3684 | }; |
| 3656 | 3685 | ||
| 3657 | DEFUN ("network-interface-info", Fnetwork_interface_info, Snetwork_interface_info, 1, 1, 0, | 3686 | Lisp_Object |
| 3658 | doc: /* Return information about network interface named IFNAME. | 3687 | network_interface_info (Lisp_Object ifname) |
| 3659 | The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS), | ||
| 3660 | where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address, | ||
| 3661 | NETMASK is the layer 3 network mask, HWADDR is the layer 2 address, and | ||
| 3662 | FLAGS is the current flags of the interface. */) | ||
| 3663 | (Lisp_Object ifname) | ||
| 3664 | { | 3688 | { |
| 3665 | struct ifreq rq; | 3689 | struct ifreq rq; |
| 3666 | Lisp_Object res = Qnil; | 3690 | Lisp_Object res = Qnil; |
| @@ -3802,7 +3826,7 @@ FLAGS is the current flags of the interface. */) | |||
| 3802 | 3826 | ||
| 3803 | return unbind_to (count, any ? res : Qnil); | 3827 | return unbind_to (count, any ? res : Qnil); |
| 3804 | } | 3828 | } |
| 3805 | #endif | 3829 | #endif /* !SIOCGIFADDR && !SIOCGIFHWADDR && !SIOCGIFFLAGS */ |
| 3806 | #endif /* defined (HAVE_NET_IF_H) */ | 3830 | #endif /* defined (HAVE_NET_IF_H) */ |
| 3807 | 3831 | ||
| 3808 | /* Turn off input and output for process PROC. */ | 3832 | /* Turn off input and output for process PROC. */ |
| @@ -7293,14 +7317,8 @@ The variable takes effect when `start-process' is called. */); | |||
| 7293 | defsubr (&Sset_network_process_option); | 7317 | defsubr (&Sset_network_process_option); |
| 7294 | defsubr (&Smake_network_process); | 7318 | defsubr (&Smake_network_process); |
| 7295 | defsubr (&Sformat_network_address); | 7319 | defsubr (&Sformat_network_address); |
| 7296 | #if defined (HAVE_NET_IF_H) | ||
| 7297 | #ifdef SIOCGIFCONF | ||
| 7298 | defsubr (&Snetwork_interface_list); | 7320 | defsubr (&Snetwork_interface_list); |
| 7299 | #endif | ||
| 7300 | #if defined (SIOCGIFADDR) || defined (SIOCGIFHWADDR) || defined (SIOCGIFFLAGS) | ||
| 7301 | defsubr (&Snetwork_interface_info); | 7321 | defsubr (&Snetwork_interface_info); |
| 7302 | #endif | ||
| 7303 | #endif /* defined (HAVE_NET_IF_H) */ | ||
| 7304 | #ifdef DATAGRAM_SOCKETS | 7322 | #ifdef DATAGRAM_SOCKETS |
| 7305 | defsubr (&Sprocess_datagram_address); | 7323 | defsubr (&Sprocess_datagram_address); |
| 7306 | defsubr (&Sset_process_datagram_address); | 7324 | defsubr (&Sset_process_datagram_address); |