-}
-
-/*
- * Print URI message.
- */
-static void print_uri_msg(struct lttng_uri *uri)
-{
- char *dst;
-
- switch (uri->dtype) {
- case LTTNG_DST_IPV4:
- dst = uri->dst.ipv4;
- break;
- case LTTNG_DST_IPV6:
- dst = uri->dst.ipv6;
- break;
- case LTTNG_DST_PATH:
- dst = uri->dst.path;
- MSG("Consumer destination set to %s", dst);
- goto end;
- default:
- DBG("Unknown URI destination");
- goto end;
- }
-
- MSG("Consumer %s stream set to %s with the %s protocol on port %d",
- uri->stype == LTTNG_STREAM_CONTROL ? "control" : "data",
- dst, uri->proto == LTTNG_TCP ? "TCP" : "UNK", uri->port);
-
-end:
- return;
-}
-
-/*
- * Setting URIs taking from the command line arguments. There is some
- * manipulations and special cases using the default args.
- */
-static int set_consumer_arg_uris(struct lttng_uri *uri, size_t size)
-{
- int ret, i;
-
- if (size == 2) {
- /* URIs are the control and data stream respectively for net:// */
- uri[0].stype = LTTNG_STREAM_CONTROL;
- uri[1].stype = LTTNG_STREAM_DATA;
-
- for (i = 0; i < size; i++) {
- ret = lttng_set_consumer_uri(handle, &uri[i]);
- if (ret < 0) {
- ERR("Setting %s stream URI: %s",
- uri[i].stype == LTTNG_STREAM_DATA ? "data" : "control",
- lttng_strerror(ret));
- goto error;
- }
- /* Set default port if none was given */
- if (uri[i].port == 0) {
- if (uri[i].stype == LTTNG_STREAM_CONTROL) {
- uri[i].port = DEFAULT_NETWORK_CONTROL_PORT;
- } else {
- uri[i].port = DEFAULT_NETWORK_DATA_PORT;
- }
- }
- print_uri_msg(&uri[i]);
- }
- } else if (size == 1 && uri[0].dtype == LTTNG_DST_PATH) {
- /* Set URI if it's file:// */
- ret = lttng_set_consumer_uri(handle, &uri[0]);
- if (ret < 0) {
- ERR("Failed to set URI %s: %s", opt_uris_arg,
- lttng_strerror(ret));
- goto error;
- }
- print_uri_msg(&uri[0]);
- } else {
- ERR("Only net:// and file:// are supported. "
- "Use -D or -U for more fine grained control");
- ret = CMD_ERROR;
- goto error;
- }
-
-error:
- return ret;
-}
-
-/*
- * Parse URI from string to lttng_uri object array.
- */
-static ssize_t parse_uri_from_str(const char *str_uri, struct lttng_uri **uris)
-{
- ssize_t size;
-
- if (*uris != NULL) {
- free(*uris);
- }
-
- size = uri_parse(str_uri, uris);
- if (size < 1) {
- ERR("Bad URI %s. Either the hostname or IP is invalid", str_uri);
- size = -1;
- }
-
- return size;
+ fprintf(ofp, "\n");
+ fprintf(ofp, "Please refer to the man page (lttng(1)) for more information on network\n");
+ fprintf(ofp, "streaming mechanisms and explanation of the control and data port\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, "URL format is has followed:\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, " proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, " Supported protocols are (proto):\n");
+ fprintf(ofp, " > file://...\n");
+ fprintf(ofp, " Local filesystem full path.\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, " > net[6]://...\n");
+ fprintf(ofp, " This will use the default network transport layer which is\n");
+ fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n");
+ fprintf(ofp, " The default ports are respectively 5342 and 5343.\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, " > tcp[4|6]://...\n");
+ fprintf(ofp, " Can only be used with -C and -D together\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, "NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)\n");
+ fprintf(ofp, "\n");
+ fprintf(ofp, "Examples:\n");
+ fprintf(ofp, " # lttng enable-consumer -u net://192.168.1.42\n");
+ fprintf(ofp, " Uses TCP and default ports for user space tracing (-u).\n");
+ fprintf(ofp, "\n");