source: trunk/include/sh_ipvx.h@ 298

Last change on this file since 298 was 295, checked in by katerina, 14 years ago

Support for IPv6 (ticket #222).

File size: 1.7 KB
Line 
1#ifndef SH_IPVX_H
2#define SH_IPVX_H
3
4#include <sys/types.h>
5#include <sys/socket.h>
6#include <netdb.h>
7#include <netinet/in.h>
8#include <arpa/inet.h>
9
10#if defined(USE_IPVX)
11#define SH_SSP_LEN(a) ((a)->ss_family == AF_INET) ? \
12 sizeof(struct sockaddr_in) : \
13 sizeof(struct sockaddr_in6)
14
15#define SH_SS_LEN(a) ((a).ss_family == AF_INET) ? \
16 sizeof(struct sockaddr_in) : \
17 sizeof(struct sockaddr_in6)
18#else
19#define SH_SSP_LEN(a) sizeof(struct sockaddr_in)
20#define SH_SS_LEN(a) sizeof(struct sockaddr_in)
21#endif
22
23struct sh_sockaddr {
24 int ss_family;
25
26 struct sockaddr_in sin;
27#if defined(USE_IPVX)
28 struct sockaddr_in6 sin6;
29#endif
30};
31
32/* Cast a sockaddress
33 */
34struct sockaddr * sh_ipvx_sockaddr_cast (struct sh_sockaddr * ss);
35
36/* Compare with any_address
37 */
38int sh_ipvx_isany (struct sh_sockaddr * a);
39
40/* Compare two addresses
41 */
42int sh_ipvx_cmp(struct sh_sockaddr * a, struct sh_sockaddr * b);
43
44/* Set the port
45 */
46int sh_ipvx_set_port(struct sh_sockaddr * ss, int port);
47
48/* Save a sockaddress
49 */
50void sh_ipvx_save(struct sh_sockaddr * ss, int sa_family, struct sockaddr * sa);
51
52/* Determine whether the given address is numeric
53 */
54int sh_ipvx_is_numeric (const char * addr);
55
56/* Convert a network address to an ascii numeric address
57 */
58int sh_ipvx_ntoa (char * name, size_t name_size, struct sh_sockaddr * ss);
59
60/* Convert an ascii numeric address to a network address
61 */
62int sh_ipvx_aton (const char * name, struct sh_sockaddr * ss);
63
64/* Try to find canonical hostname
65 */
66char * sh_ipvx_canonical(const char * hostname, char * numeric, size_t nlen);
67
68/* Convert address to hostname
69 */
70char * sh_ipvx_addrtoname(struct sh_sockaddr * ss);
71
72/* Try a reverse lookup
73 */
74int sh_ipvx_reverse_check_ok (char * peer, int port, struct sh_sockaddr * ss);
75#endif
Note: See TracBrowser for help on using the repository browser.