From e785f86176f6b8d82377cb05a79c8b932e2b468d Mon Sep 17 00:00:00 2001 From: Chris Spiegel Date: Sun, 13 May 2018 13:40:48 -0700 Subject: Add typespecs for netns and bind_to_device options Some networking functions accept the options netns (to switch network namespaces) and bind_to_device (to bind to a device with SO_BINDTODEVICE), but these functions are not annotated to accept these options, which causes dialyzer to raise issues. This patch applies these type specs to the options for gen_tcp:connect/3,4, gen_tcp:listen/2, gen_udp:open/1,2, and gen_sctp:open/0,1,2, as these are the documented functions which accept the netns and bind_to_device options. --- lib/kernel/src/gen_sctp.erl | 2 ++ lib/kernel/src/gen_tcp.erl | 4 ++++ lib/kernel/src/gen_udp.erl | 2 ++ 3 files changed, 8 insertions(+) diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl index a6aa0edd15..3526df3600 100644 --- a/lib/kernel/src/gen_sctp.erl +++ b/lib/kernel/src/gen_sctp.erl @@ -118,6 +118,8 @@ open() -> | inet:address_family() | {port,Port} | {type,SockType} + | {netns, file:filename_all()} + | {bind_to_device, binary()} | option(), IP :: inet:ip_address() | any | loopback, Port :: inet:port_number(), diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl index ac61dbc792..253c63528f 100644 --- a/lib/kernel/src/gen_tcp.erl +++ b/lib/kernel/src/gen_tcp.erl @@ -102,6 +102,8 @@ inet:address_family() | {port, inet:port_number()} | {tcp_module, module()} | + {netns, file:filename_all()} | + {bind_to_device, binary()} | option(). -type listen_option() :: {ip, inet:socket_address()} | @@ -111,6 +113,8 @@ {port, inet:port_number()} | {backlog, B :: non_neg_integer()} | {tcp_module, module()} | + {netns, file:filename_all()} | + {bind_to_device, binary()} | option(). -type socket() :: port(). diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl index 3121544719..9ab58011ec 100644 --- a/lib/kernel/src/gen_udp.erl +++ b/lib/kernel/src/gen_udp.erl @@ -97,6 +97,8 @@ open(Port) -> | {ifaddr, inet:socket_address()} | inet:address_family() | {port, inet:port_number()} + | {netns, file:filename_all()} + | {bind_to_device, binary()} | option(), Socket :: socket(), Reason :: inet:posix(). -- cgit v1.2.3