diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-03-23 16:27:09 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2010-05-19 11:22:05 +0200 |
commit | 3f7ea8e7a45b951f74a94c5eb04dd348f3906033 (patch) | |
tree | ab2ae28a0e97af9d7d0f1afd10733fe74c094107 /server/reds.c | |
parent | 881c685f904c098c968303c1ae60d0c9840d2f4c (diff) |
zap qterm interfaces
old way to handle monitor, obsolete.
Diffstat (limited to 'server/reds.c')
-rw-r--r-- | server/reds.c | 688 |
1 files changed, 0 insertions, 688 deletions
diff --git a/server/reds.c b/server/reds.c index a84fe04..a61de3c 100644 --- a/server/reds.c +++ b/server/reds.c @@ -517,85 +517,6 @@ static inline void reds_release_link(RedLinkInfo *link) peer->cb_free(peer); } -static void reds_do_disable_ticketing(void) -{ - ticketing_enabled = 0; - memset(taTicket.password, 0, sizeof(taTicket.password)); - core->term_printf(core, "Ticketing is now disabled.\n"); -} - -static void reds_do_disable_ticketing_2(const VDICmdArg* args) -{ - if (!args_is_empty(args)) { - red_printf("invalid args"); - return; - } - - reds_do_disable_ticketing(); -} - -static char *base64decode(const char *input, int length) -{ - BIO *b64; - BIO *bmem; - int n; - char *buffer = (char *)spice_malloc0(length); - char *inbuffer = (char *)spice_malloc0(length + 1); - - memcpy(inbuffer, input, length); - inbuffer[length] = '\n'; - - b64 = BIO_new(BIO_f_base64()); - bmem = BIO_new_mem_buf(inbuffer, length + 1); - - if (b64 != NULL && bmem != NULL) { - bmem = BIO_push(b64, bmem); - - n = BIO_read(bmem, buffer, length); - - if (n != 0) { - buffer[n - 1] = '\0'; - } else { - free(buffer); - buffer = NULL; - } - } else { - free(buffer); - buffer = NULL; - } - - BIO_free_all(bmem); - - return buffer; -} - -static void reds_do_info_ticket(void) -{ - core->term_printf(core, "Ticket Information:"); - if (ticketing_enabled) { - if (strlen(taTicket.password) == 0) { - core->term_printf(core, " blocked\n"); - } else { - if (taTicket.expiration_time == INT_MAX) { - core->term_printf(core, " expiration NEVER\n"); - } else { - time_t now; - - time(&now); - int expired = taTicket.expiration_time < now; - if (expired) { - core->term_printf(core, " expiration EXPIRED\n"); - } else { - core->term_printf(core, " expiration %s\n", - ctime((time_t *)&(taTicket.expiration_time))); - } - } - } - } else { - core->term_printf(core, " disabled\n"); - } -} - static struct iovec *reds_iovec_skip(struct iovec vec[], int skip, int *vec_size) { struct iovec *now = vec; @@ -612,60 +533,6 @@ static struct iovec *reds_iovec_skip(struct iovec vec[], int skip, int *vec_size #ifdef RED_STATISTICS -#define STAT_TAB_LEN 4 -#define STAT_VALUE_TABS 7 - -static void print_stat_tree(uint32_t node_index, int depth) -{ - SpiceStatNode *node = &reds->stat->nodes[node_index]; - - if ((node->flags & SPICE_STAT_NODE_MASK_SHOW) == SPICE_STAT_NODE_MASK_SHOW) { - core->term_printf(core, "%*s%s", depth * STAT_TAB_LEN, "", node->name); - if (node->flags & SPICE_STAT_NODE_FLAG_VALUE) { - core->term_printf(core, ":%*s%llu\n", - (STAT_VALUE_TABS - depth) * STAT_TAB_LEN - strlen(node->name) - 1, "", - node->value); - } else { - core->term_printf(core, "\n"); - if (node->first_child_index != INVALID_STAT_REF) { - print_stat_tree(node->first_child_index, depth + 1); - } - } - } - if (node->next_sibling_index != INVALID_STAT_REF) { - print_stat_tree(node->next_sibling_index, depth); - } -} - -static void do_info_statistics() -{ - core->term_printf(core, "Spice Statistics:\n"); - print_stat_tree(reds->stat->root_index, 0); -} - -static void do_reset_statistics() -{ - SpiceStatNode *node; - int i; - - for (i = 0; i <= REDS_MAX_STAT_NODES; i++) { - node = &reds->stat->nodes[i]; - if (node->flags & SPICE_STAT_NODE_FLAG_VALUE) { - node->value = 0; - } - } -} - -static void do_reset_statistics_2(const VDICmdArg* args) -{ - if (!args_is_empty(args)) { - red_printf("invalid args"); - return; - } - - do_reset_statistics(); -} - void insert_stat_node(StatNodeRef parent, StatNodeRef ref) { SpiceStatNode *node = &reds->stat->nodes[ref]; @@ -1185,31 +1052,6 @@ static void do_ping_client(const char *opt, int has_interval, int interval) } } -static void do_ping_client_2(const VDICmdArg* args) -{ - if (args_is_empty(args)) { - do_ping_client(NULL, FALSE, 0); - return; - } - - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - if (args_is_empty(&args[1])) { - do_ping_client(args[0].string_val, FALSE, 0); - return; - } - - if (!args_is_int(&args[1])) { - red_printf("invalid args"); - return; - } - - do_ping_client(args[0].string_val, TRUE, args[1].int_val); -} - static void ping_timer_cb() { if (!reds->peer) { @@ -3357,12 +3199,6 @@ enum { SPICE_TICKET_OPTION_CONNECTED, }; -static OptionsMap _spice_ticket_options[] = { - {"expiration", SPICE_TICKET_OPTION_EXPIRATION}, - {"connected", SPICE_TICKET_OPTION_CONNECTED}, - {NULL, 0}, -}; - static inline void on_activating_ticketing() { if (!ticketing_enabled && reds->peer) { @@ -3371,224 +3207,6 @@ static inline void on_activating_ticketing() } } -static void reds_reset_ticketing() -{ - on_activating_ticketing(); - ticketing_enabled = 1; - taTicket.expiration_time = 0; - memset(taTicket.password, 0, sizeof(taTicket.password)); -} - -static void reds_set_ticketing(const char *pass, long expiration) -{ - ASSERT(expiration >= 0); - on_activating_ticketing(); - ticketing_enabled = 1; - if (expiration == 0) { - taTicket.expiration_time = INT_MAX; - } else { - time_t ltime; - - time(<ime); - taTicket.expiration_time = ltime + expiration; - } - strncpy(taTicket.password, pass, sizeof(taTicket.password)); -} - -static void reds_do_set_ticket(const char *password, const char *args) -{ - long expiration = 0; - char *local_args = NULL; - const char *term_str = "invalid args"; - int disconnect = FALSE; - int fail = FALSE; - - if (!password) { - term_str = "unexpected NULL password"; - goto error; - } - - if (args) { - char *in_args; - int option; - char *val; - - in_args = local_args = spice_strdup(args); - do { - switch (option = get_option(&in_args, &val, _spice_ticket_options, ',')) { - case SPICE_TICKET_OPTION_EXPIRATION: { - char *endptr; - - if (!val) { - goto error; - } - expiration = strtol(val, &endptr, 0); - if (endptr != val + strlen(val) || expiration < 0) { - term_str = "invalid expiration"; - goto error; - } - break; - } - case SPICE_TICKET_OPTION_CONNECTED: - if (!val) { - goto error; - } - - if (strcmp(val, "disconnect") == 0) { - disconnect = TRUE; - fail = FALSE; - } else if (strcmp(val, "fail") == 0) { - fail = TRUE; - disconnect = FALSE; - } else if (strcmp(val, "keep") == 0) { - fail = FALSE; - disconnect = FALSE; - } else { - goto error; - } - break; - default: - goto error; - } - } while (in_args); - } - - if (fail && reds->peer) { - term_str = "Ticket set failed"; - } else { - if (disconnect) { - reds_disconnect(); - } - reds_set_ticketing(password, expiration); - term_str = "Ticket set successfully"; - } - core->term_printf(core, "%s\n", term_str); - free(local_args); - return; - -error: - reds_reset_ticketing(); - core->term_printf(core, "%s\n", term_str); - free(local_args); -} - -static void reds_do_set_ticket_2(const VDICmdArg *args) -{ - const char *arg2 = NULL; - - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - if (!args_is_empty(&args[1])) { - if (!args_is_string(&args[1])) { - red_printf("invalid args"); - return; - } - arg2 = args[1].string_val; - } - - reds_do_set_ticket(args[0].string_val, arg2); -} - -static void reds_do_set_ticket64(const char *password64, const char *args) -{ - char *password; - - if (!password64) { - reds_reset_ticketing(); - core->term_printf(core, "unexpected NULL password\n"); - return; - } - - if (!(password = base64decode(password64, strlen(password64)))) { - reds_reset_ticketing(); - core->term_printf(core, "set_ticket64 failed!\n"); - return; - } - reds_do_set_ticket(password, args); - free(password); -} - -static void reds_do_set_ticket64_2(const VDICmdArg *args) -{ - const char *arg2 = NULL; - - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - if (!args_is_empty(&args[1])) { - if (!args_is_string(&args[1])) { - red_printf("invalid args"); - return; - } - arg2 = args[1].string_val; - } - - reds_do_set_ticket64(args[0].string_val, arg2); -} - -static void reds_do_info_spice() -{ - core->term_printf(core, "spice info:"); - if (reds->peer) { - char *ip = NULL; - struct sockaddr_in sock_addr; - socklen_t len = sizeof(sock_addr); - if (getpeername(reds->peer->socket, (struct sockaddr *)&sock_addr, &len) != -1) { - ip = inet_ntoa(sock_addr.sin_addr); - } - core->term_printf(core, " client=%s", ip); - } else { - core->term_printf(core, " disconnected"); - } - core->term_printf(core, " ticketing=%s", ticketing_enabled ? "on" : "off"); - switch (image_compression) { - case SPICE_IMAGE_COMPRESS_AUTO_GLZ: - core->term_printf(core, " ic=auto_glz"); - break; - case SPICE_IMAGE_COMPRESS_AUTO_LZ: - core->term_printf(core, " ic=auto_lz"); - break; - case SPICE_IMAGE_COMPRESS_QUIC: - core->term_printf(core, " ic=quic"); - break; - case SPICE_IMAGE_COMPRESS_LZ: - core->term_printf(core, " ic=lz"); - break; - case SPICE_IMAGE_COMPRESS_GLZ: - core->term_printf(core, " ic=glz"); - break; - case SPICE_IMAGE_COMPRESS_OFF: - core->term_printf(core, " ic=off"); - break; - case SPICE_IMAGE_COMPRESS_INVALID: - default: - core->term_printf(core, " ic=invalid"); - } - - switch (streaming_video) { - case STREAM_VIDEO_ALL: - core->term_printf(core, " sv=all"); - break; - case STREAM_VIDEO_FILTER: - core->term_printf(core, " sv=filter"); - break; - case STREAM_VIDEO_OFF: - core->term_printf(core, " sv=off"); - break; - case STREAM_VIDEO_INVALID: - default: - core->term_printf(core, " sv=invalid"); - - } - core->term_printf(core, " playback-compression=%s\n", - snd_get_playback_compression() ? "on" : "off"); -} - static void set_image_compression(spice_image_compression_t val) { if (val == image_compression) { @@ -3598,136 +3216,6 @@ static void set_image_compression(spice_image_compression_t val) red_dispatcher_on_ic_change(); } -static spice_image_compression_t reds_get_image_compression(const char *val) -{ - if ((strcmp(val, "on") == 0) || (strcmp(val, "auto_glz") == 0)) { - return SPICE_IMAGE_COMPRESS_AUTO_GLZ; - } else if (strcmp(val, "auto_lz") == 0) { - return SPICE_IMAGE_COMPRESS_AUTO_LZ; - } else if (strcmp(val, "quic") == 0) { - return SPICE_IMAGE_COMPRESS_QUIC; - } else if (strcmp(val, "glz") == 0) { - return SPICE_IMAGE_COMPRESS_GLZ; - } else if (strcmp(val, "lz") == 0) { - return SPICE_IMAGE_COMPRESS_LZ; - } else if (strcmp(val, "off") == 0) { - return SPICE_IMAGE_COMPRESS_OFF; - } - return SPICE_IMAGE_COMPRESS_INVALID; -} - -static void reds_do_set_image_compression(const char *val) -{ - spice_image_compression_t real_val = reds_get_image_compression(val); - if (real_val == SPICE_IMAGE_COMPRESS_INVALID) { - core->term_printf(core, "bad image compression arg\n"); - return; - } - set_image_compression(real_val); -} - -static void reds_do_set_image_compression_2(const VDICmdArg *args) -{ - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - reds_do_set_image_compression(args[0].string_val); -} - -static int reds_get_streaming_video(const char *val) -{ - if (strcmp(val, "on") == 0) { - return STREAM_VIDEO_FILTER; - } else if (strcmp(val, "filter") == 0) { - return STREAM_VIDEO_FILTER; - } else if (strcmp(val, "all") == 0) { - return STREAM_VIDEO_ALL; - } else if (strcmp(val, "off") == 0){ - return STREAM_VIDEO_OFF; - } else { - return STREAM_VIDEO_INVALID; - } -} - -static void reds_do_set_streaming_video(const char *val) -{ - uint32_t new_val = reds_get_streaming_video(val); - if (new_val == STREAM_VIDEO_INVALID) { - core->term_printf(core, "bad streaming video arg\n"); - return; - } - - if (new_val == streaming_video) { - return; - } - streaming_video = new_val; - red_dispatcher_on_sv_change(); -} - -static void reds_do_set_streaming_video_2(const VDICmdArg *args) -{ - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - reds_do_set_streaming_video(args[0].string_val); -} - -static void reds_do_set_agent_mouse(const char *val) -{ - int new_val; - if (strcmp(val, "on") == 0) { - new_val = TRUE; - } else if (strcmp(val, "off") == 0) { - new_val = FALSE; - } else { - core->term_printf(core, "bad agent mouse arg\n"); - return; - } - if (new_val == agent_mouse) { - return; - } - agent_mouse = new_val; - reds_update_mouse_mode(); -} - -static void reds_do_set_agent_mouse_2(const VDICmdArg *args) -{ - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - reds_do_set_agent_mouse(args[0].string_val); -} - -static void reds_do_set_playback_compression(const char *val) -{ - int on; - if (strcmp(val, "on") == 0) { - on = TRUE; - } else if (strcmp(val, "off") == 0) { - on = FALSE; - } else { - core->term_printf(core, "bad playback compression arg\n"); - return; - } - snd_set_playback_compression(on); -} - -static void reds_do_set_playback_compression_2(const VDICmdArg *args) -{ - if (!args_is_string(args)) { - red_printf("invalid args"); - return; - } - - reds_do_set_playback_compression(args[0].string_val); -} - static void set_one_channel_security(int id, uint32_t security) { ChannelSecurityOptions *security_options; @@ -4513,154 +4001,6 @@ static void mm_timer_proc(void *opaque) core->arm_timer(core, reds->mm_timer, MM_TIMER_GRANULARITY_MS); } -static void add_monitor_action_commands(QTermInterface *mon) -{ - mon->add_action_command_handler(mon, "spice", "set_image_compression", "s", - reds_do_set_image_compression, - "", - "<[on|auto_glz|auto_lz|quic|glz|lz|off]>"); - mon->add_action_command_handler(mon, "spice", "set_streaming_video", "s", - reds_do_set_streaming_video, - "", - "<on|filter|all|off>"); - mon->add_action_command_handler(mon, "spice", "set_playback_compression", "s", - reds_do_set_playback_compression, - "", - "<on|off>"); - mon->add_action_command_handler(mon, "spice", "set_ticket", "ss?", - reds_do_set_ticket, - "<password> [expiration=<seconds>]" - "[,connected=keep|disconnect|fail]", - "set the spice connection ticket"); - mon->add_action_command_handler(mon, "spice", "set_ticket64", "ss?", - reds_do_set_ticket64, - "<password> [expiration=<seconds>]" - "[,connected=keep|disconnect|fail]", - "set the spice connection ticket"); - mon->add_action_command_handler(mon, "spice", "disable_ticketing", "", - reds_do_disable_ticketing, - "", - "entirely disables OTP"); - mon->add_action_command_handler(mon, "spice", "set_agent_mouse", "s", - reds_do_set_agent_mouse, - "", - "<on|off>"); -#ifdef RED_STATISTICS - mon->add_action_command_handler(mon, "spice", "reset_stat", "", - do_reset_statistics, - "", - "reset spice statistics"); - mon->add_action_command_handler(mon, "spice", "ping_client", "s?i?", - do_ping_client, - "[on [interval]|off]", - "ping spice client to measure roundtrip"); -#endif -} - -static void add_monitor_action_commands_2(QTerm2Interface *mon) -{ - VDIArgDescriptor s[] = { - { "arg1", ARG_TYPE_STRING, FALSE}, - { NULL, 0, 0}, - }; - - VDIArgDescriptor empty[] = { - { NULL, 0, 0} - }; - - VDIArgDescriptor s_s_o[] = { - { "arg1", ARG_TYPE_STRING, FALSE}, - { "arg2", ARG_TYPE_STRING, TRUE}, - { NULL, 0, 0} - }; - - VDIArgDescriptor s_o_i_o[] = { - { "arg1", ARG_TYPE_STRING, TRUE}, - { "arg2", ARG_TYPE_INT, TRUE}, - { NULL, 0, 0} - }; - - mon->add_action_command_handler(mon, "spice", "set_image_compression", s, - reds_do_set_image_compression_2, - "<[on|auto_glz|auto_lz|quic|glz|lz|off]>", - ""); - - mon->add_action_command_handler(mon, "spice", "set_streaming_video", s, - reds_do_set_streaming_video_2, - "<on|filter|all|off>", - ""); - - mon->add_action_command_handler(mon, "spice", "set_playback_compression", s, - reds_do_set_playback_compression_2, - "<on|off>", - ""); - - mon->add_action_command_handler(mon, "spice", "set_ticket", s_s_o, - reds_do_set_ticket_2, - "<password> [expiration=<seconds>]" - "[,connected=keep|disconnect|fail]", - "set the spice connection ticket"); - mon->add_action_command_handler(mon, "spice", "set_ticket64", s_s_o, - reds_do_set_ticket64_2, - "<password> [expiration=<seconds>]" - "[,connected=keep|disconnect|fail]", - "set the spice connection ticket"); - mon->add_action_command_handler(mon, "spice", "disable_ticketing", empty, - reds_do_disable_ticketing_2, - "", - "entirely disables OTP"); - mon->add_action_command_handler(mon, "spice", "set_agent_mouse", s, - reds_do_set_agent_mouse_2, - "<on|off>", - ""); -#ifdef RED_STATISTICS - mon->add_action_command_handler(mon, "spice", "reset_stat", empty, - do_reset_statistics_2, - "", - "reset spice statistics"); - mon->add_action_command_handler(mon, "spice", "ping_client", s_o_i_o, - do_ping_client_2, - "[on [interval]|off]", - "ping spice client to measure roundtrip"); -#endif -} - -static void add_monitor_info_commands(QTermInterface *mon) -{ - mon->add_info_command_handler(mon, "spice", "state", - reds_do_info_spice, - "show spice state"); - mon->add_info_command_handler(mon, "spice", "ticket", - reds_do_info_ticket, - "show ticket"); -#ifdef RED_STATISTICS - mon->add_info_command_handler(mon, "spice", "stat", - do_info_statistics, - "show spice statistics"); - mon->add_info_command_handler(mon, "spice", "rtt_client", - do_info_rtt_client, - "show rtt to spice client"); -#endif -} - -static void add_monitor_info_commands_2(QTerm2Interface *mon) -{ - mon->add_info_command_handler(mon, "spice", "state", - reds_do_info_spice, - "show spice state"); - mon->add_info_command_handler(mon, "spice", "ticket", - reds_do_info_ticket, - "show ticket"); -#ifdef RED_STATISTICS - mon->add_info_command_handler(mon, "spice", "stat", - do_info_statistics, - "show spice statistics"); - mon->add_info_command_handler(mon, "spice", "rtt_client", - do_info_rtt_client, - "show rtt to spice client"); -#endif -} - static void attach_to_red_agent(VDIPortInterface *interface) { VDIPortState *state = &reds->agent_state; @@ -4747,34 +4087,6 @@ static void interface_change_notifier(void *opaque, VDInterface *interface, } qxl_interface = (QXLInterface *)interface; red_dispatcher_init(qxl_interface); - } else if (strcmp(interface->type, VD_INTERFACE_QTERM) == 0) { - static int was_here = FALSE; - red_printf("VD_INTERFACE_QTERM"); - if (was_here) { - return; - } - was_here = TRUE; - if (interface->major_version != VD_INTERFACE_QTERM_MAJOR || - interface->minor_version < VD_INTERFACE_QTERM_MINOR) { - red_printf("unsuported qterm interface"); - return; - } - add_monitor_action_commands((QTermInterface *)interface); - add_monitor_info_commands((QTermInterface *)interface); - } else if (strcmp(interface->type, VD_INTERFACE_QTERM2) == 0) { - static int was_here = FALSE; - red_printf("VD_INTERFACE_QTERM2"); - if (was_here) { - return; - } - was_here = TRUE; - if (interface->major_version != VD_INTERFACE_QTERM2_MAJOR || - interface->minor_version < VD_INTERFACE_QTERM2_MINOR) { - red_printf("unsuported qterm interface"); - return; - } - add_monitor_action_commands_2((QTerm2Interface *)interface); - add_monitor_info_commands_2((QTerm2Interface *)interface); } else if (strcmp(interface->type, VD_INTERFACE_TABLET) == 0) { red_printf("VD_INTERFACE_TABLET"); if (tablet) { |