/usr/include/c_icap/net_io.h is in libicapapi-dev 1:0.4.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | /*
* Copyright (C) 2004-2008 Christos Tsantilas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*/
#ifndef __NET_IO_H
#define __NET_IO_H
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <fcntl.h>
#else
#include <WinSock2.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef _WIN32
#define ci_socket int
#define CI_SOCKET_ERROR -1
#else
#define ci_socket SOCKET
#define CI_SOCKET_ERROR INVALID_SOCKET
#endif
typedef struct ci_sockaddr{
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr_in sockaddr;
#endif
int ci_sin_family;/* #define ci_sin_family sockaddr.sin_family */
int ci_sin_port; /* #define ci_sin_port sockaddr.sin_port */
void *ci_sin_addr;
int ci_inaddr_len;
} ci_sockaddr_t;
#define CI_MAXHOSTNAMELEN 256
#ifdef USE_IPV6
typedef union ci_inaddr {
struct in_addr ipv4_addr;
struct in6_addr ipv6_addr;
} ci_in_addr_t;
#define ci_inaddr_zero(addr) (memset(&(addr),0,sizeof(ci_in_addr_t)))
#define ci_inaddr_copy(dest,src) (memcpy(&(dest),&(src),sizeof(ci_in_addr_t)))
#define ci_ipv4_inaddr_hostnetmask(addr)((addr).ipv4_addr.s_addr=htonl(0xFFFFFFFF))
#define ci_in6_addr_u32(addr) ((uint32_t *)&((addr).ipv6_addr))
#define ci_ipv6_inaddr_hostnetmask(addr)(ci_in6_addr_u32(addr)[0]=htonl(0xFFFFFFFF),\
ci_in6_addr_u32(addr)[1]=htonl(0xFFFFFFFF), \
ci_in6_addr_u32(addr)[2]=htonl(0xFFFFFFFF), \
ci_in6_addr_u32(addr)[3]=htonl(0xFFFFFFFF))
#define CI_IPLEN 46
#define CI_SOCKADDR_SIZE sizeof(struct sockaddr_storage)
#else /*IPV4 only*/
typedef struct in_addr ci_in_addr_t;
#define ci_inaddr_zero(addr) ((addr).s_addr=0)
#define ci_inaddr_copy(dest,src) ((dest)=(src))
#define ci_ipv4_inaddr_hostnetmask(addr)((addr).s_addr=htonl(0xFFFFFFFF))
#define CI_IPLEN 16
#define CI_SOCKADDR_SIZE sizeof(struct sockaddr_in)
#endif
#define wait_for_read 0x1
#define wait_for_write 0x2
#define wait_for_readwrite 0x3
typedef struct ci_ip {
ci_in_addr_t address;
ci_in_addr_t netmask;
int family;
} ci_ip_t;
typedef struct ci_connection{
ci_socket fd;
ci_sockaddr_t claddr;
ci_sockaddr_t srvaddr;
} ci_connection_t ;
CI_DECLARE_FUNC(void) ci_connection_destroy(ci_connection_t *connection);
CI_DECLARE_FUNC(void) ci_fill_sockaddr(ci_sockaddr_t *addr);
CI_DECLARE_FUNC(void) ci_fill_ip_t(ci_ip_t *ip, ci_sockaddr_t *addr);
CI_DECLARE_FUNC(void) ci_copy_sockaddr(ci_sockaddr_t *dest, ci_sockaddr_t *src);
CI_DECLARE_FUNC(int) ci_inet_aton(int af,const char *cp, void *inp);
CI_DECLARE_FUNC(const char *) ci_inet_ntoa(int af,const void *src, char *dst,int cnt);
CI_DECLARE_FUNC(const char *) ci_sockaddr_t_to_ip(ci_sockaddr_t *addr, char *ip,int ip_strlen);
#define ci_conn_remote_ip(conn,ip) ci_sockaddr_t_to_ip(&(conn->claddr),ip,CI_IPLEN)
#define ci_conn_local_ip(conn,ip) ci_sockaddr_t_to_ip(&(conn->srvaddr),ip,CI_IPLEN)
#ifdef USE_IPV6
CI_DECLARE_FUNC(void) ci_sockaddr_set_port(ci_sockaddr_t *addr, int port);
#define ci_sockaddr_set_family(addr,family) ((addr).sockaddr.ss_family=family)
#else
CI_DECLARE_FUNC(void) ci_sockaddr_set_port(ci_sockaddr_t *addr, int port);
#define ci_sockaddr_set_family(addr,family) ((addr).sockaddr.sin_family=family/*,(addr).ci_sin_family=family*/)
#endif
CI_DECLARE_FUNC(const char *) ci_sockaddr_t_to_host(ci_sockaddr_t *addr, char *hname, int maxhostlen);
CI_DECLARE_FUNC(int) ci_host_to_sockaddr_t(const char *servername, ci_sockaddr_t * addr, int proto);
CI_DECLARE_FUNC(void) ci_copy_connection(ci_connection_t *dest, ci_connection_t *src);
CI_DECLARE_FUNC(int) icap_socket_opts(ci_socket fd, int secs_to_linger);
CI_DECLARE_FUNC(ci_socket) icap_init_server(char *address, int port,int *protocol_family,int secs_to_linger);
CI_DECLARE_FUNC(int) ci_wait_for_data(ci_socket fd,int secs,int what_wait);
#define ci_wait_for_incomming_data(fd,timeout) ci_wait_for_data(fd,timeout,wait_for_read)
#define ci_wait_for_outgoing_data(fd,timeout) ci_wait_for_data(fd,timeout,wait_for_write)
CI_DECLARE_FUNC(int) ci_netio_init(ci_socket fd);
CI_DECLARE_FUNC(int) ci_read(ci_socket fd,void *buf,size_t count,int timeout);
CI_DECLARE_FUNC(int) ci_write(ci_socket fd, const void *buf,size_t count,int timeout);
CI_DECLARE_FUNC(int) ci_read_nonblock(ci_socket fd, void *buf,size_t count);
CI_DECLARE_FUNC(int) ci_write_nonblock(ci_socket fd, const void *buf,size_t count);
CI_DECLARE_FUNC(int) ci_linger_close(ci_socket fd,int secs_to_linger);
CI_DECLARE_FUNC(int) ci_hard_close(ci_socket fd);
#ifdef __cplusplus
}
#endif
#endif
|