epmd.epmd_proto_packets

EPMD requests and replies as pure functions over bytes.

Layouts are from erl_dist_protocol (“EPMD Protocol”); limits and the handling of malformed requests follow OTP’s erts/epmd/src/epmd_srv.c. A request is the body after the 2-byte length prefix. A decoder raises EpmdRequestError for a request that OTP’s epmd answers by closing the connection without a reply.

epmd.epmd_proto_packets.name_chars(name)

Number of characters in a node name, or -1 if it is not valid UTF-8 (overlong forms and surrogates are invalid, as in OTP’s verify_utf8).

class epmd.epmd_proto_packets.Alive2Req(port, node_type, proto, hi_ver, lo_ver, name, extra)

Bases: object

A parsed ALIVE2_REQ: what a node registers.

port: int
node_type: int
proto: int
hi_ver: int
lo_ver: int
name: bytes
extra: bytes
epmd.epmd_proto_packets.decode_alive2_req(body)

Parse an ALIVE2_REQ body. Bytes after Extra are ignored.

Raises:

EpmdRequestError – too short, a length field beyond the end, or a NUL byte in the name (OTP closes the connection without a reply).

epmd.epmd_proto_packets.encode_alive2_resp(ok, creation, hi_ver)

ALIVE2_X_RESP (32-bit creation) to a node with HighestVersion >= 6, else ALIVE2_RESP (16-bit creation).

epmd.epmd_proto_packets.decode_port2_req(body)

The node name asked for in a PORT2_REQ body. One trailing NUL is dropped, as old clients send it.

Raises:

EpmdRequestError – empty name, a NUL inside it, invalid UTF-8 or more than 255 characters (OTP closes without a reply).

class epmd.epmd_proto_packets.Port2Info(port, node_type, proto, hi_ver, lo_ver, name, extra)

Bases: object

What a PORT2_RESP describes: one registered node.

port: int
node_type: int
proto: int
hi_ver: int
lo_ver: int
name: bytes
extra: bytes
epmd.epmd_proto_packets.encode_port2_resp(node)

PORT2_RESP: the node’s entry ending in Elen:16, Extra, or result 1 if it is not registered.

epmd.epmd_proto_packets.encode_names_resp(epmd_port, nodes)

NAMES_RESP: EPMDPortNo:32, then name N at port P\n per (name, port). Parsed by erl_epmd; keep the text exact.

epmd.epmd_proto_packets.encode_dump_resp(epmd_port, active, old)

DUMP_RESP: EPMDPortNo:32, then one NUL-terminated line per (name, port, fd): registered nodes, then names kept from earlier registrations. The text, the NULs included, is what OTP’s epmd sends.