diff options
author | Micael Karlberg <bmk@erlang.org> | 2019-11-25 14:26:12 +0100 |
---|---|---|
committer | Micael Karlberg <bmk@erlang.org> | 2019-11-25 18:30:40 +0100 |
commit | 2fac8c62f5c7a360d33791c5b37e629b567e653a (patch) | |
tree | 7bc411cf4f2529ae3f7ba91d7e786503691ccc28 | |
parent | b414d33ec808ae23eecd49230b45b4cbf37883e8 (diff) | |
download | erlang-2fac8c62f5c7a360d33791c5b37e629b567e653a.tar.gz |
[enet|doc] Review update
Updated/changed according to review comments.
OTP-16212
-rw-r--r-- | lib/kernel/doc/src/net.xml | 24 | ||||
-rw-r--r-- | lib/kernel/src/net.erl | 14 |
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/kernel/doc/src/net.xml b/lib/kernel/doc/src/net.xml index 4559df11a9..e2930137fb 100644 --- a/lib/kernel/doc/src/net.xml +++ b/lib/kernel/doc/src/net.xml @@ -43,22 +43,32 @@ <name name="address_info"/> </datatype> <datatype> + <name name="ifaddrs"/> <desc> + <p>This type defines all addresses (and flags) associated with + the interface. </p> <p>Not all fields of this map has to be present. The flags field can be used to test this for some of the fields. For example <c>broadaddr</c> will only be present if the <c>broadcast</c> flag is present in flags. </p> </desc> - <name name="ifaddrs"/> - </datatype> - <datatype> - <name name="ifaddrs_flags"/> </datatype> <datatype> <name name="ifaddrs_flag"/> </datatype> <datatype> <name name="ifaddrs_filter_map"/> + <desc> + <p>The '<c>default</c>' value for <c>family</c> is interpreted + as <c>inet</c> <em>and</em> <c>inet6</c>. </p> + <p>Also, the <c>family</c> field can only have the specified values + (and not the all the values of socket:domain()). </p> + <p>The use of the <c>flags</c> field is that any flag provided must + exist for the interface. </p> + <p>For example, if <c>family</c> is set to <c>inet</c> and <c>flags</c> + to <c>[broadcast, multicast]</c> only interfaces address family <c>inet</c> + and the flags <c>broadcast</c> and <c>multicast</c> will be listen. </p> + </desc> </datatype> <datatype> <name name="name_info"/> @@ -128,9 +138,9 @@ <p>This function is used to get the machines interface addresses, possibly filtered with the <c>FilterMap</c>. </p> <p>By default, a filter with the content: - <c>#{family => default, flags => any}</c> is used. This will allow all - interfaces with addresses of the <c>inet</c> and <c>inet6</c> families - to be listed.</p> + <c>#{family => default, flags => any}</c> is used. + This will return all interfaces with adresses in the + <c>inet</c> and <c>inet6</c> families. </p> </desc> </func> diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl index 255e6f90ee..dddbcdc001 100644 --- a/lib/kernel/src/net.erl +++ b/lib/kernel/src/net.erl @@ -59,7 +59,6 @@ name_info/0, ifaddrs_flag/0, - ifaddrs_flags/0, name_info_flags/0, name_info_flag/0, @@ -81,21 +80,20 @@ -type ifaddrs_flag() :: up | broadcast | debug | loopback | pointopoint | notrailers | running | noarp | promisc | master | slave | multicast | portsel | automedia | dynamic. --type ifaddrs_flags() :: [ifaddrs_flag()]. %% Note that not all of these fields are mandatory. %% Actually there are (error) cases when only the name will be included. %% And broadaddr and dstaddr are mutually exclusive! -type ifaddrs() :: #{name := string(), - flags := ifaddrs_flags(), + flags := [ifaddrs_flag()], addr := socket:sockaddr(), netmask := socket:sockaddr(), broadaddr := socket:sockaddr(), dstaddr := socket:sockaddr()}. -type ifaddrs_filter_map() :: #{family := default | inet | inet6 | packet | all, - flags := any | ifaddrs_flags()}. + flags := any | [ifaddrs_flag()]}. -type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. -type name_info_flag() :: namereqd | @@ -297,12 +295,12 @@ getifaddrs() -> -endif. --spec getifaddrs(Namespace) -> {ok, IfAddrs} | {error, Reason} when - Namespace :: file:filename_all(), +-spec getifaddrs(FilterMap) -> {ok, IfAddrs} | {error, Reason} when + FilterMap :: ifaddrs_filter_map(), IfAddrs :: [ifaddrs()], Reason :: term(); - (FilterMap) -> {ok, IfAddrs} | {error, Reason} when - FilterMap :: ifaddrs_filter_map(), + (Namespace) -> {ok, IfAddrs} | {error, Reason} when + Namespace :: file:filename_all(), IfAddrs :: [ifaddrs()], Reason :: term(). |