1 PACKAGE utl_inaddr AUTHID CURRENT_USER AS
2
3 /*******************************************************************
4 * OVERVIEW
5 *
6 * This package allows a PL/SQL program to retrieve host name and
7 * IP address information of local or remote host. The functionality
8 * provided by this package does not cover the full functionality of
9 * Domain Name Resolution (also known as DNS).
10 *
11 * USES
12 *
13 * Call get_host_name() to retrieve the name of a local or remote host.
14 * Call get_host_address() to retrieve the IP address of a local or remote
15 * host.
16 *
17 * EXAMPLES
18 * Retrieve local host name and IP address.
19 *
20 * BEGIN
21 * dbms_output.put_line(utl_inaddr.get_host_name); -- get local host name
22 * dbms_output.put_line(utl_inaddr.get_host_address); -- get local IP addr
23 * END;
24 */
25
26 /*
27 * Exceptions
28 */
29 unknown_host EXCEPTION; -- Unknown host
30 network_access_denied EXCEPTION; -- Network access denied
31 unknown_host_errcode CONSTANT PLS_INTEGER := -29257;
32 network_access_denied_errcode CONSTANT PLS_INTEGER := -24247;
33 PRAGMA EXCEPTION_INIT(unknown_host, -29257);
34 PRAGMA EXCEPTION_INIT(network_access_denied, -24247);
35
36 /**
37 * Retrieves the name of the local or remote host given its IP address.
38 *
39 * PARAMETERS
40 * ip the IP address of the host to determine its host name.
41 * If ip is not NULL, the official name of the host with its
42 * domain name will be returned. If this is null, the name of
43 * the local host will be returned and the name will not contain
44 * the domain to which the local host belongs.
45 * RETURN
46 * The name of the local or remote host of the specified IP address.
47 * EXCEPTIONS
48 * unknown_host - the specified IP address is not known.
49 */
50 FUNCTION get_host_name(ip IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2;
51
52 /**
53 * Retrieves the IP address of the specified host.
54 *
55 * PARAMETERS
56 * host the host to determine its IP address. If this is null,
57 * the IP address of the local host will be returned.
58 * RETURN
59 * The IP address of the specified host, or that of the local host
60 * if host is NULL.
61 * EXCEPTIONS
62 * unknown_host - the specified host is not known.
63 */
64 FUNCTION get_host_address (host IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2;
65
66 END;