payload101 has asked for the wisdom of the Perl Monks concerning the following question:

Compiling libdnet on Ubuntu 9.10 fails. First failure was the same as post problems with libdnet module with file dnet.h not found. I made the recommended changes to Libdnet.xs and Makefile.PL. I did the perl Makefile.PL and the make which failed with the following errors.

Thanks

make cc -c -I/usr/include -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict- +aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSE +T_BITS=64 -O2 -g -DVERSION=\"0.92\" -DXS_VERSION=\"0.92\" -fPIC "-I +/usr/lib/perl/5.10/CORE" Libdnet.c Libdnet.xs:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ + before ‘TunHandle’ Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_open’: Libdnet.c:1963: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:1963: error: (Each undeclared identifier is reported only on +ce Libdnet.c:1963: error: for each function it appears in.) Libdnet.c:1963: error: ‘RETVAL’ undeclared (first use in this function +) Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_fileno’: Libdnet.c:1994: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:1994: error: ‘handle’ undeclared (first use in this function +) Libdnet.c:2000: error: expected expression before ‘)’ token Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_name’: Libdnet.c:2028: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:2028: error: ‘handle’ undeclared (first use in this function +) Libdnet.c:2034: error: expected expression before ‘)’ token Libdnet.xs:1208: warning: assignment makes pointer from integer withou +t a cast Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_send’: Libdnet.c:2062: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:2062: error: ‘handle’ undeclared (first use in this function +) Libdnet.c:2070: error: expected expression before ‘)’ token Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_recv’: Libdnet.c:2098: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:2098: error: ‘handle’ undeclared (first use in this function +) Libdnet.c:2108: error: expected expression before ‘)’ token Libdnet.c: In function ‘XS_Net__Libdnet_dnet_tun_close’: Libdnet.c:2142: error: ‘TunHandle’ undeclared (first use in this funct +ion) Libdnet.c:2142: error: ‘handle’ undeclared (first use in this function +) Libdnet.c:2143: error: ‘RETVAL’ undeclared (first use in this function +) Libdnet.c:2147: error: expected expression before ‘)’ token make: *** [Libdnet.o] Error 1

Replies are listed 'Best First'.
Re: libdnet make fails
by syphilis (Archbishop) on Feb 03, 2010 at 01:38 UTC
    Libdnet.xs:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘TunHandle’

    If you can fix that, the other errors will also be fixed. Unfortunately, it's not apparent to me what the problem is. The relevant section of Libdnet.xs is:
    39: typedef blob_t Blob; 40: typedef eth_addr_t EthAddr; 41: typedef eth_t EthHandle; 42: typedef intf_t IntfHandle; 43: typedef arp_t ArpHandle; 44: typedef fw_t FwHandle; 45: typedef route_t RouteHandle; 46: typedef tun_t TunHandle; 47: typedef ip_t IpHandle; 48: typedef struct intf_entry IntfEntry; 49: typedef struct arp_entry ArpEntry; 50: typedef struct fw_rule FwRule; 51: typedef struct route_entry RouteEntry;
    So, why does it pick on line 46 ?
    Could it be that the run_t type is unknown ? (Perhaps your version of libdnet does not define the type.) But if that were the case, I would have also expected a warning along the lines of "data definition has no type or storage class". Yet I don't see any such warning.

    Were there any warnings issued prior to the excerpt you've quoted above ?
    Does your dnet.h (or one of the header files included by it) define the run_t type ?

    Cheers,
    Rob
Re: libdnet make fails
by payload101 (Initiate) on Feb 03, 2010 at 19:21 UTC
    Thank you for the reply. The output shown is the complete output from make. The module is as downloaded from CPAN Net::Libdnet (Net-Libdnet-0.92). I will look at the include files as you suggested. It will take a bit of time being a noob at this. I am attempting to get Net::Packet installed and working on Ubuntu 9.10 so that I can run the following perl script and do some testing of code fixes in other devices and systems.
    my $host = shift; my $port = shift; use Net::Packet qw($Env); use Net::Packet::IPv4; my $ip = Net::Packet::IPv4->new(dst => $host); use Net::Packet::TCP; my $tcp = Net::Packet::TCP->new( dst => $port, options => "\x65\x02\x01\x01", ); use Net::Packet::Frame; my $frame = Net::Packet::Frame->new(l3 => $ip, l4 => $tcp); $frame->send;
      Not sure if you are still here. For everyones benefit, ill tell you how i made it work. Since i had no need of working with Tunnel interfaces, i removed all references to tun_t / TunHandle from .xs file. And it works. Btw, you might want to use Net::Frame as thats the one which is used. Net::Packet is deprecated