Commit graph

140 commits

Author SHA1 Message Date
Corentin Henry
a2bead8761 std::net: tests for Ipv4addr::is_ietf_protocol_assignment()
Also add tests to IpAddr to make sure these addresses are not global.
2019-04-22 17:41:43 +02:00
Corentin Henry
9dcfd9f58c std::net: tests for Ipv4addr::is_benchmarking()
also add test to Ipaddr, making sure that these addresses are not
global.
2019-04-22 17:41:37 +02:00
Corentin Henry
40d0127a09 std::net: tests for Ipv6addr::is_unicast_link_local{_strict}() 2019-04-22 17:41:32 +02:00
Corentin Henry
99d9bb640f std::net: fix tests for site-local ipv6 addresses
Ipv6Addr::is_unicast_global() now returns `true` for unicast site
local addresses, since they are deprecated.
2019-04-22 16:03:39 +02:00
Corentin Henry
c302d2c78f std::net: fix Ipv4addr::is_global() tests
Ipv4addr::is_global() previously considered 0/8 was global, but has
now been fixed, so these tests needed to be fixed as well.
2019-04-22 16:03:39 +02:00
Corentin Henry
c34bcc658b std::net: use macros to test ip properties 2019-04-22 16:03:39 +02:00
Corentin Henry
8106320009 std::net: fix documentation markdown 2019-04-22 16:03:39 +02:00
Corentin Henry
9f6a747b32 std::net: fix Ipv4Addr::is_global()
As per @therealbstern's comment[0]:

The implementation of Ipv4::is_global is not complete, according to the
IANA IPv4 Special-Purpose Address Registry.

        - It compares the address to 0.0.0.0, but anything in 0.0.0.0/8
          should not be considered global.
                - 0/8 is not global and is currently forbidden because
                  some systems used to treat it as the local network.
                - The implementation of Ipv4::is_unspecified is correct.
                  0.0.0.0 is the unspecified address.
        - It does not examine 100.64.0.0/10, which is "Shared Address
          Space" and not global.
        - Ditto 192.0.0.0/24 (IETF Protocol Assignments), except for
          192.0.0.9/32 and 192.0.0.10/32, which are carved out as
          globally reachable.
        - 198.18.0.0/15 is for "Benchmarking" and should not be globally
          reachable.
        - 240.0.0.0/4 is reserved and not currently reachable
2019-04-22 16:03:39 +02:00
Corentin Henry
67291cc971 std::net: add Ipv4Addr::is_shared() 2019-04-22 16:03:39 +02:00
Corentin Henry
f87b96773b std::net: add Ipv4Addr::is_ietf_protocol_assignment() 2019-04-22 16:03:39 +02:00
Corentin Henry
de3cf0d5eb std::net: add Ipv4Addr::is_benchmarking() 2019-04-22 16:03:39 +02:00
Corentin Henry
8f679977e0 std::net: add Ipv4Addr::is_reserved() 2019-04-22 16:03:32 +02:00
Corentin Henry
aea687c314 std::net: fix doc markdown in Ipv6Addr::is_unique_local() 2019-04-20 11:19:10 +02:00
Corentin Henry
1f0aa4043b std::net: add Ipv6Addr::is_unicast_link_local_strict()
RFC 4291 is a little unclear about what is a unicast link local address.
According to section 2.4, the entire fe80::/10 range is reserved for
these addresses, but section 2.5.3 defines a stricter format for such
addresses.

After a discussion[0] is has been decided to add a different method for
each definition, so this commit:

  - renames is_unicast_link_local() into is_unicast_link_local_strict()
  - relaxed the check in is_unicast_link_local()

[0]: https://github.com/rust-lang/rust/issues/27709#issuecomment-400370706
2019-04-20 11:19:10 +02:00
Corentin Henry
5aea18411e std::net: improve Ipv6Addr::is_unicast_site_local() doc
- quote the RFC
- add a link to the RFC
- fix markdown
2019-04-20 11:19:10 +02:00
Corentin Henry
02d815f3ce std::net: site-local ipv6 prefixes are global 2019-04-20 11:19:10 +02:00
Mazdak Farrokhzad
379c380a60 libstd: deny(elided_lifetimes_in_paths) 2019-03-31 12:56:51 +02:00
Taiki Endo
93b6d9e086 libstd => 2018 2019-02-28 04:06:15 +09:00
kennytm
98a6e720d0
Rollup merge of #58392 - scottmcm:less-shifting-in-net-ip, r=oli-obk
Use less explicit shifting in std::net::ip

Now that we have `{to|from}_be_bytes` the code can be simpler.

(Inspired by PR #57740)
2019-02-20 11:58:26 +08:00
bors
b244f61b77 Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments

This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).

r? @steveklabnik

Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-12 19:09:24 +00:00
Scott McMurray
5d8058477e Use less explicit shifting in std::net::ip
Now that we have {to|from}_be_bytes the code can be simpler.

