Esempio n. 1
0
File: list.c Progetto: xzpeter/clibs
void
list_remove(list_t *list, void *object)
{
	list_node_t *lold = list_d2l(list, object);
	ASSERT(!list_empty(list));
	ASSERT(lold->list_next != NULL);
	list_remove_node(lold);
}
Esempio n. 2
0
File: list.c Progetto: xzpeter/clibs
void
list_insert_before(list_t *list, void *object, void *nobject)
{
	if (object == NULL) {
		list_insert_tail(list, nobject);
	} else {
		list_node_t *lold = list_d2l(list, object);
		list_insert_before_node(list, lold, nobject);
	}
}
Esempio n. 3
0
File: list.c Progetto: xzpeter/clibs
void
list_insert_after(list_t *list, void *object, void *nobject)
{
	if (object == NULL) {
		list_insert_head(list, nobject);
	} else {
		list_node_t *lold = list_d2l(list, object);
		list_insert_after_node(list, lold, nobject);
	}
}
Esempio n. 4
0
File: list.c Progetto: xzpeter/clibs
void *
list_prev(list_t *list, void *object)
{
	list_node_t *node = list_d2l(list, object);

	if (node->list_prev != &list->list_head)
		return (list_object(list, node->list_prev));

	return (NULL);
}
Esempio n. 5
0
void
list_remove(list_t *list, void *object)
{
	list_node_t *lold = list_d2l(list, object);
	ASSERT(!list_empty(list));
	ASSERT(lold->list_next != NULL);
	lold->list_prev->list_next = lold->list_next;
	lold->list_next->list_prev = lold->list_prev;
	lold->list_next = lold->list_prev = NULL;
}
Esempio n. 6
0
/*
 * SCTP interface for geting the first source address of a sctp_t.
 */
int
sctp_getsockaddr(sctp_t *sctp, struct sockaddr *addr)
{
	int			err = -1;
	int			i;
	int			l;
	sctp_saddr_ipif_t	*pobj;
	sctp_saddr_ipif_t	obj;
	size_t			added = 0;
	sin6_t			*sin6;
	sin_t			*sin4;
	int			scanned = 0;
	boolean_t		skip_lback = B_FALSE;
	conn_t			*connp = sctp->sctp_connp;

	addr->sa_family = connp->conn_family;
	if (sctp->sctp_nsaddrs == 0)
		goto done;

	/*
	 * Skip loopback addresses for non-loopback assoc.
	 */
	if (sctp->sctp_state >= SCTPS_ESTABLISHED && !sctp->sctp_loopback) {
		skip_lback = B_TRUE;
	}

	for (i = 0; i < SCTP_IPIF_HASH; i++) {
		if (sctp->sctp_saddrs[i].ipif_count == 0)
			continue;

		pobj = list_object(&sctp->sctp_saddrs[i].sctp_ipif_list,
		    sctp->sctp_saddrs[i].sctp_ipif_list.list_head.list_next);
		if (mdb_vread(&obj, sizeof (sctp_saddr_ipif_t),
		    (uintptr_t)pobj) == -1) {
			mdb_warn("failed to read sctp_saddr_ipif_t");
			return (err);
		}

		for (l = 0; l < sctp->sctp_saddrs[i].ipif_count; l++) {
			sctp_ipif_t	ipif;
			in6_addr_t	laddr;
			list_node_t 	*pnode;
			list_node_t	node;

			if (mdb_vread(&ipif, sizeof (sctp_ipif_t),
			    (uintptr_t)obj.saddr_ipifp) == -1) {
				mdb_warn("failed to read sctp_ipif_t");
				return (err);
			}
			laddr = ipif.sctp_ipif_saddr;

			scanned++;
			if ((ipif.sctp_ipif_state == SCTP_IPIFS_CONDEMNED) ||
			    SCTP_DONT_SRC(&obj) ||
			    (ipif.sctp_ipif_ill->sctp_ill_flags &
			    PHYI_LOOPBACK) && skip_lback) {
				if (scanned >= sctp->sctp_nsaddrs)
					goto done;

				/* LINTED: alignment */
				pnode = list_d2l(&sctp->sctp_saddrs[i].
				    sctp_ipif_list, pobj);
				if (mdb_vread(&node, sizeof (list_node_t),
				    (uintptr_t)pnode) == -1) {
					mdb_warn("failed to read list_node_t");
					return (err);
				}
				pobj = list_object(&sctp->sctp_saddrs[i].
				    sctp_ipif_list, node.list_next);
				if (mdb_vread(&obj, sizeof (sctp_saddr_ipif_t),
				    (uintptr_t)pobj) == -1) {
					mdb_warn("failed to read "
					    "sctp_saddr_ipif_t");
					return (err);
				}
				continue;
			}

			switch (connp->conn_family) {
			case AF_INET:
				/* LINTED: alignment */
				sin4 = (sin_t *)addr;
				if ((sctp->sctp_state <= SCTPS_LISTEN) &&
				    sctp->sctp_bound_to_all) {
					sin4->sin_addr.s_addr = INADDR_ANY;
					sin4->sin_port = connp->conn_lport;
				} else {
					sin4 += added;
					sin4->sin_family = AF_INET;
					sin4->sin_port = connp->conn_lport;
					IN6_V4MAPPED_TO_INADDR(&laddr,
					    &sin4->sin_addr);
				}
				break;

			case AF_INET6:
				/* LINTED: alignment */
				sin6 = (sin6_t *)addr;
				if ((sctp->sctp_state <= SCTPS_LISTEN) &&
				    sctp->sctp_bound_to_all) {
					bzero(&sin6->sin6_addr,
					    sizeof (sin6->sin6_addr));
					sin6->sin6_port = connp->conn_lport;
				} else {
					sin6 += added;
					sin6->sin6_family = AF_INET6;
					sin6->sin6_port = connp->conn_lport;
					sin6->sin6_addr = laddr;
				}
				sin6->sin6_flowinfo = connp->conn_flowinfo;
				sin6->sin6_scope_id = 0;
				sin6->__sin6_src_id = 0;
				break;
			}
			added++;
			if (added >= 1) {
				err = 0;
				goto done;
			}
			if (scanned >= sctp->sctp_nsaddrs)
				goto done;

			/* LINTED: alignment */
			pnode = list_d2l(&sctp->sctp_saddrs[i].sctp_ipif_list,
			    pobj);
			if (mdb_vread(&node, sizeof (list_node_t),
			    (uintptr_t)pnode) == -1) {
				mdb_warn("failed to read list_node_t");
				return (err);
			}
			pobj = list_object(&sctp->sctp_saddrs[i].
			    sctp_ipif_list, node.list_next);
			if (mdb_vread(&obj, sizeof (sctp_saddr_ipif_t),
			    (uintptr_t)pobj) == -1) {
				mdb_warn("failed to read sctp_saddr_ipif_t");
				return (err);
			}
		}
	}
done:
	return (err);
}
Esempio n. 7
0
void
list_insert_before(list_t *list, void *object, void *nobject)
{
	list_node_t *lold = list_d2l(list, object);
	list_insert_before_node(list, lold, nobject)
}
Esempio n. 8
0
void
list_insert_after(list_t *list, void *object, void *nobject)
{
	list_node_t *lold = list_d2l(list, object);
	list_insert_after_node(list, lold, nobject);
}