Net-IP-XS
view release on metacpan or search on metacpan
OUTPUT:
RETVAL
void
ip_set_Errno(data, num)
void *data
int num
CODE:
NI_set_Errno(num);
SV *
ip_is_ipv4(ip)
char *ip
CODE:
RETVAL = newSViv(NI_ip_is_ipv4(ip));
OUTPUT:
RETVAL
SV *
ip_is_ipv6(ip)
char *ip
CODE:
RETVAL = newSViv(NI_ip_is_ipv6(ip));
OUTPUT:
RETVAL
SV *
ip_binadd(begin, end)
char *begin
char *end
PREINIT:
char buf[IPV6_BITSTR_LEN];
int res;
CODE:
buf[0] = '\0';
res = NI_ip_binadd(begin, end, buf, IPV6_BITSTR_LEN);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_get_prefix_length(bin1, bin2)
char *bin1
char *bin2
PREINIT:
int res;
int result;
CODE:
res = NI_ip_get_prefix_length(bin1, bin2, &result);
RETVAL = (res) ? newSViv(result) : &PL_sv_undef;
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
PREINIT:
int res;
CODE:
res = NI_ip_is_valid_mask(mask, ipversion);
RETVAL = (res) ? newSViv(1) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_expand_address(ip, ipversion)
char *ip
int ipversion
PREINIT:
int res;
char buf[MAX_IPV6_STR_LEN];
CODE:
buf[0] = '\0';
res = NI_ip_expand_address(ip, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_bincomp(begin, op_arg, end)
char *begin
char *op_arg
char *end
PREINIT:
int res;
int result;
CODE:
res = NI_ip_bincomp(begin, op_arg, end, &result);
RETVAL = (res) ? newSViv(result) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_get_mask(len, ipversion)
int len
int ipversion
PREINIT:
int res;
char buf[128];
CODE:
res = NI_ip_get_mask(len, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, NI_iplengths(ipversion)) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
int res;
CODE:
buf[0] = '\0';
res = NI_ip_bintoip(ip, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_iptobin(ip, ipversion)
char *ip
int ipversion
PREINIT:
char buf[128];
int res;
CODE:
res = NI_ip_iptobin(ip, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, NI_iplengths(ipversion))
: &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_is_overlap(b1, e1, b2, e2)
char *b1
char *e1
char *b2
char *e2
PREINIT:
int res;
int result;
CODE:
res = NI_ip_is_overlap(b1, e1, b2, e2, &result);
RETVAL = (res) ? newSViv(result) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_check_prefix(ip, len, ipversion)
char *ip
int len
int ipversion
PREINIT:
int res;
CODE:
res = NI_ip_check_prefix(ip, len, ipversion);
RETVAL = (res) ? newSViv(res) : &PL_sv_undef;
OUTPUT:
RETVAL
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)));
free(prefixes[i]);
}
}
SV *
ip_get_embedded_ipv4(ipv6)
char *ipv6
PREINIT:
char buf[16];
int res;
CODE:
res = NI_ip_get_embedded_ipv4(ipv6, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_aggregate(b1, e1, b2, e2, ipversion)
char *b1
char *e1
char *b2
char *e2
int ipversion
PREINIT:
char buf[MAX_IPV6_RANGE_STR_LEN];
int res;
CODE:
res = NI_ip_aggregate(b1, e1, b2, e2, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
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)
char *ip
int len
int ipversion
PREINIT:
char buf[MAX_IPV6_REVERSE_LEN];
int res;
CODE:
buf[0] = '\0';
res = NI_ip_reverse(ip, len, ipversion, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
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)));
}
SV *
ip_normal_range(ip)
char *ip
PREINIT:
char buf[MAX_IPV6_NORMAL_RANGE];
int res;
CODE:
res = NI_ip_normal_range(ip, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_compress_address(ip, version)
char *ip
int version
PREINIT:
char buf[MAX_IPV6_STR_LEN];
int res;
CODE:
buf[0] = '\0';
res = NI_ip_compress_address(ip, version, buf);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_compress_v4_prefix(ip, len)
char *ip
int len
PREINIT:
char buf[MAX_IPV4_RANGE_STR_LEN];
int res;
CODE:
buf[0] = '\0';
res = NI_ip_compress_v4_prefix(ip, len, buf,
MAX_IPV4_RANGE_STR_LEN);
RETVAL = (res) ? newSVpv(buf, 0) : &PL_sv_undef;
OUTPUT:
RETVAL
SV *
ip_iptype(ip, ipversion)
char *ip
int ipversion
PREINIT:
char buf[MAX_TYPE_STR_LEN];
int res;
CODE:
res = NI_ip_iptype(ip, ipversion, buf);
OUTPUT:
RETVAL
SV *
binadd(self, other)
SV *self
SV *other
PREINIT:
SV *new_ip;
CODE:
if (!sv_isa(self, "Net::IP::XS") || !sv_isa(other, "Net::IP::XS")) {
RETVAL = &PL_sv_undef;
} else {
new_ip = NI_binadd(self, other);
RETVAL = (new_ip) ? new_ip : &PL_sv_undef;
}
OUTPUT:
RETVAL
SV *
aggregate(self, other)
SV *self
SV *other
PREINIT:
SV *new_ip;
CODE:
if (!sv_isa(self, "Net::IP::XS") || !sv_isa(other, "Net::IP::XS")) {
RETVAL = &PL_sv_undef;
} else {
new_ip = NI_aggregate(self, other);
RETVAL = (new_ip) ? new_ip : &PL_sv_undef;
}
OUTPUT:
RETVAL
SV *
overlaps(self, other)
SV *self
SV *other
PREINIT:
int res;
int result;
CODE:
if (!sv_isa(self, "Net::IP::XS") || !sv_isa(other, "Net::IP::XS")) {
RETVAL = &PL_sv_undef;
} else {
res = NI_overlaps(self, other, &result);
RETVAL = (res) ? newSViv(result) : &PL_sv_undef;
}
OUTPUT:
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;
} else {
for (i = 0; i < pcount; i++) {
XPUSHs(sv_2mortal(newSVpv(prefixes[i], 0)));
free(prefixes[i]);
}
}
}
SV *
ip_add_num(self, num, unused)
SV *self
char *num
SV *unused
PREINIT:
SV *new_ip;
CODE:
if (!sv_isa(self, "Net::IP::XS")) {
RETVAL = &PL_sv_undef;
} else {
new_ip = NI_ip_add_num(self, num);
RETVAL = (new_ip) ? new_ip : &PL_sv_undef;
}
OUTPUT:
RETVAL
SV *
set_ipv6_n128s(self)
SV *self
PREINIT:
int res;
CODE:
if (!sv_isa(self, "Net::IP::XS")) {
RETVAL = &PL_sv_undef;
} else {
res = NI_set_ipv6_n128s(self);
RETVAL = (res) ? newSViv(1) : &PL_sv_undef;
}
OUTPUT:
RETVAL
( run in 0.740 second using v1.01-cache-2.11-cpan-5511b514fd6 )