otp_net.c

Include dependency graph for otp_net.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "8" [label="stdbool.h" tooltip="stdbool.h"]
    "30" [label="interop.h" tooltip="interop.h"]
    "24" [label="refc_binary.h" tooltip="refc_binary.h"]
    "37" [label="netinet/in.h" tooltip="netinet/in.h"]
    "31" [label="nifs.h" tooltip="nifs.h"]
    "28" [label="defaultatoms.h" tooltip="defaultatoms.h"]
    "5" [label="atom.h" tooltip="atom.h"]
    "11" [label="assert.h" tooltip="assert.h"]
    "22" [label="utils.h" tooltip="utils.h"]
    "16" [label="synclist.h" tooltip="synclist.h"]
    "15" [label="list.h" tooltip="list.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "2" [label="context.h" tooltip="context.h"]
    "21" [label="memory.h" tooltip="memory.h"]
    "35" [label="errno.h" tooltip="errno.h"]
    "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/otp_net.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/otp_net.c" fillcolor="#BFBFBF"]
    "33" [label="otp_net.h" tooltip="otp_net.h"]
    "25" [label="resources.h" tooltip="resources.h"]
    "29" [label="inet.h" tooltip="inet.h"]
    "19" [label="term.h" tooltip="term.h"]
    "23" [label="stddef.h" tooltip="stddef.h"]
    "9" [label="erl_nif.h" tooltip="erl_nif.h"]
    "36" [label="netdb.h" tooltip="netdb.h"]
    "32" [label="exportedfunction.h" tooltip="exportedfunction.h"]
    "12" [label="limits.h" tooltip="limits.h"]
    "7" [label="atom_table.h" tooltip="atom_table.h"]
    "20" [label="string.h" tooltip="string.h"]
    "10" [label="term_typedef.h" tooltip="term_typedef.h"]
    "39" [label="unistd.h" tooltip="unistd.h"]
    "3" [label="globalcontext.h" tooltip="globalcontext.h"]
    "18" [label="smp.h" tooltip="smp.h"]
    "27" [label="timer_list.h" tooltip="timer_list.h"]
    "38" [label="sys/socket.h" tooltip="sys/socket.h"]
    "26" [label="mailbox.h" tooltip="mailbox.h"]
    "34" [label="port.h" tooltip="port.h"]
    "40" [label="trace.h" tooltip="trace.h"]
    "17" [label="stdio.h" tooltip="stdio.h"]
    "14" [label="ets.h" tooltip="ets.h"]
    "13" [label="inttypes.h" tooltip="inttypes.h"]
    "30" -> "2" [dir=forward tooltip="include"]
    "30" -> "19" [dir=forward tooltip="include"]
    "24" -> "8" [dir=forward tooltip="include"]
    "24" -> "6" [dir=forward tooltip="include"]
    "24" -> "15" [dir=forward tooltip="include"]
    "24" -> "25" [dir=forward tooltip="include"]
    "31" -> "5" [dir=forward tooltip="include"]
    "31" -> "2" [dir=forward tooltip="include"]
    "31" -> "32" [dir=forward tooltip="include"]
    "28" -> "3" [dir=forward tooltip="include"]
    "5" -> "4" [dir=forward tooltip="include"]
    "5" -> "6" [dir=forward tooltip="include"]
    "22" -> "23" [dir=forward tooltip="include"]
    "22" -> "17" [dir=forward tooltip="include"]
    "22" -> "6" [dir=forward tooltip="include"]
    "16" -> "17" [dir=forward tooltip="include"]
    "16" -> "15" [dir=forward tooltip="include"]
    "16" -> "18" [dir=forward tooltip="include"]
    "15" -> "8" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "15" [dir=forward tooltip="include"]
    "2" -> "26" [dir=forward tooltip="include"]
    "2" -> "18" [dir=forward tooltip="include"]
    "2" -> "19" [dir=forward tooltip="include"]
    "2" -> "27" [dir=forward tooltip="include"]
    "21" -> "4" [dir=forward tooltip="include"]
    "21" -> "6" [dir=forward tooltip="include"]
    "21" -> "9" [dir=forward tooltip="include"]
    "21" -> "10" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "28" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "29" [dir=forward tooltip="include"]
    "1" -> "30" [dir=forward tooltip="include"]
    "1" -> "31" [dir=forward tooltip="include"]
    "1" -> "33" [dir=forward tooltip="include"]
    "1" -> "34" [dir=forward tooltip="include"]
    "1" -> "19" [dir=forward tooltip="include"]
    "1" -> "35" [dir=forward tooltip="include"]
    "1" -> "36" [dir=forward tooltip="include"]
    "1" -> "37" [dir=forward tooltip="include"]
    "1" -> "38" [dir=forward tooltip="include"]
    "1" -> "39" [dir=forward tooltip="include"]
    "1" -> "40" [dir=forward tooltip="include"]
    "33" -> "3" [dir=forward tooltip="include"]
    "33" -> "31" [dir=forward tooltip="include"]
    "25" -> "6" [dir=forward tooltip="include"]
    "25" -> "9" [dir=forward tooltip="include"]
    "25" -> "15" [dir=forward tooltip="include"]
    "25" -> "21" [dir=forward tooltip="include"]
    "29" -> "30" [dir=forward tooltip="include"]
    "29" -> "21" [dir=forward tooltip="include"]
    "19" -> "8" [dir=forward tooltip="include"]
    "19" -> "4" [dir=forward tooltip="include"]
    "19" -> "17" [dir=forward tooltip="include"]
    "19" -> "6" [dir=forward tooltip="include"]
    "19" -> "20" [dir=forward tooltip="include"]
    "19" -> "21" [dir=forward tooltip="include"]
    "19" -> "24" [dir=forward tooltip="include"]
    "19" -> "22" [dir=forward tooltip="include"]
    "19" -> "10" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "32" -> "19" [dir=forward tooltip="include"]
    "7" -> "8" [dir=forward tooltip="include"]
    "7" -> "5" [dir=forward tooltip="include"]
    "10" -> "11" [dir=forward tooltip="include"]
    "10" -> "12" [dir=forward tooltip="include"]
    "10" -> "13" [dir=forward tooltip="include"]
    "10" -> "4" [dir=forward tooltip="include"]
    "3" -> "4" [dir=forward tooltip="include"]
    "3" -> "5" [dir=forward tooltip="include"]
    "3" -> "7" [dir=forward tooltip="include"]
    "3" -> "9" [dir=forward tooltip="include"]
    "3" -> "14" [dir=forward tooltip="include"]
    "3" -> "15" [dir=forward tooltip="include"]
    "3" -> "26" [dir=forward tooltip="include"]
    "3" -> "18" [dir=forward tooltip="include"]
    "3" -> "16" [dir=forward tooltip="include"]
    "3" -> "19" [dir=forward tooltip="include"]
    "3" -> "27" [dir=forward tooltip="include"]
    "18" -> "8" [dir=forward tooltip="include"]
    "27" -> "8" [dir=forward tooltip="include"]
    "27" -> "4" [dir=forward tooltip="include"]
    "27" -> "15" [dir=forward tooltip="include"]
    "26" -> "8" [dir=forward tooltip="include"]
    "26" -> "15" [dir=forward tooltip="include"]
    "26" -> "10" [dir=forward tooltip="include"]
    "26" -> "22" [dir=forward tooltip="include"]
    "34" -> "2" [dir=forward tooltip="include"]
    "34" -> "28" [dir=forward tooltip="include"]
    "34" -> "3" [dir=forward tooltip="include"]
    "34" -> "21" [dir=forward tooltip="include"]
    "34" -> "19" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "14" -> "16" [dir=forward tooltip="include"]
    "14" -> "19" [dir=forward tooltip="include"]
}

