mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
ipv4 & ipv6: implement connect() by setting the socket's peer address
Change-Id: Ic0fdc3f1a880aaef9326d8d4bfb13199c1d61dd4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7476 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
c9d1e840ac
commit
e4efd92e78
@ -1150,9 +1150,21 @@ ipv4_free(net_protocol* protocol)
|
||||
|
||||
|
||||
status_t
|
||||
ipv4_connect(net_protocol* protocol, const struct sockaddr* address)
|
||||
ipv4_connect(net_protocol* _protocol, const struct sockaddr* address)
|
||||
{
|
||||
return B_ERROR;
|
||||
ipv4_protocol* protocol = (ipv4_protocol*)_protocol;
|
||||
RawSocket* raw = protocol->raw;
|
||||
if (raw == NULL)
|
||||
return B_ERROR;
|
||||
if (address->sa_len != sizeof(struct sockaddr_in))
|
||||
return B_BAD_VALUE;
|
||||
if (address->sa_family != AF_INET)
|
||||
return EAFNOSUPPORT;
|
||||
|
||||
memcpy(&protocol->socket->peer, address, sizeof(struct sockaddr_in));
|
||||
sSocketModule->set_connected(protocol->socket);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1045,9 +1045,21 @@ ipv6_free(net_protocol* protocol)
|
||||
|
||||
|
||||
status_t
|
||||
ipv6_connect(net_protocol* protocol, const struct sockaddr* address)
|
||||
ipv6_connect(net_protocol* _protocol, const struct sockaddr* address)
|
||||
{
|
||||
return B_ERROR;
|
||||
ipv6_protocol* protocol = (ipv6_protocol*)_protocol;
|
||||
RawSocket* raw = protocol->raw;
|
||||
if (raw == NULL)
|
||||
return B_ERROR;
|
||||
if (address->sa_len != sizeof(struct sockaddr_in6))
|
||||
return B_BAD_VALUE;
|
||||
if (address->sa_family != AF_INET6)
|
||||
return EAFNOSUPPORT;
|
||||
|
||||
memcpy(&protocol->socket->peer, address, sizeof(struct sockaddr_in6));
|
||||
sSocketModule->set_connected(protocol->socket);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user