version 1.1.1.2, 2012/10/09 09:22:28
|
version 1.1.1.3, 2016/11/02 10:09:11
|
Line 220 int
|
Line 220 int
|
setsockopt_ipv4_multicast(int sock, |
setsockopt_ipv4_multicast(int sock, |
int optname, |
int optname, |
unsigned int mcast_addr, |
unsigned int mcast_addr, |
unsigned int ifindex) | ifindex_t ifindex) |
{ |
{ |
#ifdef HAVE_RFC3678 |
#ifdef HAVE_RFC3678 |
struct group_req gr; |
struct group_req gr; |
Line 318 setsockopt_ipv4_multicast(int sock,
|
Line 318 setsockopt_ipv4_multicast(int sock,
|
* Set IP_MULTICAST_IF socket option in an OS-dependent manner. |
* Set IP_MULTICAST_IF socket option in an OS-dependent manner. |
*/ |
*/ |
int |
int |
setsockopt_ipv4_multicast_if(int sock, | setsockopt_ipv4_multicast_if(int sock, ifindex_t ifindex) |
unsigned int ifindex) | |
{ |
{ |
|
|
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX |
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX |
Line 345 setsockopt_ipv4_multicast_if(int sock,
|
Line 344 setsockopt_ipv4_multicast_if(int sock,
|
} |
} |
|
|
static int |
static int |
setsockopt_ipv4_ifindex (int sock, int val) | setsockopt_ipv4_ifindex (int sock, ifindex_t val) |
{ |
{ |
int ret; |
int ret; |
|
|
Line 381 setsockopt_ipv4_tos(int sock, int tos)
|
Line 380 setsockopt_ipv4_tos(int sock, int tos)
|
|
|
|
|
int |
int |
setsockopt_ifindex (int af, int sock, int val) | setsockopt_ifindex (int af, int sock, ifindex_t val) |
{ |
{ |
int ret = -1; |
int ret = -1; |
|
|
Line 408 setsockopt_ifindex (int af, int sock, int val)
|
Line 407 setsockopt_ifindex (int af, int sock, int val)
|
* Returns the interface index (small integer >= 1) if it can be |
* Returns the interface index (small integer >= 1) if it can be |
* determined, or else 0. |
* determined, or else 0. |
*/ |
*/ |
static int | static ifindex_t |
getsockopt_ipv4_ifindex (struct msghdr *msgh) |
getsockopt_ipv4_ifindex (struct msghdr *msgh) |
{ |
{ |
/* XXX: initialize to zero? (Always overwritten, so just cosmetic.) */ |
/* XXX: initialize to zero? (Always overwritten, so just cosmetic.) */ |
int ifindex = -1; | ifindex_t ifindex = -1; |
|
|
#if defined(IP_PKTINFO) |
#if defined(IP_PKTINFO) |
/* Linux pktinfo based ifindex retrieval */ |
/* Linux pktinfo based ifindex retrieval */ |
Line 432 getsockopt_ipv4_ifindex (struct msghdr *msgh)
|
Line 431 getsockopt_ipv4_ifindex (struct msghdr *msgh)
|
struct sockaddr_dl *sdl; |
struct sockaddr_dl *sdl; |
#else |
#else |
/* SUNOS_5 uses an integer with the index. */ |
/* SUNOS_5 uses an integer with the index. */ |
int *ifindex_p; | ifindex_t *ifindex_p; |
#endif /* SUNOS_5 */ |
#endif /* SUNOS_5 */ |
|
|
#ifndef SUNOS_5 |
#ifndef SUNOS_5 |
Line 473 getsockopt_ipv4_ifindex (struct msghdr *msgh)
|
Line 472 getsockopt_ipv4_ifindex (struct msghdr *msgh)
|
} |
} |
|
|
/* return ifindex, 0 if none found */ |
/* return ifindex, 0 if none found */ |
int | ifindex_t |
getsockopt_ifindex (int af, struct msghdr *msgh) |
getsockopt_ifindex (int af, struct msghdr *msgh) |
{ |
{ |
switch (af) |
switch (af) |
Line 516 sockopt_iphdrincl_swab_systoh (struct ip *iph)
|
Line 515 sockopt_iphdrincl_swab_systoh (struct ip *iph)
|
#endif /* HAVE_IP_HDRINCL_BSD_ORDER */ |
#endif /* HAVE_IP_HDRINCL_BSD_ORDER */ |
|
|
iph->ip_id = ntohs(iph->ip_id); |
iph->ip_id = ntohs(iph->ip_id); |
|
} |
|
|
|
int |
|
sockopt_tcp_rtt (int sock) |
|
{ |
|
#ifdef TCP_INFO |
|
struct tcp_info ti; |
|
socklen_t len = sizeof(ti); |
|
|
|
if (getsockopt (sock, IPPROTO_TCP, TCP_INFO, &ti, &len) != 0) |
|
return 0; |
|
|
|
return ti.tcpi_rtt / 1000; |
|
#else |
|
return 0; |
|
#endif |
} |
} |
|
|
int |
int |