FreeBSD/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
/*
 * Look for the socket that listens on given bdaddr.
 * Returns exact or close match (if any).
 * Caller must hold ng_btsocket_sco_sockets_mtx.
 * Returns with locked pcb.
 */
Look for the socket that listens on given bdaddr.
Returns exact or close match (if any).
Caller must hold ng_btsocket_sco_sockets_mtx.
Returns with locked pcb.
Look for the socket that listens on given bdaddr . Returns exact or close match ( if any ) . Caller must hold ng_btsocket_sco_sockets_mtx . Returns with locked pcb .
static ng_btsocket_sco_pcb_p
ng_btsocket_sco_pcb_by_addr(bdaddr_p bdaddr)
{
	ng_btsocket_sco_pcb_p	p = NULL, p1 = NULL;
	mtx_assert(&ng_btsocket_sco_sockets_mtx, MA_OWNED);
	LIST_FOREACH(p, &ng_btsocket_sco_sockets, next) {
		mtx_lock(&p->pcb_mtx);
		if (p->so == NULL || !(p->so->so_options & SO_ACCEPTCONN)) {
			mtx_unlock(&p->pcb_mtx);
			continue;
		}
		if (bcmp(&p->src, bdaddr, sizeof(p->src)) == 0)
			return (p); 
		if (bcmp(&p->src, NG_HCI_BDADDR_ANY, sizeof(p->src)) == 0)
			p1 = p;
		mtx_unlock(&p->pcb_mtx);
	}
	if (p1 != NULL)
		mtx_lock(&p1->pcb_mtx);
	return (p1);
}
static ng_btsocket_sco_pcb_p ng_btsocket_sco_pcb_by_addr ( bdaddr_p bdaddr ) { ng_btsocket_sco_pcb_p p = NULL , p1 = NULL ; mtx_assert ( & ng_btsocket_sco_sockets_mtx , MA_OWNED ) ; LIST_FOREACH ( p , & ng_btsocket_sco_sockets , next ) { mtx_lock ( & p -> pcb_mtx ) ; if ( p -> so == NULL || ! ( p -> so -> so_options & SO_ACCEPTCONN ) ) { mtx_unlock ( & p -> pcb_mtx ) ; continue ; } if ( bcmp ( & p -> src , bdaddr , sizeof ( p -> src ) ) == 0 ) return ( p ) ; if ( bcmp ( & p -> src , NG_HCI_BDADDR_ANY , sizeof ( p -> src ) ) == 0 ) p1 = p ; mtx_unlock ( & p -> pcb_mtx ) ; } if ( p1 != NULL ) mtx_lock ( & p1 -> pcb_mtx ) ; return ( p1 ) ; }
Look for the socket that listens on given bdaddr.
Look for the socket that listens on given bdaddr .
/* return with locked pcb */