LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-13-2003, 01:44 AM   #1
smn
LQ Newbie
 
Registered: Nov 2003
Distribution: red hat 9
Posts: 3

Rep: Reputation: 0
capture packets with libpcap.


i'm trying to capture packets between my computer and internet, then i copy codes from examples. now i get two questions about libpcap.
i wrote these:

pcap_lookupdev(...);
pcap_lookupnet(...);
pcap_open_live(...);
pcap_loop(...);

and in my callbak function

u_int16_t handle_ethernet(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *packet)
{
struct ether_header *eptr;
eptr=(struct ether_header*)packet;
if(ntohs(eptr->ether_type)==ETHERTYPE_IP)
{
printf("ip\n");
}
else if(ntohs(eptr->ether_type)==ETHERTYPE_ARP)
{
printf("arp\n");
}
elseif(ntohs(eptr->ether_type)==ETHERTYPE_REVARP)
{
printf("revarp\n");
}
else
printf("unknown\n");
...
}

1. when i connect to internet via ADSL modem and "ping google.com", the programm always prints "unknown", shouldn't it be "ip"? if not, what is it? and when i ping the ADSL modem like this--ping 192.168.1.1, it prints "ip".

2. how can i know what the destinaion ip and source ip is? in brief, i want to get this "from 202.96.128.68 to 66.11.22.33" while i "ping google.com", can i do that with libpcap?


thanks.

Last edited by smn; 11-13-2003 at 07:17 PM.
 
Old 11-18-2003, 11:11 PM   #2
smn
LQ Newbie
 
Registered: Nov 2003
Distribution: red hat 9
Posts: 3

Original Poster
Rep: Reputation: 0
no one helps me?
 
Old 11-19-2003, 06:02 PM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
DSL is PPP, not broadcast. that means all those ethernet tests you are doing are worthless as you are not on an ethernet. that is unless you are behind a router on a LAN?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building libpcap with pf_ring Machiaveli Linux - Software 1 12-15-2005 05:58 AM
Which rel. of libpcap for RH9????? DeepakRajendran Linux - General 2 04-13-2005 01:10 AM
mandrake 9.2 libpcap problem ziegen Mandriva 1 11-07-2003 01:24 AM
libpcap trojan baduba Linux - Security 3 11-20-2002 06:00 AM
libpcap oulevon Linux - General 1 09-25-2001 09:06 AM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration