status_t l2cap_l2ca_con_ind(L2capChannel* channel) { L2capEndpoint* endpoint = L2capEndpoint::ForPsm(channel->psm); if (endpoint == NULL) { // TODO: refuse connection no endpoint bound debugf("No endpoint bound for psm %d\n", channel->psm); return B_ERROR; } // Pair Channel with endpoint endpoint->BindToChannel(channel); net_buffer* buf = l2cap_con_rsp(channel->ident, channel->scid, channel->dcid, L2CAP_SUCCESS, L2CAP_NO_INFO); L2capFrame* cmd = btCoreData->SpawnSignal(channel->conn, channel, buf, channel->ident, L2CAP_CON_RSP); if (cmd == NULL) { gBufferModule->free(buf); return ENOMEM; } // we can move to configuration... channel->state = L2CAP_CHAN_CONFIG; // Link command to the queue SchedConnectionPurgeThread(channel->conn); return B_OK; }
status_t send_l2cap_con_rej(HciConnection* conn, uint8 ident, uint16 scid, uint16 dcid, uint16 result) { L2capFrame* cmd = NULL; cmd = btCoreData->SpawnSignal(conn, NULL, l2cap_con_rsp(ident, scid, dcid, result, 0), ident, L2CAP_CON_RSP); if (cmd == NULL) return ENOMEM; /* Link command to the queue */ SchedConnectionPurgeThread(conn); return B_OK; }