From 2c08787a53d30bb60d2b604eedb19389dc5a0d9e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 20 May 2019 15:23:48 +0200 Subject: [esock,kernel] net -> prim_net and add (new) net Renamed the current preloaded net module to prim_net and removed the deprecated functions (call, cast, ...). Introduce a "new" net module (in kernel) as an interface module to the (preloaded) prim_net. This one also contains the deprecated functions (call, cast, ...). OTP-15765 --- lib/kernel/src/Makefile | 4 +- lib/kernel/src/net.erl | 278 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 lib/kernel/src/net.erl (limited to 'lib/kernel') diff --git a/lib/kernel/src/Makefile b/lib/kernel/src/Makefile index fcb599859b..88752431eb 100644 --- a/lib/kernel/src/Makefile +++ b/lib/kernel/src/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 1996-2018. All Rights Reserved. +# Copyright Ericsson AB 1996-2019. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -123,6 +123,7 @@ MODULES = \ logger_server \ logger_simple_h \ logger_sup \ + net \ net_adm \ net_kernel \ os \ @@ -180,6 +181,7 @@ ERL_COMPILE_FLAGS += -Werror endif ERL_COMPILE_FLAGS += -I../include + # ---------------------------------------------------- # Targets # ---------------------------------------------------- diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl new file mode 100644 index 0000000000..ac8b600e4b --- /dev/null +++ b/lib/kernel/src/net.erl @@ -0,0 +1,278 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2019-2019. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +-module(net). + +-ifdef(USE_ESOCK). +%% Administrative and utility functions +-export([ + info/0, + command/1 + ]). + +-export([ + gethostname/0, + getnameinfo/1, getnameinfo/2, + getaddrinfo/1, getaddrinfo/2, + + if_name2index/1, + if_index2name/1, + if_names/0 + ]). +-endif. + +%% Deprecated functions from the "old" net module +-export([call/4, + cast/4, + broadcast/3, + ping/1, + relay/1, + sleep/1]). + +-ifdef(USE_ESOCK). + +%% Should we define these here or refer to the prim_net module +-export_type([ + address_info/0, + name_info/0, + + name_info_flags/0, + name_info_flag/0, + name_info_flag_ext/0, + + network_interface_name/0, + network_interface_index/0 + ]). +-endif. + +-deprecated({call, 4, eventually}). +-deprecated({cast, 4, eventually}). +-deprecated({broadcast, 3, eventually}). +-deprecated({ping, 1, eventually}). +-deprecated({relay, 1, eventually}). +-deprecated({sleep, 1, eventually}). + + +-ifdef(USE_ESOCK). +-type name_info_flags() :: prim_net:name_info_flags(). +-type name_info_flag() :: prim_net:name_info_flag(). +-type name_info_flag_ext() :: prim_net:name_info_flag_ext(). +-type name_info() :: prim_net:name_info(). +-type address_info() :: prim_net:address_info(). +-type network_interface_name() :: prim_net:network_interface_name(). +-type network_interface_index() :: prim_net:network_interface_index(). + +%% -type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. +%% -type name_info_flag() :: namereqd | +%% dgram | +%% nofqdn | +%% numerichost | +%% nomericserv. +%% -type name_info_flag_ext() :: idn | +%% idna_allow_unassigned | +%% idna_use_std3_ascii_rules. +%% -type name_info() :: #{host := string(), +%% service := string()}. +%% -type address_info() :: #{family := socket:domain(), +%% socktype := socket:type(), +%% protocol := socket:protocol(), +%% address := socket:sockaddr()}. +%% -type network_interface_name() :: string(). +%% -type network_interface_index() :: non_neg_integer(). + +-endif. + + +%% =========================================================================== +%% +%% D E P R E C A T E D F U N C T I O N S +%% +%% =========================================================================== + +call(N,M,F,A) -> rpc:call(N,M,F,A). +cast(N,M,F,A) -> rpc:cast(N,M,F,A). +broadcast(M,F,A) -> rpc:eval_everywhere(M,F,A). +ping(Node) -> net_adm:ping(Node). +sleep(T) -> receive after T -> ok end. +relay(X) -> slave:relay(X). + + +-ifdef(USE_ESOCK). + +%% =========================================================================== +%% +%% Administrative and utility API +%% +%% =========================================================================== + +-spec info() -> list(). + +info() -> + prim_net:info(). + + +-spec command(Cmd :: term()) -> term(). + +command(Cmd) -> + prim_net:command(Cmd). + + + +%% =========================================================================== +%% +%% The proper net API +%% +%% =========================================================================== + +%% =========================================================================== +%% +%% gethostname - Get the name of the current host. +%% +%% + +-spec gethostname() -> {ok, HostName} | {error, Reason} when + HostName :: string(), + Reason :: term(). + +gethostname() -> + prim_net:gethostname(). + + +%% =========================================================================== +%% +%% getnameinfo - Address-to-name translation in protocol-independent manner. +%% +%% + +-spec getnameinfo(SockAddr) -> {ok, Info} | {error, Reason} when + SockAddr :: socket:sockaddr(), + Info :: name_info(), + Reason :: term(). + +getnameinfo(SockAddr) -> + getnameinfo(SockAddr, undefined). + +-spec getnameinfo(SockAddr, Flags) -> {ok, Info} | {error, Reason} when + SockAddr :: socket:sockaddr(), + Flags :: name_info_flags() | undefined, + Info :: name_info(), + Reason :: term(). + +getnameinfo(SockAddr, [] = _Flags) -> + getnameinfo(SockAddr, undefined); +getnameinfo(#{family := Fam, addr := _Addr} = SockAddr, Flags) + when ((Fam =:= inet) orelse (Fam =:= inet6)) andalso + (is_list(Flags) orelse (Flags =:= undefined)) -> + prim_net:getnameinfo(socket:ensure_sockaddr(SockAddr), Flags); +getnameinfo(#{family := Fam, path := _Path} = SockAddr, Flags) + when (Fam =:= local) andalso (is_list(Flags) orelse (Flags =:= undefined)) -> + prim_net:getnameinfo(SockAddr, Flags). + + + +%% =========================================================================== +%% +%% getaddrinfo - Network address and service translation +%% +%% There is also a "hint" argument that we "at some point" should implement. + +-spec getaddrinfo(Host) -> {ok, Info} | {error, Reason} when + Host :: string(), + Info :: [address_info()], + Reason :: term(). + +getaddrinfo(Host) when is_list(Host) -> + getaddrinfo(Host, undefined). + + +-spec getaddrinfo(Host, undefined) -> {ok, Info} | {error, Reason} when + Host :: string(), + Info :: [address_info()], + Reason :: term() + ; (undefined, Service) -> {ok, Info} | {error, Reason} when + Service :: string(), + Info :: [address_info()], + Reason :: term() + ; (Host, Service) -> {ok, Info} | {error, Reason} when + Host :: string(), + Service :: string(), + Info :: [address_info()], + Reason :: term(). + +getaddrinfo(Host, Service) + when (is_list(Host) orelse (Host =:= undefined)) andalso + (is_list(Service) orelse (Service =:= undefined)) andalso + (not ((Service =:= undefined) andalso (Host =:= undefined))) -> + prim_net:getaddrinfo(Host, Service). + + + +%% =========================================================================== +%% +%% if_name2index - Mappings between network interface names and indexes: +%% name -> idx +%% +%% + +-spec if_name2index(Name) -> {ok, Idx} | {error, Reason} when + Name :: network_interface_name(), + Idx :: network_interface_index(), + Reason :: term(). + +if_name2index(If) when is_list(If) -> + prim_net:if_name2index(If). + + + +%% =========================================================================== +%% +%% if_index2name - Mappings between network interface index and names: +%% idx -> name +%% +%% + +-spec if_index2name(Idx) -> {ok, Name} | {error, Reason} when + Idx :: network_interface_index(), + Name :: network_interface_name(), + Reason :: term(). + +if_index2name(Idx) when is_integer(Idx) -> + prim_net:if_index2name(Idx). + + + +%% =========================================================================== +%% +%% if_names - Get network interface names and indexes +%% +%% + +-spec if_names() -> Names | {error, Reason} when + Names :: [{Idx, If}], + Idx :: network_interface_index(), + If :: network_interface_name(), + Reason :: term(). + +if_names() -> + prim_net:if_names(). + + + +-endif. -- cgit v1.2.3 From 1fe29381876838e26c5ffbd2efaf449a5a9522a9 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 14 Jun 2019 17:41:57 +0200 Subject: Move net.xml from erts to kernel --- lib/kernel/doc/src/Makefile | 1 + lib/kernel/doc/src/net.xml | 129 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 lib/kernel/doc/src/net.xml (limited to 'lib/kernel') diff --git a/lib/kernel/doc/src/Makefile b/lib/kernel/doc/src/Makefile index f8867ccf25..9a1379d21e 100644 --- a/lib/kernel/doc/src/Makefile +++ b/lib/kernel/doc/src/Makefile @@ -62,6 +62,7 @@ XML_REF3_FILES = application.xml \ logger_disk_log_h.xml \ logger_filters.xml \ logger_formatter.xml \ + net.xml \ net_adm.xml \ net_kernel.xml \ os.xml \ diff --git a/lib/kernel/doc/src/net.xml b/lib/kernel/doc/src/net.xml new file mode 100644 index 0000000000..6fbc37076c --- /dev/null +++ b/lib/kernel/doc/src/net.xml @@ -0,0 +1,129 @@ + + + + +
+ + 20182018 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + net + + + + + net.xml +
+ net + Network interface. + +

