On 09/27/2010 02:19 PM, Angus Salkeld wrote:
> If we are not in the range 224.0.0.0 ->  239.255.255.255 then exit
> with a configuration error. (mcastaddr is not a correct multicast address.)
>
> -Angus
>
> Signed-off-by: Angus Salkeld<[email protected]>
> ---
>   exec/totemconfig.c               |    4 ++++
>   exec/totemip.c                   |   18 ++++++++++++++++++
>   include/corosync/totem/totemip.h |    1 +
>   3 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/exec/totemconfig.c b/exec/totemconfig.c
> index 381cf4f..ad1b116 100644
> --- a/exec/totemconfig.c
> +++ b/exec/totemconfig.c
> @@ -453,6 +453,10 @@ int totem_config_validate (
>                               error_reason =  "Not all bind address belong to 
> the same IP family";
>                               goto parse_error;
>                       }
> +                     if (totemip_is_mcast 
> (&totem_config->interfaces[i].mcast_addr) != 0) {
> +                             error_reason = "mcastaddr is not a correct 
> multicast address.";
> +                             goto parse_error;
> +                     }
>               }
>       }
>
> diff --git a/exec/totemip.c b/exec/totemip.c
> index f6613e8..d6bb34a 100644
> --- a/exec/totemip.c
> +++ b/exec/totemip.c
> @@ -123,6 +123,24 @@ void totemip_copy_endian_convert(struct totem_ip_address 
> *addr1,
>       memcpy(addr1->addr, addr2->addr, TOTEMIP_ADDRLEN);
>   }
>
> +/*
> + * Multicast address range is 224.0.0.0 to 239.255.255.255 this
> + * translates to the first 4 bits == 1110 (0xE).
> + * http://en.wikipedia.org/wiki/Multicast_address
> + */
> +int32_t totemip_is_mcast(struct totem_ip_address *ip_addr)
> +{
> +     uint32_t addr = 0;
> +
> +     if (ip_addr->family == AF_INET) {
> +             addr = ntohl(*(int32_t*)ip_addr->addr);
> +             if ((addr>>  28) != 0xE) {
> +                     return -1;
> +             }
> +     }
> +     return 0;
> +}
> +
>   /* For sorting etc. params are void * for qsort's benefit */
>   int totemip_compare(const void *a, const void *b)
>   {
> diff --git a/include/corosync/totem/totemip.h 
> b/include/corosync/totem/totemip.h
> index 9f45b5f..e7f1d18 100644
> --- a/include/corosync/totem/totemip.h
> +++ b/include/corosync/totem/totemip.h
> @@ -68,6 +68,7 @@ struct totem_ip_address
>   extern int totemip_equal(const struct totem_ip_address *addr1,
>                        const struct totem_ip_address *addr2);
>   extern int totemip_compare(const void *a, const void *b);
> +extern int totemip_is_mcast(struct totem_ip_address *addr);
>   extern void totemip_copy(struct totem_ip_address *addr1,
>                        const struct totem_ip_address *addr2);
>   extern void totemip_copy_endian_convert(struct totem_ip_address *addr1,
looks good

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to