Header And Logo

PostgreSQL
| The world's most advanced open source database.

ip.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * ip.h
00004  *    Definitions for IPv6-aware network access.
00005  *
00006  * These definitions are used by both frontend and backend code.  Be careful
00007  * what you include here!
00008  *
00009  * Copyright (c) 2003-2013, PostgreSQL Global Development Group
00010  *
00011  * src/include/libpq/ip.h
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #ifndef IP_H
00016 #define IP_H
00017 
00018 #include "getaddrinfo.h"        /* pgrminclude ignore */
00019 #include "libpq/pqcomm.h"       /* pgrminclude ignore */
00020 
00021 
00022 #ifdef  HAVE_UNIX_SOCKETS
00023 #define IS_AF_UNIX(fam) ((fam) == AF_UNIX)
00024 #else
00025 #define IS_AF_UNIX(fam) (0)
00026 #endif
00027 
00028 typedef void (*PgIfAddrCallback) (struct sockaddr * addr,
00029                                               struct sockaddr * netmask,
00030                                               void *cb_data);
00031 
00032 extern int pg_getaddrinfo_all(const char *hostname, const char *servname,
00033                    const struct addrinfo * hintp,
00034                    struct addrinfo ** result);
00035 extern void pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo * ai);
00036 
00037 extern int pg_getnameinfo_all(const struct sockaddr_storage * addr, int salen,
00038                    char *node, int nodelen,
00039                    char *service, int servicelen,
00040                    int flags);
00041 
00042 extern int pg_range_sockaddr(const struct sockaddr_storage * addr,
00043                   const struct sockaddr_storage * netaddr,
00044                   const struct sockaddr_storage * netmask);
00045 
00046 extern int pg_sockaddr_cidr_mask(struct sockaddr_storage * mask,
00047                       char *numbits, int family);
00048 
00049 #ifdef HAVE_IPV6
00050 extern void pg_promote_v4_to_v6_addr(struct sockaddr_storage * addr);
00051 extern void pg_promote_v4_to_v6_mask(struct sockaddr_storage * addr);
00052 #endif
00053 
00054 extern int  pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data);
00055 
00056 #endif   /* IP_H */