C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-10-2009, 09:27 AM   #1
Registered User
 
Join Date: Feb 2008
Posts: 24
Parsing pcap without libpcap

Hello fellows.

I'm writing an application for iPhone (using objective-c) but as I want it to parse a pcap file (packet dump) I thought of writing that part in strict C.

The thing is, I'm not really sure how to do this. I've googled for resources but have yet to find anything.

I have to parse the contents of a pcap dump file so that I can add each packets to a table that I've already set up.

Do you have any resources of small snippets on how to successfully parse a pcap file?

Regards,
n1mda
n1mda is offline   Reply With Quote
Old 06-10-2009, 09:35 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,688
Why do you want to decode a pcap file on an iPhone?

How did the pcap file get there in the first place?
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 06-10-2009, 09:47 AM   #3
Registered User
 
Join Date: Feb 2008
Posts: 24
It's supposed to be a packet analyzer on the go, and it is also possible (for jailbroken devices) to sniff and collect packets.

The thing is that since this app should enter the appstore, I can not use libpcap, so I have to code my own functions.
n1mda is offline   Reply With Quote
Old 06-10-2009, 11:59 AM   #4
Registered User
 
Join Date: Oct 2008
Location: TX
Posts: 1,442
libpcap makes extensive use of the dlpi() APIs; not sure if iPhone has support for them though you can browse its source for some pointers.
itCbitC is offline   Reply With Quote
Old 06-10-2009, 02:04 PM   #5
Registered User
 
Join Date: Feb 2008
Posts: 24
I've gone over the parts of the sourcecode from libpcap that I want, but it is still really huge with a lot of structs and other things I don't really need. I simply want to open a pcap dump and print it's content using the given structure (timestamp, caplen and len)

This shouldn't be to hard but as still quite a novice and an idiot when it comes to logics I could need some advice and hints.

pcap_fopen_offline() is the function I want to reconstruct but it contain's a lot of info that makes no sense to me.
n1mda is offline   Reply With Quote
Old 06-15-2009, 01:52 PM   #6
Registered User
 
Join Date: Feb 2008
Posts: 24
I still need help with this, does anyone have any information?
n1mda is offline   Reply With Quote
Old 06-15-2009, 03:05 PM   #7
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 10,640
I'm pretty sure no one here feels like writing their own version of libpcap. Programming with pcap


Quzah.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?
quzah is offline   Reply With Quote
Old 06-16-2009, 01:21 AM   #8
Registered User
 
Join Date: Feb 2008
Posts: 24
Oh don't get me wrong, I don't want someone to write it for me. Definitly not, I'm probably capable of doing it myself. Just wanted to see if someone already wrote a small wrapper that handles offline file controlling.
n1mda is offline   Reply With Quote
Old 06-16-2009, 04:43 PM   #9
30 Helens Agree
 
neandrake's Avatar
 
Join Date: Jan 2002
Posts: 607
So you're just looking to read data from a file and display it? This problem is not specific to (lib)pcap, rather to file I/O. Learn the format which the data is stored in and parse it.

http://www.cprogramming.com/tutorial/c/lesson10.html
__________________

AIM: Neandrake
EMAIL: nta0 @ yahoo . com

Operating System: Windows XP SP2
Compiler: GCC
IDE: Notepad++


Don't give up your freedom to think - www.cognitiveliberty.org
neandrake is offline   Reply With Quote
Old 06-18-2009, 12:35 AM   #10
Registered User
 
Join Date: Feb 2008
Posts: 24
Thank you for the tip!
I've started out and it's actually coming along pretty well, I have so far been able to read the header of the dump file and can parse that pretty easy.

I'll post some code later if I run in to any problems or when I think it's finished, so you guys perhaps could take a look and clean it up Data and memory management is pretty important, since pcapfiles could end up to be quite a lot of data, but the iPhone only has about 25Mb RAM to work with, which includes my gui.
n1mda is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pcap and ipv6 IsmAvatar2 Networking/Device Communication 1 06-10-2008 10:25 AM
pcap "packet" processing and storage ForensicsGuy817 C Programming 3 04-11-2008 12:28 PM
draw tree graph of yacc parsing talz13 C Programming 2 07-23-2006 01:33 AM
Parsing for Dummies MisterWonderful C++ Programming 4 03-08-2004 05:31 PM
I hate string parsing with a passion DavidP A Brief History of Cprogramming.com 2 03-19-2002 07:30 PM


All times are GMT -6. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22