staging: usbip: set usbipd server port via "-t" / "--tcp-port" option.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / usbip / userspace / src / usbipd.c
index f31b8b4246a36f5423629cdef0cd8afe60e8872f..f41ba5beb404377627a5b45fb49469876b1f9900 100644 (file)
@@ -66,6 +66,9 @@ static const char usbipd_help_string[] =
        "               Write process id to FILE.\n"
        "               If no FILE specified, use " DEFAULT_PID_FILE "\n"
        "\n"
+       "       -tPORT, --tcp-port PORT\n"
+       "               Listen on TCP/IP port PORT.\n"
+       "\n"
        "       -h, --help\n"
        "               Print this help.\n"
        "\n"
@@ -417,9 +420,9 @@ static struct addrinfo *do_getaddrinfo(char *host, int ai_family)
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_flags    = AI_PASSIVE;
 
-       rc = getaddrinfo(host, USBIP_PORT_STRING, &hints, &ai_head);
+       rc = getaddrinfo(host, usbip_port_string, &hints, &ai_head);
        if (rc) {
-               err("failed to get a network address %s: %s", USBIP_PORT_STRING,
+               err("failed to get a network address %s: %s", usbip_port_string,
                    gai_strerror(rc));
                return NULL;
        }
@@ -560,6 +563,7 @@ int main(int argc, char *argv[])
                { "daemon",  no_argument, NULL, 'D' },
                { "debug",   no_argument, NULL, 'd' },
                { "pid",     optional_argument, NULL, 'P' },
+               { "tcp-port", required_argument, NULL, 't' },
                { "help",    no_argument, NULL, 'h' },
                { "version", no_argument, NULL, 'v' },
                { NULL,      0,           NULL,  0  }
@@ -583,7 +587,7 @@ int main(int argc, char *argv[])
 
        cmd = cmd_standalone_mode;
        for (;;) {
-               opt = getopt_long(argc, argv, "DdP::hv", longopts, NULL);
+               opt = getopt_long(argc, argv, "DdP::t:hv", longopts, NULL);
 
                if (opt == -1)
                        break;
@@ -601,6 +605,9 @@ int main(int argc, char *argv[])
                case 'P':
                        pid_file = optarg ? optarg : DEFAULT_PID_FILE;
                        break;
+               case 't':
+                       usbip_setup_port_number(optarg);
+                       break;
                case 'v':
                        cmd = cmd_version;
                        break;