static void cmd_logic_link_cancel(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_logic_link_cancel *cmd = data; struct bt_hci_rsp_logic_link_cancel rsp; if (cmd->phy_handle == 0x00) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LOGIC_LINK_CANCEL); return; } if (amp->phy_mode != PHY_MODE_IDLE) { cmd_status(amp, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LOGIC_LINK_CANCEL); return; } amp->logic_handle = 0x0000; rsp.status = BT_HCI_ERR_SUCCESS; rsp.phy_handle = amp->phy_handle; rsp.flow_spec = 0x00; cmd_complete(amp, BT_HCI_CMD_LOGIC_LINK_CANCEL, &rsp, sizeof(rsp)); }
static void cmd_accept_logic_link(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_accept_logic_link *cmd = data; if (cmd->phy_handle == 0x00) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_ACCEPT_LOGIC_LINK); return; } if (amp->phy_mode != PHY_MODE_IDLE) { cmd_status(amp, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_ACCEPT_LOGIC_LINK); return; } if (amp->logic_handle != 0x00) { cmd_status(amp, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_ACCEPT_LOGIC_LINK); return; } cmd_status(amp, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_ACCEPT_LOGIC_LINK); amp->logic_handle = 0x0023; evt_logic_link_complete(amp); }
static void cmd_le_create_conn(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_create_conn *cmd = data; if (hci->le_conn_enable == 0x01) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_CREATE_CONN); return; } /* Valid range for peer address type is 0x00 to 0x03 */ if (cmd->peer_addr_type > 0x03) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_CREATE_CONN); return; } /* Valid range for own address type is 0x00 to 0x03 */ if (cmd->own_addr_type > 0x03) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_CREATE_CONN); return; } hci->le_conn_peer_addr_type = cmd->peer_addr_type; memcpy(hci->le_conn_peer_addr, cmd->peer_addr, 6); hci->le_conn_own_addr_type = cmd->own_addr_type; hci->le_conn_enable = 0x01; cmd_status(hci, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_CREATE_CONN); }
static void cmd_disconn_phy_link(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_disconn_phy_link *cmd = data; if (cmd->phy_handle == 0x00) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_DISCONN_PHY_LINK); return; } if (amp->phy_mode == PHY_MODE_IDLE) { cmd_status(amp, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_DISCONN_PHY_LINK); return; } if (cmd->phy_handle != amp->phy_handle) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_DISCONN_PHY_LINK); return; } cmd_status(amp, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_DISCONN_PHY_LINK); mainloop_remove_fd(amp->phylink_fd); close(amp->phylink_fd); evt_disconn_phy_link_complete(amp, cmd->reason); amp->phy_mode = PHY_MODE_IDLE; amp->phy_handle = 0x00; }
static void process_command(struct bt_le *hci, const void *data, size_t size) { const struct bt_hci_cmd_hdr *hdr = data; uint16_t opcode; unsigned int i; if (size < sizeof(*hdr)) return; data += sizeof(*hdr); size -= sizeof(*hdr); opcode = le16_to_cpu(hdr->opcode); if (hdr->plen != size) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, opcode); return; } for (i = 0; cmd_table[i].func; i++) { if (cmd_table[i].opcode != opcode) continue; if ((cmd_table[i].fixed && size != cmd_table[i].size) || size < cmd_table[i].size) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, opcode); return; } cmd_table[i].func(hci, data, size); return; } cmd_status(hci, BT_HCI_ERR_UNKNOWN_COMMAND, opcode); }
static void cmd_le_set_scan_enable(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_set_scan_enable *cmd = data; uint8_t status; /* Valid range for scan enable is 0x00 to 0x01 */ if (cmd->enable > 0x01) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_SCAN_ENABLE); return; } /* Valid range for filter duplicates is 0x00 to 0x01 */ if (cmd->filter_dup > 0x01) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_SCAN_ENABLE); return; } if (cmd->enable == hci->le_scan_enable) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_SET_SCAN_ENABLE); return; } clear_scan_cache(hci); hci->le_scan_enable = cmd->enable; hci->le_scan_filter_dup = cmd->filter_dup; status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_SET_SCAN_ENABLE, &status, sizeof(status)); }
static void cmd_le_set_adv_enable(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_set_adv_enable *cmd = data; uint8_t status; /* Valid range for advertising enable is 0x00 to 0x01 */ if (cmd->enable > 0x01) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_ADV_ENABLE); return; } if (cmd->enable == hci->le_adv_enable) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_SET_ADV_ENABLE); return; } hci->le_adv_enable = cmd->enable; status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_SET_ADV_ENABLE, &status, sizeof(status)); }
static void cmd_le_create_conn_cancel(struct bt_le *hci, const void *data, uint8_t size) { struct bt_hci_evt_le_conn_complete evt; uint8_t status; if (hci->le_conn_enable == 0x00) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_CREATE_CONN_CANCEL); return; } hci->le_conn_enable = 0x00; status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_CREATE_CONN_CANCEL, &status, sizeof(status)); evt.status = BT_HCI_ERR_UNKNOWN_CONN_ID; evt.handle = cpu_to_le16(0x0000); evt.role = 0x00; evt.peer_addr_type = 0x00; memset(evt.peer_addr, 0, 6); evt.interval = cpu_to_le16(0x0000); evt.latency = cpu_to_le16(0x0000); evt.supv_timeout = cpu_to_le16(0x0000); evt.clock_accuracy = 0x00; if (hci->le_event_mask[0] & 0x01) le_meta_event(hci, BT_HCI_EVT_LE_CONN_COMPLETE, &evt, sizeof(evt)); }
static int gscd_ioctl (struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) { unsigned char to_do[10]; unsigned char dummy; switch (cmd) { case CDROMSTART: /* Spin up the drive */ /* Don't think we can do this. Even if we could, * I think the drive times out and stops after a while * anyway. For now, ignore it. */ return 0; case CDROMRESUME: /* keine Ahnung was das ist */ return 0; case CDROMEJECT: cmd_status (); to_do[0] = CMD_TRAY_CTL; cmd_out (TYPE_INFO, (char *)&to_do, (char *)&dummy, 0); return 0; default: return -EINVAL; } }
static void exchange_mtu_cb(guint8 status, const guint8 *pdu, guint16 plen, gpointer user_data) { uint16_t mtu; if (status != 0) { resp_error(err_COMM_ERR); // Todo: status return; } if (!dec_mtu_resp(pdu, plen, &mtu)) { resp_error(err_PROTO_ERR); return; } mtu = MIN(mtu, opt_mtu); /* Set new value for MTU in client */ if (g_attrib_set_mtu(attrib, mtu)) { opt_mtu = mtu; cmd_status(0, NULL); } else { printf("# Error exchanging MTU\n"); resp_error(err_COMM_ERR); } }
static void cmd_read_local_amp_assoc(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_read_local_amp_assoc *cmd = data; struct bt_hci_rsp_read_local_amp_assoc rsp; uint16_t len_so_far, remain_assoc_len, fragment_len; if (cmd->phy_handle != amp->phy_handle) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_READ_LOCAL_AMP_ASSOC); return; } len_so_far = le16_to_cpu(cmd->len_so_far); remain_assoc_len = amp->local_assoc_len - len_so_far; fragment_len = remain_assoc_len > 248 ? 248 : remain_assoc_len; rsp.status = BT_HCI_ERR_SUCCESS; rsp.phy_handle = cmd->phy_handle; rsp.remain_assoc_len = cpu_to_le16(remain_assoc_len); memcpy(rsp.assoc_fragment, amp->local_assoc + len_so_far, fragment_len); cmd_complete(amp, BT_HCI_CMD_READ_LOCAL_AMP_ASSOC, &rsp, 4 + fragment_len); }
/***************************************************************************** Main program. *****************************************************************************/ int main (int argc, char* argv[]) { const char* usage0 = "usage: rtkgps [-h] [-v] [-d <dev> [-r <rate>] | -b <addr>]\n" " ([-e] status | date | list | [-y] erase |\n" " [-c <flg>] [-l <lgtp>] [-m <mfo>] [-s <int>] set |\n" " [-n] [-p] [-o <dest> [-u]] [-f <nstr>] read)\n\n" " -h display usage\n" " -v verbose mode\n" " -d <dev> specify serial device\n" " -r <rate> specify baud rate for serial device\n" " -b <addr> specify bluetooth address\n" " -e display extended status information\n"; const char* usage1 = " -c <flg> set real-time output (GPS mouse) mode " "(0=disable, 1=enable)\n" " -l <lgtp> set log record type (tl, tla, or tlav)\n" " -m <mfo> set memory overwrite behaviour (o=overwrite, s=stop)\n" " -s <int> set sampling interval in seconds\n" " -n output data in simple native text form\n" " -p display text progress bar\n" " -o <dest> specify destination file or directory\n" " -u skip downloading date for existing files\n"; const char* usage2 = " -f <nstr> string specifying index number(s) of log file(s) \n" " to retrieve as a single file number, or range of \n" " file numbers in the format -n, n-, or n-m\n" " -y don't ask for confirmation\n"; /* most Royalteks operate on 57600 baud, use that as the default */ cmdlnopts_t cmdopt = {0,0,0,0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,-1,-1,-1,57600,""}; /* Initialise usage string */ strcpy(cmdopt.usgs, usage0); strcat(cmdopt.usgs, usage1); strcat(cmdopt.usgs, usage2); /* Scan command line options */ scan_cmdline(argc, argv, &cmdopt); /* Set up warning callback function */ gcwrnfp = warning; /* Perform requested task */ if (strcmp(cmdopt.cmds,"status") == 0) { cmd_status(&cmdopt); } else if (strcmp(cmdopt.cmds,"date") == 0) { cmd_date(&cmdopt); } else if (strcmp(cmdopt.cmds,"list") == 0) { cmd_list(&cmdopt); } else if (strcmp(cmdopt.cmds,"set") == 0) { cmd_set(&cmdopt); } else if (strcmp(cmdopt.cmds,"read") == 0) { cmd_read(&cmdopt); } else if (strcmp(cmdopt.cmds,"erase") == 0) { cmd_erase(&cmdopt); } exit(0); }
static void cmd_le_add_to_resolv_list(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_add_to_resolv_list *cmd = data; uint8_t status; bool exists = false; int i, pos = -1; /* Valid range for address type is 0x00 to 0x01 */ if (cmd->addr_type > 0x01) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST); return; } for (i = 0; i < hci->le_resolv_list_size; i++) { if (hci->le_resolv_list[i][0] == cmd->addr_type && !memcmp(&hci->le_resolv_list[i][1], cmd->addr, 6)) { exists = true; break; } else if (pos < 0 && hci->le_resolv_list[i][0] == 0xff) pos = i; } if (exists) { cmd_status(hci, BT_HCI_ERR_UNSPECIFIED_ERROR, BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST); return; } if (pos < 0) { cmd_status(hci, BT_HCI_ERR_MEM_CAPACITY_EXCEEDED, BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST); return; } hci->le_resolv_list[pos][0] = cmd->addr_type; memcpy(&hci->le_resolv_list[pos][1], cmd->addr, 6); memcpy(&hci->le_resolv_list[pos][7], cmd->peer_irk, 16); memcpy(&hci->le_resolv_list[pos][23], cmd->local_irk, 16); status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST, &status, sizeof(status)); }
static void cmd_help(int argcp, char **argvp) { int i; for (i = 0; commands[i].cmd; i++) printf("#%-15s %-30s %s\n", commands[i].cmd, commands[i].params, commands[i].desc); cmd_status(0, NULL); }
static void cmd_le_set_data_length(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_set_data_length *cmd = data; struct bt_hci_rsp_le_set_data_length rsp; uint16_t handle, tx_len, tx_time; handle = le16_to_cpu(cmd->handle); tx_len = le16_to_cpu(cmd->tx_len); tx_time = le16_to_cpu(cmd->tx_time); /* Valid range for connection handle is 0x0000 to 0x0eff */ if (handle > 0x0eff) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_DATA_LENGTH); return; } /* Valid range for suggested max TX octets is 0x001b to 0x00fb */ if (tx_len < 0x001b || tx_len > 0x00fb) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_DATA_LENGTH); return; } /* Valid range for suggested max TX time is 0x0148 to 0x0848 */ if (tx_time < 0x0148 || tx_time > 0x0848) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_DATA_LENGTH); return; } /* Max TX len and time shall be less or equal supported */ if (tx_len > MAX_TX_LEN || tx_time > MAX_TX_TIME) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_SET_DATA_LENGTH); return; } rsp.status = BT_HCI_ERR_SUCCESS; rsp.handle = cpu_to_le16(handle); cmd_complete(hci, BT_HCI_CMD_LE_SET_DATA_LENGTH, &rsp, sizeof(rsp)); }
std::wstring processServerCommand(ServerCommandContext *ctx) { std::wostringstream os(std::ios_base::binary); ctx->flags = 1; // Default, unless we change it. u64 privs = ctx->privs; if(ctx->parms.size() == 0 || ctx->parms[0] == L"help") { os<<L"-!- Available commands: "; os<<L"status privs "; if(privs & PRIV_SERVER) os<<L"shutdown setting "; if(privs & PRIV_SETTIME) os<<L" time"; if(privs & PRIV_TELEPORT) os<<L" teleport"; if(privs & PRIV_PRIVS) os<<L" grant revoke"; } else if(ctx->parms[0] == L"status") { cmd_status(os, ctx); } else if(ctx->parms[0] == L"privs") { cmd_privs(os, ctx); } else if(ctx->parms[0] == L"grant" || ctx->parms[0] == L"revoke") { cmd_grantrevoke(os, ctx); } else if(ctx->parms[0] == L"time") { cmd_time(os, ctx); } else if(ctx->parms[0] == L"shutdown") { cmd_shutdown(os, ctx); } else if(ctx->parms[0] == L"setting") { cmd_setting(os, ctx); } else if(ctx->parms[0] == L"teleport") { cmd_teleport(os, ctx); } else { os<<L"-!- Invalid command: " + ctx->parms[0]; } return os.str(); }
std::wstring processServerCommand(ServerCommandContext *ctx) { std::wostringstream os(std::ios_base::binary); ctx->flags = SEND_TO_SENDER; // Default, unless we change it. u64 privs = ctx->privs; if(ctx->parms.size() == 0 || ctx->parms[0] == L"help") { os<<L"-!- Available commands: "; os<<L"me status privs"; if(privs & PRIV_SERVER) os<<L" shutdown setting clearobjects"; if(privs & PRIV_SETTIME) os<<L" time"; if(privs & PRIV_TELEPORT) os<<L" teleport"; if(privs & PRIV_PRIVS) os<<L" grant revoke"; if(privs & PRIV_BAN) os<<L" ban unban"; if(privs & PRIV_PASSWORD) os<<L" setpassword clearpassword"; } else if(ctx->parms[0] == L"status") cmd_status(os, ctx); else if(ctx->parms[0] == L"privs") cmd_privs(os, ctx); else if(ctx->parms[0] == L"grant" || ctx->parms[0] == L"revoke") cmd_grantrevoke(os, ctx); else if(ctx->parms[0] == L"time") cmd_time(os, ctx); else if(ctx->parms[0] == L"shutdown") cmd_shutdown(os, ctx); else if(ctx->parms[0] == L"setting") cmd_setting(os, ctx); else if(ctx->parms[0] == L"teleport") cmd_teleport(os, ctx); else if(ctx->parms[0] == L"ban" || ctx->parms[0] == L"unban") cmd_banunban(os, ctx); else if(ctx->parms[0] == L"setpassword" || ctx->parms[0] == L"clearpassword") cmd_setclearpassword(os, ctx); else if(ctx->parms[0] == L"me") cmd_me(os, ctx); else if(ctx->parms[0] == L"clearobjects") cmd_clearobjects(os, ctx); else os<<L"-!- Invalid command: " + ctx->parms[0]; return os.str(); }
static void cmd_accept_phy_link(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_accept_phy_link *cmd = data; if (cmd->phy_handle == 0x00) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_ACCEPT_PHY_LINK); return; } if (amp->phy_mode != PHY_MODE_IDLE) { cmd_status(amp, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_ACCEPT_PHY_LINK); return; } amp->phy_mode = PHY_MODE_ACCEPTOR; amp->phy_handle = cmd->phy_handle; cmd_status(amp, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_ACCEPT_PHY_LINK); }
static void cmd_le_write_default_data_length(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_write_default_data_length *cmd = data; uint16_t tx_len, tx_time; uint8_t status; tx_len = le16_to_cpu(cmd->tx_len); tx_time = le16_to_cpu(cmd->tx_time); /* Valid range for suggested max TX octets is 0x001b to 0x00fb */ if (tx_len < 0x001b || tx_len > 0x00fb) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_WRITE_DEFAULT_DATA_LENGTH); return; } /* Valid range for suggested max TX time is 0x0148 to 0x0848 */ if (tx_time < 0x0148 || tx_time > 0x0848) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_WRITE_DEFAULT_DATA_LENGTH); return; } /* Suggested max TX len and time shall be less or equal supported */ if (tx_len > MAX_TX_LEN || tx_time > MAX_TX_TIME) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_WRITE_DEFAULT_DATA_LENGTH); return; } hci->le_default_tx_len = tx_len; hci->le_default_tx_time = tx_time; status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_WRITE_DEFAULT_DATA_LENGTH, &status, sizeof(status)); }
static void cmd_disconn_logic_link(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_disconn_logic_link *cmd = data; if (cmd->handle == 0x00) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_DISCONN_LOGIC_LINK); return; } if (cmd->handle != amp->logic_handle) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_DISCONN_LOGIC_LINK); return; } cmd_status(amp, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_DISCONN_LOGIC_LINK); evt_disconn_logic_link_complete(amp, 0x13); amp->logic_handle = 0x0000; }
static void cmd_le_rand(struct bt_le *hci, const void *data, uint8_t size) { struct bt_hci_rsp_le_rand rsp; if (!bt_crypto_random_bytes(hci->crypto, rsp.number, 8)) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_RAND); return; } rsp.status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_RAND, &rsp, sizeof(rsp)); }
static void cmd_le_read_local_pk256(struct bt_le *hci, const void *data, uint8_t size) { struct bt_hci_evt_le_read_local_pk256_complete evt; cmd_status(hci, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_READ_LOCAL_PK256); evt.status = BT_HCI_ERR_SUCCESS; ecc_make_key(evt.local_pk256, hci->le_local_sk256); if (hci->le_event_mask[0] & 0x80) le_meta_event(hci, BT_HCI_EVT_LE_READ_LOCAL_PK256_COMPLETE, &evt, sizeof(evt)); }
int __init find_drives (void) { int *pdrv; int drvnum; int subdrv; int i; speed = 0; pdrv = (int *)&drv_states; curr_drv_state = 0xFE; subdrv = 0; drvnum = 0; for ( i=0 ; i<8 ; i++ ) { subdrv++; cmd_status (); disk_state &= ST_x08 | ST_x04 | ST_INVALID | ST_x01; if ( disk_state != (ST_x08 | ST_x04 | ST_INVALID) ) { /* LOC_240 */ *pdrv = curr_drv_state; init_cd_drive (drvnum); pdrv++; drvnum++; } else { if ( subdrv < 2 ) { continue; } else { subdrv = 0; } } /* curr_drv_state<<1; <-- das geht irgendwie nicht */ /* muss heissen: curr_drv_state <<= 1; (ist ja Wert-Zuweisung) */ curr_drv_state *= 2; curr_drv_state |= 1; #ifdef GSCD_DEBUG printk ("DriveState: %d\n", curr_drv_state ); #endif } ndrives = drvnum; return drvnum; }
static void cmd_le_encrypt(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_encrypt *cmd = data; struct bt_hci_rsp_le_encrypt rsp; if (!bt_crypto_e(hci->crypto, cmd->key, cmd->plaintext, rsp.data)) { cmd_status(hci, BT_HCI_ERR_COMMAND_DISALLOWED, BT_HCI_CMD_LE_ENCRYPT); return; } rsp.status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_ENCRYPT, &rsp, sizeof(rsp)); }
static void cmd_le_generate_dhkey(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_generate_dhkey *cmd = data; struct bt_hci_evt_le_generate_dhkey_complete evt; cmd_status(hci, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_GENERATE_DHKEY); evt.status = BT_HCI_ERR_SUCCESS; ecdh_shared_secret(cmd->remote_pk256, hci->le_local_sk256, evt.dhkey); if (hci->le_event_mask[1] & 0x01) le_meta_event(hci, BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE, &evt, sizeof(evt)); }
static void cmd_le_remove_from_resolv_list(struct bt_le *hci, const void *data, uint8_t size) { const struct bt_hci_cmd_le_remove_from_resolv_list *cmd = data; uint8_t status; int i, pos = -1; /* Valid range for address type is 0x00 to 0x01 */ if (cmd->addr_type > 0x01) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST); return; } for (i = 0; i < hci->le_resolv_list_size; i++) { if (hci->le_resolv_list[i][0] == cmd->addr_type && !memcmp(&hci->le_resolv_list[i][1], cmd->addr, 6)) { pos = i; break; } } if (pos < 0) { cmd_status(hci, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST); return; } hci->le_resolv_list[pos][0] = 0xff; memset(&hci->le_resolv_list[pos][1], 0, 38); status = BT_HCI_ERR_SUCCESS; cmd_complete(hci, BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST, &status, sizeof(status)); }
static void cmd_write_flow_control_mode(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_write_flow_control_mode *cmd = data; uint8_t status; if (cmd->mode != 0x01) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_WRITE_FLOW_CONTROL_MODE); return; } status = BT_HCI_ERR_SUCCESS; cmd_complete(amp, BT_HCI_CMD_WRITE_FLOW_CONTROL_MODE, &status, sizeof(status)); }
static void cmd_write_location_data(struct bt_amp *amp, const void *data, uint8_t size) { const struct bt_hci_cmd_write_location_data *cmd = data; uint8_t status; if (cmd->domain_aware > 0x01) { cmd_status(amp, BT_HCI_ERR_INVALID_PARAMETERS, BT_HCI_CMD_WRITE_LOCATION_DATA); return; } status = BT_HCI_ERR_SUCCESS; cmd_complete(amp, BT_HCI_CMD_WRITE_LOCATION_DATA, &status, sizeof(status)); }
static void mplex_timer_handler (Tox *m) { TOX_USER_STATUS current_status, new_status; const char *new_note; if (mplex == MPLEX_NONE) return; int detached = mplex_is_detached (); pthread_mutex_lock (&Winthread.lock); current_status = tox_self_get_status (m); pthread_mutex_unlock (&Winthread.lock); if (auto_away_active && current_status == TOX_USER_STATUS_AWAY && !detached) { auto_away_active = false; new_status = prev_status; new_note = prev_note; } else if (current_status == TOX_USER_STATUS_NONE && detached) { auto_away_active = true; prev_status = current_status; new_status = TOX_USER_STATUS_AWAY; pthread_mutex_lock (&Winthread.lock); size_t slen = tox_self_get_status_message_size(m); tox_self_get_status_message (m, (uint8_t*) prev_note); prev_note[slen] = '\0'; pthread_mutex_unlock (&Winthread.lock); new_note = user_settings->mplex_away_note; } else return; char argv[3][MAX_STR_SIZE]; strcpy (argv[0], "/status"); strcpy (argv[1], (new_status == TOX_USER_STATUS_AWAY ? "away" : new_status == TOX_USER_STATUS_BUSY ? "busy" : "online")); argv[2][0] = '\"'; strcpy (argv[2] + 1, new_note); strcat (argv[2], "\""); pthread_mutex_lock (&Winthread.lock); cmd_status (prompt->chatwin->history, prompt, m, 2, argv); pthread_mutex_unlock (&Winthread.lock); }
int get_status (void) { int status; cmd_status (); status = disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01); if ( status == (ST_x08 | ST_x04 | ST_INVALID | ST_x01) ) { cc_invalidate (); return 1; } else { return 0; } }