The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Libpcap: Set a filter. (C) Dedalus High Level Programming 2 06-02-2009 11:25 AM
Understanding PCI Express Maximum Payload Size on OpenSolaris iBot Solaris BigAdmin RSS 0 12-18-2008 09:20 AM
libpcap 1.0.0 (Default branch) iBot Software Releases - RSS News 0 10-28-2008 09:40 PM
libpcap++ 0.0.2 (Default branch) iBot Software Releases - RSS News 0 04-16-2008 02:00 AM
libpcap++ 0.0.1 (Default branch) iBot Software Releases - RSS News 0 04-11-2008 01:10 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
shuwo shuwo is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 1
Extract payload with libpcap

hi!

im having a problem while extracting payload from a tcp packet that is captured with libpcap. this is what ive got so far:

PHP Code:
const struct ethernet_header *ethernet;
    const 
struct ip_header *ip;
    const 
struct tcp_header *tcp;
    const 
char *payload;
    
u_int size_ip;
    
u_int size_tcp;

    
ip = (struct ip_header*)(packet SIZE_ETHERNET);
    
size_ip IP_HL(ip)*4;    

    
tcp = (struct tcp_header*)(packet SIZE_ETHERNET size_ip);
    
size_tcp TH_OFF(tcp)*4;
    
   
payload = (u_char *)(packet SIZE_ETHERNET size_ip size_tcp); 
the result look like this:

actual payload: foobar
my program shows: foobar

actual payload 2: foo
my program shows:
foo
ar

data from the last payload is still there somehow.. maybe i need to clean the memory or something after each packet.. i dunno!

hope youll understand! thanks

---------- Post updated at 11:58 AM ---------- Previous update was at 07:45 AM ----------

another question:

how do i get the correct seq and ack numbers from the tcp struct? when i print them i get just get really big numbers.. and when i check them in wireshark they should be like 1,2,3
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0