comparison src/process.c @ 52525:fd2be6cea0e7

(Fnetwork_interface_list, Fnetwork_interface_info): Require HAVE_NET_IF_H and HAVE_SYS_IOCTL_H to include these fns. (Fnetwork_interface_info): Check that ifreq struct has required fields before accessing them; this requires that those fields are defined as macros, which may be too restrictive on some platforms, but it is better than failing on other platforms. (syms_of_process): Only defsubr above fns when included.
author Kim F. Storm <storm@cua.dk>
date Wed, 17 Sep 2003 21:31:53 +0000
parents 0ca23eb697b9
children 3ea59ac8dfa5
comparison
equal deleted inserted replaced
52524:84470539e96f 52525:fd2be6cea0e7
3334 return proc; 3334 return proc;
3335 } 3335 }
3336 #endif /* HAVE_SOCKETS */ 3336 #endif /* HAVE_SOCKETS */
3337 3337
3338 3338
3339 #ifdef HAVE_SOCKETS 3339 #if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
3340 3340
3341 #ifdef SIOCGIFCONF 3341 #ifdef SIOCGIFCONF
3342 DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, 3342 DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0,
3343 doc: /* Return an alist of all network interfaces and their network address. 3343 doc: /* Return an alist of all network interfaces and their network address.
3344 Each element is a cons, the car of which is a string containing the 3344 Each element is a cons, the car of which is a string containing the
3395 res); 3395 res);
3396 } 3396 }
3397 3397
3398 return res; 3398 return res;
3399 } 3399 }
3400 #endif 3400 #endif /* SIOCGIFCONF */
3401 3401
3402 #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) 3402 #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
3403 3403
3404 struct ifflag_def { 3404 struct ifflag_def {
3405 int flag_bit; 3405 int flag_bit;
3481 s = socket (AF_INET, SOCK_STREAM, 0); 3481 s = socket (AF_INET, SOCK_STREAM, 0);
3482 if (s < 0) 3482 if (s < 0)
3483 return Qnil; 3483 return Qnil;
3484 3484
3485 elt = Qnil; 3485 elt = Qnil;
3486 #ifdef SIOCGIFFLAGS 3486 #if defined(SIOCGIFFLAGS) && defined(ifr_flags)
3487 if (ioctl (s, SIOCGIFFLAGS, &rq) == 0) 3487 if (ioctl (s, SIOCGIFFLAGS, &rq) == 0)
3488 { 3488 {
3489 int flags = rq.ifr_flags; 3489 int flags = rq.ifr_flags;
3490 struct ifflag_def *fp; 3490 struct ifflag_def *fp;
3491 int fnum; 3491 int fnum;
3509 } 3509 }
3510 #endif 3510 #endif
3511 res = Fcons (elt, res); 3511 res = Fcons (elt, res);
3512 3512
3513 elt = Qnil; 3513 elt = Qnil;
3514 #ifdef SIOCGIFHWADDR 3514 #if defined(SIOCGIFHWADDR) && defined(ifr_hwaddr)
3515 if (ioctl (s, SIOCGIFHWADDR, &rq) == 0) 3515 if (ioctl (s, SIOCGIFHWADDR, &rq) == 0)
3516 { 3516 {
3517 Lisp_Object hwaddr = Fmake_vector (6, Qnil); 3517 Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil);
3518 register struct Lisp_Vector *p = XVECTOR (hwaddr); 3518 register struct Lisp_Vector *p = XVECTOR (hwaddr);
3519 int n; 3519 int n;
3520 3520
3521 any++; 3521 any++;
3522 for (n = 0; n < 6; n++) 3522 for (n = 0; n < 6; n++)
3525 } 3525 }
3526 #endif 3526 #endif
3527 res = Fcons (elt, res); 3527 res = Fcons (elt, res);
3528 3528
3529 elt = Qnil; 3529 elt = Qnil;
3530 #ifdef SIOCGIFNETMASK 3530 #if defined(SIOCGIFNETMASK) && defined(ifr_netmask)
3531 if (ioctl (s, SIOCGIFNETMASK, &rq) == 0) 3531 if (ioctl (s, SIOCGIFNETMASK, &rq) == 0)
3532 { 3532 {
3533 any++; 3533 any++;
3534 elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask)); 3534 elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask));
3535 } 3535 }
3536 #endif 3536 #endif
3537 res = Fcons (elt, res); 3537 res = Fcons (elt, res);
3538 3538
3539 elt = Qnil; 3539 elt = Qnil;
3540 #ifdef SIOCGIFBRDADDR 3540 #if defined(SIOCGIFBRDADDR) && defined(ifr_broadaddr)
3541 if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) 3541 if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0)
3542 { 3542 {
3543 any++; 3543 any++;
3544 elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr)); 3544 elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr));
3545 } 3545 }
3546 #endif 3546 #endif
3547 res = Fcons (elt, res); 3547 res = Fcons (elt, res);
3548 3548
3549 elt = Qnil; 3549 elt = Qnil;
3550 #ifdef SIOCGIFADDR 3550 #if defined(SIOCGIFADDR) && defined(ifr_addr)
3551 if (ioctl (s, SIOCGIFADDR, &rq) == 0) 3551 if (ioctl (s, SIOCGIFADDR, &rq) == 0)
3552 { 3552 {
3553 any++; 3553 any++;
3554 elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); 3554 elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr));
3555 } 3555 }
6654 defsubr (&Sstart_process); 6654 defsubr (&Sstart_process);
6655 #ifdef HAVE_SOCKETS 6655 #ifdef HAVE_SOCKETS
6656 defsubr (&Sset_network_process_option); 6656 defsubr (&Sset_network_process_option);
6657 defsubr (&Smake_network_process); 6657 defsubr (&Smake_network_process);
6658 defsubr (&Sformat_network_address); 6658 defsubr (&Sformat_network_address);
6659 #endif /* HAVE_SOCKETS */
6660 #if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
6659 #ifdef SIOCGIFCONF 6661 #ifdef SIOCGIFCONF
6660 defsubr (&Snetwork_interface_list); 6662 defsubr (&Snetwork_interface_list);
6661 #endif 6663 #endif
6662 #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) 6664 #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
6663 defsubr (&Snetwork_interface_info); 6665 defsubr (&Snetwork_interface_info);
6664 #endif 6666 #endif
6665 #endif /* HAVE_SOCKETS */ 6667 #endif /* HAVE_SOCKETS ... */
6666 #ifdef DATAGRAM_SOCKETS 6668 #ifdef DATAGRAM_SOCKETS
6667 defsubr (&Sprocess_datagram_address); 6669 defsubr (&Sprocess_datagram_address);
6668 defsubr (&Sset_process_datagram_address); 6670 defsubr (&Sset_process_datagram_address);
6669 #endif 6671 #endif
6670 defsubr (&Saccept_process_output); 6672 defsubr (&Saccept_process_output);