Added SILC Thread Queue API
[silc.git] / lib / silcutil / silcnet.h
1 /*
2
3   silcnet.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2007 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/SILC Net Interface
21  *
22  * DESCRIPTION
23  *
24  * SILC Net API provides various network routines for applications. It
25  * can be used to create TCP/IP and UDP/IP connections and listeners.
26  * Various utility functions for resolving various information is also
27  * provided.
28  *
29  ***/
30
31 #ifndef SILCNET_H
32 #define SILCNET_H
33
34 /* Prototypes */
35
36 /****s* silcutil/SilcNetAPI/SilcNetListener
37  *
38  * NAME
39  *
40  *    typedef struct SilcNetListenerStruct *SilcNetListener;
41  *
42  * DESCRIPTION
43  *
44  *    The network listenr context.  This context is created with the
45  *    silc_net_create_listener function and destroyed with
46  *    silc_net_close_listener function.
47  *
48  ***/
49 typedef struct SilcNetListenerStruct *SilcNetListener;
50
51 /****f* silcutil/SilcNetAPI/SilcNetCallback
52  *
53  * SYNOPSIS
54  *
55  *    typedef void (*SilcNetCallback)(SilcResult status,
56  *                                    SilcStream stream, void *context);
57  *
58  * DESCRIPTION
59  *
60  *    A callback of this type is returned by silc_net_tcp_create_listener
61  *    and silc_net_tcp_connect functions.  For silc_net_tcp_create_listener
62  *    this callback means that new incoming connection was accepted, and the
63  *    `stream' is the socket stream representing the socket connection.
64  *
65  *    For silc_net_tcp_connect this means that we have connected to the
66  *    remote host and the `stream' is the socket stream for the socket
67  *    connection.  The SILC Stream API (such as silc_stream_read, etc.) can
68  *    be used to read and write to the stream.  The created stream is socket
69  *    stream so various SilcSocketStream API functions can be used with
70  *    the `stream'.
71  *
72  ***/
73 typedef void (*SilcNetCallback)(SilcResult status,
74                                 SilcStream stream, void *context);
75
76 /****f* silcutil/SilcNetAPI/silc_net_tcp_create_listener
77  *
78  * SYNOPSIS
79  *
80  *    SilcNetListener
81  *    silc_net_tcp_create_listener(const char **local_ip_addr,
82  *                                 SilcUInt32 local_ip_count, int port,
83  *                                 SilcBool lookup, SilcBool require_fqdn,
84  *                                 SilcSchedule schedule,
85  *                                 SilcNetCallback callback, void *context);
86  *
87  * DESCRIPTION
88  *
89  *    This function creates TCP listener.  This is used to create network
90  *    listener for incoming connections, and `callback' will be called
91  *    everytime new connection is received.  If `local_ip_addr' is NULL 'any'
92  *    address is used.  If provided it can be used bind the listener to
93  *    `local_ip_count' many IP addresses provided in `local_ip_addr' table.
94  *    On success returns the SilcNetListener context, or NULL on error.
95  *    If `require_fqdn' is TRUE the listener will require that the incoming
96  *    connection has FQDN to be able to connect.  If the `lookup' is TRUE
97  *    then the incoming connection hostname will be resolved.  If the `port'
98  *    is zero (0), operating system will define it automatically.
99  *
100  *    The `callback' always delivers valid new stream.  It is not called
101  *    with an error status.  If `schedule' is NULL this will call
102  *    silc_schedule_get_global to try to get global scheduler.
103  *
104  ***/
105 SilcNetListener
106 silc_net_tcp_create_listener(const char **local_ip_addr,
107                              SilcUInt32 local_ip_count, int port,
108                              SilcBool lookup, SilcBool require_fqdn,
109                              SilcSchedule schedule,
110                              SilcNetCallback callback, void *context);
111
112 /****f* silcutil/SilcNetAPI/silc_net_tcp_create_listener2
113  *
114  * SYNOPSIS
115  *
116  *    SilcNetListener
117  *    silc_net_tcp_create_listener2(const char *local_ip_addr, int *ports,
118  *                                  SilcUInt32 port_count,
119  *                                  SilcBool ignore_port_error,
120  *                                  SilcBool lookup, SilcBool require_fqdn,
121  *                                  SilcSchedule schedule,
122  *                                  SilcNetCallback callback, void *context);
123  *
124  * DESCRIPTION
125  *
126  *    This function creates TCP listener.  This is used to create network
127  *    listener for incoming connections, and `callback' will be called
128  *    everytime new connection is received.  If `local_ip_addr' is NULL 'any'
129  *    address is used.  If `ports' is NULL or it contains a zero (0) port,
130  *    operating system will define it automatically.  This function can be
131  *    used to bind to many ports at the same time.  If `ignore_port_error'
132  *    is TRUE this won't return NULL if at least one of the ports could
133  *    be bound.  Otherwise, NULL will be returned on error.
134  *
135  *    If `require_fqdn' is TRUE the listener will require that the incoming
136  *    connection has FQDN to be able to connect.  If the `lookup' is TRUE
137  *    then the incoming connection hostname will be resolved.
138  *
139  *    The `callback' always delivers valid new stream.  It is not called
140  *    with an error status.  If `schedule' is NULL this will call
141  *    silc_schedule_get_global to try to get global scheduler.
142  *
143  ***/
144 SilcNetListener
145 silc_net_tcp_create_listener2(const char *local_ip_addr, int *ports,
146                               SilcUInt32 port_count,
147                               SilcBool ignore_port_error,
148                               SilcBool lookup, SilcBool require_fqdn,
149                               SilcSchedule schedule,
150                               SilcNetCallback callback, void *context);
151
152 /****f* silcutil/SilcNetAPI/silc_net_listener_get_port
153  *
154  * SYNOPSIS
155  *
156  *    SilcUInt16 silc_net_listener_get_port(SilcNetListener listener);
157  *
158  * DESCRIPTION
159  *
160  *    Returns the ports to where the `listener' is bound.  This can be used
161  *    to get the port if none was specified in silc_net_tcp_create_listener.
162  *    Returns an array of ports of size of `port_count'.  The caller must
163  *    free the array with silc_free.  There are as many ports in the array
164  *    as there were IP addresses provided in silc_net_tcp_create_listener,
165  *    as there were ports provided in silc_net_tcp_create_listener2.
166  *
167  ***/
168 SilcUInt16 *silc_net_listener_get_port(SilcNetListener listener,
169                                        SilcUInt32 *port_count);
170
171 /****f* silcutil/SilcNetAPI/silc_net_listener_get_ip
172  *
173  * SYNOPSIS
174  *
175  *    char **silc_net_listener_get_ip(SilcNetListener listener,
176  *                                    SilcUInt32 *ip_count);
177  *
178  * DESCRIPTION
179  *
180  *    Returns the IP's to where the `listener' is bound.  Returns an array
181  *    of IP addresses of size of `port_count'.  The caller must free the
182  *    array and its strings with silc_free.
183  *
184  ***/
185 char **silc_net_listener_get_ip(SilcNetListener listener,
186                                 SilcUInt32 *ip_count);
187
188 /****f* silcutil/SilcNetAPI/silc_net_listener_get_hostname
189  *
190  * SYNOPSIS
191  *
192  *    char **silc_net_listener_get_hostname(SilcNetListener listener,
193  *                                          SilcUInt32 *hostname_count);
194  *
195  * DESCRIPTION
196  *
197  *    Returns the hostnames to where the `listener' is bound.  Returns an
198  *    array of hostnames of size of `port_count'.  The caller must free the
199  *    array and its strings with silc_free.
200  *
201  ***/
202 char **silc_net_listener_get_hostname(SilcNetListener listener,
203                                       SilcUInt32 *hostname_count);
204
205 /****f* silcutil/SilcNetAPI/silc_net_close_listener
206  *
207  * SYNOPSIS
208  *
209  *    void silc_net_close_listener(SilcNetListener listener);
210  *
211  * DESCRIPTION
212  *
213  *    Closes the network listener indicated by `listener'.
214  *
215  ***/
216 void silc_net_close_listener(SilcNetListener listener);
217
218 /****f* silcutil/SilcNetAPI/silc_net_tcp_connect
219  *
220  * SYNOPSIS
221  *
222  *    SilcAsyncOperation silc_net_tcp_connect(const char *local_ip_addr,
223  *                                            const char *remote_ip_addr,
224  *                                            int remote_port,
225  *                                            SilcSchedule schedule,
226  *                                            SilcNetCallback callback,
227  *                                            void *context);
228  *
229  * DESCRIPTION
230  *
231  *    Creates TCP/IP connection to the remote host indicated by `remote_host'
232  *    which may be hostname or IP address, on the port indicated by
233  *    `remote_port'.  If the `local_ip_addr' is provided the local host is
234  *    bound to that address before creating the connection.  This is
235  *    asynchronous call, and this function returns before the connection is
236  *    actually established.  The `callback' will be called after the
237  *    connection is created to deliver the SilcStream for the created
238  *    connection.  This function supports IPv6 if the platform supports it.
239  *
240  *    The returned SilcAsyncOperation context can be used to control the
241  *    asynchronous connecting, such as to abort it.  If it is aborted
242  *    using silc_async_abort the `callback' will not be called.  If NULL
243  *    is returned the operation cannot be aborted.  If `schedule' is NULL
244  *    this will call silc_schedule_get_global to try to get global scheduler.
245  *
246  ***/
247 SilcAsyncOperation silc_net_tcp_connect(const char *local_ip_addr,
248                                         const char *remote_ip_addr,
249                                         int remote_port,
250                                         SilcSchedule schedule,
251                                         SilcNetCallback callback,
252                                         void *context);
253
254 /****f* silcutil/SilcNetAPI/silc_net_udp_connect
255  *
256  * SYNOPSIS
257  *
258  *    SilcStream
259  *    silc_net_udp_connect(const char *local_ip_addr, int local_port,
260  *                         const char *remote_ip_addr, int remote_port,
261  *                         SilcSchedule schedule);
262  *
263  * DESCRIPTION
264  *
265  *    This function creates UDP stream.  The UDP stream is bound to the
266  *    `local_ip_addr' if it is specified.  If `local_port' is non-zero the
267  *    stream is bound to that port.  If the `remote_ip_addr' and `remote_port'
268  *    is also provided, packets may be sent to that address using
269  *    silc_stream_write function and packets may be received using
270  *    silc_stream_read function.
271  *
272  *    If the remote address is not provided the stream is in connectionless
273  *    state.  This means that packets can be received only by using
274  *    silc_net_udp_receive and sent only by using the function
275  *    silc_net_udp_send.
276  *
277  *    To receive packets the silc_stream_set_notifier must be called for the
278  *    returned SilcStream.  The packets are always received in the notifier
279  *    callback when the SILC_STREAM_CAN_READ is returned to the callback
280  *    To read the packet use silc_stream_read if the remote address was
281  *    provided, and silc_net_udp_receive if it was not.
282  *
283  *    Supports IPv6 if the platform supports it.  If `schedule' is NULL this
284  *    will call silc_schedule_get_global to try to get global scheduler.
285  *
286  * EXAMPLE
287  *
288  *    SilcStream udpstream;
289  *
290  *    // Create UDP stream and prepare to receive packets
291  *    udpstream = silc_net_udp_connect("10.2.1.7", 5000,
292  *                                     "10.2.1.100, 5000, schedule);
293  *    silc_stream_set_notifier(udpstream, schedule, receive_callback, context);
294  *
295  *    // Send packet to remote host
296  *    silc_stream_write(udpstream, data, data_len);
297  *
298  *    Create UDP listener:
299  *
300  *    udpstream = silc_net_udp_connect("0.0.0.0", 500, NULL, 0, schedule);
301  *    silc_stream_set_notifier(udpstream, schedule, receive_callback, context);
302  *
303  ***/
304 SilcStream silc_net_udp_connect(const char *local_ip_addr, int local_port,
305                                 const char *remote_ip_addr, int remote_port,
306                                 SilcSchedule schedule);
307
308 /****f* silcutil/SilcNetAPI/silc_net_udp_receive
309  *
310  * SYNOPSIS
311  *
312  *    int
313  *    silc_net_udp_receive(SilcStream stream, char *remote_ip_addr,
314  *                         SilcUInt32 remote_ip_addr_size, int *remote_port,
315  *                         unsigned char *ret_data, SilcUInt32 data_size)
316  *
317  * DESCRIPTION
318  *
319  *    Receive a UDP packet from the `stream'.  The IP address and port of
320  *    the sender is returned into `remote_ip_addr' buffer and `remote_port'
321  *    pointer.  The packet data is returned into the `ret_data' buffer.
322  *
323  *    Returns the length of the packet, or -1 on error or 0 in case of EOF.
324  *
325  ***/
326 int silc_net_udp_receive(SilcStream stream, char *remote_ip_addr,
327                          SilcUInt32 remote_ip_addr_size, int *remote_port,
328                          unsigned char *ret_data, SilcUInt32 data_size);
329
330 /****f* silcutil/SilcNetAPI/silc_net_udp_send
331  *
332  * SYNOPSIS
333  *
334  *    int silc_net_udp_send(SilcStream stream,
335  *                          const char *remote_ip_addr, int remote_port,
336  *                          const unsigned char *data, SilcUInt32 data_len);
337  *
338  * DESCRIPTION
339  *
340  *    Sends an UDP packet to remote host `remote_ip_addr' on `remote_port'.
341  *    This may be used with UDP streams that are not connected to any
342  *    specific remote host.  With those stream silc_stream_write cannot be
343  *    used.  In those cases, this function must be used.  This may also be
344  *    used even if the stream is connected.
345  *
346  *    Returns the amount of data written, -1 if data could not be written
347  *    at this moment, or -2 if error occurred.  If -1 is returned the
348  *    notifier callback will later be called with SILC_STREAM_CAN_WRITE
349  *    status when stream is again ready for writing.
350  *
351  ***/
352 int silc_net_udp_send(SilcStream stream,
353                       const char *remote_ip_addr, int remote_port,
354                       const unsigned char *data, SilcUInt32 data_len);
355
356 /****f* silcutil/SilcNetAPI/silc_net_close_connection
357  *
358  * SYNOPSIS
359  *
360  *    void silc_net_close_connection(int sock);
361  *
362  * DESCRIPTION
363  *
364  *    Closes the connection by closing the socket connection.  This routine
365  *    can only be used with POSIX compliant systems.
366  *
367  ***/
368 void silc_net_close_connection(int sock);
369
370 /****f* silcutil/SilcNetAPI/silc_net_accept_connection
371  *
372  * SYNOPSIS
373  *
374  *    int silc_net_accept_connection(int sock);
375  *
376  * DESCRIPTION
377  *
378  *    Accepts a connection from a particular socket.  This routine can only
379  *    be used with POSIX compliant systems.  This call is equivalent to
380  *    accept(2).
381  *
382  ***/
383 int silc_net_accept_connection(int sock);
384
385 /****f* silcutil/SilcNetAPI/silc_net_set_socket_opt
386  *
387  * SYNOPSIS
388  *
389  *    int silc_net_set_socket_opt(int sock, int level, int option, int on);
390  *
391  * DESCRIPTION
392  *
393  *    Sets a option for a socket.  This function can be used to set
394  *    various options for the socket.  Some of the options might be
395  *    system specific.  This routine can only be used with POSIX compliant
396  *    systems.  This call is equivalent to setsockopt(2);
397  *
398  ***/
399 int silc_net_set_socket_opt(int sock, int level, int option, int on);
400
401 /****f* silcutil/SilcNetAPI/silc_net_get_socket_opt
402  *
403  * SYNOPSIS
404  *
405  *    int silc_net_get_socket_opt(int sock, int level, int option,
406  *                                void *optval, int *opt_len);
407  *
408  * DESCRIPTION
409  *
410  *    Return socket options to the `optval' and `opt_len'.  This routine
411  *    can only be used with POSIX compliant systems.  This call is
412  *    equivalent to getsockopt(2).
413  *
414  ***/
415 int silc_net_get_socket_opt(int sock, int level, int option,
416                             void *optval, int *opt_len);
417
418 /****f* silcutil/SilcNetAPI/silc_net_set_socket_nonblock
419  *
420  * SYNOPSIS
421  *
422  *    int silc_net_set_socket_nonblock(SilcSocket sock);
423  *
424  * DESCRIPTION
425  *
426  *    Sets the socket `sock' to non-blocking mode.
427  *
428  ***/
429 int silc_net_set_socket_nonblock(SilcSocket sock);
430
431 /****f* silcutil/SilcNetAPI/silc_net_is_ip4
432  *
433  * SYNOPSIS
434  *
435  *    SilcBool silc_net_is_ip4(const char *addr);
436  *
437  * DESCRIPTION
438  *
439  *    Checks whether IP address sent as argument is valid IPv4 address.
440  *
441  ***/
442 SilcBool silc_net_is_ip4(const char *addr);
443
444 /****f* silcutil/SilcNetAPI/silc_net_is_ip6
445  *
446  * SYNOPSIS
447  *
448  *    SilcBool silc_net_is_ip6(const char *addr);
449  *
450  * DESCRIPTION
451  *
452  *    Checks whether IP address sent as argument is valid IPv6 address.
453  *
454  ***/
455 SilcBool silc_net_is_ip6(const char *addr);
456
457 /****f* silcutil/SilcNetAPI/silc_net_is_ip
458  *
459  * SYNOPSIS
460  *
461  *    SilcBool silc_net_is_ip(const char *addr);
462  *
463  * DESCRIPTION
464  *
465  *    Checks whether IP address sent as argument is valid IP address.
466  *    This supports both IPv4 and IPv6 addresses.
467  *
468  ***/
469 SilcBool silc_net_is_ip(const char *addr);
470
471 /****f* silcutil/SilcNetAPI/silc_net_addr2bin
472  *
473  * SYNOPSIS
474  *
475  *    SilcBool silc_net_addr2bin(const char *addr, void *bin,
476  *                               SilcUInt32 bin_len);
477  *
478  * DESCRIPTION
479  *
480  *    Converts the IP number string from numbers-and-dots notation to
481  *    binary form in network byte order.  The address can be either
482  *    IPv4 or IPv6 address.
483  *
484  ***/
485 SilcBool silc_net_addr2bin(const char *addr, void *bin, SilcUInt32 bin_len);
486
487 /****f* silcutil/SilcNetAPI/SilcNetResolveCallback
488  *
489  * SYNOPSIS
490  *
491  *    typedef void (*SilcNetResolveCallback)(const char *result,
492  *                                           void *context);
493  *
494  * DESCRIPTION
495  *
496  *    A callback function of this type is called after the asynchronous
497  *    resolving operation has been completed.  This callback is used
498  *    when asynchronously resolving IP addresses and hostnames.
499  *
500  ***/
501 typedef void (*SilcNetResolveCallback)(const char *result, void *context);
502
503 /****f* silcutil/SilcNetAPI/silc_net_gethostbyname
504  *
505  * SYNOPSIS
506  *
507  *    SilcBool silc_net_gethostbyname(const char *name, SilcBool prefer_ipv6,
508  *                                    char *address, SilcUInt32 address_len);
509  *
510  * DESCRIPTION
511  *
512  *    Resolves the IP address of the hostname indicated by the `name'.
513  *    This returns TRUE and the IP address of the host to the `address'
514  *    buffer, or FALSE if the address could not be resolved.  This is
515  *    synchronous function and will block the calling process.  If the
516  *    `prefer_ipv6' is TRUE then this will return IPv6 address if it
517  *    finds.  If FALSE if returns IPv4 address even if it found IPv6
518  *    address also.
519  *
520  ***/
521 SilcBool silc_net_gethostbyname(const char *name, SilcBool prefer_ipv6,
522                                 char *address, SilcUInt32 address_len);
523
524 /****f* silcutil/SilcNetAPI/silc_net_gethostbyname_async
525  *
526  * SYNOPSIS
527  *
528  *    void silc_net_gethostbyname_async(const char *name,
529  *                                      SilcBool prefer_ipv6,
530  *                                      SilcSchedule schedule,
531  *                                      SilcNetResolveCallback completion,
532  *                                      void *context)
533  *
534  * DESCRIPTION
535  *
536  *    Asynchronously resolves the IP address of the hostname indicated
537  *    by the `name'.  This function returns immediately, and the
538  *    `completion' callback will be called after the resolving is
539  *    completed.  If `schedule' is NULL this will call silc_schedule_get_global
540  *    to try to get global scheduler.
541  *
542  *    If the `prefer_ipv6' is TRUE then this will return IPv6 address if it
543  *    finds.  If FALSE if returns IPv4 address even if it found IPv6
544  *    address also.
545  *
546  ***/
547 void silc_net_gethostbyname_async(const char *name,
548                                   SilcBool prefer_ipv6,
549                                   SilcSchedule schedule,
550                                   SilcNetResolveCallback completion,
551                                   void *context);
552
553 /****f* silcutil/SilcNetAPI/silc_net_gethostbyaddr
554  *
555  * SYNOPSIS
556  *
557  *   SilcBool silc_net_gethostbyaddr(const char *addr, char *name,
558  *                                   SilcUInt32 name_len);
559  *
560 x * DESCRIPTION
561  *
562  *    Resolves the hostname for the IP address indicated by the `addr'
563  *    This returns TRUE and the resolved hostname to the `name' buffer,
564  *    or FALSE on error. The `addr' may be either IPv4 or IPv6 address.
565  *    This is synchronous function and will block the calling process.
566  *
567  ***/
568 SilcBool silc_net_gethostbyaddr(const char *addr, char *name,
569                                 SilcUInt32 name_len);
570
571 /****f* silcutil/SilcNetAPI/silc_net_gethostbyaddr_async
572  *
573  * SYNOPSIS
574  *
575  *    void silc_net_gethostbyaddr_async(const char *addr,
576  *                                      SilcSchedule schedule,
577  *                                      SilcNetResolveCallback completion,
578  *                                      void *context)
579  *
580  * DESCRIPTION
581  *
582  *    Asynchronously resolves the hostname for the IP address indicated
583  *    by the `addr'.  This function returns immediately, and the
584  *    `completion' callback will be called after the resolving is
585  *    completed.  If `schedule' is NULL this will call silc_schedule_get_global
586  *    to try to get global scheduler.
587  *
588  ***/
589 void silc_net_gethostbyaddr_async(const char *addr,
590                                   SilcSchedule schedule,
591                                   SilcNetResolveCallback completion,
592                                   void *context);
593
594 /****f* silcutil/SilcNetAPI/silc_net_check_host_by_sock
595  *
596  * SYNOPSIS
597  *
598  *    SilcBool silc_net_check_host_by_sock(SilcSocket sock, char **hostname,
599  *                                         char **ip);
600  *
601  * DESCRIPTION
602  *
603  *    Performs lookups for remote name and IP address. This peforms reverse
604  *    lookup as well to verify that the IP has FQDN.
605  *
606  ***/
607 SilcBool silc_net_check_host_by_sock(SilcSocket sock, char **hostname,
608                                      char **ip);
609
610 /****f* silcutil/SilcNetAPI/silc_net_check_local_by_sock
611  *
612  * SYNOPSIS
613  *
614  *    SilcBool silc_net_check_local_by_sock(SilcSocket sock, char **hostname,
615  *                                          char **ip);
616  *
617  * DESCRIPTION
618  *
619  *    Performs lookups for local name and IP address. This peforms reverse
620  *    lookup as well to verify that the IP has FQDN.
621  *
622  ***/
623 SilcBool silc_net_check_local_by_sock(SilcSocket sock, char **hostname,
624                                       char **ip);
625
626 /****f* silcutil/SilcNetAPI/silc_net_get_remote_port
627  *
628  * SYNOPSIS
629  *
630  *    SilcUInt16 silc_net_get_remote_port(SilcSocket sock);
631  *
632  * DESCRIPTION
633  *
634  *    Return remote port by socket.
635  *
636  ***/
637 SilcUInt16 silc_net_get_remote_port(SilcSocket sock);
638
639 /****f* silcutil/SilcNetAPI/silc_net_get_local_port
640  *
641  * SYNOPSIS
642  *
643  *    SilcUInt16 silc_net_get_local_port(SilcSocket sock);
644  *
645  * DESCRIPTION
646  *
647  *    Return local port by socket.
648  *
649  ***/
650 SilcUInt16 silc_net_get_local_port(SilcSocket sock);
651
652 /****f* silcutil/SilcNetAPI/silc_net_localhost
653  *
654  * SYNOPSIS
655  *
656  *    char *silc_net_localhost(void);
657  *
658  * DESCRIPTION
659  *
660  *    Return name of localhost.  This will also attempt to resolve
661  *    the real hostname by the local host's IP address.  If unsuccessful
662  *    the first found hostname is returned.  The caller must free
663  *    returned hostname.
664  *
665  ***/
666 char *silc_net_localhost(void);
667
668 /****f* silcutil/SilcNetAPI/silc_net_localip
669  *
670  * SYNOPSIS
671  *
672  *    char *silc_net_localip(void)
673  *
674  * DESCRIPTION
675  *
676  *    Return IP of localhost.  The caller must free the returned IP.
677  *
678  ***/
679 char *silc_net_localip(void);
680
681 #include "silcnet_i.h"
682
683 #endif /* SILCNET_H */