Added more debugging statements.
This commit is contained in:
parent
c4993739f5
commit
c821cdcbe4
13
mdns.c
13
mdns.c
@ -246,6 +246,19 @@ static uint8_t *uncompress_nlabel(uint8_t *pkt_buf, size_t pkt_len, size_t off)
|
||||
|
||||
// ----- 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);
|
||||
|
2
mdns.h
2
mdns.h
@ -173,6 +173,8 @@ struct rr_entry *rr_create(uint8_t *name, enum rr_type type);
|
||||
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);
|
||||
|
8
mdnsd.c
8
mdnsd.c
@ -261,7 +261,7 @@ static int process_mdns_pkt(struct mdnsd *svr, struct mdns_pkt *pkt, struct mdns
|
||||
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
|
||||
@ -282,6 +282,10 @@ static int process_mdns_pkt(struct mdnsd *svr, struct mdns_pkt *pkt, struct mdns
|
||||
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;
|
||||
@ -354,6 +358,8 @@ static void main_loop(struct mdnsd *svr) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user