Net-IP-XS

 view release on metacpan or  search on metacpan

NetIpXs.xs  view on Meta::CPAN

    OUTPUT:
        RETVAL

void
ip_splitprefix(prefix)
        char *prefix
    PREINIT:
        char buf[MAX_IPV6_STR_LEN];
        int len;
        int res;
    PPCODE:
        res = NI_ip_splitprefix(prefix, buf, &len);
        if (res) {
            XPUSHs(sv_2mortal(newSVpv(buf, 0)));
            XPUSHs(sv_2mortal(newSViv(len)));
        }

SV *
ip_is_valid_mask(mask, ipversion)
        char *mask
        int ipversion

NetIpXs.xs  view on Meta::CPAN

void
ip_range_to_prefix(begin, end, ipversion)
        char *begin
        char *end
        int ipversion
    PREINIT:
        char *prefixes[MAX_PREFIXES];
        int pcount;
        int res;
        int i;
    PPCODE:
        pcount = 0;
        res = NI_ip_range_to_prefix(begin, end, ipversion, prefixes, &pcount);
        if (!res) {
            for (i = 0; i < pcount; i++) {
                free(prefixes[i]);
            }
            ST(0) = &PL_sv_undef;
        } else {
            for (i = 0; i < pcount; i++) {
                XPUSHs(sv_2mortal(newSVpv(prefixes[i], 0)));

NetIpXs.xs  view on Meta::CPAN

        RETVAL

void
ip_prefix_to_range(ip, len, version)
        char *ip
        int len
        int version
    PREINIT:
        char buf[MAX_IPV6_RANGE_STR_LEN];
        int res;
    PPCODE:
        res = NI_ip_prefix_to_range(ip, len, version, buf);
        if (res) {
            XPUSHs(sv_2mortal(newSVpv(ip, 0)));
            XPUSHs(sv_2mortal(newSVpv(buf, 0)));
        } else {
            ST(0) = &PL_sv_undef;
        }

SV *
ip_reverse(ip, len, ipversion)

NetIpXs.xs  view on Meta::CPAN

    OUTPUT:
        RETVAL

void
ip_normalize(ip)
        char *ip
    PREINIT:
        char buf1[MAX_IPV6_STR_LEN];
        char buf2[MAX_IPV6_STR_LEN];
        int res;
    PPCODE:
        buf1[0] = '\0';
        buf2[0] = '\0';
        res = NI_ip_normalize(ip, buf1, buf2);
        if (res >= 1) {
            XPUSHs(sv_2mortal(newSVpv(buf1, 0)));
        }
        if (res >= 2) {
            XPUSHs(sv_2mortal(newSVpv(buf2, 0)));
        }

NetIpXs.xs  view on Meta::CPAN

        RETVAL

void
find_prefixes(self)
        SV *self
    PREINIT:
        char *prefixes[MAX_PREFIXES];
        int pcount;
        int res;
        int i;
    PPCODE:
        if (!sv_isa(self, "Net::IP::XS")) {
            ST(0) = &PL_sv_undef;
        } else {
            pcount = 0;
            res = NI_find_prefixes(self, prefixes, &pcount);
            if (!res) {
                for (i = 0; i < pcount; i++) {
                    free(prefixes[i]);
                }
                ST(0) = &PL_sv_undef;



( run in 0.624 second using v1.01-cache-2.11-cpan-5511b514fd6 )