LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 04-27-2012, 02:29 PM   #1
bayoulinux
Member
 
Registered: Oct 2011
Posts: 34

Rep: Reputation: Disabled
sockets: AF_PACKET versus PF_PACKET


Hi:

I'm new to socket programming... I notice that within the kernel AF_PACKET and PF_PACKET are defined to be the same, as do many (all?) AF_* and PF_* definitions.

When I create a socket:

socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));

or

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

I was just wondering what's the history, or the reasoning, for both the existence of AF_PACKET and PF_PACKET? Differences?

Thanks!
 
Old 04-27-2012, 05:03 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by bayoulinux View Post
AF_PACKET and PF_PACKET are defined to be the same, as do many (all?) AF_* and PF_* definitions.
Yes. AF_foo means address family foo, and PF_foo means protocol family foo. In Linux, they are always been the same values, I believe.

Traditionally, the PF_foo constants were used for socket(), but AF_foo in the struct sockaddr structure.

According to man 2 socket, even the (historical) BSD 4.x manpage states that "The protocol family generally is the same as the address family", and subsequent standards use AF_* everywhere.

Thus, today, there really should be no difference between AF_foo and PF_foo.
 
  


Reply



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
LXer: TLWIR 35: Open Versus Closed Mobility â?? The Nokia N900 Versus The Nokia Lumia 900 LXer Syndicated Linux News 0 04-07-2012 06:31 PM
Receive self-sent packages with au AF_PACKET, SOCK_RAW socket TheJonnyX Programming 0 12-19-2011 12:48 PM
[SOLVED] bash - versus --perl - versus python ow1 Linux - Software 2 05-03-2010 07:57 PM
Program to forward tcp sockets to unix domain sockets mikepol Linux - Networking 0 09-27-2007 09:49 AM
Chkrootkit : ppp0: not promisc and no PF_PACKET sockets tour Linux - Security 6 08-06-2004 12:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:32 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration