Packages
partisan
5.0.0-beta.21
5.0.3
5.0.2
5.0.1
5.0.0
5.0.0-rc.16
5.0.0-rc.8
5.0.0-rc.2
5.0.0-rc.1
5.0.0-beta.24
5.0.0-beta.21
5.0.0-beta.20
5.0.0-beta.18
5.0.0-beta.17
5.0.0-beta.16
5.0.0-beta.15
5.0.0-beta.14
5.0.0-beta.13
4.1.0
3.0.0
2.1.0
2.0.0
1.4.1
1.4.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0
1.1.0
1.0.2
1.0.1
1.0.0
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0
0.0.1
Partisan is a scalable and flexible, TCP-based membership system and distribution layer for the BEAM.
Current section
Files
Jump to
Current section
Files
include/partisan_util.hrl
-define(RECORD_TO_LIST(Record),
lists:zip(?MODULE:record_info(fields, Record), tl(tuple_to_list(Record)))
).
-define(RECORD_TO_MAP(Record),
maps:from_list(?RECORD_TO_LIST(Record))
).
-define(IS_IP(X), (?IS_IP4(X) orelse ?IS_IP6(X))).
%% copied from inet_int.hrl
%% macro for guards only that checks IP address {A,B,C,D}
%% that returns true for an IP address, but returns false
%% or crashes for other terms
-define(IS_IP4(A, B, C, D),
(((A) bor (B) bor (C) bor (D)) band (bnot 16#ff)) =:= 0
).
%% d:o for IP address as one term
-define(IS_IP4(Addr),
(tuple_size(Addr) =:= 4 andalso
?IS_IP4(element(1, (Addr)), element(2, (Addr)),
element(3, (Addr)), element(4, (Addr))))
).
%% d:o IPv6 address
-define(IS_IP6(A, B, C, D, E, F, G, H),
(((A) bor (B) bor (C) bor (D) bor (E) bor (F) bor (G) bor (H))
band (bnot 16#ffff)) =:= 0).
-define(IS_IP6(Addr),
(tuple_size(Addr) =:= 8 andalso
?IS_IP6(element(1, (Addr)), element(2, (Addr)),
element(3, (Addr)), element(4, (Addr)),
element(5, (Addr)), element(6, (Addr)),
element(7, (Addr)), element(8, (Addr))))
).
-define(IS_PORT_NBR(N), (N >= 1 andalso N =< 65535)).