@@ -250,30 +250,30 @@ static mdns_host_item_t *get_host_item(const char *hostname)
250250}
251251
252252static  bool  create_answer_from_service (mdns_tx_packet_t  * packet , mdns_service_t  * service ,
253-                                               mdns_parsed_question_t  * question , bool  shared , bool  send_flush )
253+                                        mdns_parsed_question_t  * question , bool  shared , bool  send_flush )
254254{
255255    mdns_host_item_t  * host  =  get_host_item (service -> hostname );
256256    bool  is_delegated  =  (host  !=  mdns_priv_get_self_host ());
257257    if  (question -> type  ==  MDNS_TYPE_PTR  ||  question -> type  ==  MDNS_TYPE_ANY ) {
258258        // According to RFC6763-section12.1, for DNS-SD, SRV, TXT and all address records 
259259        // should be included in additional records. 
260260        if  (!mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_PTR , service , NULL , false, false) || 
261-             !mdns_priv_create_answer (is_delegated  ? & packet -> additional  : & packet -> answers , MDNS_TYPE_SRV , service ,
262-                                      NULL , send_flush , false) || 
263-             !mdns_priv_create_answer (is_delegated  ? & packet -> additional  : & packet -> answers , MDNS_TYPE_TXT , service ,
264-                                      NULL , send_flush , false) || 
265-             !mdns_priv_create_answer ((shared  ||  is_delegated ) ? & packet -> additional  : & packet -> answers , MDNS_TYPE_A ,
261+                  !mdns_priv_create_answer (is_delegated  ? & packet -> additional  : & packet -> answers , MDNS_TYPE_SRV , service ,
262+                                           NULL , send_flush , false) || 
263+                  !mdns_priv_create_answer (is_delegated  ? & packet -> additional  : & packet -> answers , MDNS_TYPE_TXT , service ,
264+                                           NULL , send_flush , false) || 
265+                  !mdns_priv_create_answer ((shared  ||  is_delegated ) ? & packet -> additional  : & packet -> answers , MDNS_TYPE_A ,
266266                                         service , host , send_flush ,
267267                                         false) || 
268-             !mdns_priv_create_answer ((shared  ||  is_delegated ) ? & packet -> additional  : & packet -> answers ,
268+                  !mdns_priv_create_answer ((shared  ||  is_delegated ) ? & packet -> additional  : & packet -> answers ,
269269                                         MDNS_TYPE_AAAA , service , host ,
270270                                         send_flush , false)) {
271271            return  false;
272272        }
273273    } else  if  (question -> type  ==  MDNS_TYPE_SRV ) {
274274        if  (!mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_SRV , service , NULL , send_flush , false) || 
275-             !mdns_priv_create_answer (& packet -> additional , MDNS_TYPE_A , service , host , send_flush , false) || 
276-             !mdns_priv_create_answer (& packet -> additional , MDNS_TYPE_AAAA , service , host , send_flush , false)) {
275+                  !mdns_priv_create_answer (& packet -> additional , MDNS_TYPE_A , service , host , send_flush , false) || 
276+                  !mdns_priv_create_answer (& packet -> additional , MDNS_TYPE_AAAA , service , host , send_flush , false)) {
277277            return  false;
278278        }
279279    } else  if  (question -> type  ==  MDNS_TYPE_TXT ) {
@@ -292,7 +292,7 @@ static bool create_answer_from_hostname(mdns_tx_packet_t *packet, const char *ho
292292{
293293    mdns_host_item_t  * host  =  get_host_item (hostname );
294294    if  (!mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_A , NULL , host , send_flush , false) || 
295-         !mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_AAAA , NULL , host , send_flush , false)) {
295+              !mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_AAAA , NULL , host , send_flush , false)) {
296296        return  false;
297297    }
298298    return  true;
@@ -411,7 +411,7 @@ static bool append_host_question(mdns_out_question_t **questions, const char *ho
411411}
412412
413413static  bool  append_host_questions_for_services (mdns_out_question_t  * * questions , mdns_srv_item_t  * services [],
414-                                                       size_t  len , bool  unicast )
414+                                                size_t  len , bool  unicast )
415415{
416416    if  (!mdns_utils_str_null_or_empty (mdns_priv_get_global_hostname ()) && 
417417            !append_host_question (questions , mdns_priv_get_global_hostname (), unicast )) {
@@ -491,12 +491,12 @@ static uint8_t append_reverse_ptr_record(uint8_t *packet, uint16_t *index, const
491491        return  0 ;
492492    }
493493
494-     if  (!_mdns_append_type (packet , index , MDNS_ANSWER_PTR , false, 10  /* TTL set to 10s*/ )) {
494+     if  (!append_type (packet , index , MDNS_ANSWER_PTR , false, 10  /* TTL set to 10s*/ )) {
495495        return  0 ;
496496    }
497497
498498    uint16_t  data_len_location  =  * index  -  2 ; /* store the position of size (2=16bis) of this record */ 
499-     const  char  * str [2 ] =  {priv_get_self_host ()-> hostname , MDNS_UTILS_DEFAULT_DOMAIN  };
499+     const  char  * str [2 ] =  {mdns_priv_get_self_host ()-> hostname , MDNS_UTILS_DEFAULT_DOMAIN  };
500500
501501    int  part_length  =  append_fqdn (packet , index , str , 2 , MDNS_MAX_PACKET_SIZE );
502502    if  (!part_length ) {
@@ -588,8 +588,7 @@ void mdns_priv_create_answer_from_parsed_packet(mdns_parsed_packet_t *parsed_pac
588588#ifdef  CONFIG_MDNS_RESPOND_REVERSE_QUERIES 
589589        } else  if  (q -> type  ==  MDNS_TYPE_PTR ) {
590590            mdns_host_item_t  * host  =  get_host_item (q -> host );
591- #error 
592-             if  (!_mdns_alloc_answer (& packet -> answers , MDNS_TYPE_PTR , NULL , host , send_flush , false)) {
591+             if  (!mdns_priv_create_answer (& packet -> answers , MDNS_TYPE_PTR , NULL , host , send_flush , false)) {
593592                mdns_priv_free_tx_packet (packet );
594593                return ;
595594            } else  {
@@ -829,8 +828,8 @@ static uint16_t append_ptr_record(uint8_t *packet, uint16_t *index, const char *
829828 * @return length of added data: 0 on error or length on success 
830829 */ 
831830static  uint16_t  append_subtype_ptr_record (uint8_t  * packet , uint16_t  * index , const  char  * instance ,
832-                                                  const  char  * subtype , const  char  * service , const  char  * proto , bool  flush ,
833-                                                  bool  bye )
831+                                           const  char  * subtype , const  char  * service , const  char  * proto , bool  flush ,
832+                                           bool  bye )
834833{
835834    const  char  * subtype_str [5 ] =  {subtype , MDNS_SUB_STR , service , proto , MDNS_UTILS_DEFAULT_DOMAIN };
836835    const  char  * instance_str [4 ] =  {instance , service , proto , MDNS_UTILS_DEFAULT_DOMAIN };
@@ -868,12 +867,12 @@ static uint16_t append_subtype_ptr_record(uint8_t *packet, uint16_t *index, cons
868867 *  @return number of answers added to the packet 
869868 */ 
870869static  uint8_t  append_service_ptr_answers (uint8_t  * packet , uint16_t  * index , mdns_service_t  * service , bool  flush ,
871-                                                  bool  bye )
870+                                           bool  bye )
872871{
873872    uint8_t  appended_answers  =  0 ;
874873
875874    if  (append_ptr_record (packet , index , mdns_utils_get_service_instance_name (service ), service -> service ,
876-                                  service -> proto , flush , bye ) <= 0 ) {
875+                           service -> proto , flush , bye ) <= 0 ) {
877876        return  appended_answers ;
878877    }
879878    appended_answers ++ ;
@@ -882,7 +881,7 @@ static uint8_t append_service_ptr_answers(uint8_t *packet, uint16_t *index, mdns
882881    while  (subtype ) {
883882        appended_answers  += 
884883            (append_subtype_ptr_record (packet , index , mdns_utils_get_service_instance_name (service ), subtype -> subtype ,
885-                                               service -> service , service -> proto , flush , bye ) >  0 );
884+                                        service -> service , service -> proto , flush , bye ) >  0 );
886885        subtype  =  subtype -> next ;
887886    }
888887
@@ -1180,7 +1179,7 @@ static uint16_t append_aaaa_record(uint8_t *packet, uint16_t *index, const char
11801179#endif 
11811180
11821181static  uint8_t  append_host_answer (uint8_t  * packet , uint16_t  * index , mdns_host_item_t  * host ,
1183-                                          uint8_t  address_type , bool  flush , bool  bye )
1182+                                   uint8_t  address_type , bool  flush , bool  bye )
11841183{
11851184    mdns_ip_addr_t  * addr  =  host -> address_list ;
11861185    uint8_t  num_records  =  0 ;
@@ -1196,7 +1195,7 @@ static uint8_t append_host_answer(uint8_t *packet, uint16_t *index, mdns_host_it
11961195#ifdef  CONFIG_LWIP_IPV6 
11971196            if  (address_type  ==  ESP_IPADDR_TYPE_V6  && 
11981197                    append_aaaa_record (packet , index , host -> hostname , (uint8_t  * )addr -> addr .u_addr .ip6 .addr , flush ,
1199-                                               bye ) <= 0 ) {
1198+                                        bye ) <= 0 ) {
12001199                break ;
12011200            }
12021201#endif  /* CONFIG_LWIP_IPV6 */ 
@@ -1238,8 +1237,8 @@ static uint8_t append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t
12381237#endif  /* CONFIG_MDNS_RESPOND_REVERSE_QUERIES */ 
12391238        } else  {
12401239            return  append_ptr_record (packet , index ,
1241-                                             answer -> custom_instance , answer -> custom_service , answer -> custom_proto ,
1242-                                             answer -> flush , answer -> bye ) >  0 ;
1240+                                      answer -> custom_instance , answer -> custom_service , answer -> custom_proto ,
1241+                                      answer -> flush , answer -> bye ) >  0 ;
12431242        }
12441243    } else  if  (answer -> type  ==  MDNS_TYPE_SRV ) {
12451244        return  append_srv_record (packet , index , answer -> service , answer -> flush , answer -> bye ) >  0 ;
@@ -1294,7 +1293,7 @@ static uint8_t append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t
12941293                    return  0 ;
12951294                }
12961295                if  (append_aaaa_record (packet , index , mdns_priv_get_global_hostname (), (uint8_t  * )if_ip6s [i ].addr ,
1297-                                               answer -> flush , answer -> bye ) <= 0 ) {
1296+                                        answer -> flush , answer -> bye ) <= 0 ) {
12981297                    return  0 ;
12991298                }
13001299            }
@@ -1308,13 +1307,13 @@ static uint8_t append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t
13081307                return  count ;
13091308            }
13101309            if  (append_aaaa_record (packet , index , mdns_priv_get_global_hostname (), (uint8_t  * )other_ip6 .addr ,
1311-                                           answer -> flush , answer -> bye ) >  0 ) {
1310+                                    answer -> flush , answer -> bye ) >  0 ) {
13121311                return  1  +  count ;
13131312            }
13141313            return  count ;
13151314        } else  if  (answer -> host  !=  NULL ) {
13161315            return  append_host_answer (packet , index , answer -> host , ESP_IPADDR_TYPE_V6 , answer -> flush ,
1317-                                              answer -> bye );
1316+                                       answer -> bye );
13181317        }
13191318    }
13201319#endif  /* CONFIG_LWIP_IPV6 */ 
0 commit comments