static status_t
create_socket(int family, int type, int protocol, net_socket_private** _socket)
{
	struct net_socket_private* socket = new(std::nothrow) net_socket_private;
	if (socket == NULL)
		return B_NO_MEMORY;
	status_t status = socket->InitCheck();
	if (status != B_OK) {
		delete socket;
		return status;
	}

	socket->family = family;
	socket->type = type;
	socket->protocol = protocol;

	status = get_domain_protocols(socket);
	if (status != B_OK) {
		delete socket;
		return status;
	}

	TRACE("create net_socket %p (%u.%u.%u):\n", socket, socket->family,
		socket->type, socket->protocol);

#ifdef TRACE_SOCKET
	net_protocol* current = socket->first_protocol;
	for (int i = 0; current != NULL; current = current->next, i++)
		TRACE("  [%d] %p  %s\n", i, current, current->module->info.name);
#endif

	*_socket = socket;
	return B_OK;
}
Example #2
0
static status_t
create_socket(int family, int type, int protocol, net_socket_private** _socket)
{
	struct net_socket_private* socket = new(std::nothrow) net_socket_private;
	if (socket == NULL)
		return B_NO_MEMORY;

	socket->family = family;
	socket->type = type;
	socket->protocol = protocol;

	status_t status = get_domain_protocols(socket);
	if (status < B_OK) {
		delete socket;
		return status;
	}

	*_socket = socket;
	return B_OK;
}