2019-11-30 05:10:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2019 by John D. Robertson *
|
|
|
|
* john@rrci.com *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 3 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 *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
2019-11-30 19:14:42 +00:00
|
|
|
/*
|
|
|
|
* JDR Sat 30 Nov 2019 08:27:23 AM EST
|
|
|
|
* Performs DNS reverse + fwd lookups in parallel. Having to use a bunch of threads
|
|
|
|
* to overcome the serialization inherent in blocking calls is a travesty, but
|
|
|
|
* I couldn't find a non-blocking version of getnameinfo().
|
|
|
|
*
|
|
|
|
* Oh yeah, and I'm not in the mood to write it myself ;-)
|
|
|
|
*/
|
|
|
|
|
2019-11-30 05:10:25 +00:00
|
|
|
#ifndef PARALLEL_DNS_H
|
|
|
|
#define PARALLEL_DNS_H
|
|
|
|
|
2019-11-30 19:14:42 +00:00
|
|
|
|
|
|
|
/* Number of threads to use in parallel */
|
|
|
|
#define PDNS_MAX_THREADS 200
|
2019-12-01 18:04:41 +00:00
|
|
|
/* Size manager's inbox to avoid overflow */
|
2019-11-30 19:14:42 +00:00
|
|
|
#define PDNS_MGR_INBOX_SZ PDNS_MAX_THREADS*2
|
|
|
|
#define PDNS_WORKER_INBOX_SZ 1
|
|
|
|
/* Give worker threads a chance to join */
|
|
|
|
#define PDNS_SHUTDOWN_PAUSE_MS 500
|
|
|
|
|
|
|
|
enum PDNS_flags {
|
|
|
|
PDNS_SERVFAIL_FLG= 1<<0,
|
|
|
|
PDNS_NXDOMAIN_FLG= 1<<1,
|
|
|
|
PDNS_REV_DNS_FLG= 1<<2,
|
|
|
|
PDNS_FWD_DNS_FLG= 1<<3,
|
|
|
|
PDNS_FWD_FAIL_FLG= 1<<4,
|
|
|
|
PDNS_FWD_NONE_FLG= 1<<5,
|
2019-12-01 02:30:17 +00:00
|
|
|
PDNS_FWD_MISMATCH_FLG= 1<<6,
|
2019-12-01 18:04:41 +00:00
|
|
|
PDNS_DONE_MASK= PDNS_SERVFAIL_FLG|PDNS_NXDOMAIN_FLG|PDNS_FWD_DNS_FLG,
|
|
|
|
PDNS_BAD_MASK= PDNS_SERVFAIL_FLG|
|
|
|
|
PDNS_NXDOMAIN_FLG|
|
|
|
|
PDNS_FWD_FAIL_FLG|
|
|
|
|
PDNS_FWD_NONE_FLG|
|
|
|
|
PDNS_FWD_MISMATCH_FLG
|
|
|
|
|
2019-11-30 19:14:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
2019-12-01 22:23:30 +00:00
|
|
|
#include "offEntry.h"
|
2019-11-30 05:10:25 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:14:42 +00:00
|
|
|
/* Fix recursive #include dependency */
|
2019-12-02 03:29:32 +00:00
|
|
|
struct _OFFENTRY;
|
2019-11-30 05:10:25 +00:00
|
|
|
|
|
|
|
int
|
2019-12-02 03:29:32 +00:00
|
|
|
PDNS_lookup(struct _OFFENTRY *lePtrArr[], unsigned nItems, unsigned timeout_ms);
|
2019-11-30 05:10:25 +00:00
|
|
|
/**************************************************************
|
2019-12-02 03:29:32 +00:00
|
|
|
* Perform parallel DNS reverse lookups on all OFFENTRY objects
|
2019-11-30 14:35:29 +00:00
|
|
|
* referenced in lePtrArr until finished, or timeout_ms has lapsed.
|
|
|
|
*
|
2019-12-02 03:29:32 +00:00
|
|
|
* lePtrArr: array of pointers to OFFENTRY objects
|
2019-11-30 14:35:29 +00:00
|
|
|
* nItems: length of array
|
|
|
|
* timeout_ms: maximum amount of time to spend performing lookups.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* suceess - number of lookups completed
|
|
|
|
* -1 Failures
|
2019-11-30 05:10:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|