static void port_server_cmd_create(char * token, Channel * c) { int err = 0; PortRedirectionInfo * port = loc_alloc_zero(sizeof(PortRedirectionInfo)); PortServer * server; json_read_struct(&c->inp, read_port_server_property, port); if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX); if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX); /* In case the current channel is a proxy (value-add), use the * target channel. */ port->c = proxy_get_target_channel(c); if (port->c == NULL) port->c = c; server = create_port_redirection(port); if (server == NULL) err = errno; write_stringz(&c->out, "R"); write_stringz(&c->out, token); write_errno(&c->out, err); if (err) write_stringz(&c->out, "null"); else { write_port_server_info(&c->out, server); write_stream(&c->out, 0); } write_stream(&c->out, MARKER_EOM); }
static void port_server_cmd_create(char * token, Channel * c) { int err = 0; PortAttribute * attrs = NULL; PortServer * server; Channel * port_channel; json_read_struct(&c->inp, read_port_server_property, &attrs); if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX); if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX); /* In case the current channel is a proxy (value-add), use the * target channel. Otherwise, use the provided channel. */ port_channel = proxy_get_target_channel(c); if (port_channel == NULL) port_channel = c; server = create_port_server(c, attrs, NULL, NULL, NULL, NULL); if (server == NULL) err = errno; write_stringz(&c->out, "R"); write_stringz(&c->out, token); write_errno(&c->out, err); if (err) write_stringz(&c->out, "null"); else { write_port_server_info(&c->out, server); write_stream(&c->out, 0); } write_stream(&c->out, MARKER_EOM); }
static void port_server_cmd_get_config(char * token, Channel * c) { char id[256]; PortServer * server; int err = 0; json_read_string(&c->inp, id, sizeof(id)); if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX); if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX); if ((server = find_port_server(id)) == NULL) err = EINVAL; write_stringz(&c->out, "R"); write_stringz(&c->out, token); write_errno(&c->out, err); if (err == 0) { write_port_server_info(&c->out, server); write_stream(&c->out, 0); } else { write_stringz(&c->out, "null"); } write_stream(&c->out, MARKER_EOM); }