Mercurial > emacs
comparison src/process.c @ 52594:d03629d1d293
(set_socket_option): Fix :bindtodevice option.
(Fset_network_process_option): Update process contact list when
setting option succeeds.
(Fmake_network_process): Doc fix.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 23 Sep 2003 21:57:51 +0000 |
parents | 03137a8dc8cb |
children | 2d5bfd1be536 |
comparison
equal
deleted
inserted
replaced
52593:e560ea7636d6 | 52594:d03629d1d293 |
---|---|
2316 char *name; | 2316 char *name; |
2317 /* Option level SOL_... */ | 2317 /* Option level SOL_... */ |
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 }, |
2330 #endif | 2330 #endif |
2331 #ifdef SO_DONTROUTE | 2331 #ifdef SO_DONTROUTE |
2392 ret = setsockopt (s, sopt->optlevel, sopt->optnum, | 2392 ret = setsockopt (s, sopt->optlevel, sopt->optnum, |
2393 &optval, sizeof (optval)); | 2393 &optval, sizeof (optval)); |
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: |
2415 { | 2422 { |
2416 struct linger linger; | 2423 struct linger linger; |
2448 (process, option, value, no_error) | 2455 (process, option, value, no_error) |
2449 Lisp_Object process, option, value; | 2456 Lisp_Object process, option, value; |
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); |
2455 | 2463 p = XPROCESS (process); |
2456 s = XINT (XPROCESS (process)->infd); | 2464 if (!NETCONN1_P (p)) |
2465 error ("Process is not a network process"); | |
2466 | |
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"); |
2465 | 2479 |
2466 return Qnil; | 2480 return Qnil; |
2588 pending connection queue (also known as the backlog); the default | 2602 pending connection queue (also known as the backlog); the default |
2589 queue length is 5. Default is to create a client process. | 2603 queue length is 5. Default is to create a client process. |
2590 | 2604 |
2591 The following network options can be specified for this connection: | 2605 The 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. |
2597 :linger BOOL or TIMEOUT -- Send queued messages before closing. | 2610 :linger BOOL or TIMEOUT -- Send queued messages before closing. |
2598 :oobinline BOOL -- Place out-of-band data in receive data stream. | 2611 :oobinline BOOL -- Place out-of-band data in receive data stream. |
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 |
2603 Consult the relevant system programmer's manual pages for more | 2618 Consult the relevant system programmer's manual pages for more |
2604 information on using these options. | 2619 information on using these options. |
2605 | 2620 |
2606 | 2621 |