LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Libnet Seg. Fault calling libnet_pblock_new() from libnet_build_tcp() (http://www.linuxquestions.org/questions/programming-9/libnet-seg-fault-calling-libnet_pblock_new-from-libnet_build_tcp-4175428958/)

REmaxer 09-25-2012 10:34 AM

Libnet Seg. Fault calling libnet_pblock_new() from libnet_build_tcp()
 
Solved previous problem i got another one.
In building a TCP packet through libnet function libnet_build_tcp() i got a SIGSEV in calling of libnet_pblock_new() function.

This is what libnet shows:

Code:

#0  0x00007ffff7bd0bf9 in libnet_pblock_new () from /usr/lib64/libnet.so.1
No symbol table info available.
#1  0x00007ffff7bcda52 in libnet_build_tcp () from /usr/lib64/libnet.so.1
No symbol table info available.
#2  0x000000000040172c in caught_packet (user_args=0x7fffffffe458 "\020\060`",
    cap_header=0x7fffffffe3a0, packet=0x7ffff73d4046 "") at rst_hijack.c:86
        libnet_ctx = 0x7fffffffe458
        bcount = 0
        IPhdr = 0x7ffff73d4054
        TCPhdr = 0x7ffff73d4068
        source_ip = 1008806360678825902
        dest_ip = 9214452798765137930

and the SIGSEV:

Code:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd0bf9 in libnet_pblock_new () from /usr/lib64/libnet.so.1

My code:

Code:

        libnet_build_tcp(htons(TCPhdr->th_dport),//Source port
                                htons(TCPhdr->th_sport),//Destination port
                                htonl(TCPhdr->th_ack),//SEQ
                                htonl(libnet_get_prand(LIBNET_PRu32)),//Ack
                                TH_RST,//control flags
                                libnet_get_prand(LIBNET_PRu16),//Win Size
                                0,//Sum
                                0,//Urgent pointer
                                LIBNET_TCP_H,//tcp len
                                NULL,//Payload
                                0,//Payload length
                                libnet_ctx,//Libnet Context
                                0//Ptag IPv4 Header
                                );

TCPhdr is a struct which contains a TCP header, libnet_ctx is a libnet context .

What's wrong with it ?


All times are GMT -5. The time now is 06:01 AM.