コード例 #1
0
ファイル: tester.c プロジェクト: drb/firedns
void do_firedns_getip4(firedns_state *state, char * string) {
	int fd;
	fd_set s;
	int n;
	struct timeval tv;
	char *m;
	struct in_addr addr4;

	fprintf(stderr,"taking firedns_getip4(%s): ",string);
	fd = firedns_getip4(state, string);
	fprintf(stderr,"%d\n",fd);
	if (fd == -1)
		return;
	tv.tv_sec = 5;
	tv.tv_usec = 0;
	FD_ZERO(&s);
	FD_SET(fd,&s);
	n = select(fd + 1,&s,NULL,NULL,&tv);
	(void) n;
	m = firedns_getresult(state, fd);
	if (m == NULL)
		fprintf(stderr,"getting result: (null)\n");
	else {
		memcpy(&addr4,m,sizeof(struct in_addr));
		char result[256];
		firedns_ntoa4(&addr4, result);
		fprintf(stderr,"getting result: %s\n", result);
	}
}
コード例 #2
0
ファイル: firedns.cpp プロジェクト: nukleus/psotnic-ng
static inline struct in_addr *firedns_resolveip4_i(const char *const name, char *(*result)(int)) { /* immediate A query */
	int fd;
	int t,i;
	struct in_addr *ret;
	fd_set s;
	struct timeval tv;

	for (t = 0; t < FIREDNS_TRIES; t++) {
		fd = firedns_getip4(name);
		if (fd == -1)
			return NULL;
		tv.tv_sec = 5;
		tv.tv_usec = 0;
		FD_ZERO(&s);
		FD_SET(fd,&s);
		i = select(fd + 1,&s,NULL,NULL,&tv);
		ret = (struct in_addr *) result(fd);
		if (ret != NULL || i != 0)
			return ret;
	}
	return NULL;
}
コード例 #3
0
ファイル: firedns.cpp プロジェクト: nukleus/psotnic-ng
int firedns_dnsbl_lookup_a(const struct in_addr *const ip, const char *const name) { /* build, add and send A query to given DNSBL list; retrieve result with firedns_getresult() */
	char hostname[256];
	firestring_snprintf(hostname,256,"%u.%u.%u.%u.%s",(unsigned int) ((unsigned char *)&ip->s_addr)[3],(unsigned int) ((unsigned char *)&ip->s_addr)[2],(unsigned int) ((unsigned char *)&ip->s_addr)[1],(unsigned int) ((unsigned char *)&ip->s_addr)[0],name);
	return firedns_getip4(hostname);
}