Skip to content

Commit

Permalink
Merge branch 'bmk/esock/20240605/net_getaddinfo/OTP-19132' into maint
Browse files Browse the repository at this point in the history
  • Loading branch information
bmk committed Jul 23, 2024
2 parents 58cd1af + eddca2b commit 2d11368
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
15 changes: 11 additions & 4 deletions erts/emulator/nifs/common/prim_net_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand All @@ -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};
Expand Down
1 change: 1 addition & 0 deletions erts/emulator/nifs/common/prim_socket_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
1 change: 1 addition & 0 deletions erts/emulator/nifs/common/socket_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
14 changes: 7 additions & 7 deletions lib/kernel/src/net.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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().

Expand Down
2 changes: 1 addition & 1 deletion lib/kernel/test/net_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d11368

Please sign in to comment.