Commits

geekman  committed 0e43136

Added more debugging statements.

  • Participants
  • Parent commits ea6495c

Comments (0)

Files changed (3)

 
 // ----- RR list & group functions -----
 
+const char *rr_get_type_name(enum rr_type type) {
+	switch (type) {
+		case RR_A:		return "A";
+		case RR_PTR:	return "PTR";
+		case RR_TXT:	return "TXT";
+		case RR_AAAA:	return "AAAA";
+		case RR_SRV:	return "SRV";
+		case RR_NSEC:	return "NSEC";
+		case RR_ANY:	return "ANY";
+	}
+	return NULL;
+}
+
 void rr_entry_destroy(struct rr_entry *rr) {
 	struct rr_data_txt *txt_rec;
 	assert(rr);
 void rr_set_nsec(struct rr_entry *rr_nsec, enum rr_type type);
 void rr_add_txt(struct rr_entry *rr_txt, const char *txt);
 
+const char *rr_get_type_name(enum rr_type type);
+
 uint8_t *create_label(const char *txt);
 uint8_t *create_nlabel(const char *name);
 char *nlabel_to_str(const uint8_t *name);
 			int num_ans_added = 0;
 
 			char *namestr = nlabel_to_str(qn->name);
-			DEBUG_PRINTF("qn #%d: type 0x%02x %s - ", i, qn->type, namestr);
+			DEBUG_PRINTF("qn #%d: type %s (%02x) %s - ", i, rr_get_type_name(qn->type), qn->type, namestr);
 			free(namestr);
 
 			// check if it's a unicast query - we ignore those
 			struct rr_list *next_ans = ans->next;
 
 			if (rr_entry_match(pkt->rr_ans, ans->e)) {
+				char *namestr = nlabel_to_str(ans->e->name);
+				DEBUG_PRINTF("removing answer for %s\n", namestr);
+				free(namestr);
+
 				// check if list item is head
 				if (prev_ans == NULL)
 					reply->rr_ans = ans->next;
 				if (process_mdns_pkt(svr, mdns, mdns_reply)) {
 					size_t replylen = mdns_encode_pkt(mdns_reply, pkt_buffer, PACKET_SIZE);
 					send_packet(svr->sockfd, pkt_buffer, replylen);
+				} else if (mdns->num_qn == 0) {
+					DEBUG_PRINTF("(no questions in packet)\n\n");
 				}
 
 				mdns_pkt_destroy(mdns);