network.h
Go to the documentation of this file.
/* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _PURPLE_NETWORK_H_
#define _PURPLE_NETWORK_H_
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************/
/**************************************************************************/
typedef struct _PurpleNetworkListenData PurpleNetworkListenData;
typedef void (*PurpleNetworkListenCallback) (int listenfd, gpointer data);
const unsigned char *purple_network_ip_atoi(const char *ip);
void purple_network_set_public_ip(const char *ip);
const char *purple_network_get_public_ip(void);
const char *purple_network_get_local_system_ip(int fd);
GList *purple_network_get_all_local_system_ips(void);
const char *purple_network_get_my_ip(int fd);
void purple_network_listen_map_external(gboolean map_external);
PurpleNetworkListenData *purple_network_listen(unsigned short port,
int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
PurpleNetworkListenData *purple_network_listen_family(unsigned short port,
int socket_family, int socket_type, PurpleNetworkListenCallback cb,
gpointer cb_data);
PurpleNetworkListenData *purple_network_listen_range(unsigned short start,
unsigned short end, int socket_type,
PurpleNetworkListenCallback cb, gpointer cb_data);
PurpleNetworkListenData *purple_network_listen_range_family(
unsigned short start, unsigned short end, int socket_family,
int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
void purple_network_listen_cancel(PurpleNetworkListenData *listen_data);
unsigned short purple_network_get_port_from_fd(int fd);
gboolean purple_network_is_available(void);
void purple_network_force_online(void);
void *purple_network_get_handle(void);
void purple_network_set_stun_server(const gchar *stun_server);
const gchar *purple_network_get_stun_ip(void);
void purple_network_set_turn_server(const gchar *turn_server);
const gchar *purple_network_get_turn_ip(void);
void purple_network_remove_port_mapping(gint fd);
int purple_network_convert_idn_to_ascii(const gchar *in, gchar **out);
void purple_network_init(void);
void purple_network_uninit(void);
#ifdef __cplusplus
}
#endif
#endif /* _PURPLE_NETWORK_H_ */
purple_network_listen_range_family
PurpleNetworkListenData * purple_network_listen_range_family(unsigned short start, unsigned short end, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
Opens a listening port selected from a range of ports.
purple_network_set_public_ip
void purple_network_set_public_ip(const char *ip)
Sets the IP address of the local system in preferences.
purple_network_listen_family
PurpleNetworkListenData * purple_network_listen_family(unsigned short port, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
Attempts to open a listening port ONLY on the specified port number.
purple_network_set_turn_server
void purple_network_set_turn_server(const gchar *turn_server)
Update the TURN server IP given the host name Will result in a DNS query being executed asynchronous...
purple_network_get_local_system_ip
const char * purple_network_get_local_system_ip(int fd)
Returns the IP address of the local system.
purple_network_ip_atoi
const unsigned char * purple_network_ip_atoi(const char *ip)
Converts a dot-decimal IP address to an array of unsigned chars.
purple_network_listen_cancel
void purple_network_listen_cancel(PurpleNetworkListenData *listen_data)
This can be used to cancel any in-progress listener connection by passing in the return value from ei...
purple_network_uninit
void purple_network_uninit(void)
Shuts down the network subsystem.
purple_network_listen_range
PurpleNetworkListenData * purple_network_listen_range(unsigned short start, unsigned short end, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
Opens a listening port selected from a range of ports.
purple_network_get_handle
void * purple_network_get_handle(void)
Get the handle for the network system.
purple_network_get_all_local_system_ips
GList * purple_network_get_all_local_system_ips(void)
Returns all IP addresses of the local system.
purple_network_is_available
gboolean purple_network_is_available(void)
Detects if there is an available network connection.
purple_network_force_online
void purple_network_force_online(void)
Makes purple_network_is_available() always return TRUE.
purple_network_get_turn_ip
const gchar * purple_network_get_turn_ip(void)
Get the IP address of the TURN server as a string representation.
purple_network_listen_map_external
void purple_network_listen_map_external(gboolean map_external)
Should calls to purple_network_listen() and purple_network_listen_range() map the port externally usi...
purple_network_get_public_ip
const char * purple_network_get_public_ip(void)
Returns the IP address of the local system set in preferences.
purple_network_get_port_from_fd
unsigned short purple_network_get_port_from_fd(int fd)
Gets a port number from a file descriptor.
purple_network_convert_idn_to_ascii
int purple_network_convert_idn_to_ascii(const gchar *in, gchar **out)
Convert a UTF-8 domain name to ASCII in accordance with the IDNA specification.
purple_network_get_stun_ip
const gchar * purple_network_get_stun_ip(void)
Get the IP address of the STUN server as a string representation.
purple_network_set_stun_server
void purple_network_set_stun_server(const gchar *stun_server)
Update the STUN server IP given the host name Will result in a DNS query being executed asynchronous...
purple_network_listen
PurpleNetworkListenData * purple_network_listen(unsigned short port, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
Attempts to open a listening port ONLY on the specified port number.
purple_network_get_my_ip
const char * purple_network_get_my_ip(int fd)
Returns the IP address that should be used anywhere a public IP addresses is needed (listening for an...
purple_network_init
void purple_network_init(void)
Initializes the network subsystem.
purple_network_remove_port_mapping
void purple_network_remove_port_mapping(gint fd)
Remove a port mapping (UPnP or NAT-PMP) associated with listening socket.