FreeBSD/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
/* 
 * Process HC and baseband command return parameters
 */
Process HC and baseband command return parameters
Process HC and baseband command return parameters
int
process_hc_baseband_params(ng_hci_unit_p unit, u_int16_t ocf, 
		struct mbuf *mcp, struct mbuf *mrp)
{
	int	error = 0;
	switch (ocf) {
	case NG_HCI_OCF_SET_EVENT_MASK:
	case NG_HCI_OCF_SET_EVENT_FILTER:
	case NG_HCI_OCF_FLUSH:	
	case NG_HCI_OCF_READ_PIN_TYPE:
	case NG_HCI_OCF_WRITE_PIN_TYPE:
	case NG_HCI_OCF_CREATE_NEW_UNIT_KEY:
	case NG_HCI_OCF_WRITE_STORED_LINK_KEY:
	case NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO:
	case NG_HCI_OCF_WRITE_PAGE_TIMO:
	case NG_HCI_OCF_READ_SCAN_ENABLE:
	case NG_HCI_OCF_WRITE_SCAN_ENABLE:
	case NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY:
	case NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY:
	case NG_HCI_OCF_READ_AUTH_ENABLE:
	case NG_HCI_OCF_WRITE_AUTH_ENABLE:
	case NG_HCI_OCF_READ_ENCRYPTION_MODE:
	case NG_HCI_OCF_WRITE_ENCRYPTION_MODE:
	case NG_HCI_OCF_WRITE_VOICE_SETTINGS:
	case NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS:
	case NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS:
	case NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY:
	case NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY:
	case NG_HCI_OCF_READ_SCO_FLOW_CONTROL:
	case NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL:
	case NG_HCI_OCF_H2HC_FLOW_CONTROL: 
	case NG_HCI_OCF_HOST_BUFFER_SIZE:
	case NG_HCI_OCF_READ_IAC_LAP:
	case NG_HCI_OCF_WRITE_IAC_LAP:
	case NG_HCI_OCF_READ_PAGE_SCAN_PERIOD:
	case NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD:
	case NG_HCI_OCF_READ_PAGE_SCAN:
	case NG_HCI_OCF_WRITE_PAGE_SCAN:
	case NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO:
	case NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO:
	case NG_HCI_OCF_READ_SUPPORTED_IAC_NUM:
	case NG_HCI_OCF_READ_STORED_LINK_KEY:
	case NG_HCI_OCF_DELETE_STORED_LINK_KEY:
	case NG_HCI_OCF_READ_CON_ACCEPT_TIMO:
	case NG_HCI_OCF_READ_PAGE_TIMO:
	case NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY:
	case NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY:
	case NG_HCI_OCF_READ_VOICE_SETTINGS:
	case NG_HCI_OCF_READ_AUTO_FLUSH_TIMO:
	case NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO:
	case NG_HCI_OCF_READ_XMIT_LEVEL:
	case NG_HCI_OCF_HOST_NUM_COMPL_PKTS:	
	case NG_HCI_OCF_CHANGE_LOCAL_NAME:
	case NG_HCI_OCF_READ_LOCAL_NAME:
	case NG_HCI_OCF_READ_UNIT_CLASS:
	case NG_HCI_OCF_WRITE_UNIT_CLASS:
	case NG_HCI_OCF_READ_LE_HOST_SUPPORTED:
	case NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED:
		break;
	case NG_HCI_OCF_RESET: {
		ng_hci_unit_con_p	con = NULL;
		int			size;
		while (!LIST_EMPTY(&unit->con_list)) {
			con = LIST_FIRST(&unit->con_list);
			if (con->flags & NG_HCI_CON_TIMEOUT_PENDING)
				ng_hci_con_untimeout(con);
			ng_hci_lp_discon_ind(con, 0x16);
			ng_hci_free_con(con);
		}
		NG_HCI_BUFF_ACL_TOTAL(unit->buffer, size);
		NG_HCI_BUFF_ACL_FREE(unit->buffer, size);
		NG_HCI_BUFF_SCO_TOTAL(unit->buffer, size);
		NG_HCI_BUFF_SCO_FREE(unit->buffer, size);
		unit->state &= ~NG_HCI_UNIT_INITED;
		} break;
	default:
		error = EINVAL;
		break;
	}
	NG_FREE_M(mcp);
	NG_FREE_M(mrp);
	return (error);
}
int process_hc_baseband_params ( ng_hci_unit_p unit , u_int16_t ocf , struct mbuf * mcp , struct mbuf * mrp ) { int error = 0 ; switch ( ocf ) { case NG_HCI_OCF_SET_EVENT_MASK : case NG_HCI_OCF_SET_EVENT_FILTER : case NG_HCI_OCF_FLUSH : case NG_HCI_OCF_READ_PIN_TYPE : case NG_HCI_OCF_WRITE_PIN_TYPE : case NG_HCI_OCF_CREATE_NEW_UNIT_KEY : case NG_HCI_OCF_WRITE_STORED_LINK_KEY : case NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO : case NG_HCI_OCF_WRITE_PAGE_TIMO : case NG_HCI_OCF_READ_SCAN_ENABLE : case NG_HCI_OCF_WRITE_SCAN_ENABLE : case NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY : case NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY : case NG_HCI_OCF_READ_AUTH_ENABLE : case NG_HCI_OCF_WRITE_AUTH_ENABLE : case NG_HCI_OCF_READ_ENCRYPTION_MODE : case NG_HCI_OCF_WRITE_ENCRYPTION_MODE : case NG_HCI_OCF_WRITE_VOICE_SETTINGS : case NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS : case NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS : case NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY : case NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY : case NG_HCI_OCF_READ_SCO_FLOW_CONTROL : case NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL : case NG_HCI_OCF_H2HC_FLOW_CONTROL : case NG_HCI_OCF_HOST_BUFFER_SIZE : case NG_HCI_OCF_READ_IAC_LAP : case NG_HCI_OCF_WRITE_IAC_LAP : case NG_HCI_OCF_READ_PAGE_SCAN_PERIOD : case NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD : case NG_HCI_OCF_READ_PAGE_SCAN : case NG_HCI_OCF_WRITE_PAGE_SCAN : case NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO : case NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO : case NG_HCI_OCF_READ_SUPPORTED_IAC_NUM : case NG_HCI_OCF_READ_STORED_LINK_KEY : case NG_HCI_OCF_DELETE_STORED_LINK_KEY : case NG_HCI_OCF_READ_CON_ACCEPT_TIMO : case NG_HCI_OCF_READ_PAGE_TIMO : case NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY : case NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY : case NG_HCI_OCF_READ_VOICE_SETTINGS : case NG_HCI_OCF_READ_AUTO_FLUSH_TIMO : case NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO : case NG_HCI_OCF_READ_XMIT_LEVEL : case NG_HCI_OCF_HOST_NUM_COMPL_PKTS : case NG_HCI_OCF_CHANGE_LOCAL_NAME : case NG_HCI_OCF_READ_LOCAL_NAME : case NG_HCI_OCF_READ_UNIT_CLASS : case NG_HCI_OCF_WRITE_UNIT_CLASS : case NG_HCI_OCF_READ_LE_HOST_SUPPORTED : case NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED : break ; case NG_HCI_OCF_RESET : { ng_hci_unit_con_p con = NULL ; int size ; while ( ! LIST_EMPTY ( & unit -> con_list ) ) { con = LIST_FIRST ( & unit -> con_list ) ; if ( con -> flags & NG_HCI_CON_TIMEOUT_PENDING ) ng_hci_con_untimeout ( con ) ; ng_hci_lp_discon_ind ( con , 0x16 ) ; ng_hci_free_con ( con ) ; } NG_HCI_BUFF_ACL_TOTAL ( unit -> buffer , size ) ; NG_HCI_BUFF_ACL_FREE ( unit -> buffer , size ) ; NG_HCI_BUFF_SCO_TOTAL ( unit -> buffer , size ) ; NG_HCI_BUFF_SCO_FREE ( unit -> buffer , size ) ; unit -> state &= ~ NG_HCI_UNIT_INITED ; } break ; default : error = EINVAL ; break ; } NG_FREE_M ( mcp ) ; NG_FREE_M ( mrp ) ; return ( error ) ; }
Process HC and baseband command return parameters
Process HC and baseband command return parameters
/* XXX Do we need to handle that? */ /* XXX Not supported this time */ /* XXX Can get here? */ /* These do not need post processing */ /*
		 * XXX 
		 *
		 * After RESET command unit goes into standby mode
		 * and all operational state is lost. Host controller
		 * will revert to default values for all parameters.
		 * 
		 * For now we shall terminate all connections and drop
		 * inited bit. After RESET unit must be re-initialized.
		 */ /* Remove all timeouts (if any) */ /* Connection terminated by local host */