Finally, I implement this functions by looking at the Pcap.xs file (I
never made a Perl module and how no idea on how they're really created)
and it seems to be working properly. The documentation part is missing
still and I know that the implementation could be better (arguments
check and maybe some more errors checks) but at least this is a begining
(I hope).
It would be great if someone with more experience with Perl modules
check this patch and does finally implement the functions on the main
package.
Greettings.
Ernesto
--- Pcap.xs.old 2003-06-14 09:15:18.000000000 -0300
+++ Pcap.xs.new 2004-09-09 16:41:59.000000000 -0300
@@ -89,7 +89,7 @@
char *dev;
dev = pcap_lookupdev(errbuf);
- if (!strcmp(dev,"\\")) {
+ if (!strcmp(dev,"\\")) {
pcap_if_t *alldevs;
if (pcap_findalldevs(&alldevs, errbuf) == -1) {
sv_setpv(err_sv, errbuf);
@@ -114,6 +114,53 @@
err
int
+pcap_setnonblock(p, nb, err)
+ pcap_t *p
+ int nb
+ SV *err
+
+ CODE:
+ char *errbuf = safemalloc(PCAP_ERRBUF_SIZE);
+ SV *err_sv = SvRV(err);
+
+ RETVAL = pcap_setnonblock(p, nb, errbuf);
+
+ if (RETVAL == -1) {
+ sv_setpv(err_sv, errbuf);
+ } else {
+ err_sv = &PL_sv_undef;
+ }
+
+ safefree(errbuf);
+
+ OUTPUT:
+ RETVAL
+ err
+
+int
+pcap_getnonblock(p, err)
+ pcap_t *p
+ SV *err
+
+ CODE:
+ char *errbuf = safemalloc(PCAP_ERRBUF_SIZE);
+ SV *err_sv = SvRV(err);
+
+ RETVAL = pcap_getnonblock(p, errbuf);
+
+ if (RETVAL == -1) {
+ sv_setpv(err_sv, errbuf);
+ } else {
+ err_sv = &PL_sv_undef;
+ }
+
+ safefree(errbuf);
+
+ OUTPUT:
+ RETVAL
+ err
+
+int
pcap_lookupnet(device, net, mask, err)
char *device
SV *net