summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/apr_errno.h10
-rw-r--r--include/apr_network_io.h33
2 files changed, 39 insertions, 4 deletions
diff --git a/include/apr_errno.h b/include/apr_errno.h
index fa5184dda..148817a58 100644
--- a/include/apr_errno.h
+++ b/include/apr_errno.h
@@ -177,6 +177,8 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
* APR_EDSOOPEN APR was unable to open the dso object. For more
* information call apr_dso_error().
* APR_EGENERAL General failure (specific information not available)
+ * APR_EBADIP The specified IP address is invalid
+ * APR_EBADMASK The specified netmask is invalid
* </PRE>
*
* <PRE>
@@ -232,8 +234,8 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13)
#define APR_EGENERAL (APR_OS_START_ERROR + 14)
#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15)
-/* empty slot: +16 */
-/* empty slot: +17 */
+#define APR_EBADIP (APR_OS_START_ERROR + 16)
+#define APR_EBADMASK (APR_OS_START_ERROR + 17)
/* empty slot: +18 */
#define APR_EDSOOPEN (APR_OS_START_ERROR + 19)
@@ -254,8 +256,8 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY)
#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL)
#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL)
-/* empty slot: +16 */
-/* empty slot: +17 */
+#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP)
+#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK)
/* empty slot: +18 */
#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN)
diff --git a/include/apr_network_io.h b/include/apr_network_io.h
index 585d64245..aecd41c44 100644
--- a/include/apr_network_io.h
+++ b/include/apr_network_io.h
@@ -218,6 +218,19 @@ struct apr_hdtr_t {
int numtrailers;
};
+/** A structure to represent an IP subnet */
+typedef struct apr_ipsubnet_t apr_ipsubnet_t;
+struct apr_ipsubnet_t {
+ int family;
+#if APR_HAVE_IPV6
+ apr_uint32_t sub[4]; /* big enough for IPv4 and IPv6 addresses */
+ apr_uint32_t mask[4];
+#else
+ apr_uint32_t sub[1];
+ apr_uint32_t mask[1];
+#endif
+};
+
/* function definitions */
/**
@@ -754,6 +767,26 @@ APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock,
APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr,
const char *servname);
+/**
+ * Build an ip-subnet representation from an IP address and optional netmask or
+ * number-of-bits.
+ * @param ipsub The new ip-subnet representation
+ * @param ipstr The input IP address string
+ * @param mask_or_numbits The input netmask or number-of-bits string, or NULL
+ * @param p The pool to allocate from
+ */
+APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char *ipstr,
+ const char *mask_or_numbits, apr_pool_t *p);
+
+/**
+ * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet
+ * representation.
+ * @param ipsub The ip-subnet representation
+ * @param sa The socket address to test
+ * @return non-zero if the socket address is within the subnet, 0 otherwise
+ */
+APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);
+
#ifdef __cplusplus
}
#endif