Why protocol families macros and address families macros are duplicatedWhy doesn't “cd” work in a shell script?What are the differences among grep, awk & sed?why does <linux/socket.h> file not define socket types?vmalloc_to_pfn returns 32 bit address on Linux 32 system. Why does it chop off higher bits of PAE physical address?Why this macro is defined as ( 1; )?Difference between SIOCGIFCONF and NETLINK protocol results when enumerating IPv6 addresses on LinuxWhy Linux/gnu linker chose address 0x400000?What address families can getaddrinfo return?Why does the C preprocessor interpret the word “linux” as the constant “1”?understanding the protocol family argument of socket() and result list of getaddrinfo()
Where can I get an anonymous Rav Kav card issued?
Why would "an mule" be used instead of "a mule"?
How to help my 2.5-year-old daughter take her medicine when she refuses to?
Linear Programming with additional "if-then"/"Default to zero" constraints?
Why did it become so much more expensive to start a university?
Why is Kirchoff's loop rule true in a DC circuit?
Uncovering the Accelerated Dragon opening
What officially disallows US presidents from driving?
Is there any way to land a rover on the Moon without using any thrusters?
Has SHA256 been broken by Treadwell Stanton DuPont?
Resume: How to quantify my contributions as a software engineer?
Can a corpse possessed by a Dybbuk be turned via Turn Undead?
Might have gotten a coworker sick, should I address this?
Will replacing a fake visa with a different fake visa cause me problems when applying for a legal study permit?
Sol Ⅲ = Earth: What is the origin of this planetary naming scheme?
Can the UK veto its own extension request?
Integer Decision Variables Always Forced to Zero in Minimization Problem (MINLP)
What are uses of the byte after BRK instruction on 6502?
Do they still use tiger roars in the 2019 "Lion King" movie?
Are Democrats more likely to believe Astrology is a science?
Telling my mother that I have anorexia without panicking her
Can I disable a battery powered device by reversing half of its batteries?
I asked for a graduate student position from a professor. He replied "welcome". What does that mean?
How is Team Scooby Doo (Mystery Inc.) funded?
Why protocol families macros and address families macros are duplicated
Why doesn't “cd” work in a shell script?What are the differences among grep, awk & sed?why does <linux/socket.h> file not define socket types?vmalloc_to_pfn returns 32 bit address on Linux 32 system. Why does it chop off higher bits of PAE physical address?Why this macro is defined as ( 1; )?Difference between SIOCGIFCONF and NETLINK protocol results when enumerating IPv6 addresses on LinuxWhy Linux/gnu linker chose address 0x400000?What address families can getaddrinfo return?Why does the C preprocessor interpret the word “linux” as the constant “1”?understanding the protocol family argument of socket() and result list of getaddrinfo()
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In bits/socket.h of Linux systems, the address families macros are defined in terms of protocol families macros. there is a one-to-one correspondence among them with the form of
#define AF_something PF_something
Since the one-to-to mapping between the AF macros and the PF macros, they seem like unnecessary duplications.
My question is: is there a reason for this?
linux sockets
add a comment
|
In bits/socket.h of Linux systems, the address families macros are defined in terms of protocol families macros. there is a one-to-one correspondence among them with the form of
#define AF_something PF_something
Since the one-to-to mapping between the AF macros and the PF macros, they seem like unnecessary duplications.
My question is: is there a reason for this?
linux sockets
1
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30
add a comment
|
In bits/socket.h of Linux systems, the address families macros are defined in terms of protocol families macros. there is a one-to-one correspondence among them with the form of
#define AF_something PF_something
Since the one-to-to mapping between the AF macros and the PF macros, they seem like unnecessary duplications.
My question is: is there a reason for this?
linux sockets
In bits/socket.h of Linux systems, the address families macros are defined in terms of protocol families macros. there is a one-to-one correspondence among them with the form of
#define AF_something PF_something
Since the one-to-to mapping between the AF macros and the PF macros, they seem like unnecessary duplications.
My question is: is there a reason for this?
linux sockets
linux sockets
asked Mar 28 at 9:04
John Z. LiJohn Z. Li
8457 silver badges15 bronze badges
8457 silver badges15 bronze badges
1
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30
add a comment
|
1
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30
1
1
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30
add a comment
|
1 Answer
1
active
oldest
votes
The original idea was to have address and protocol families independent. An address can potentially be used in various protocols. Authors expected that for example IPv4 address can be used by another hypothetical protocol different than IP. And vice versa - independent families are prepared to use a new kind of addresses in IP protocol.
So the only reason is that author of the socket API wanted to be future proof. As far as I know there is still one to one mapping between PF and AF.
It is a good habit to follow the original idea. That means have independent constant and use PF constants when working with protocol for example creating socket: s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
and use AF constant when working with addresses for example sa.sin_family = AF_INET
.
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393683%2fwhy-protocol-families-macros-and-address-families-macros-are-duplicated%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The original idea was to have address and protocol families independent. An address can potentially be used in various protocols. Authors expected that for example IPv4 address can be used by another hypothetical protocol different than IP. And vice versa - independent families are prepared to use a new kind of addresses in IP protocol.
So the only reason is that author of the socket API wanted to be future proof. As far as I know there is still one to one mapping between PF and AF.
It is a good habit to follow the original idea. That means have independent constant and use PF constants when working with protocol for example creating socket: s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
and use AF constant when working with addresses for example sa.sin_family = AF_INET
.
add a comment
|
The original idea was to have address and protocol families independent. An address can potentially be used in various protocols. Authors expected that for example IPv4 address can be used by another hypothetical protocol different than IP. And vice versa - independent families are prepared to use a new kind of addresses in IP protocol.
So the only reason is that author of the socket API wanted to be future proof. As far as I know there is still one to one mapping between PF and AF.
It is a good habit to follow the original idea. That means have independent constant and use PF constants when working with protocol for example creating socket: s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
and use AF constant when working with addresses for example sa.sin_family = AF_INET
.
add a comment
|
The original idea was to have address and protocol families independent. An address can potentially be used in various protocols. Authors expected that for example IPv4 address can be used by another hypothetical protocol different than IP. And vice versa - independent families are prepared to use a new kind of addresses in IP protocol.
So the only reason is that author of the socket API wanted to be future proof. As far as I know there is still one to one mapping between PF and AF.
It is a good habit to follow the original idea. That means have independent constant and use PF constants when working with protocol for example creating socket: s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
and use AF constant when working with addresses for example sa.sin_family = AF_INET
.
The original idea was to have address and protocol families independent. An address can potentially be used in various protocols. Authors expected that for example IPv4 address can be used by another hypothetical protocol different than IP. And vice versa - independent families are prepared to use a new kind of addresses in IP protocol.
So the only reason is that author of the socket API wanted to be future proof. As far as I know there is still one to one mapping between PF and AF.
It is a good habit to follow the original idea. That means have independent constant and use PF constants when working with protocol for example creating socket: s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
and use AF constant when working with addresses for example sa.sin_family = AF_INET
.
answered Mar 29 at 11:48
Zaboj CampulaZaboj Campula
2,1102 gold badges18 silver badges28 bronze badges
2,1102 gold badges18 silver badges28 bronze badges
add a comment
|
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393683%2fwhy-protocol-families-macros-and-address-families-macros-are-duplicated%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
IMHO this is a bug. Both sets of constants are allocated by IANA, and they happen to have this mapping, but there is nothing at IANA that justifies defining one set in terms of the other.
– user207421
Mar 28 at 9:30