2318 |
int optlevel; |
int optlevel; |
2319 |
/* Option number SO_... */ |
/* Option number SO_... */ |
2320 |
int optnum; |
int optnum; |
2321 |
enum { SOPT_UNKNOWN, SOPT_BOOL, SOPT_INT, SOPT_STR, SOPT_LINGER } opttype; |
enum { SOPT_UNKNOWN, SOPT_BOOL, SOPT_INT, SOPT_IFNAME, SOPT_LINGER } opttype; |
2322 |
enum { OPIX_NONE=0, OPIX_MISC=1, OPIX_REUSEADDR=2 } optbit; |
enum { OPIX_NONE=0, OPIX_MISC=1, OPIX_REUSEADDR=2 } optbit; |
2323 |
} socket_options[] = |
} socket_options[] = |
2324 |
{ |
{ |
2325 |
#ifdef SO_BINDTODEVICE |
#ifdef SO_BINDTODEVICE |
2326 |
{ ":bindtodevice", SOL_SOCKET, SO_BINDTODEVICE, SOPT_STR, OPIX_MISC }, |
{ ":bindtodevice", SOL_SOCKET, SO_BINDTODEVICE, SOPT_IFNAME, OPIX_MISC }, |
2327 |
#endif |
#endif |
2328 |
#ifdef SO_BROADCAST |
#ifdef SO_BROADCAST |
2329 |
{ ":broadcast", SOL_SOCKET, SO_BROADCAST, SOPT_BOOL, OPIX_MISC }, |
{ ":broadcast", SOL_SOCKET, SO_BROADCAST, SOPT_BOOL, OPIX_MISC }, |
2394 |
break; |
break; |
2395 |
} |
} |
2396 |
|
|
2397 |
case SOPT_STR: |
#ifdef SO_BINDTODEVICE |
2398 |
|
case SOPT_IFNAME: |
2399 |
{ |
{ |
2400 |
char *arg; |
char devname[IFNAMSIZ+1]; |
2401 |
|
|
2402 |
if (NILP (val)) |
/* This is broken, at least in the Linux 2.4 kernel. |
2403 |
arg = ""; |
To unbind, the arg must be a zero integer, not the empty string. |
2404 |
else if (STRINGP (val)) |
This should work on all systems. KFS. 2003-09-23. */ |
2405 |
arg = (char *) SDATA (val); |
bzero (devname, sizeof devname); |
2406 |
else if (XSYMBOL (val)) |
if (STRINGP (val)) |
2407 |
arg = (char *) SDATA (SYMBOL_NAME (val)); |
{ |
2408 |
else |
char *arg = (char *) SDATA (val); |
2409 |
|
int len = min (strlen (arg), IFNAMSIZ); |
2410 |
|
bcopy (arg, devname, len); |
2411 |
|
} |
2412 |
|
else if (!NILP (val)) |
2413 |
error ("Bad option value for %s", name); |
error ("Bad option value for %s", name); |
2414 |
ret = setsockopt (s, sopt->optlevel, sopt->optnum, |
ret = setsockopt (s, sopt->optlevel, sopt->optnum, |
2415 |
arg, strlen (arg)); |
devname, IFNAMSIZ); |
2416 |
|
break; |
2417 |
} |
} |
2418 |
|
#endif |
2419 |
|
|
2420 |
#ifdef SO_LINGER |
#ifdef SO_LINGER |
2421 |
case SOPT_LINGER: |
case SOPT_LINGER: |
2457 |
Lisp_Object no_error; |
Lisp_Object no_error; |
2458 |
{ |
{ |
2459 |
int s; |
int s; |
2460 |
|
struct Lisp_Process *p; |
2461 |
|
|
2462 |
CHECK_PROCESS (process); |
CHECK_PROCESS (process); |
2463 |
|
p = XPROCESS (process); |
2464 |
|
if (!NETCONN1_P (p)) |
2465 |
|
error ("Process is not a network process"); |
2466 |
|
|
2467 |
s = XINT (XPROCESS (process)->infd); |
s = XINT (p->infd); |
2468 |
if (s < 0) |
if (s < 0) |
2469 |
error ("Process is not running"); |
error ("Process is not running"); |
2470 |
|
|
2471 |
if (set_socket_option (s, option, value)) |
if (set_socket_option (s, option, value)) |
2472 |
return Qt; |
{ |
2473 |
|
p->childp = Fplist_put (p->childp, option, value); |
2474 |
|
return Qt; |
2475 |
|
} |
2476 |
|
|
2477 |
if (NILP (no_error)) |
if (NILP (no_error)) |
2478 |
error ("Unknown or unsupported option"); |
error ("Unknown or unsupported option"); |
2604 |
|
|
2605 |
The following network options can be specified for this connection: |
The following network options can be specified for this connection: |
2606 |
|
|
|
:bindtodevice NAME -- bind to interface NAME. |
|
2607 |
:broadcast BOOL -- Allow send and receive of datagram broadcasts. |
:broadcast BOOL -- Allow send and receive of datagram broadcasts. |
2608 |
:dontroute BOOL -- Only send to directly connected hosts. |
:dontroute BOOL -- Only send to directly connected hosts. |
2609 |
:keepalive BOOL -- Send keep-alive messages on network stream. |
:keepalive BOOL -- Send keep-alive messages on network stream. |
2612 |
:priority INT -- Set protocol defined priority for sent packets. |
:priority INT -- Set protocol defined priority for sent packets. |
2613 |
:reuseaddr BOOL -- Allow reusing a recently used local address |
:reuseaddr BOOL -- Allow reusing a recently used local address |
2614 |
(this is allowed by default for a server process). |
(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. |
2617 |
|
|
2618 |
Consult the relevant system programmer's manual pages for more |
Consult the relevant system programmer's manual pages for more |
2619 |
information on using these options. |
information on using these options. |