Defines

UNKNOWN_TABLE_VALUE -1

Functions

static inline term make_error_tuple(term reason, Context *ctx)
static term eai_errno_to_term(int err, GlobalContext *glb)
static term make_getaddrinfo_result(term *keys, int ai_protocol, int ai_socktype, term inner_addr, GlobalContext *global, Heap *heap)

Make a getaddrino result item as part of the iteration.

This function is called in a loop to create optimized maps that share keys.

Parameters:
  • keys – pointer to a term to store the keys of the map. If it’s invalid_term, a non-shared map will be created and the keys term will be updated. Otherwise, it’s used to create a shared map

  • ai_protocol – protocol field of the addrinfo

  • ai_socktype – socktype field of the addrinfo

  • inner_addr – IP address that will be stored in both address and addr entries of the map

  • global – the global context

  • heap – the heap to create terms in, should have sufficient free space

Returns:

the getaddrinfo result item term

static term nif_net_getaddrinfo(Context *ctx, int argc, term argv[])
const struct Nif *otp_net_nif_get_nif(const char *nifname)
void otp_net_init(GlobalContext *global)

Variables

static const AtomStringIntPair protocol_table [] = {{ATOM_STR("\x3", "tcp"), IPPROTO_TCP },{ATOM_STR("\x3", "udp"), IPPROTO_UDP },}
static const AtomStringIntPair type_table [] = {{ATOM_STR("\x5", "dgram"), SOCK_DGRAM },{ATOM_STR("\x6", "stream"), SOCK_STREAM },}
static const struct Nif net_getaddrinfo_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_net_getaddrinfo}