-
Notifications
You must be signed in to change notification settings - Fork 18.1k
[libc] Add struct sockaddr_in #197909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Add struct sockaddr_in #197909
Changes from 1 commit
c86b410
9c11754
12ba7f6
15a0ad2
d8eaf05
2002b1f
00af0e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Definition of macros from netinet/in.h. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_HDR_NETINET_IN_MACROS_H | ||
| #define LLVM_LIBC_HDR_NETINET_IN_MACROS_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-macros/netinet-in-macros.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include <netinet/in.h> | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_NETINET_IN_MACROS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Proxy for struct sockaddr_in. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
| #ifndef LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_IN_H | ||
| #define LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_IN_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/struct_sockaddr_in.h" | ||
|
|
||
| #else | ||
|
|
||
| #include <netinet/in.h> | ||
|
|
||
| #endif // LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_IN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Definition of struct sockaddr_in. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_TYPES_STRUCT_SOCKADDR_IN_H | ||
| #define LLVM_LIBC_TYPES_STRUCT_SOCKADDR_IN_H | ||
|
|
||
| #include "in_port_t.h" | ||
| #include "sa_family_t.h" | ||
| #include "struct_in_addr.h" | ||
|
|
||
| // This is the sockaddr specialization for AF_INET sockets, as | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't critical, but I wonder if this should be a doxygen comment on top (since we're introducing \file, I've been wondering what else we should be doing) (OK to not do this, just as a thought)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LLVM hasn't been very consistent in use of doxygen comments, but yeah, this very much is a file-level comment, so let's move that there. |
||
| // defined by posix. | ||
|
|
||
| struct __attribute__((may_alias)) sockaddr_in { | ||
| sa_family_t sin_family; /* AF_INET */ | ||
| in_port_t sin_port; | ||
| struct in_addr sin_addr; | ||
|
|
||
| // For historic reasons, AF_INET addresses are 16 bytes. Users are not | ||
| // expected to access the padding field, but it traditionally uses a | ||
| // non-private name. | ||
| char sin_zero[8]; | ||
| }; | ||
|
|
||
| #endif // LLVM_LIBC_TYPES_STRUCT_SOCKADDR_IN_H | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is 4.3BSD? We should get say that if that's right (or as close as we can figure out) rather than what it's not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI seems to think that is the case, but I don't see any evidence supporting that (in fact, I see evidence disproving that). The closest I got was SVR4: https://github.com/calmsacibis995/svr4-src/blob/7dabeda6fc10bd1bbd1a84d502f05642b1bf0c9e/uts/i386/netinet/in.h#L198