FreeBSD and illumos do not define SOL_TCP
This commit is contained in:
18
lib/socket.c
18
lib/socket.c
@@ -512,7 +512,17 @@ iscsi_free_iscsi_inqueue(struct iscsi_in_pdu *inqueue)
|
|||||||
|
|
||||||
int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval)
|
int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval)
|
||||||
{
|
{
|
||||||
int value;
|
int level, value;
|
||||||
|
#if defined(__FreeBSD__) || defined(__sun)
|
||||||
|
struct protoent *buf;
|
||||||
|
|
||||||
|
if ((buf = getprotobyname("tcp")) != NULL)
|
||||||
|
level = buf->p_proto;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
level = SOL_TCP;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SO_KEEPALIVE
|
#ifdef SO_KEEPALIVE
|
||||||
value =1;
|
value =1;
|
||||||
@@ -523,21 +533,21 @@ int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, in
|
|||||||
#endif
|
#endif
|
||||||
#ifdef TCP_KEEPCNT
|
#ifdef TCP_KEEPCNT
|
||||||
value = count;
|
value = count;
|
||||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPCNT, &value, sizeof(value)) != 0) {
|
if (setsockopt(iscsi->fd, level, TCP_KEEPCNT, &value, sizeof(value)) != 0) {
|
||||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive count. Error %s(%d)", strerror(errno), errno);
|
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive count. Error %s(%d)", strerror(errno), errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TCP_KEEPINTVL
|
#ifdef TCP_KEEPINTVL
|
||||||
value = interval;
|
value = interval;
|
||||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPINTVL, &value, sizeof(value)) != 0) {
|
if (setsockopt(iscsi->fd, level, TCP_KEEPINTVL, &value, sizeof(value)) != 0) {
|
||||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive interval. Error %s(%d)", strerror(errno), errno);
|
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive interval. Error %s(%d)", strerror(errno), errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TCP_KEEPIDLE
|
#ifdef TCP_KEEPIDLE
|
||||||
value = idle;
|
value = idle;
|
||||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPIDLE, &value, sizeof(value)) != 0) {
|
if (setsockopt(iscsi->fd, level, TCP_KEEPIDLE, &value, sizeof(value)) != 0) {
|
||||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive idle. Error %s(%d)", strerror(errno), errno);
|
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive idle. Error %s(%d)", strerror(errno), errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user