aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-08-03 15:08:30 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit01601a4db44b3adccfbcc07129a4584649252736 (patch)
tree57d55b377b3358decca0a6ae938be1c283bbca38 /erts/preloaded
parentd8b1eace1cfe3184497752f345e5f6bc5def9769 (diff)
downloadotp-01601a4db44b3adccfbcc07129a4584649252736.tar.gz
otp-01601a4db44b3adccfbcc07129a4584649252736.tar.bz2
otp-01601a4db44b3adccfbcc07129a4584649252736.zip
[socket-nif] Add more data types (with doc) and (C) debug
Add more debug printouts for the new sendmsg. Also added new (erlang) types with doc. OTP-14831
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin64304 -> 64540 bytes
-rw-r--r--erts/preloaded/src/socket.erl64
2 files changed, 42 insertions, 22 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index f84b9b8369..125191c1d0 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 1459ee4869..3d65f52a2b 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -99,6 +99,8 @@
ip_pktinfo/0,
ipv6_mreq/0,
ipv6_pmtudisc/0,
+ sctp_assoc_id/0,
+ sctp_sndrcvinfo/0,
sctp_event_subscribe/0,
sctp_assocparams/0,
sctp_initmsg/0,
@@ -116,7 +118,8 @@
uint8/0,
uint16/0,
uint20/0,
- uint32/0
+ uint32/0,
+ int32/0
]).
@@ -124,6 +127,7 @@
-type uint16() :: 0..16#FFFF.
-type uint20() :: 0..16#FFFFF.
-type uint32() :: 0..16#FFFFFFFF.
+-type int32() :: -2147483648..2147483647.
%% We support only a subset of all domains.
@@ -171,6 +175,12 @@
-type timeval() :: #{sec := integer(),
usec := integer()}.
+-type ip_pktinfo() :: #{
+ ifindex := non_neg_integer(), % Interface Index
+ spec_dst := ip4_address(), % Local Address
+ addr := ip4_address() % Header Destination address
+ }.
+
%% If the integer value is used its up to the caller to ensure its valid!
-type ip_tos() :: lowdeley |
throughput |
@@ -208,16 +218,29 @@
%% slist: List of source addresses
-type ip_msfilter_mode() :: include | exclude.
--type ip_msfilter() :: #{multiaddr => ip4_address(),
- interface => ip4_address(),
- mode => ip_msfilter_mode(),
- slist => [ip4_address()]}.
+-type ip_msfilter() :: #{multiaddr := ip4_address(),
+ interface := ip4_address(),
+ mode := ip_msfilter_mode(),
+ slist := [ip4_address()]}.
-type ipv6_mreq() :: #{multiaddr := ip6_address(),
interface := non_neg_integer()}.
-type ipv6_pmtudisc() :: ip_pmtudisc().
+-type sctp_assoc_id() :: int32().
+-type sctp_sndrcvinfo() :: #{
+ stream := uint16(),
+ ssn := uint16(),
+ flags := uint16(),
+ ppid := uint16(),
+ context := uint16(),
+ timetolive := uint16(),
+ tsn := uint16(),
+ cumtsn := uint16(),
+ assoc_id := sctp_assoc_id()
+ }.
+
-type sctp_event_subscribe() :: #{data_in := boolean(),
association := boolean(),
address := boolean(),
@@ -229,7 +252,7 @@
authentication := boolean(),
sender_dry := boolean()}.
--type sctp_assocparams() :: #{assoc_id := integer(),
+-type sctp_assocparams() :: #{assoc_id := sctp_assoc_id(),
max_rxt := uint16(),
num_peer_dests := uint16(),
peer_rwnd := uint32(),
@@ -242,7 +265,7 @@
max_init_timeo := uint16()
}.
--type sctp_rtoinfo() :: #{assoc_id := integer(),
+-type sctp_rtoinfo() :: #{assoc_id := sctp_assoc_id(),
initial := uint32(),
max := uint32(),
min := uint32()}.
@@ -510,32 +533,29 @@
%% *Optional* target address
%% Used on an unconnected socket to specify the
%% target address for a datagram.
- addr => sockaddr(),
+ addr := sockaddr(),
- iov => [binary()],
+ iov := [binary()],
%% The maximum size of the control buffer is platform
%% specific. It is the users responsibility to ensure
%% that its not exceeded.
- ctrl => [cmsghdr()],
+ ctrl := [cmsghdr()],
%% Only valid with recvmsg
- flags => msghdr_flags()
+ flags := msghdr_flags()
}.
%% We are able to (completely) decode *some* control message headers.
%% Even if we are able to decode both level and type, we may not be
%% able to decode the data, in which case it will be a binary.
--type ip_pktinfo() :: #{
- ifindex => non_neg_integer(), % Interface Index
- spec_dst => ip4_address(), % Local Address
- addr => ip4_address() % Header Destination address
- }.
+
-type cmsghdr_level() :: socket | protocol() | integer().
-type cmsghdr_type() :: timestamp |
- rights |
- credentials |
+ pktinfo |
tos |
ttl |
+ rights |
+ credentials |
origdstaddr |
integer().
-type cmsghdr_data() :: timeval() | % if level = socket and type = timstamp
@@ -545,9 +565,9 @@
sockaddr_in4() | % if level = ip and type = origdstaddr
binary().
-type cmsghdr() :: #{
- level => cmsghdr_level(),
- type => cmsghdr_type(),
- data => cmsghdr_data()
+ level := cmsghdr_level(),
+ type := cmsghdr_type(),
+ data := cmsghdr_data()
}.
-define(SOCKET_DOMAIN_LOCAL, 1).
@@ -1476,6 +1496,7 @@ do_sendmsg(SockRef, MsgHdr, EFlags, Timeout) ->
ensure_msghdr(#{iov := IOV} = M) when is_list(IOV) andalso (IOV =/= []) ->
M#{iov := erlang:iolist_to_iovec(IOV)};
+ %% M;
ensure_msghdr(_) ->
einval().
@@ -1887,7 +1908,6 @@ do_recvfrom(SockRef, BufSz, EFlags, Timeout) ->
end.
-
%% ---------------------------------------------------------------------------
%%