Skip to content

Commit 39bab10

Browse files
committed
Merge branch 'bmk/erts/20250630/family_encoding/OTP-19674' into maint
2 parents d8ad183 + 2940eb9 commit 39bab10

9 files changed

Lines changed: 1022 additions & 96 deletions

File tree

erts/emulator/nifs/common/prim_net_nif.c

Lines changed: 133 additions & 95 deletions
Large diffs are not rendered by default.

erts/emulator/nifs/common/prim_socket_nif.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,7 @@ static const struct in6_addr in6addr_loopback =
20732073
GLOBAL_ATOM_DECL(family); \
20742074
GLOBAL_ATOM_DECL(fastroute); \
20752075
GLOBAL_ATOM_DECL(fast_retrans); \
2076+
GLOBAL_ATOM_DECL(file_not_found); \
20762077
GLOBAL_ATOM_DECL(fin_wait_1); \
20772078
GLOBAL_ATOM_DECL(fin_wait_2); \
20782079
GLOBAL_ATOM_DECL(flags); \

erts/emulator/nifs/common/socket_int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ typedef long ssize_t;
349349
GLOBAL_ATOM_DEF(family); \
350350
GLOBAL_ATOM_DEF(fastroute); \
351351
GLOBAL_ATOM_DEF(fast_retrans); \
352+
GLOBAL_ATOM_DEF(file_not_found); \
352353
GLOBAL_ATOM_DEF(fin_wait_1); \
353354
GLOBAL_ATOM_DEF(fin_wait_2); \
354355
GLOBAL_ATOM_DEF(flags); \

erts/emulator/nifs/common/socket_util.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,65 @@ BOOLEAN_T esock_get_bool_from_map(ErlNifEnv* env,
236236
}
237237

238238

239+
/* *** esock_get_string_from_map ***
240+
*
241+
* Simple utility function used to extract a string value from a map.
242+
* If the map does not contain the map value, the string is set to NULL
243+
* and TRUE is returned (its acceptible to not provide a value).
244+
* If it fails to extract the value (for whatever reason) the string
245+
* is set to NULL and FALSE is returned.
246+
*/
247+
248+
extern
249+
BOOLEAN_T esock_get_string_from_map(ErlNifEnv* env,
250+
ERL_NIF_TERM map,
251+
ERL_NIF_TERM key,
252+
ErlNifCharEncoding encoding,
253+
char** str)
254+
{
255+
ERL_NIF_TERM eval;
256+
unsigned int len;
257+
char* buf;
258+
int written;
259+
260+
/* Try extract the string in erlang form from the map */
261+
if (!GET_MAP_VAL(env, map, key, &eval)) {
262+
*str = NULL;
263+
return TRUE;
264+
}
265+
266+
/* Check if its a list */
267+
if (!enif_is_list(env, eval)) {
268+
*str = NULL;
269+
return FALSE;
270+
}
271+
272+
/* Get the string length */
273+
if (!enif_get_string_length(env, eval, &len, encoding)) {
274+
*str = NULL;
275+
return FALSE;
276+
}
277+
278+
/* Allocate the string */
279+
if ((buf = MALLOC(len+1)) == NULL) {
280+
*str = NULL;
281+
return FALSE;
282+
}
283+
284+
/* And finally copy it out */
285+
written = enif_get_string(env, eval, buf, len+1, encoding);
286+
if (written == (len+1)) {
287+
*str = buf;
288+
return TRUE;
289+
} else {
290+
FREE( buf );
291+
*str = NULL;
292+
return FALSE;
293+
}
294+
295+
}
296+
297+
239298
/* +++ esock_encode_iov +++
240299
*
241300
* Encode an IO Vector. In erlang we represented this as a list of binaries.

erts/emulator/nifs/common/socket_util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ BOOLEAN_T esock_get_bool_from_map(ErlNifEnv* env,
8787
ERL_NIF_TERM key,
8888
BOOLEAN_T def);
8989

90+
extern
91+
BOOLEAN_T esock_get_string_from_map(ErlNifEnv* env,
92+
ERL_NIF_TERM map,
93+
ERL_NIF_TERM key,
94+
ErlNifCharEncoding encoding,
95+
char** str);
96+
9097
extern
9198
BOOLEAN_T esock_decode_iov(ErlNifEnv* env,
9299
ERL_NIF_TERM eIOV,

erts/preloaded/ebin/prim_net.beam

0 Bytes
Binary file not shown.

erts/preloaded/src/prim_net.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
-type interface_info_args() :: #{debug => boolean()}.
110110
-type if_entry_args() :: #{index := non_neg_integer(),
111111
debug => boolean()}.
112-
-type ip_address_table_args() :: #{debug => boolean()}.
112+
-type ip_address_table_args() :: #{sort => boolean(),
113+
debug => boolean()}.
113114

114115
-type if_type() :: other | ethernet_csmacd | iso88025_tokenring |
115116
fddi | ppp | software_loopback | atm | ieee80211 |

lib/kernel/test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ MODULES= \
117117
logger_stress_SUITE \
118118
logger_test_lib \
119119
net_SUITE \
120+
prim_net_SUITE \
120121
os_SUITE \
121122
pg_SUITE \
122123
rtnode \

0 commit comments

Comments
 (0)