This module provides an API for the network interface.

+ +

There is currently no support for Windows.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get hostname. + +

Returns the name of the current host.

+
+
+ + + + + Address-to-name transaltion. + +

Address-to-name translation in a protocol-independant manner.

+

This function is the inverse of + getaddrinfo. + It converts a socket address to a corresponding host and service.

+
+
+ + + + + + + Network address and service transation. + +

Network address and service translation.

+

This function is the inverse of + getnameinfo. + It converts host and service to a corresponding socket address.

+

One of the Host and Service may be undefined + but not both.

+
+
+ + + + Mappings between network interface names and indexes. + +

Mappings between network interface names and indexes.

+
+
+ + + + Mappings between network interface index and names. + +

Mappings between network interface index and names.

+
+
+ + + + Get network interface names and indexes. + +

Get network interface names and indexes.

+
+
+ +
+ +
+ -- cgit v1.2.3 From fdffb35fc3209e20459a03fc21924295b96becee Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 14 Jun 2019 18:49:52 +0200 Subject: Remove ESOCK stuff from doc build --- lib/kernel/doc/src/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/kernel') diff --git a/lib/kernel/doc/src/Makefile b/lib/kernel/doc/src/Makefile index 9a1379d21e..366631e912 100644 --- a/lib/kernel/doc/src/Makefile +++ b/lib/kernel/doc/src/Makefile @@ -36,6 +36,13 @@ RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # Target Specs # ---------------------------------------------------- XML_APPLICATION_FILES = ref_man.xml + +ifeq ($(USE_ESOCK), yes) +XML_REF3_ESOCK_FILES = net.xml +else +XML_REF3_ESOCK_FILES = +endif + XML_REF3_FILES = application.xml \ auth.xml \ code.xml \ @@ -62,7 +69,7 @@ XML_REF3_FILES = application.xml \ logger_disk_log_h.xml \ logger_filters.xml \ logger_formatter.xml \ - net.xml \ + $(XML_REF3_ESOCK_FILES) \ net_adm.xml \ net_kernel.xml \ os.xml \ -- cgit v1.2.3 From 55685630a4c2edccda1954e4bfb2ee590a4467f9 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 17 Jun 2019 18:14:29 +0200 Subject: [esock] Documentation woes Still trying to make --disable-esock to work properly. Now the primary chore is the doc building. OTP-15765 --- lib/kernel/doc/src/Makefile | 39 +++++++++++++++----- lib/kernel/doc/src/ref_man.xml | 72 ------------------------------------- lib/kernel/doc/src/ref_man.xml.src | 73 ++++++++++++++++++++++++++++++++++++++ lib/kernel/doc/src/specs.xml | 1 + lib/kernel/src/net.erl | 43 ++++++++++------------ 5 files changed, 122 insertions(+), 106 deletions(-) delete mode 100644 lib/kernel/doc/src/ref_man.xml create mode 100644 lib/kernel/doc/src/ref_man.xml.src (limited to 'lib/kernel') diff --git a/lib/kernel/doc/src/Makefile b/lib/kernel/doc/src/Makefile index 366631e912..817f592ad4 100644 --- a/lib/kernel/doc/src/Makefile +++ b/lib/kernel/doc/src/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 1997-2018. All Rights Reserved. +# Copyright Ericsson AB 1997-2019. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,10 +37,13 @@ RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- XML_APPLICATION_FILES = ref_man.xml -ifeq ($(USE_ESOCK), yes) +# The doc build has problems with if-defing out modules... +ifeq ($(USE_ESOCK),yes) XML_REF3_ESOCK_FILES = net.xml +ESOCK_USE_NET_XML= else XML_REF3_ESOCK_FILES = +ESOCK_USE_NET_XML = endif XML_REF3_FILES = application.xml \ @@ -120,6 +123,7 @@ SPECS_FILES = $(XML_REF3_FILES:%.xml=$(SPECDIR)/specs_%.xml) TOP_SPECS_FILE = specs.xml + # ---------------------------------------------------- # FIGURES # ---------------------------------------------------- @@ -146,7 +150,7 @@ SPECS_FLAGS = -I../../include $(HTMLDIR)/%: % $(INSTALL_DATA) $< $@ -docs: man pdf html +docs: ref_man man pdf html $(TOP_PDF_FILE): $(XML_FILES) @@ -156,19 +160,31 @@ html: images $(HTML_REF_MAN_FILE) man: $(MAN3_FILES) $(MAN4_FILES) $(MAN6_FILES) +ref_man: ref_man.xml + images: $(IMAGE_FILES:%=$(HTMLDIR)/%) +info: + @echo "XML_APPLICATION_FILES: $(XML_APPLICATION_FILES)" + @echo "XML_REF3_ESOCK_FILES: $(XML_REF3_ESOCK_FILES)" + @echo "XML_REF3_FILES: $(XML_REF3_FILES)" + @echo "XML_REF4_FILES: $(XML_REF4_FILES)" + @echo "XML_REF6_FILES: $(XML_REF6_FILES)" + @echo "XML_PART_FILES: $(XML_PART_FILES)" + @echo "XML_CHAPTER_FILES: $(XML_CHAPTER_FILES)" + @echo "BOOK_FILES: $(BOOK_FILES)" + debug opt: clean clean_docs: rm -rf $(HTMLDIR)/* rm -rf $(XMLDIR) - rm -f $(MAN3DIR)/* - rm -f $(MAN4DIR)/* - rm -f $(MAN6DIR)/* - rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo) - rm -f $(SPECDIR)/* - rm -f errs core *~ *.eps + rm -f $(MAN3DIR)/* + rm -f $(MAN4DIR)/* + rm -f $(MAN6DIR)/* + rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo) + rm -f $(SPECDIR)/* + rm -f errs core *~ *.eps $(SPECDIR)/specs_erl_prim_loader_stub.xml: $(gen_verbose)escript $(SPECS_EXTRACTOR) $(SPECS_FLAGS) \ @@ -183,6 +199,11 @@ $(SPECDIR)/specs_zlib_stub.xml: $(gen_verbose)escript $(SPECS_EXTRACTOR) $(SPECS_FLAGS) \ -o$(dir $@) -module zlib_stub +ref_man.xml: ref_man.xml.src + ($(PERL) -p -e 's?%ESOCK_USE_NET_XML%?$(ESOCK_USE_NET_XML)?' \ + $<) > $@ + + # ---------------------------------------------------- # Release Target # ---------------------------------------------------- diff --git a/lib/kernel/doc/src/ref_man.xml b/lib/kernel/doc/src/ref_man.xml deleted file mode 100644 index d3b947527f..0000000000 --- a/lib/kernel/doc/src/ref_man.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - -
- - 19962018 - Ericsson AB. All Rights Reserved. - - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - - Kernel Reference Manual - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/lib/kernel/doc/src/ref_man.xml.src b/lib/kernel/doc/src/ref_man.xml.src new file mode 100644 index 0000000000..72e3409123 --- /dev/null +++ b/lib/kernel/doc/src/ref_man.xml.src @@ -0,0 +1,73 @@ + + + + +
+ + 19962019 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + Kernel Reference Manual + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %ESOCK_USE_NET_XML% + + + + + + + + + +
diff --git a/lib/kernel/doc/src/specs.xml b/lib/kernel/doc/src/specs.xml index b8c25ca53b..9e258910db 100644 --- a/lib/kernel/doc/src/specs.xml +++ b/lib/kernel/doc/src/specs.xml @@ -26,6 +26,7 @@ + diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl index ac8b600e4b..01409c736a 100644 --- a/lib/kernel/src/net.erl +++ b/lib/kernel/src/net.erl @@ -71,31 +71,24 @@ -ifdef(USE_ESOCK). --type name_info_flags() :: prim_net:name_info_flags(). --type name_info_flag() :: prim_net:name_info_flag(). --type name_info_flag_ext() :: prim_net:name_info_flag_ext(). --type name_info() :: prim_net:name_info(). --type address_info() :: prim_net:address_info(). --type network_interface_name() :: prim_net:network_interface_name(). --type network_interface_index() :: prim_net:network_interface_index(). - -%% -type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. -%% -type name_info_flag() :: namereqd | -%% dgram | -%% nofqdn | -%% numerichost | -%% nomericserv. -%% -type name_info_flag_ext() :: idn | -%% idna_allow_unassigned | -%% idna_use_std3_ascii_rules. -%% -type name_info() :: #{host := string(), -%% service := string()}. -%% -type address_info() :: #{family := socket:domain(), -%% socktype := socket:type(), -%% protocol := socket:protocol(), -%% address := socket:sockaddr()}. -%% -type network_interface_name() :: string(). -%% -type network_interface_index() :: non_neg_integer(). + +-type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. +-type name_info_flag() :: namereqd | + dgram | + nofqdn | + numerichost | + nomericserv. +-type name_info_flag_ext() :: idn | + idna_allow_unassigned | + idna_use_std3_ascii_rules. +-type name_info() :: #{host := string(), + service := string()}. +-type address_info() :: #{family := socket:domain(), + socktype := socket:type(), + protocol := socket:protocol(), + address := socket:sockaddr()}. +-type network_interface_name() :: string(). +-type network_interface_index() :: non_neg_integer(). -endif. -- cgit v1.2.3 From 878741953069a8d0a7d683cf2b7cbbfe957e880d Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 24 Jun 2019 09:43:58 +0200 Subject: [esock] More doc woes Also needed to take care of the specs files (in erts and kernel docs). Also, ifdef'ing the net module adjusted (again). --- lib/kernel/doc/src/Makefile | 8 +++- lib/kernel/doc/src/specs.xml | 39 ------------------- lib/kernel/doc/src/specs.xml.src | 39 +++++++++++++++++++ lib/kernel/src/net.erl | 81 +++++++++++++++++++++++++++++++++------- 4 files changed, 113 insertions(+), 54 deletions(-) delete mode 100644 lib/kernel/doc/src/specs.xml create mode 100644 lib/kernel/doc/src/specs.xml.src (limited to 'lib/kernel') diff --git a/lib/kernel/doc/src/Makefile b/lib/kernel/doc/src/Makefile index 817f592ad4..70623ab9aa 100644 --- a/lib/kernel/doc/src/Makefile +++ b/lib/kernel/doc/src/Makefile @@ -41,8 +41,10 @@ XML_APPLICATION_FILES = ref_man.xml ifeq ($(USE_ESOCK),yes) XML_REF3_ESOCK_FILES = net.xml ESOCK_USE_NET_XML= +ESOCK_USE_NET_SPECS_XML= else XML_REF3_ESOCK_FILES = +ESOCK_USE_NET_SPECS_XML = ESOCK_USE_NET_XML = endif @@ -150,7 +152,7 @@ SPECS_FLAGS = -I../../include $(HTMLDIR)/%: % $(INSTALL_DATA) $< $@ -docs: ref_man man pdf html +docs: ref_man specs man pdf html $(TOP_PDF_FILE): $(XML_FILES) @@ -161,6 +163,7 @@ html: images $(HTML_REF_MAN_FILE) man: $(MAN3_FILES) $(MAN4_FILES) $(MAN6_FILES) ref_man: ref_man.xml +specs: specs.xml images: $(IMAGE_FILES:%=$(HTMLDIR)/%) @@ -202,6 +205,9 @@ $(SPECDIR)/specs_zlib_stub.xml: ref_man.xml: ref_man.xml.src ($(PERL) -p -e 's?%ESOCK_USE_NET_XML%?$(ESOCK_USE_NET_XML)?' \ $<) > $@ +specs.xml: specs.xml.src + ($(PERL) -p -e 's?%ESOCK_USE_NET_SPECS_XML%?$(ESOCK_USE_NET_SPECS_XML)?' \ + $<) > $@ # ---------------------------------------------------- diff --git a/lib/kernel/doc/src/specs.xml b/lib/kernel/doc/src/specs.xml deleted file mode 100644 index 9e258910db..0000000000 --- a/lib/kernel/doc/src/specs.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/kernel/doc/src/specs.xml.src b/lib/kernel/doc/src/specs.xml.src new file mode 100644 index 0000000000..ccb26b9458 --- /dev/null +++ b/lib/kernel/doc/src/specs.xml.src @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %ESOCK_USE_NET_SPECS_XML% + + + + + + + + + + diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl index 01409c736a..b8ffa64043 100644 --- a/lib/kernel/src/net.erl +++ b/lib/kernel/src/net.erl @@ -20,7 +20,13 @@ -module(net). --ifdef(USE_ESOCK). +%% We should really ifdef this module depending on if we actually built +%% the system with esock support (socket and prim_net), but our doc-building +%% can't handle the "variables" we need (USE_ESOCK). So instead, we just +%% leave everything hanging... +%% If one of the "hanging" functions is called when esock has been disabled, +%% the function will through a 'notsup' error (erlang:error/1). + %% Administrative and utility functions -export([ info/0, @@ -36,7 +42,6 @@ if_index2name/1, if_names/0 ]). --endif. %% Deprecated functions from the "old" net module -export([call/4, @@ -46,8 +51,6 @@ relay/1, sleep/1]). --ifdef(USE_ESOCK). - %% Should we define these here or refer to the prim_net module -export_type([ address_info/0, @@ -60,7 +63,7 @@ network_interface_name/0, network_interface_index/0 ]). --endif. + -deprecated({call, 4, eventually}). -deprecated({cast, 4, eventually}). @@ -70,8 +73,6 @@ -deprecated({sleep, 1, eventually}). --ifdef(USE_ESOCK). - -type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. -type name_info_flag() :: namereqd | dgram | @@ -90,8 +91,6 @@ -type network_interface_name() :: string(). -type network_interface_index() :: non_neg_integer(). --endif. - %% =========================================================================== %% @@ -107,8 +106,6 @@ sleep(T) -> receive after T -> ok end. relay(X) -> slave:relay(X). --ifdef(USE_ESOCK). - %% =========================================================================== %% %% Administrative and utility API @@ -117,14 +114,26 @@ relay(X) -> slave:relay(X). -spec info() -> list(). +-ifdef(USE_ESOCK). info() -> prim_net:info(). +-else. +-dialyzer({nowarn_function, info/0}). +info() -> + erlang:error(notsup). +-endif. -spec command(Cmd :: term()) -> term(). +-ifdef(USE_ESOCK). command(Cmd) -> prim_net:command(Cmd). +-else. +-dialyzer({nowarn_function, command/1}). +command(_Cmd) -> + erlang:error(notsup). +-endif. @@ -144,8 +153,14 @@ command(Cmd) -> HostName :: string(), Reason :: term(). +-ifdef(USE_ESOCK). gethostname() -> prim_net:gethostname(). +-else. +-dialyzer({nowarn_function, gethostname/0}). +gethostname() -> + erlang:error(notsup). +-endif. %% =========================================================================== @@ -168,6 +183,7 @@ getnameinfo(SockAddr) -> Info :: name_info(), Reason :: term(). +-ifdef(USE_ESOCK). getnameinfo(SockAddr, [] = _Flags) -> getnameinfo(SockAddr, undefined); getnameinfo(#{family := Fam, addr := _Addr} = SockAddr, Flags) @@ -177,7 +193,18 @@ getnameinfo(#{family := Fam, addr := _Addr} = SockAddr, Flags) getnameinfo(#{family := Fam, path := _Path} = SockAddr, Flags) when (Fam =:= local) andalso (is_list(Flags) orelse (Flags =:= undefined)) -> prim_net:getnameinfo(SockAddr, Flags). - +-else. +-dialyzer({nowarn_function, getnameinfo/2}). +getnameinfo(SockAddr, [] = _Flags) -> + getnameinfo(SockAddr, undefined); +getnameinfo(#{family := Fam, addr := _Addr} = _SockAddr, Flags) + when ((Fam =:= inet) orelse (Fam =:= inet6)) andalso + (is_list(Flags) orelse (Flags =:= undefined)) -> + erlang:error(notsup); +getnameinfo(#{family := Fam, path := _Path} = _SockAddr, Flags) + when (Fam =:= local) andalso (is_list(Flags) orelse (Flags =:= undefined)) -> + erlang:error(notsup). +-endif. %% =========================================================================== @@ -209,11 +236,21 @@ getaddrinfo(Host) when is_list(Host) -> Info :: [address_info()], Reason :: term(). +-ifdef(USE_ESOCK). getaddrinfo(Host, Service) when (is_list(Host) orelse (Host =:= undefined)) andalso (is_list(Service) orelse (Service =:= undefined)) andalso (not ((Service =:= undefined) andalso (Host =:= undefined))) -> prim_net:getaddrinfo(Host, Service). +-else. +-dialyzer({nowarn_function, getaddrinfo/2}). +getaddrinfo(Host, Service) + when (is_list(Host) orelse (Host =:= undefined)) andalso + (is_list(Service) orelse (Service =:= undefined)) andalso + (not ((Service =:= undefined) andalso (Host =:= undefined))) -> + erlang:error(notsup). +-endif. + @@ -229,8 +266,14 @@ getaddrinfo(Host, Service) Idx :: network_interface_index(), Reason :: term(). +-ifdef(USE_ESOCK). if_name2index(If) when is_list(If) -> prim_net:if_name2index(If). +-else. +-dialyzer({nowarn_function, if_name2index/1}). +if_name2index(If) when is_list(If) -> + erlang:error(notsup). +-endif. @@ -246,8 +289,14 @@ if_name2index(If) when is_list(If) -> Name :: network_interface_name(), Reason :: term(). +-ifdef(USE_ESOCK). if_index2name(Idx) when is_integer(Idx) -> prim_net:if_index2name(Idx). +-else. +-dialyzer({nowarn_function, if_index2name/1}). +if_index2name(Idx) when is_integer(Idx) -> + erlang:error(notsup). +-endif. @@ -263,9 +312,13 @@ if_index2name(Idx) when is_integer(Idx) -> If :: network_interface_name(), Reason :: term(). +-ifdef(USE_ESOCK). if_names() -> prim_net:if_names(). +-else. +-dialyzer({nowarn_function, if_names/0}). +if_names() -> + erlang:error(notsup). +-endif. - --endif. -- cgit v1.2.3 From f967324f020808955465a0714d9b0704d1c1d82c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 27 Jun 2019 16:35:01 +0200 Subject: [esock|kernel] Updated kernel app file Added the (re-) added net module to the application app file. OTP-15765 --- lib/kernel/src/kernel.app.src | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/kernel') diff --git a/lib/kernel/src/kernel.app.src b/lib/kernel/src/kernel.app.src index 8fe6bdd1ca..c2ff6b63e9 100644 --- a/lib/kernel/src/kernel.app.src +++ b/lib/kernel/src/kernel.app.src @@ -74,6 +74,7 @@ logger_simple_h, logger_std_h, logger_sup, + net, net_adm, net_kernel, os, -- cgit v1.2.3