Hi,

comments inline

On 02/10/2015 14:13, [email protected] wrote:
> From: Javier Domingo Cansino <[email protected]>
> 
> Signed-off-by: Javier Domingo Cansino <[email protected]>
> ---
>  usock.c | 5 ++++-
>  usock.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/usock.c b/usock.c
> index 6748ef3..58f16da 100644
> --- a/usock.c
> +++ b/usock.c
> @@ -43,16 +43,19 @@ static void usock_set_flags(int sock, unsigned int type)
>  static int usock_connect(int type, struct sockaddr *sa, int sa_len, int 
> family, int socktype, bool server)
>  {
>       int sock;
> +     int flags = SO_REUSEADDR;
>  

people tend to sort these by alphabetic order or line width. your patch
does neither of the 2.

>       sock = socket(family, socktype, 0);
>       if (sock < 0)
>               return -1;
>  
>       usock_set_flags(sock, type);
> +     if (flags & USOCK_BROADCAST)
> +             flags |= SO_BROADCAST;
>  

this should be guarded by "socktype != SOCK_STREAM" or similar. check
what the rest of the code does and change the patch accordingly please.

        John



>       if (server) {
>               const int one = 1;
> -             setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
> +             setsockopt(sock, SOL_SOCKET, flags, &one, sizeof(one));
>  
>               if (!bind(sock, sa, sa_len) &&
>                   (socktype != SOCK_STREAM || !listen(sock, SOMAXCONN)))
> diff --git a/usock.h b/usock.h
> index b0b952b..3471f2a 100644
> --- a/usock.h
> +++ b/usock.h
> @@ -26,6 +26,7 @@
>  #define USOCK_NOCLOEXEC              0x0200
>  #define USOCK_NONBLOCK               0x0400
>  #define USOCK_NUMERIC                0x0800
> +#define USOCK_BROADCAST              0x1000
>  #define USOCK_IPV6ONLY               0x2000
>  #define USOCK_IPV4ONLY               0x4000
>  #define USOCK_UNIX           0x8000
> 
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to