/* NOTE: This routine doesn't need to take the socket lock since it only accesses socket information that is unchanging (or which changes in a completely predictable manner).  */
static int get_name(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
/* NOTE: This routine doesn't need to take the socket lock since it only accesses socket information that is unchanging (or which changes in a completely predictable manner).  */
static int get_name(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
{
	struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
	struct tipc_sock *tsock = tipc_sk(sock->sk);
	if (peer) {
		if ((sock->state != SS_CONNECTED) &&
			((peer != 2) || (sock->state != SS_DISCONNECTING)))
			return -ENOTCONN;
		addr->addr.id.ref = tsock->peer_name.ref;
		addr->addr.id.node = tsock->peer_name.node;
	} else {
		tipc_ownidentity(tsock->p->ref, &addr->addr.id);
	}
	*uaddr_len = sizeof(*addr);
	addr->addrtype = TIPC_ADDR_ID;
	addr->family = AF_TIPC;
	addr->scope = 0;
	addr->addr.name.domain = 0;
	return 0;
}