(Inspired by PR #57740)
2019-02-11 23:00:01 -08:00
Alexander Regueiro
99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Guillaume Gomez
d9f9780918
Rollup merge of #57740 - JakubOnderka:ipv4addr-to_ne_bytes, r=scottmcm
Use `to_ne_bytes` for converting IPv4Addr to octets

It is easier and it should be also faster, because [`to_ne_bytes`](https://doc.rust-lang.org/std/primitive.u32.html#method.to_ne_bytes) just calls `mem::transmute`.
2019-02-10 21:45:08 +01:00
Mark Rousskov
b7f030e114 Bump bootstrap compiler to 1.33 beta 2019-01-26 08:02:08 -07:00
Jakub Onderka
87f5a98a5d
Use to_ne_bytes for converting IPv4Address to octets
It is easier and it should be also faster, because `to_ne_bytes` just calls `mem::transmute`.
2019-01-18 19:08:31 +01:00
Mazdak Farrokhzad
14be8a7f14 const-stabilize Ipv4Addr::new 2018-12-31 16:36:39 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Pietro Albini
66fcb3ceb2
Rollup merge of #55901 - euclio:speling, r=petrochenkov
fix various typos in doc comments
2018-11-15 11:04:42 +01:00
Andy Russell
4e35cbb22e
fix various typos in doc comments 2018-11-13 14:45:31 -05:00
Mazdak Farrokhzad
d1d2aa22c0 reduce list to functions callable in const ctx. 2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
f65b630d33 constify parts of libstd. 2018-11-10 01:10:07 +01:00
kennytm
fa3d56aca8
Rollup merge of #53213 - tmccombs:stable-ipconstructors, r=KodrAus
Stabilize IP associated constants

Fixes #44582
2018-08-21 01:20:10 +08:00
Thayne McCombs
e6244e5979 Stabilize IP associated constants
Fixes #44582
2018-08-14 23:43:21 -06:00
Linus Färnstrand
cbe80a9752 Replace _.. with just .. in slice pattern 2018-08-10 23:42:33 +02:00
Linus Färnstrand
f0eed1e3ff Make use of match ergonomics in ip methods 2018-08-10 21:06:37 +02:00
Linus Färnstrand
2f1f43fcd4 Use slice patterns to check IP octets 2018-08-10 21:06:36 +02:00
Linus Färnstrand
83464591ed Simplify Ipv6Addr::from(octets) to not use unsafe 2018-08-08 10:52:10 +02:00
Linus Färnstrand
d45a703a74 Simplify is_broadcast 2018-08-08 10:52:10 +02:00
Linus Färnstrand
7167a065d1 Add Ipv4Addr BROADCAST assoc const 2018-08-08 10:52:10 +02:00
Linus Färnstrand
e9a96c0433 Move IPs to assoc consts 2018-08-08 10:52:10 +02:00
Linus Färnstrand
02c272db2d Make Ipv{4,6}Addr::new const fns 2018-08-08 10:52:10 +02:00
bors
cb1f89864e Auto merge of #49418 - frewsxcv:frewsxcv-network-order, r=TimNN
Clarify network byte order conversions for integer / IP address conversions.

Opened primarily to address https://github.com/rust-lang/rust/issues/48819.

Also added a few other conversion docs/examples.
2018-04-01 10:09:58 +00:00
Corey Farwell
b89fb71441 Clarify network byte order conversions for integer / IP address conversions.
Opened primarily to address https://github.com/rust-lang/rust/issues/48819.
2018-03-28 13:17:12 +02:00
bors
188e693b39 Auto merge of #49101 - mark-i-m:stabilize_i128, r=nagisa
Stabilize 128-bit integers 🎉

cc #35118

EDIT: This should be merged only after the following have been merged:
- [x] https://github.com/rust-lang-nursery/compiler-builtins/pull/236
- [x] https://github.com/rust-lang/book/pull/1230
2018-03-26 18:41:38 +00:00
Mark Mansi
a7f21f1c0a Fix a few more 2018-03-26 08:37:56 -05:00
Phlosioneer
efd04423c3 Add backticks 2018-03-24 23:41:34 -04:00
Phlosioneer
e63b1a0e36 Remove "and may change between Rust releases" 2018-03-11 17:17:18 -04:00
Phlosioneer
908328fca0 Document when types have OS-dependent sizes
As per issue #43601, types that can change size depending on the
target operating system should say so in their documentation.

I used this template when adding doc comments:

 The size of a(n) <name> struct may vary depending on the target
 operating system, and may change between Rust releases.

For enums, I used "instance" instead of "struct".
2018-03-11 07:53:19 -04:00
varkor
bd1cf04ca7 Reject superfluous :: in IPv6 addresses
Fixes #46263.
2017-12-11 23:02:14 +00:00
Ariel Ben-Yehuda
7dbbbf6607 fix NetBSD 2017-11-26 16:12:43 +02:00