Commit 61f4597d authored by Jukka Rissanen's avatar Jukka Rissanen
Browse files

net: sockets: tls: Register handler for TLS sockets



Use the automatic registration of TLS socket.

Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
parent 89bf1578
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -151,13 +151,6 @@ int z_impl_zsock_socket(int family, int type, int proto)
		return sock_family->handler(family, type, proto);
	}

#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
	if (((proto >= IPPROTO_TLS_1_0) && (proto <= IPPROTO_TLS_1_2)) ||
	    (proto >= IPPROTO_DTLS_1_0 && proto <= IPPROTO_DTLS_1_2)) {
		return ztls_socket(family, type, proto);
	}
#endif

#if defined(CONFIG_NET_SOCKETS_PACKET)
	if (family == AF_PACKET) {
		return zpacket_socket(family, type, proto);
+0 −2
Original line number Diff line number Diff line
@@ -47,8 +47,6 @@ struct socket_op_vtable {
			  const void *optval, socklen_t optlen);
};

int ztls_socket(int family, int type, int proto);

int zpacket_socket(int family, int type, int proto);
int zcan_socket(int family, int type, int proto);

+14 −1
Original line number Diff line number Diff line
@@ -1100,7 +1100,7 @@ static int tls_opt_dtls_role_set(struct net_context *context,
	return 0;
}

int ztls_socket(int family, int type, int proto)
static int ztls_socket(int family, int type, int proto)
{
	enum net_ip_protocol_secure tls_proto = 0;
	int fd = z_reserve_fd();
@@ -2017,3 +2017,16 @@ static const struct socket_op_vtable tls_sock_fd_op_vtable = {
	.getsockopt = tls_sock_getsockopt_vmeth,
	.setsockopt = tls_sock_setsockopt_vmeth,
};

static bool tls_is_supported(int family, int type, int proto)
{
	if ((family == AF_INET || family == AF_INET6) &&
	    (((proto >= IPPROTO_TLS_1_0) && (proto <= IPPROTO_TLS_1_2)) ||
	     (proto >= IPPROTO_DTLS_1_0 && proto <= IPPROTO_DTLS_1_2))) {
		return true;
	}

	return false;
}

NET_SOCKET_REGISTER(tls, AF_UNSPEC, tls_is_supported, ztls_socket);