FreeBSD/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
/*
 * Process getsockopt/setsockopt system calls
 */
Process getsockopt/setsockopt system calls
Process getsockopt / setsockopt system calls
int
ng_btsocket_sco_ctloutput(struct socket *so, struct sockopt *sopt)
{
	ng_btsocket_sco_pcb_p	pcb = so2sco_pcb(so);
        int			error, tmp;
	if (ng_btsocket_sco_node == NULL) 
		return (EINVAL);
	if (pcb == NULL)
		return (EINVAL);
	if (sopt->sopt_level != SOL_SCO)
		return (0);
	mtx_lock(&pcb->pcb_mtx);
	switch (sopt->sopt_dir) {
	case SOPT_GET:
		if (pcb->state != NG_BTSOCKET_SCO_OPEN) {
			error = ENOTCONN;
			break;
		}
		switch (sopt->sopt_name) {
		case SO_SCO_MTU:
			tmp = pcb->rt->pkt_size;
			error = sooptcopyout(sopt, &tmp, sizeof(tmp));
			break;
		case SO_SCO_CONNINFO:
			tmp = pcb->con_handle;
			error = sooptcopyout(sopt, &tmp, sizeof(tmp));
			break;
		default:
			error = EINVAL;
			break;
		}
		break;
	case SOPT_SET:
		error = ENOPROTOOPT;
		break;
	default:
		error = EINVAL;
		break;
	}
	mtx_unlock(&pcb->pcb_mtx);
	return (error);
}
int ng_btsocket_sco_ctloutput ( struct socket * so , struct sockopt * sopt ) { ng_btsocket_sco_pcb_p pcb = so2sco_pcb ( so ) ; int error , tmp ; if ( ng_btsocket_sco_node == NULL ) return ( EINVAL ) ; if ( pcb == NULL ) return ( EINVAL ) ; if ( sopt -> sopt_level != SOL_SCO ) return ( 0 ) ; mtx_lock ( & pcb -> pcb_mtx ) ; switch ( sopt -> sopt_dir ) { case SOPT_GET : if ( pcb -> state != NG_BTSOCKET_SCO_OPEN ) { error = ENOTCONN ; break ; } switch ( sopt -> sopt_name ) { case SO_SCO_MTU : tmp = pcb -> rt -> pkt_size ; error = sooptcopyout ( sopt , & tmp , sizeof ( tmp ) ) ; break ; case SO_SCO_CONNINFO : tmp = pcb -> con_handle ; error = sooptcopyout ( sopt , & tmp , sizeof ( tmp ) ) ; break ; default : error = EINVAL ; break ; } break ; case SOPT_SET : error = ENOPROTOOPT ; break ; default : error = EINVAL ; break ; } mtx_unlock ( & pcb -> pcb_mtx ) ; return ( error ) ; }
Process getsockopt/setsockopt system calls
Process getsockopt / setsockopt system calls