Commit e082d989 authored by Jukka Rissanen's avatar Jukka Rissanen
Browse files

net: sockets: can: Register handler for AF_CAN



Use the automatic registration of AF_CAN type sockets.

Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
parent b3cd478a
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -151,12 +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_CAN)
	if (family == AF_CAN) {
		return zcan_socket(family, type, proto);
	}
#endif

	return zsock_socket_internal(family, type, proto);
}

+11 −5
Original line number Diff line number Diff line
@@ -42,11 +42,6 @@ int zcan_socket(int family, int type, int proto)
	int fd;
	int ret;

	if (proto != CAN_RAW) {
		errno = EOPNOTSUPP;
		return -1;
	}

	fd = z_reserve_fd();
	if (fd < 0) {
		return -1;
@@ -429,3 +424,14 @@ static const struct socket_op_vtable can_sock_fd_op_vtable = {
	.getsockopt = can_sock_getsockopt_vmeth,
	.setsockopt = can_sock_setsockopt_vmeth,
};

static bool can_is_supported(int family, int type, int proto)
{
	if (type != SOCK_RAW || proto != CAN_RAW) {
		return false;
	}

	return true;
}

NET_SOCKET_REGISTER(af_can, AF_CAN, can_is_supported, zcan_socket);
+0 −2
Original line number Diff line number Diff line
@@ -47,6 +47,4 @@ struct socket_op_vtable {
			  const void *optval, socklen_t optlen);
};

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

#endif /* _SOCKETS_INTERNAL_H_ */