[Spice-devel] [PATCH] usbredirserver: add support for bind specific address
Chen Hanxiao
chen_han_xiao at 126.com
Fri Nov 17 08:48:40 UTC 2017
At 2017-11-17 16:06:13, "Marc-André Lureau" <marcandre.lureau at redhat.com> wrote:
>Hi
>
>----- Original Message -----
>> From: Chen Hanxiao <chenhanxiao at gmail.com>
>>
>> We bind our listen address to in6addr_any, which may be
>> unsecure with multi network cards that belong to
>> internal or external networks.
>>
>> This patch introduces option -4 and -6 to bind a specific
>> address.
>>
...
>> - exit(1);
>> + if (bind(server_fd, (struct sockaddr *)&serveraddr4,
>> + sizeof(serveraddr4))) {
>> + fprintf(stderr, "Error binding port %d: %s\n", port,
>> strerror(errno));
>
>Why not perror() like the rest of the code?
Sure, will fix in v2.
Regards,
- Chen
>
>> + exit(1);
>> + }
>> + } else {
>> + memset(&serveraddr, 0, sizeof(serveraddr));
>> + serveraddr.sin6_family = AF_INET6;
>> + serveraddr.sin6_port = htons(port);
>> + if (ipv6_addr) {
>> + if ((inet_pton(AF_INET6, ipv4_addr, &serveraddr.sin6_addr)) !=
>> 1) {
>> + perror("Error convert ipv4 address");
>> + exit(1);
>> + }
>> + } else {
>> + serveraddr.sin6_addr = in6addr_any;
>> + }
>> +
>> + if (bind(server_fd, (struct sockaddr *)&serveraddr,
>> + sizeof(serveraddr))) {
>> + fprintf(stderr, "Error binding port %d: %s\n",
>> + port, strerror(errno));
>
>same here
>
>> + exit(1);
>> + }
>> }
>>
>> if (listen(server_fd, 1)) {
>> --
>> 2.13.6
>
>Look good otherwise,
>
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>>
More information about the Spice-devel
mailing list