void fb_queue_flash_sparse(const char *ptn, struct sparse_file *s, unsigned sz) { Action *a; a = queue_action(OP_DOWNLOAD_SPARSE, ""); a->data = s; a->size = 0; a->msg = mkmsg("sending sparse '%s' (%d KB)", ptn, sz / 1024); a = queue_action(OP_COMMAND, "flash:%s", ptn); a->msg = mkmsg("writing '%s'", ptn); }
void fb_queue_flash(const char *ptn, void *data, unsigned sz) { Action *a; a = queue_action(OP_DOWNLOAD, ""); a->data = data; a->size = sz; a->msg = mkmsg("sending '%s' (%d KB)", ptn, sz / 1024); a = queue_action(OP_COMMAND, "flash:%s", ptn); a->msg = mkmsg("writing '%s'", ptn); }
/* * Request an indication on if BRCM module is loaded or not * * Example response: * "Response: Follows * Privilege: Command * --END COMMAND--" */ void ami_send_brcm_module_show(ami_connection* con, ami_response_cb on_response) { //printf("Queueing Action: ami_send_brcm_module_show\n"); ami_action* action = malloc(sizeof(ami_action)); action->callback = on_response; sprintf(action->message, "Action: Command\r\nCommand: module show like chan_brcm\r\n\r\n"); queue_action(con, action); }
/* * Request an indication on the port configuration * * Example response: * "Response: Success * Message: * FXS 2 * DECT 4" */ void ami_send_brcm_ports_show(ami_connection* con, ami_response_cb on_response) { //printf("Queueing Action: ami_send_brcm_ports_show\n"); ami_action* action = malloc(sizeof(ami_action)); action->callback = on_response; sprintf(action->message, "Action: BRCMPortsShow\r\n\r\n"); queue_action(con, action); }
/* * Send command to reload sip channel. * CHANNELRELOAD event will be received when reload is completed. * * Example response: * "Response: Follows * Privilege: Command * --END COMMAND--" */ void ami_send_sip_reload(ami_connection* con, ami_response_cb on_response) { //printf("Queueing Action: ami_send_sip_reload\n"); ami_action* action = malloc(sizeof(ami_action)); action->callback = on_response; sprintf(action->message,"Action: Command\r\nCommand: sip reload\r\n\r\n"); queue_action(con, action); }
void fb_queue_download(const char *name, void *data, unsigned size) { Action *a = queue_action(OP_DOWNLOAD, ""); a->data = data; a->size = size; a->msg = mkmsg("downloading '%s'", name); }
void fb_queue_display(const char *var, const char *prettyname) { Action *a; a = queue_action(OP_QUERY, "getvar:%s", var); a->data = strdup(prettyname); if (a->data == 0) die("out of memory"); a->func = cb_display; }
void fb_queue_query_save(const char *var, char *dest, unsigned dest_size) { Action *a; a = queue_action(OP_QUERY, "getvar:%s", var); a->data = (void *)dest; a->size = dest_size; a->func = cb_save; }
void fb_queue_format(const char *partition, int skip_if_not_supported) { Action *a; a = queue_action(OP_FORMAT, partition); a->data = (void*)skip_if_not_supported; a->msg = mkmsg("formatting '%s' partition", partition); }
/* * Send username and password to AMI * * Example response: * "Response: Success * Message: Authentication accepted" */ void ami_send_login(ami_connection* con, char* username, char* password, ami_response_cb on_response) { //printf("Queueing Action: ami_send_login\n"); strncpy(con->message_frame, MESSAGE_FRAME, MESSAGE_FRAME_LEN); //Login sent, now there's always <CR><LF><CR><LR> after a message ami_action* action = malloc(sizeof(ami_action)); action->callback = on_response; sprintf(action->message,"Action: Login\r\nUsername: %s\r\nSecret: %s\r\n\r\n", username, password); queue_action(con, action); }
void fb_queue_erase(const char *ptn) { Action *a; a = queue_action(OP_COMMAND, "erase:%s", ptn); if (ptn && strlen(ptn) > 0) a->msg = mkmsg("erasing '%s'", ptn); else a->msg = mkmsg(""); }
void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value) { Action *a; a = queue_action(OP_QUERY, "getvar:%s", var); a->data = value; a->size = nvalues; a->msg = mkmsg("checking %s", var); a->func = invert ? cb_reject : cb_require; if (a->data == 0) die("out of memory"); }
void fb_queue_stream_flash(const char *ptn, void *data, unsigned sz) { Action *a; a = queue_action(OP_FLASH, "flash:%s:%08X", ptn, sz); a->data = data; a->size = sz; if (ptn && strlen(ptn) > 0) a->msg = mkmsg("streaming flash '%s', size (%d KB)", ptn, sz / 1024); else a->msg = mkmsg(""); }
void fb_queue_require(const char *prod, const char *var, bool invert, size_t nvalues, const char **value) { Action *a; a = queue_action(OP_QUERY, "getvar:%s", var); a->prod = prod; a->data = value; a->size = nvalues; a->msg = mkmsg("checking %s", var); a->func = invert ? cb_reject : cb_require; if (a->data == nullptr) die("out of memory"); }
static void action_run_on_cpu(struct cpu_info *ci, struct cpu_action *action, int sync) { struct cpu_action_queue *q = &ci->action_queue; /* Don't run actions on non-online cpus. */ if (!cpu_online(ci)) return; if (ci->id == smp_processor_id()) { action->run(action->arg); return; } queue_action(q, action); /* Wait for CPU to pick it up. Empty slot means it was picked up. */ wait_for_action_queue_slot(q); /* Wait for completion if requested. */ if (sync) wait_for_action_complete(q, action); }
void fb_queue_notice(const char *notice) { Action *a = queue_action(OP_NOTICE, ""); a->data = (void*) notice; }
void fb_queue_command(const char *cmd, const char *msg) { Action *a = queue_action(OP_COMMAND, cmd); a->msg = msg; }
void fb_queue_reboot(void) { Action *a = queue_action(OP_COMMAND, "reboot"); a->func = cb_do_nothing; a->msg = "rebooting"; }
/* * Request SIP Registry information * (response is a simple message, then the registry events * follow separately, one per registered account) * Example response: * Response: Success * EventList: start * Message: Registrations will follow * * Event: RegistryEntry * Host: sip0 * Port: 5060 * Username: 0510409896 * Domain: 62.80.209.10 * DomainPort: 5060 * Refresh: 5385 * State: Registered * RegistrationTime: 1401282865 * * Event: RegistrationsComplete * EventList: Complete * ListItems: 1 */ void ami_send_sip_show_registry(ami_connection* con, ami_response_cb on_response) { ami_action* action = (ami_action*)malloc(sizeof(ami_action)); action->callback = on_response; sprintf(action->message, "Action: SIPshowregistry\r\n\r\n"); queue_action(con, action); }
void fb_set_active(const char *slot) { Action *a; a = queue_action(OP_COMMAND, "set_active:%s", slot); a->msg = mkmsg("Setting current slot to '%s'", slot); }
void fb_queue_wait_for_disconnect(void) { queue_action(OP_WAIT_FOR_DISCONNECT, ""); }
void fb_queue_erase(const char *ptn) { Action *a; a = queue_action(OP_COMMAND, "erase:%s", ptn); a->msg = mkmsg("erasing '%s'", ptn); }