Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] [OMPI svn-full] svn:open-mpi r24665
From: Ralph Castain (rhc_at_[hidden])
Date: 2011-05-01 10:44:32


Mostly because I thought it of some value to make the resulting mask readable and apparent to someone looking at the code.

On Apr 30, 2011, at 8:14 PM, Tim Mattox wrote:

> Why not do this instead of a big switch statement?
>
> pval = strtol(msk, NULL, 10);
> if ((pval > 30) || (pval < 1)) {
> opal_output(0, "opal_iftupletoaddr: unknown mask");
> free(addr);
> return OPAL_ERROR;
> }
> *mask = 0xFFFFFFFF << (32 - pval);
>
>
> On Fri, Apr 29, 2011 at 1:56 PM, <rhc_at_[hidden]> wrote:
>> Author: rhc
>> Date: 2011-04-29 13:56:15 EDT (Fri, 29 Apr 2011)
>> New Revision: 24665
>> URL: https://svn.open-mpi.org/trac/ompi/changeset/24665
>>
>> Log:
>> Cover all the netmask values
>>
>> Text files modified:
>> trunk/opal/util/if.c | 103 +++++++++++++++++++++++++++++++++++++--
>> 1 files changed, 96 insertions(+), 7 deletions(-)
>>
>> Modified: trunk/opal/util/if.c
>> ==============================================================================
>> --- trunk/opal/util/if.c (original)
>> +++ trunk/opal/util/if.c 2011-04-29 13:56:15 EDT (Fri, 29 Apr 2011)
>> @@ -534,13 +534,102 @@
>> * much of the addr to use: e.g., /16
>> */
>> pval = strtol(msk, NULL, 10);
>> - if (24 == pval) {
>> - *mask = 0xFFFFFF00;
>> - } else if (16 == pval) {
>> - *mask = 0xFFFF0000;
>> - } else if (8 == pval) {
>> - *mask = 0xFF000000;
>> - } else {
>> + switch(pval) {
>> + case 30:
>> + *mask = parse_dots("255.255.255.252");
>> + break;
>> + case 29:
>> + *mask = parse_dots("255.255.255.248");
>> + break;
>> + case 28:
>> + *mask = parse_dots("255.255.255.240");
>> + break;
>> + case 27:
>> + *mask = parse_dots("255.255.255.224");
>> + break;
>> + case 26:
>> + *mask = parse_dots("255.255.255.192");
>> + break;
>> + case 25:
>> + *mask = parse_dots("255.255.255.128");
>> + break;
>> + case 24:
>> + break;
>> + *mask = parse_dots("255.255.255.0");
>> + break;
>> + case 23:
>> + *mask = parse_dots("255.255.254.0");
>> + break;
>> + case 22:
>> + *mask = parse_dots("255.255.252.0");
>> + break;
>> + case 21:
>> + *mask = parse_dots("255.255.248.0");
>> + break;
>> + case 20:
>> + *mask = parse_dots("255.255.240.0");
>> + break;
>> + case 19:
>> + *mask = parse_dots("255.255.224.0");
>> + break;
>> + case 18:
>> + *mask = parse_dots("255.255.192.0");
>> + break;
>> + case 17:
>> + *mask = parse_dots("255.255.128.0");
>> + break;
>> + case 16:
>> + *mask = parse_dots("255.255.0.0");
>> + break;
>> + case 15:
>> + *mask = parse_dots("255.254.0.0");
>> + break;
>> + case 14:
>> + *mask = parse_dots("255.252.0.0");
>> + break;
>> + case 13:
>> + *mask = parse_dots("255.248.0.0");
>> + break;
>> + case 12:
>> + *mask = parse_dots("255.240.0.0");
>> + break;
>> + case 11:
>> + *mask = parse_dots("255.224.0.0");
>> + break;
>> + case 10:
>> + *mask = parse_dots("255.192.0.0");
>> + break;
>> + case 9:
>> + *mask = parse_dots("255.128.0.0");
>> + break;
>> + case 8:
>> + *mask = parse_dots("255.0.0.0");
>> + break;
>> + case 7:
>> + *mask = parse_dots("254.0.0.0");
>> + break;
>> + case 6:
>> + *mask = parse_dots("252.0.0.0");
>> + break;
>> + case 5:
>> + *mask = parse_dots("248.0.0.0");
>> + break;
>> + case 4:
>> + *mask = parse_dots("240.0.0.0");
>> + break;
>> + case 3:
>> + *mask = parse_dots("224.0.0.0");
>> + break;
>> + case 2:
>> + *mask = parse_dots("192.0.0.0");
>> + break;
>> + case 1:
>> + *mask = parse_dots("128.0.0.0");
>> + break;
>> + case 0:
>> + *mask = parse_dots("0.0.0.0");
>> + break;
>> + default:
>> opal_output(0, "opal_iftupletoaddr: unknown mask");
>> free(addr);
>> return OPAL_ERROR;
>> _______________________________________________
>> svn-full mailing list
>> svn-full_at_[hidden]
>> http://www.open-mpi.org/mailman/listinfo.cgi/svn-full
>>
>
>
>
> --
> Tim Mattox, Ph.D. - http://homepage.mac.com/tmattox/
> timattox_at_[hidden] || tmattox_at_[hidden]
> I'm a bright... http://www.the-brights.net/
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel