Fedora Linux Support Community & Resources Center
  #1  
Old 29th January 2010, 05:02 AM
era_pk Offline
Registered User
 
Join Date: Jan 2008
Location: Pakistan
Posts: 20
windows_xp_2003firefox
Question socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL) behaviour

Dear All,

I am writing a small packet sniffing application to perform some operations. The following call

SOCKET_ID = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));

works fine on my Linux kernel 2.6.20 but it returns a negative value on Linux kernel 2.4.26.
I am running my application with root privileges.


Is PF_PACKET & SOCK_RAW available to kernel 2.6 or other kernel versions as well


Any ideas?
__________________
Dont follow me. I m always late :)
Reply With Quote
  #2  
Old 1st August 2010, 02:11 PM
backyes Offline
Registered User
 
Join Date: Aug 2010
Posts: 1
linuxchrome
Re: socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL) behaviour

Maybe the AF_PACKET module is invalid.
Reply With Quote
  #3  
Old 1st August 2010, 03:01 PM
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,765
linuxfedorafirefox
Re: socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL) behaviour

This is from F13.
[root@nidula ~]# strace -f -etrace=socket /usr/sbin/tcpdump -i eth1
socket(PF_PACKET, SOCK_RAW, 768) = 3
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
....


So there is nothing wrong with socket(PF_PACKET, SOCK_RAW,...
and your third arg to socket looks correct.

Maybe it's time you checked the errno !

There is a chance that you need to deal with either SELinux or else the capabilities.
See pscap and getcap
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe

Last edited by stevea; 1st August 2010 at 03:57 PM.
Reply With Quote
Reply

Tags
pf_packet, socket, sock_raw

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling Socket arkkundan Servers & Networking 1 4th December 2008 11:02 AM
raw socket baappi Programming & Packaging 0 21st December 2007 11:23 AM
Talk daemon and Socket operation on non-socket Br0kan Using Fedora 3 1st March 2006 07:29 PM
Socket jai Programming & Packaging 6 23rd January 2006 10:38 AM
Socket program in C/C++ JPEM Programming & Packaging 8 26th September 2005 05:08 AM


Current GMT-time: 12:40 (Wednesday, 20-08-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat