← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:18 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/Socket6.pm
StatementsExecuted 25 statements in 1.81ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.07ms3.83msSocket6::::BEGIN@215Socket6::BEGIN@215
111225µs225µsSocket6::::gethostbyname2Socket6::gethostbyname2 (xsub)
111138µs179µsSocket6::::AUTOLOADSocket6::AUTOLOAD
11158µs58µsSocket6::::bootstrapSocket6::bootstrap (xsub)
11150µs65µsSocket6::::BEGIN@38Socket6::BEGIN@38
41130µs30µsSocket6::::inet_ptonSocket6::inet_pton (xsub)
11129µs353µsSocket6::::BEGIN@39Socket6::BEGIN@39
11127µs214µsSocket6::::BEGIN@213Socket6::BEGIN@213
11125µs25µsSocket6::::constantSocket6::constant (xsub)
11116µs16µsSocket6::::CORE:substSocket6::CORE:subst (opcode)
0000s0sSocket6::::sockaddr_in6Socket6::sockaddr_in6
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Copyright (C) 2000-2016 Hajimu UMEMOTO <ume@mahoroba.org>.
2# All rights reserved.
3#
4# This module is based on perl5.005_55-v6-19990721 written by KAME
5# Project.
6#
7# Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
8# All rights reserved.
9#
10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions
12# are met:
13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16# notice, this list of conditions and the following disclaimer in the
17# documentation and/or other materials provided with the distribution.
18# 3. Neither the name of the project nor the names of its contributors
19# may be used to endorse or promote products derived from this software
20# without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
23# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32# SUCH DAMAGE.
33
34# $Id: Socket6.pm 683 2016-07-11 05:45:26Z ume $
35
36package Socket6;
37
38279µs280µs
# spent 65µs (50+15) within Socket6::BEGIN@38 which was called: # once (50µs+15µs) by NetAddr::IP::Lite::BEGIN@9 at line 38
use strict;
# spent 65µs making 1 call to Socket6::BEGIN@38 # spent 15µs making 1 call to strict::import
392419µs2677µs
# spent 353µs (29+324) within Socket6::BEGIN@39 which was called: # once (29µs+324µs) by NetAddr::IP::Lite::BEGIN@9 at line 39
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
# spent 353µs making 1 call to Socket6::BEGIN@39 # spent 324µs making 1 call to vars::import
4012µs$VERSION = "0.28";
41
42=head1 NAME
43
44Socket6 - IPv6 related part of the C socket.h defines and structure manipulators
45
46=head1 SYNOPSIS
47
48 use Socket;
49 use Socket6;
50
51 @res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
52 $family = -1;
53 while (scalar(@res) >= 5) {
54 ($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
55
56 ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
57 print STDERR "Trying to connect to $host port $port...\n";
58
59 socket(Socket_Handle, $family, $socktype, $proto) || next;
60 connect(Socket_Handle, $saddr) && last;
61
62 close(Socket_Handle);
63 $family = -1;
64 }
65
66 if ($family != -1) {
67 print STDERR "connected to $host port $port\n";
68 } else {
69 die "connect attempt failed\n";
70 }
71
72=head1 DESCRIPTION
73
74This module provides glue routines to the various IPv6 functions.
75
76If you use the Socket6 module,
77be sure to specify "use Socket" as well as "use Socket6".
78
79Functions supplied are:
80
81=over
82
83=item inet_pton FAMILY, TEXT_ADDRESS
84
85 This function takes an IP address in presentation (or string) format
86 and converts it into numeric (or binary) format.
87 The type of IP address conversion (IPv4 versus IPv6) is controlled
88 by the FAMILY argument.
89
90=item inet_ntop FAMILY, BINARY_ADDRESS
91
92 This function takes an IP address in numeric (or binary) format
93 and converts it into presentation (or string) format
94 The type of IP address conversion (IPv4 versus IPv6) is controlled
95 by the FAMILY argument.
96
97=item pack_sockaddr_in6 PORT, ADDR
98
99 This function takes two arguments: a port number, and a 16-octet
100 IPv6 address structure (as returned by inet_pton()).
101 It returns the sockaddr_in6 structure with these arguments packed
102 into their correct fields, as well as the AF_INET6 family.
103 The other fields are not set and their values should not be relied upon.
104
105=item pack_sockaddr_in6_all PORT, FLOWINFO, ADDR, SCOPEID
106
107 This function takes four arguments: a port number, a 16-octet
108 IPv6 address structure (as returned by inet_pton), any
109 special flow information, and any specific scope information.
110 It returns a complete sockaddr_in6 structure with these arguments packed
111 into their correct fields, as well as the AF_INET6 family.
112
113=item unpack_sockaddr_in6 NAME
114
115 This function takes a sockaddr_in6 structure (as returned by
116 pack_sockaddr_in6()) and returns a list of two elements:
117 the port number and the 16-octet IP address.
118 This function will croak if it determines it has not been
119 passed an IPv6 structure.
120
121=item unpack_sockaddr_in6_all NAME
122
123 This function takes a sockaddr_in6 structure (as returned by
124 pack_sockaddr_in6()) and returns a list of four elements:
125 the port number, the flow information, the 16-octet IP address,
126 and the scope information.
127 This function will croak if it determines it has not been
128 passed an IPv6 structure.
129
130=item gethostbyname2 HOSTNAME, FAMILY
131
132=item getaddrinfo NODENAME, SERVICENAME, [FAMILY, SOCKTYPE, PROTOCOL, FLAGS]
133
134 This function converts node names to addresses and service names
135 to port numbers.
136 If the NODENAME argument is not a false value,
137 then a nodename to address lookup is performed;
138 otherwise a service name to port number lookup is performed.
139 At least one of NODENAME and SERVICENAME must have a true value.
140
141 If the lookup is successful, a list consisting of multiples of
142 five elements is returned.
143 Each group of five elements consists of the address family,
144 socket type, protocol, 16-octet IP address, and the canonical
145 name (undef if the node name passed is already the canonical name).
146
147 The arguments FAMILY, SOCKTYPE, PROTOCOL, and FLAGS are all optional.
148
149 This function will croak if it determines it has not been
150 passed an IPv6 structure.
151
152 If the lookup is unsuccessful, the function returns a single scalar.
153 This will contain the string version of that error in string context,
154 and the numeric value in numeric context.
155
156=item getnameinfo NAME, [FLAGS]
157
158 This function takes a socket address structure. If successful, it returns
159 two strings containing the node name and service name.
160
161 The optional FLAGS argument controls what kind of lookup is performed.
162
163 If the lookup is unsuccessful, the function returns a single scalar.
164 This will contain the string version of that error in string context,
165 and the numeric value in numeric context.
166
167=item getipnodebyname HOST, [FAMILY, FLAGS]
168
169 This function takes either a node name or an IP address string
170 and performs a lookup on that name (or conversion of the string).
171 It returns a list of five elements: the canonical host name,
172 the address family, the length in octets of the IP addresses
173 returned, a reference to a list of IP address structures, and
174 a reference to a list of aliases for the host name.
175
176 The arguments FAMILY and FLAGS are optional.
177 Note: This function does not handle IPv6 scope identifiers,
178 and should be used with care.
179 And, this function was deprecated in RFC3493.
180 The getnameinfo function should be used instead.
181
182=item getipnodebyaddr FAMILY, ADDRESS
183
184 This function takes an IP address family and an IP address structure
185 and performs a reverse lookup on that address.
186 It returns a list of five elements: the canonical host name,
187 the address family, the length in octets of the IP addresses
188 returned, a reference to a list of IP address structures, and
189 a reference to a list of aliases for the host name.
190
191 Note: This function does not handle IPv6 scope identifiers,
192 and should be used with care.
193 And, this function was deprecated in RFC3493.
194 The getaddrinfo function should be used instead.
195
196=item gai_strerror ERROR_NUMBER
197
198 This function returns a string corresponding to the error number
199 passed in as an argument.
200
201=item in6addr_any
202
203 This function returns the 16-octet wildcard address.
204
205=item in6addr_loopback
206
207 This function returns the 16-octet loopback address.
208
209=back
210
211=cut
212
213273µs2402µs
# spent 214µs (27+187) within Socket6::BEGIN@213 which was called: # once (27µs+187µs) by NetAddr::IP::Lite::BEGIN@9 at line 213
use Carp;
# spent 214µs making 1 call to Socket6::BEGIN@213 # spent 187µs making 1 call to Exporter::import
214
2152945µs24.34ms
# spent 3.83ms (3.07+759µs) within Socket6::BEGIN@215 which was called: # once (3.07ms+759µs) by NetAddr::IP::Lite::BEGIN@9 at line 215
use base qw(Exporter DynaLoader);
# spent 3.83ms making 1 call to Socket6::BEGIN@215 # spent 510µs making 1 call to base::import
216
217112µs@EXPORT = qw(
218 inet_pton inet_ntop pack_sockaddr_in6 pack_sockaddr_in6_all
219 unpack_sockaddr_in6 unpack_sockaddr_in6_all sockaddr_in6
220 gethostbyname2 getaddrinfo getnameinfo
221 in6addr_any in6addr_loopback
222 gai_strerror getipnodebyname getipnodebyaddr
223 AI_ADDRCONFIG
224 AI_ALL
225 AI_CANONNAME
226 AI_NUMERICHOST
227 AI_NUMERICSERV
228 AI_DEFAULT
229 AI_MASK
230 AI_PASSIVE
231 AI_V4MAPPED
232 AI_V4MAPPED_CFG
233 EAI_ADDRFAMILY
234 EAI_AGAIN
235 EAI_BADFLAGS
236 EAI_FAIL
237 EAI_FAMILY
238 EAI_MEMORY
239 EAI_NODATA
240 EAI_NONAME
241 EAI_SERVICE
242 EAI_SOCKTYPE
243 EAI_SYSTEM
244 EAI_BADHINTS
245 EAI_PROTOCOL
246 IP_AUTH_TRANS_LEVEL
247 IP_AUTH_NETWORK_LEVEL
248 IP_ESP_TRANS_LEVEL
249 IP_ESP_NETWORK_LEVEL
250 IPPROTO_IP
251 IPPROTO_IPV6
252 IPSEC_LEVEL_AVAIL
253 IPSEC_LEVEL_BYPASS
254 IPSEC_LEVEL_DEFAULT
255 IPSEC_LEVEL_NONE
256 IPSEC_LEVEL_REQUIRE
257 IPSEC_LEVEL_UNIQUE
258 IPSEC_LEVEL_USE
259 IPV6_AUTH_TRANS_LEVEL
260 IPV6_AUTH_NETWORK_LEVEL
261 IPV6_ESP_NETWORK_LEVEL
262 IPV6_ESP_TRANS_LEVEL
263 NI_NOFQDN
264 NI_NUMERICHOST
265 NI_NAMEREQD
266 NI_NUMERICSERV
267 NI_DGRAM
268 NI_WITHSCOPEID
269);
27025µspush @EXPORT, qw(AF_INET6) unless defined eval {Socket::AF_INET6()};
271213µspush @EXPORT, qw(PF_INET6) unless defined eval {Socket::PF_INET6()};
272
27312µs@EXPORT_OK = qw(AF_INET6 PF_INET6);
274
275123µs%EXPORT_TAGS = (
276 all => [@EXPORT],
277);
278
279sub sockaddr_in6 {
280 if (wantarray) {
281 croak "usage: (port,iaddr) = sockaddr_in6(sin_sv)" unless @_ == 1;
282 unpack_sockaddr_in6(@_);
283 } else {
284 croak "usage: sin_sv = sockaddr_in6(port,iaddr))" unless @_ == 2;
285 pack_sockaddr_in6(@_);
286 }
287}
288
289
# spent 179µs (138+41) within Socket6::AUTOLOAD which was called: # once (138µs+41µs) by base::import at line 958 of Net/DNS/Resolver/Base.pm
sub AUTOLOAD {
29012µs my($constname);
291130µs116µs ($constname = $AUTOLOAD) =~ s/.*:://o;
# spent 16µs making 1 call to Socket6::CORE:subst
29213µs $! = 0;
293139µs125µs my $val = constant($constname, @_ ? $_[0] : 0);
# spent 25µs making 1 call to Socket6::constant
29416µs if ($! != 0) {
295 croak "Your vendor has not defined Socket macro $constname, used";
296 }
297183µs eval "sub $AUTOLOAD { $val }";
# spent 14µs executing statements in string eval
# includes 4µs spent executing 1 call to 1 sub defined therein.
298117µs14µs goto &$AUTOLOAD;
# spent 4µs making 1 call to Socket6::AI_NUMERICHOST
299}
300
301120µs1578µsbootstrap Socket6 $VERSION;
# spent 578µs making 1 call to DynaLoader::bootstrap
302
303134µs1;
 
# spent 16µs within Socket6::CORE:subst which was called: # once (16µs+0s) by Socket6::AUTOLOAD at line 291
sub Socket6::CORE:subst; # opcode
# spent 58µs within Socket6::bootstrap which was called: # once (58µs+0s) by DynaLoader::bootstrap at line 210 of DynaLoader.pm
sub Socket6::bootstrap; # xsub
# spent 25µs within Socket6::constant which was called: # once (25µs+0s) by Socket6::AUTOLOAD at line 293
sub Socket6::constant; # xsub
# spent 225µs within Socket6::gethostbyname2 which was called: # once (225µs+0s) by NetAddr::IP::Lite::BEGIN@18 at line 240 of NetAddr/IP/Util.pm
sub Socket6::gethostbyname2; # xsub
# spent 30µs within Socket6::inet_pton which was called 4 times, avg 8µs/call: # 4 times (30µs+0s) by Net::Patricia::AF_INET6::add at line 250 of Net/Patricia.pm, avg 8µs/call
sub Socket6::inet_pton; # xsub