return addr;
}
+rspamd_inet_addr_t *
+rspamd_inet_address_from_rnds (const struct rdns_reply_entry *rep)
+{
+ rspamd_inet_addr_t *addr = NULL;
+
+ g_assert (rep != NULL);
+
+ if (rep->type == RDNS_REQUEST_A) {
+ addr = rspamd_inet_addr_create (AF_INET);
+ memcpy (&addr->u.in.addr.s4.sin_addr, &rep->content.a.addr,
+ sizeof (struct in_addr));
+ }
+ else if (rep->type == RDNS_REQUEST_AAAA) {
+ addr = rspamd_inet_addr_create (AF_INET6);
+ memcpy (&addr->u.in.addr.s6.sin6_addr, &rep->content.aaa.addr,
+ sizeof (struct in6_addr));
+ }
+
+ return addr;
+}
+
void
rspamd_inet_address_apply_mask (rspamd_inet_addr_t *addr, guint mask)
{
#define ADDR_H_
#include "config.h"
+#include "rdns.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
rspamd_inet_addr_t * rspamd_inet_address_from_sa (const struct sockaddr *sa,
socklen_t slen);
+/**
+ * Create new inet address from rdns reply
+ * @param rep reply element
+ * @return new ipv4 or ipv6 addr (port is NOT set)
+ */
+rspamd_inet_addr_t * rspamd_inet_address_from_rnds (
+ const struct rdns_reply_entry *rep);
+
/**
* Parse string with ipv6 address of length `len` to `target` which should be
* at least sizeof (in6_addr_t)