mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 21:00:40 +02:00
..adding new files..
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@171 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
d01b094151
commit
c95034c6de
206 changed files with 31247 additions and 0 deletions
71
src/core/network.h
Normal file
71
src/core/network.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef __NETWORK_H
|
||||
#define __NETWORK_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct _ipaddr {
|
||||
unsigned short family;
|
||||
union {
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr ip6;
|
||||
#else
|
||||
struct in_addr ip;
|
||||
#endif
|
||||
} addr;
|
||||
};
|
||||
|
||||
typedef struct _ipaddr IPADDR;
|
||||
|
||||
/* maxmimum string length of IP address */
|
||||
#ifdef HAVE_IPV6
|
||||
# define MAX_IP_LEN INET6_ADDRSTRLEN
|
||||
#else
|
||||
# define MAX_IP_LEN 20
|
||||
#endif
|
||||
|
||||
#define is_ipv6_addr(ip) ((ip)->family != AF_INET)
|
||||
|
||||
/* returns 1 if IPADDRs are the same */
|
||||
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
||||
|
||||
/* Connect to socket */
|
||||
int net_connect(const char *addr, int port, IPADDR *my_ip);
|
||||
/* Connect to socket with ip address */
|
||||
int net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip);
|
||||
/* Disconnect socket */
|
||||
void net_disconnect(int handle);
|
||||
/* Try to let the other side close the connection, if it still isn't
|
||||
disconnected after certain amount of time, close it ourself */
|
||||
void net_disconnect_later(int handle);
|
||||
|
||||
/* Listen for connections on a socket */
|
||||
int net_listen(IPADDR *my_ip, int *port);
|
||||
/* Accept a connection on a socket */
|
||||
int net_accept(int handle, IPADDR *addr, int *port);
|
||||
|
||||
/* Read data from socket, return number of bytes read, -1 = error */
|
||||
int net_receive(int handle, char *buf, int len);
|
||||
/* Transmit data, return number of bytes sent, -1 = error */
|
||||
int net_transmit(int handle, const char *data, int len);
|
||||
|
||||
/* Get IP address for host, returns 0 = ok,
|
||||
others = error code for net_gethosterror() */
|
||||
int net_gethostname(const char *addr, IPADDR *ip);
|
||||
/* get error of net_gethostname() */
|
||||
const char *net_gethosterror(int error);
|
||||
|
||||
/* Get socket address/port */
|
||||
int net_getsockname(int handle, IPADDR *addr, int *port);
|
||||
|
||||
int net_ip2host(IPADDR *ip, char *host);
|
||||
int net_host2ip(const char *host, IPADDR *ip);
|
||||
|
||||
/* Get socket error */
|
||||
int net_geterror(int handle);
|
||||
|
||||
int is_ipv4_address(const char *host);
|
||||
int is_ipv6_address(const char *host);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue