Beispiel #1
0
int firedns_getname4(const struct in_addr *const ip) { /* build, add and send PTR query; retrieve result with firedns_getresult() */
	char query[512];
	struct s_header h;
	struct s_connection *s;
	unsigned char *c;
	int l;

	firedns_init();

	c = (unsigned char *)&ip->s_addr;

	sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]);

	l = firedns_build_query_payload(query,FDNS_QRY_PTR,1,(unsigned char *)&h.payload);
	if (l == -1)
		return -1;
	s = firedns_add_query(&h);
	if (s == NULL)
		return -1;
	s->class_ = 1;
	s->type = FDNS_QRY_PTR;
	if (firedns_send_requests(&h,s,l) == -1)
		return -1;

	return s->fd;
}
Beispiel #2
0
int firedns_getname6(const struct in6_addr *const ip) {
	char query[512];
	struct s_header h;
	struct s_connection *s;
	int l;

	firedns_init();

	sprintf(query,"%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.%0x.ip6.int",
			ip->s6_addr[15] & 0x0f,
			(ip->s6_addr[15] & 0xf0) >> 4,
			ip->s6_addr[14] & 0x0f,
			(ip->s6_addr[14] & 0xf0) >> 4,
			ip->s6_addr[13] & 0x0f,
			(ip->s6_addr[13] & 0xf0) >> 4,
			ip->s6_addr[12] & 0x0f,
			(ip->s6_addr[12] & 0xf0) >> 4,
			ip->s6_addr[11] & 0x0f,
			(ip->s6_addr[11] & 0xf0) >> 4,
			ip->s6_addr[10] & 0x0f,
			(ip->s6_addr[10] & 0xf0) >> 4,
			ip->s6_addr[9] & 0x0f,
			(ip->s6_addr[9] & 0xf0) >> 4,
			ip->s6_addr[8] & 0x0f,
			(ip->s6_addr[8] & 0xf0) >> 4,
			ip->s6_addr[7] & 0x0f,
			(ip->s6_addr[7] & 0xf0) >> 4,
			ip->s6_addr[6] & 0x0f,
			(ip->s6_addr[6] & 0xf0) >> 4,
			ip->s6_addr[5] & 0x0f,
			(ip->s6_addr[5] & 0xf0) >> 4,
			ip->s6_addr[4] & 0x0f,
			(ip->s6_addr[4] & 0xf0) >> 4,
			ip->s6_addr[3] & 0x0f,
			(ip->s6_addr[3] & 0xf0) >> 4,
			ip->s6_addr[2] & 0x0f,
			(ip->s6_addr[2] & 0xf0) >> 4,
			ip->s6_addr[1] & 0x0f,
			(ip->s6_addr[1] & 0xf0) >> 4,
			ip->s6_addr[0] & 0x0f,
			(ip->s6_addr[0] & 0xf0) >> 4
			);

	l = firedns_build_query_payload(query,FDNS_QRY_PTR,1,(unsigned char *)&h.payload);
	if (l == -1)
		return -1;
	s = (struct s_connection *) firedns_add_query(&h);
	if (s == NULL)
		return -1;
	s->class_ = 1;
	s->type = FDNS_QRY_PTR;
	if (firedns_send_requests(&h,s,l) == -1)
		return -1;

	return s->fd;
}
Beispiel #3
0
int firedns_gettxt(firedns_state* self, const char* name) { 
	struct s_header h;
	struct s_connection* s;
	int l;
	l = firedns_build_query_payload(name, FDNS_QRY_TXT, 1, (unsigned char*) &h.payload);
	if (l == -1)
		return -1;
	s = firedns_add_query(self, &h);
	if (s == NULL)
		return -1;
	s->dclass = 1;
	s->type = FDNS_QRY_TXT;
	if (firedns_send_requests(self, &h, s, l) == -1)
		return -1;
	return s->fd;
}
Beispiel #4
0
int firedns_getcname(const char *const name) {
	struct s_header h;
	struct s_connection *s;
	int l;

	firedns_init();

	l = firedns_build_query_payload(name,FDNS_QRY_CNAME,1,(unsigned char *)&h.payload);
	if (l == -1)
		return -1;
	s = (struct s_connection *) firedns_add_query(&h);
	if (s == NULL)
		return -1;
	s->class_ = 1;
	s->type = FDNS_QRY_CNAME;
	if (firedns_send_requests(&h,s,l) == -1)
		return -1;

	return s->fd;
}
Beispiel #5
0
int firedns_getmx(const char *const name) { /* build, add and send MX query; retrieve result with firedns_getresult() */
	struct s_header h;
	struct s_connection *s;
	int l;

	firedns_init();

	l = firedns_build_query_payload(name,FDNS_QRY_MX,1,(unsigned char *)&h.payload);
	if (l == -1)
		return -1;
	s = firedns_add_query(&h);
	if (s == NULL)
		return -1;
	s->class_ = 1;
	s->type = FDNS_QRY_MX;
	if (firedns_send_requests(&h,s,l) == -1)
		return -1;

	return s->fd;
}