diff --git a/erts/emulator/nifs/common/prim_net_nif.c b/erts/emulator/nifs/common/prim_net_nif.c index f8dc1856cd5b..e5b4502e0ebf 100644 --- a/erts/emulator/nifs/common/prim_net_nif.c +++ b/erts/emulator/nifs/common/prim_net_nif.c @@ -4751,17 +4751,24 @@ ERL_NIF_TERM encode_address_info_family(ErlNifEnv* env, /* Convert an "native" socket type to an erlang socket type. * Note that this is not currently exhaustive, but only supports - * stream and dgram. Other values will be returned as is, that is - * in the form of an integer. + * stream, dgram, raw, seqpacket and rdm. + * Also, the value 0 (zero) has the special meaning: any. + * Other values will be returned as is, that is in the form of + * an integer. */ static ERL_NIF_TERM encode_address_info_type(ErlNifEnv* env, int socktype) { ERL_NIF_TERM etype; + ERL_NIF_TERM zero = MKI(env, 0); esock_encode_type(env, socktype, &etype); - return etype; + + if (IS_IDENTICAL(zero, etype)) + return esock_atom_any; + else + return etype; } @@ -4775,7 +4782,7 @@ void make_address_info(ErlNifEnv* env, ERL_NIF_TERM* ai) { ERL_NIF_TERM keys[] = {esock_atom_family, - esock_atom_type, + esock_atom_socktype, esock_atom_protocol, esock_atom_addr}; ERL_NIF_TERM vals[] = {fam, sockType, proto, addr}; diff --git a/erts/emulator/nifs/common/prim_socket_nif.c b/erts/emulator/nifs/common/prim_socket_nif.c index c147c07b2223..80d7072c9ae3 100644 --- a/erts/emulator/nifs/common/prim_socket_nif.c +++ b/erts/emulator/nifs/common/prim_socket_nif.c @@ -2260,6 +2260,7 @@ static const struct in6_addr in6addr_loopback = GLOBAL_ATOM_DECL(snd_wnd); \ GLOBAL_ATOM_DECL(sockaddr); \ GLOBAL_ATOM_DECL(socket); \ + GLOBAL_ATOM_DECL(socktype); \ GLOBAL_ATOM_DECL(spec_dst); \ GLOBAL_ATOM_DECL(staticarp); \ GLOBAL_ATOM_DECL(state); \ diff --git a/erts/emulator/nifs/common/socket_int.h b/erts/emulator/nifs/common/socket_int.h index 82fbd85331a1..c88efdd02d0a 100644 --- a/erts/emulator/nifs/common/socket_int.h +++ b/erts/emulator/nifs/common/socket_int.h @@ -535,6 +535,7 @@ typedef long ssize_t; GLOBAL_ATOM_DEF(sockaddr); \ GLOBAL_ATOM_DEF(socket); \ GLOBAL_ATOM_DEF(socket_tag); \ + GLOBAL_ATOM_DEF(socktype); \ GLOBAL_ATOM_DEF(spec_dst); \ GLOBAL_ATOM_DEF(state); \ GLOBAL_ATOM_DEF(status); \ diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl index 2f3fe5c83dc7..1513516bac71 100644 --- a/lib/kernel/src/net.erl +++ b/lib/kernel/src/net.erl @@ -174,13 +174,13 @@ net:getifaddrs( %% The following (ext) flags has been removed %% (as they are deprecated by later version of gcc): %% idn_allow_unassigned | idn_use_std3_ascii_rules. --type name_info_flag_ext() :: idn. --type name_info() :: #{host := string(), - service := string()}. --type address_info() :: #{family := socket:domain(), - socktype := socket:type(), - protocol := socket:protocol(), - address := socket:sockaddr()}. +-type name_info_flag_ext() :: idn. +-type name_info() :: #{host := string(), + service := string()}. +-type address_info() :: #{family := socket:domain(), + socktype := any | socket:type() | integer(), + protocol := socket:protocol(), + address := socket:sockaddr()}. -type network_interface_name() :: string(). -type network_interface_index() :: non_neg_integer(). diff --git a/lib/kernel/test/net_SUITE.erl b/lib/kernel/test/net_SUITE.erl index 62bdbef7f468..a19666dd1a9a 100644 --- a/lib/kernel/test/net_SUITE.erl +++ b/lib/kernel/test/net_SUITE.erl @@ -763,7 +763,7 @@ verify_addr_info2([#{addr := #{addr := Addr, family := Domain, port := Port}, family := Domain, - type := _Type, + socktype := _Type, protocol := _Proto}|T], Domain) when is_integer(Port) andalso (((Domain =:= inet) andalso is_tuple(Addr) andalso (size(Addr) =:= 4)) orelse