casbin/ip_parser/parser/IPNet.cpp
bool IPNet :: contains(IP ipNew) {
    std::pair<IP, IPMask> p = networkNumberAndMask(*this);
    IP x;
    x = ipNew.To4();
    if(x.isLegal == true) {
        ipNew = x;
    }
    int l = int(ipNew.ip.size());
    if(l != p.first.ip.size()) {
        return false;
    }
    for(int i = 0 ; i < l ; i++) {
        if((p.first.ip[i]&p.second[i]) != (ipNew.ip[i]&p.second[i])) {
            return false;
        }
    }
    return true;
}
// Contains reports whether the network includes ip.
Contains reports whether the network includes ip.
Contains reports whether the network includes ip .
bool IPNet :: contains(IP ipNew) {
    std::pair<IP, IPMask> p = networkNumberAndMask(*this);
    IP x;
    x = ipNew.To4();
    if(x.isLegal == true) {
        ipNew = x;
    }
    int l = int(ipNew.ip.size());
    if(l != p.first.ip.size()) {
        return false;
    }
    for(int i = 0 ; i < l ; i++) {
        if((p.first.ip[i]&p.second[i]) != (ipNew.ip[i]&p.second[i])) {
            return false;
        }
    }
    return true;
}
bool IPNet :: contains ( IP ipNew ) { std :: pair < IP , IPMask > p = networkNumberAndMask ( * this ) ; IP x ; x = ipNew . To4 ( ) ; if ( x . isLegal == true ) { ipNew = x ; } int l = int ( ipNew . ip . size ( ) ) ; if ( l != p . first . ip . size ( ) ) { return false ; } for ( int i = 0 ; i < l ; i ++ ) { if ( ( p . first . ip [ i ] & p . second [ i ] ) != ( ipNew . ip [ i ] & p . second [ i ] ) ) { return false ; } } return true ; }
Contains reports whether the network includes ip.
Contains reports whether the network includes ip .