Re: FreeBSD libnet_pblock_find() problem

Frédéric Raynal <[email protected]> Tue, 1 Mar 2005 20:16:23 +0100
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
On Mon, Feb 28, 2005 at 11:30:12PM -0300, Victor Lima wrote:
> void
> echo_server ( const unsigned char *packet ) {
> ...
>  libnet_t               *lnet;
> ... 
>         udp = libnet_build_udp( ntohs( udp_hdr->uh_dport ),
>                                 ntohs( udp_hdr->uh_sport ),
>                                 LIBNET_UDP_H + strlen( payload ),
>                                 0,
>                                 payload,
>                                 strlen(payload),
>                                 lnet,
>                                 udp );
> 
>         if( udp == -1 ) {
>               fprintf (stderr, "%s: libnet_build_udp() failed: %s\n",
>                                 prefix, libnet_geterror(lnet));
>                 goto bad;
>         }
> -----------------------
> 
>         Whenever I run it, it first blocks on libpcap listening for
>  packets, after it recieves one it sends the packet to echo_server, where
>  the appropriate headers are pointed to the correct places in the packet,
>  so that I can build a response based on the received information. The
>  code compiles with no problem except that when I run it, libnet_build_udp
>  returns -1 and the following error message appears:
> 
> ---
> libnet_pblock_find() - couldn't find protocol block
> ---
>          Ive googled a bit, and found a few misleading answers none that
>  solved my problem, so I came here. Hope you guys can help me...

Just a try ...

Your udp variable is not initialised. So I guess it is not 0. Hence,
libnet_build_udp() tries to find the pblock referred by this value,
but cant find it.

Try to set udp = 0; during the initialisation, and it should run
properly.

	Fred Raynal