aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/process.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/process.c b/src/process.c
index e2b122701c9..0916fd171d4 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2318,12 +2318,12 @@ static struct socket_options {
2318 int optlevel; 2318 int optlevel;
2319 /* Option number SO_... */ 2319 /* Option number SO_... */
2320 int optnum; 2320 int optnum;
2321 enum { SOPT_UNKNOWN, SOPT_BOOL, SOPT_INT, SOPT_STR, SOPT_LINGER } opttype; 2321 enum { SOPT_UNKNOWN, SOPT_BOOL, SOPT_INT, SOPT_IFNAME, SOPT_LINGER } opttype;
2322 enum { OPIX_NONE=0, OPIX_MISC=1, OPIX_REUSEADDR=2 } optbit; 2322 enum { OPIX_NONE=0, OPIX_MISC=1, OPIX_REUSEADDR=2 } optbit;
2323} socket_options[] = 2323} socket_options[] =
2324 { 2324 {
2325#ifdef SO_BINDTODEVICE 2325#ifdef SO_BINDTODEVICE
2326 { ":bindtodevice", SOL_SOCKET, SO_BINDTODEVICE, SOPT_STR, OPIX_MISC }, 2326 { ":bindtodevice", SOL_SOCKET, SO_BINDTODEVICE, SOPT_IFNAME, OPIX_MISC },
2327#endif 2327#endif
2328#ifdef SO_BROADCAST 2328#ifdef SO_BROADCAST
2329 { ":broadcast", SOL_SOCKET, SO_BROADCAST, SOPT_BOOL, OPIX_MISC }, 2329 { ":broadcast", SOL_SOCKET, SO_BROADCAST, SOPT_BOOL, OPIX_MISC },
@@ -2394,21 +2394,28 @@ set_socket_option (s, opt, val)
2394 break; 2394 break;
2395 } 2395 }
2396 2396
2397 case SOPT_STR: 2397#ifdef SO_BINDTODEVICE
2398 case SOPT_IFNAME:
2398 { 2399 {
2399 char *arg; 2400 char devname[IFNAMSIZ+1];
2400 2401
2401 if (NILP (val)) 2402 /* This is broken, at least in the Linux 2.4 kernel.
2402 arg = ""; 2403 To unbind, the arg must be a zero integer, not the empty string.
2403 else if (STRINGP (val)) 2404 This should work on all systems. KFS. 2003-09-23. */
2404 arg = (char *) SDATA (val); 2405 bzero (devname, sizeof devname);
2405 else if (XSYMBOL (val)) 2406 if (STRINGP (val))
2406 arg = (char *) SDATA (SYMBOL_NAME (val)); 2407 {
2407 else 2408 char *arg = (char *) SDATA (val);
2409 int len = min (strlen (arg), IFNAMSIZ);
2410 bcopy (arg, devname, len);
2411 }
2412 else if (!NILP (val))
2408 error ("Bad option value for %s", name); 2413 error ("Bad option value for %s", name);
2409 ret = setsockopt (s, sopt->optlevel, sopt->optnum, 2414 ret = setsockopt (s, sopt->optlevel, sopt->optnum,
2410 arg, strlen (arg)); 2415 devname, IFNAMSIZ);
2416 break;
2411 } 2417 }
2418#endif
2412 2419
2413#ifdef SO_LINGER 2420#ifdef SO_LINGER
2414 case SOPT_LINGER: 2421 case SOPT_LINGER:
@@ -2450,15 +2457,22 @@ OPTION is not a supported option, return nil instead; otherwise return t. */)
2450 Lisp_Object no_error; 2457 Lisp_Object no_error;
2451{ 2458{
2452 int s; 2459 int s;
2460 struct Lisp_Process *p;
2453 2461
2454 CHECK_PROCESS (process); 2462 CHECK_PROCESS (process);
2463 p = XPROCESS (process);
2464 if (!NETCONN1_P (p))
2465 error ("Process is not a network process");
2455 2466
2456 s = XINT (XPROCESS (process)->infd); 2467 s = XINT (p->infd);
2457 if (s < 0) 2468 if (s < 0)
2458 error ("Process is not running"); 2469 error ("Process is not running");
2459 2470
2460 if (set_socket_option (s, option, value)) 2471 if (set_socket_option (s, option, value))
2461 return Qt; 2472 {
2473 p->childp = Fplist_put (p->childp, option, value);
2474 return Qt;
2475 }
2462 2476
2463 if (NILP (no_error)) 2477 if (NILP (no_error))
2464 error ("Unknown or unsupported option"); 2478 error ("Unknown or unsupported option");
@@ -2590,7 +2604,6 @@ queue length is 5. Default is to create a client process.
2590 2604
2591The following network options can be specified for this connection: 2605The following network options can be specified for this connection:
2592 2606
2593:bindtodevice NAME -- bind to interface NAME.
2594:broadcast BOOL -- Allow send and receive of datagram broadcasts. 2607:broadcast BOOL -- Allow send and receive of datagram broadcasts.
2595:dontroute BOOL -- Only send to directly connected hosts. 2608:dontroute BOOL -- Only send to directly connected hosts.
2596:keepalive BOOL -- Send keep-alive messages on network stream. 2609:keepalive BOOL -- Send keep-alive messages on network stream.
@@ -2599,6 +2612,8 @@ The following network options can be specified for this connection:
2599:priority INT -- Set protocol defined priority for sent packets. 2612:priority INT -- Set protocol defined priority for sent packets.
2600:reuseaddr BOOL -- Allow reusing a recently used local address 2613:reuseaddr BOOL -- Allow reusing a recently used local address
2601 (this is allowed by default for a server process). 2614 (this is allowed by default for a server process).
2615:bindtodevice NAME -- bind to interface NAME. Using this may require
2616 special privileges on some systems.
2602 2617
2603Consult the relevant system programmer's manual pages for more 2618Consult the relevant system programmer's manual pages for more
2604information on using these options. 2619information on using these options.