* Added TCPEndpoint::GetOption(), currently only supports TCP_NODELAY, and
TCP_MAXSEG. * Note, TCP_MAXSEG cannot be set yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25241 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -906,7 +906,33 @@ TCPEndpoint::SetReceiveBufferSize(size_t length)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TCPEndpoint::SetOption(int option, const void *_value, int length)
|
TCPEndpoint::GetOption(int option, void* _value, int* _length)
|
||||||
|
{
|
||||||
|
if (*_length != sizeof(int))
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
int* value = (int*)_value;
|
||||||
|
|
||||||
|
switch (option) {
|
||||||
|
case TCP_NODELAY:
|
||||||
|
if ((fOptions & TCP_NODELAY) != 0)
|
||||||
|
*value = 1;
|
||||||
|
else
|
||||||
|
*value = 0;
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
case TCP_MAXSEG:
|
||||||
|
*value = fReceiveMaxSegmentSize;
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TCPEndpoint::SetOption(int option, const void* _value, int length)
|
||||||
{
|
{
|
||||||
if (option != TCP_NODELAY)
|
if (option != TCP_NODELAY)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -914,7 +940,7 @@ TCPEndpoint::SetOption(int option, const void *_value, int length)
|
|||||||
if (length != sizeof(int))
|
if (length != sizeof(int))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
const int *value = (const int *)_value;
|
const int* value = (const int*)_value;
|
||||||
|
|
||||||
MutexLocker _(fLock);
|
MutexLocker _(fLock);
|
||||||
if (*value)
|
if (*value)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
status_t SetSendBufferSize(size_t length);
|
status_t SetSendBufferSize(size_t length);
|
||||||
status_t SetReceiveBufferSize(size_t length);
|
status_t SetReceiveBufferSize(size_t length);
|
||||||
|
|
||||||
|
status_t GetOption(int option, void* value, int* _length);
|
||||||
status_t SetOption(int option, const void* value, int length);
|
status_t SetOption(int option, const void* value, int length);
|
||||||
|
|
||||||
tcp_state State() const { return fState; }
|
tcp_state State() const { return fState; }
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ name_for_state(tcp_state state)
|
|||||||
case TIME_WAIT:
|
case TIME_WAIT:
|
||||||
return "time-wait";
|
return "time-wait";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,9 @@ tcp_getsockopt(net_protocol *_protocol, int level, int option, void *value,
|
|||||||
{
|
{
|
||||||
TCPEndpoint *protocol = (TCPEndpoint *)_protocol;
|
TCPEndpoint *protocol = (TCPEndpoint *)_protocol;
|
||||||
|
|
||||||
/* TODO getting IPPROTO_TCP options is missing */
|
if (level == IPPROTO_TCP)
|
||||||
|
return protocol->GetOption(option, value, _length);
|
||||||
|
|
||||||
return protocol->next->module->getsockopt(protocol->next, level, option,
|
return protocol->next->module->getsockopt(protocol->next, level, option,
|
||||||
value, _length);
|
value, _length);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user