| 1 |
/*=* Global settings. |
| 2 |
* |
| 3 |
* package: Sockets.Naming |
| 4 |
* intro: |
| 5 |
* The @code{Sockets.Naming} package contains types and helper functions |
| 6 |
* needed to manipulate Internet host names and addresses. |
| 7 |
=*/ |
| 8 |
|
| 9 |
/*=type String_Access |
| 10 |
* |
| 11 |
* what: Access on string |
| 12 |
* def: access String |
| 13 |
* doc: |
| 14 |
* Helper type |
| 15 |
=*/ |
| 16 |
|
| 17 |
/*=type String_Array |
| 18 |
* |
| 19 |
* what: Array of strings |
| 20 |
* def: array (Positive range <>) of String_Access |
| 21 |
* doc: |
| 22 |
* Helper type |
| 23 |
=*/ |
| 24 |
|
| 25 |
/*=type Address_Component |
| 26 |
* |
| 27 |
* what: IPv4 address component (subtype) |
| 28 |
* def: Natural range 0 .. 255 |
| 29 |
* doc: |
| 30 |
* Helper type |
| 31 |
=*/ |
| 32 |
|
| 33 |
/*=type Address |
| 34 |
* |
| 35 |
* what: IPv4 address (subtype) |
| 36 |
* def: record@*@w{ }H1, H2, H3, H4 : Address_Component;@*end record |
| 37 |
* doc: |
| 38 |
* This type represents an IPv4 address with @code{H1} being the first |
| 39 |
* octet and @code{H4} the last one. For example, 137.194.161.2 is |
| 40 |
* represented by @code{H1=137, H2=194, H3=161, H4=2}. |
| 41 |
=*/ |
| 42 |
|
| 43 |
/*=type Address_Array |
| 44 |
* |
| 45 |
* what: array of IPv4 addresses |
| 46 |
* def: array (Positive range <>) of Address |
| 47 |
* doc: |
| 48 |
* Helper type |
| 49 |
=*/ |
| 50 |
|
| 51 |
/*=type Host_Entry |
| 52 |
* |
| 53 |
* discr: N_Aliases, N_Addresses : Natural |
| 54 |
* def: new Ada.Finalization.Controlled with record@*@w{ } Name : String_Access;@*@w{ } Aliases : String_Array (1 .. N_Aliases);@*@w{ } Addresses : Address_Array (1 .. N_Addresses);@* end record |
| 55 |
* doc: |
| 56 |
* The @code{Host_Entry} type holds a set of names and IP addresses |
| 57 |
* associated with a host. Each host can have several IP address |
| 58 |
* as well as several aliases. |
| 59 |
=*/ |
| 60 |
|
| 61 |
/*=subprogram Image |
| 62 |
* |
| 63 |
* what: Make a string from an address |
| 64 |
* kind: function |
| 65 |
* arg: Add, in, Address,, IP address |
| 66 |
* ret: String, String representation of the IP address |
| 67 |
* concept: Representing IP addresses |
| 68 |
* see: Value (function) |
| 69 |
=*/ |
| 70 |
|
| 71 |
/*=subprogram Value |
| 72 |
* |
| 73 |
* what: Transform a string into an address |
| 74 |
* kind: function |
| 75 |
* arg: Add, in, String,, Textual representation of an IP address |
| 76 |
* ret: Address, Corresponding Address |
| 77 |
* concept: Representing IP addresses |
| 78 |
* see: Image (function) |
| 79 |
=*/ |
| 80 |
|
| 81 |
/*=subprogram Is_IP_Address |
| 82 |
* |
| 83 |
* what: Check if given string is a valid IP address |
| 84 |
* kind: function |
| 85 |
* arg: Something, in, String,, String to check |
| 86 |
* ret: Boolean, @samp{True} if @var{Something} is an IP address |
| 87 |
=*/ |
| 88 |
|
| 89 |
/*=subprogram Info_Of_Name_Or_IP |
| 90 |
* |
| 91 |
* what: Get addresses and names of a host |
| 92 |
* kind: function |
| 93 |
* arg: Something, in, String,, Host name or IP address |
| 94 |
* ret: Host_Entry, Corresponding host entry |
| 95 |
* exc: Naming_Error, No information available for this name or address |
| 96 |
* doc: |
| 97 |
* This function extracts all the names and addresses from the |
| 98 |
* naming service. |
| 99 |
=*/ |
| 100 |
|
| 101 |
/*=subprogram Address_Of |
| 102 |
* |
| 103 |
* what: Get the IP address of a host |
| 104 |
* kind: function |
| 105 |
* arg: Something, in, String,, Host name or IP address |
| 106 |
* ret: Address, IPv4 address |
| 107 |
* exc: Naming_Error, No information available for this name or address |
| 108 |
* see: Name_Of (function) |
| 109 |
=*/ |
| 110 |
|
| 111 |
/*=subprogram Host_Name |
| 112 |
* |
| 113 |
* what: Get the name of the current host |
| 114 |
* kind: function |
| 115 |
* ret: String, Name of the current host |
| 116 |
* doc: |
| 117 |
* This function returns the name of the current host. Depending on |
| 118 |
* the local configuration, it may or may not be a fully qualified |
| 119 |
* domain name (FQDN). |
| 120 |
=*/ |
| 121 |
|
| 122 |
/*=subprogram Name_Of |
| 123 |
* |
| 124 |
* what: Official name of the host |
| 125 |
* kind: function |
| 126 |
* arg: Something, in, String,, Host name or IP address |
| 127 |
* ret: String, Name of the host |
| 128 |
* exc: Naming_Error, No information available for this name or address |
| 129 |
* see: Address_Of (function) |
| 130 |
=*/ |
| 131 |
|
| 132 |
/*=subprogram Any_Address |
| 133 |
* |
| 134 |
* what: Special address representing any address on the local host |
| 135 |
* kind: function |
| 136 |
* ret: Address, Equivalent to @code{INADDR_ANY} in the C programming language |
| 137 |
=*/ |
| 138 |
|
| 139 |
/*=subprogram Get_Peer_Addr |
| 140 |
* |
| 141 |
* what: Retrieve IP address of remote host |
| 142 |
* kind: function |
| 143 |
* arg: Socket, in, Socket_FD,, Connected socket object |
| 144 |
* ret: Address, Peer address |
| 145 |
* see: Get_Peer_Port (function) |
| 146 |
* see: Get_Sock_Addr (function) |
| 147 |
=*/ |
| 148 |
|
| 149 |
/*=subprogram Get_Peer_Port |
| 150 |
* |
| 151 |
* what: Retrieve port used by remote host |
| 152 |
* kind: function |
| 153 |
* arg: Socket, in, Socket_FD,, Connected socket object |
| 154 |
* ret: Positive, Port used on the remote host |
| 155 |
* see: Get_Sock_Port (function) |
| 156 |
* see: Get_Peer_Addr (function) |
| 157 |
=*/ |
| 158 |
|
| 159 |
/*=subprogram Get_Sock_Addr |
| 160 |
* |
| 161 |
* what: Retrieve IP address of local host |
| 162 |
* kind: function |
| 163 |
* arg: Socket, in, Socket_FD,, Connected socket object |
| 164 |
* ret: Address, Address of local interface used |
| 165 |
* see: Get_Sock_Port (function) |
| 166 |
* see: Get_Peer_Addr (function) |
| 167 |
=*/ |
| 168 |
|
| 169 |
/*=subprogram Get_Sock_Port |
| 170 |
* |
| 171 |
* what: Retrieve port used by local host |
| 172 |
* kind: function |
| 173 |
* arg: Socket, in, Socket_FD,, Connected socket object |
| 174 |
* ret: Positive, Port used on the local host |
| 175 |
* see: Get_Peer_Port (function) |
| 176 |
* see: Get_Sock_Addr (function) |
| 177 |
=*/ |