openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libpam/1.3.1-r0/Linux-PAM-1.3.1/modules/pam_access/pam_access.c
static int are_addresses_equal(const char* ipaddr0, const char* ipaddr1,
                               const char* netmask)
{
    struct sockaddr_storage addr0;
    struct sockaddr_storage addr1;
    int addr_type0 = 0;
    int addr_type1 = 0;

    if (isipaddr(ipaddr0, &addr_type0, &addr0) == NO)
        return NO;

    if (isipaddr(ipaddr1, &addr_type1, &addr1) == NO)
        return NO;

    if (addr_type0 != addr_type1)
        /* different address types */
        return NO;

    if (netmask != NULL)
    {
        /* Got a netmask, so normalize addresses? */
        struct sockaddr_storage nmask;
        unsigned char *byte_a, *byte_nm;

        memset(&nmask, 0, sizeof(struct sockaddr_storage));
        if (inet_pton(addr_type0, netmask, (void*)&nmask) > 0)
        {
            unsigned int i;
            byte_a = (unsigned char*)(&addr0);
            byte_nm = (unsigned char*)(&nmask);
            for (i = 0; i < sizeof(struct sockaddr_storage); i++)
            {
                byte_a[i] = byte_a[i] & byte_nm[i];
            }

            byte_a = (unsigned char*)(&addr1);
            byte_nm = (unsigned char*)(&nmask);
            for (i = 0; i < sizeof(struct sockaddr_storage); i++)
            {
                byte_a[i] = byte_a[i] & byte_nm[i];
            }
        }
    }

    /* Are the two addresses equal? */
    if (memcmp((void*)&addr0, (void*)&addr1, sizeof(struct sockaddr_storage)) ==
        0)
    {
        return (YES);
    }

    return (NO);
}
/* are_addresses_equal - translate IP address strings to real IP
 * addresses and compare them to find out if they are equal.
 * If netmask was provided it will be used to focus comparation to
 * relevant bits.
 */
translate IP address strings to real IP
addresses and compare them to find out if they are equal.
If netmask was provided it will be used to focus comparation to
relevant bits.
translate IP address strings to real IP addresses and compare them to find out if they are equal . If netmask was provided it will be used to focus comparation to relevant bits .
static int are_addresses_equal(const char* ipaddr0, const char* ipaddr1,
                               const char* netmask)
{
    struct sockaddr_storage addr0;
    struct sockaddr_storage addr1;
    int addr_type0 = 0;
    int addr_type1 = 0;
    if (isipaddr(ipaddr0, &addr_type0, &addr0) == NO)
        return NO;
    if (isipaddr(ipaddr1, &addr_type1, &addr1) == NO)
        return NO;
    if (addr_type0 != addr_type1)
        return NO;
    if (netmask != NULL)
    {
        struct sockaddr_storage nmask;
        unsigned char *byte_a, *byte_nm;
        memset(&nmask, 0, sizeof(struct sockaddr_storage));
        if (inet_pton(addr_type0, netmask, (void*)&nmask) > 0)
        {
            unsigned int i;
            byte_a = (unsigned char*)(&addr0);
            byte_nm = (unsigned char*)(&nmask);
            for (i = 0; i < sizeof(struct sockaddr_storage); i++)
            {
                byte_a[i] = byte_a[i] & byte_nm[i];
            }
            byte_a = (unsigned char*)(&addr1);
            byte_nm = (unsigned char*)(&nmask);
            for (i = 0; i < sizeof(struct sockaddr_storage); i++)
            {
                byte_a[i] = byte_a[i] & byte_nm[i];
            }
        }
    }
    if (memcmp((void*)&addr0, (void*)&addr1, sizeof(struct sockaddr_storage)) ==
        0)
    {
        return (YES);
    }
    return (NO);
}
static int are_addresses_equal ( const char * ipaddr0 , const char * ipaddr1 , const char * netmask ) { struct sockaddr_storage addr0 ; struct sockaddr_storage addr1 ; int addr_type0 = 0 ; int addr_type1 = 0 ; if ( isipaddr ( ipaddr0 , & addr_type0 , & addr0 ) == NO ) return NO ; if ( isipaddr ( ipaddr1 , & addr_type1 , & addr1 ) == NO ) return NO ; if ( addr_type0 != addr_type1 ) return NO ; if ( netmask != NULL ) { struct sockaddr_storage nmask ; unsigned char * byte_a , * byte_nm ; memset ( & nmask , 0 , sizeof ( struct sockaddr_storage ) ) ; if ( inet_pton ( addr_type0 , netmask , ( void * ) & nmask ) > 0 ) { unsigned int i ; byte_a = ( unsigned char * ) ( & addr0 ) ; byte_nm = ( unsigned char * ) ( & nmask ) ; for ( i = 0 ; i < sizeof ( struct sockaddr_storage ) ; i ++ ) { byte_a [ i ] = byte_a [ i ] & byte_nm [ i ] ; } byte_a = ( unsigned char * ) ( & addr1 ) ; byte_nm = ( unsigned char * ) ( & nmask ) ; for ( i = 0 ; i < sizeof ( struct sockaddr_storage ) ; i ++ ) { byte_a [ i ] = byte_a [ i ] & byte_nm [ i ] ; } } } if ( memcmp ( ( void * ) & addr0 , ( void * ) & addr1 , sizeof ( struct sockaddr_storage ) ) == 0 ) { return ( YES ) ; } return ( NO ) ; }
are_addresses_equal - translate IP address strings to real IP
 addresses and compare them to find out if they are equal.
are_addresses_equal - translate IP address strings to real IP addresses and compare them to find out if they are equal .
/* different address types */ /* Got a netmask, so normalize addresses? */ /* Are the two addresses equal? */