@@ -697,6 +697,7 @@ static struct {
697
697
struct arg_str * proto ;
698
698
struct arg_int * port ;
699
699
struct arg_str * instance ;
700
+ struct arg_str * host ;
700
701
struct arg_str * txt ;
701
702
struct arg_end * end ;
702
703
} mdns_add_args ;
@@ -718,6 +719,11 @@ static int cmd_mdns_service_add(int argc, char **argv)
718
719
instance = mdns_add_args .instance -> sval [0 ];
719
720
printf ("MDNS: Service Instance: %s\n" , instance );
720
721
}
722
+ const char * host = NULL ;
723
+ if (mdns_add_args .host -> count && mdns_add_args .host -> sval [0 ]) {
724
+ host = mdns_add_args .host -> sval [0 ];
725
+ printf ("MDNS: Service for delegated host: %s\n" , host );
726
+ }
721
727
mdns_txt_item_t * items = NULL ;
722
728
if (mdns_add_args .txt -> count ) {
723
729
items = _convert_items (mdns_add_args .txt -> sval , mdns_add_args .txt -> count );
@@ -728,7 +734,8 @@ static int cmd_mdns_service_add(int argc, char **argv)
728
734
}
729
735
}
730
736
731
- ESP_ERROR_CHECK ( mdns_service_add (instance , mdns_add_args .service -> sval [0 ], mdns_add_args .proto -> sval [0 ], mdns_add_args .port -> ival [0 ], items , mdns_add_args .txt -> count ) );
737
+ ESP_ERROR_CHECK ( mdns_service_add_for_host (instance , mdns_add_args .service -> sval [0 ], mdns_add_args .proto -> sval [0 ],
738
+ host , mdns_add_args .port -> ival [0 ], items , mdns_add_args .txt -> count ) );
732
739
free (items );
733
740
return 0 ;
734
741
}
@@ -739,6 +746,7 @@ static void register_mdns_service_add(void)
739
746
mdns_add_args .proto = arg_str1 (NULL , NULL , "<proto>" , "IP Protocol" );
740
747
mdns_add_args .port = arg_int1 (NULL , NULL , "<port>" , "Service Port" );
741
748
mdns_add_args .instance = arg_str0 ("i" , "instance" , "<instance>" , "Instance name" );
749
+ mdns_add_args .host = arg_str0 ("h" , "host" , "<hostname>" , "Service for this (delegated) host" );
742
750
mdns_add_args .txt = arg_strn (NULL , NULL , "item" , 0 , 30 , "TXT Items (name=value)" );
743
751
mdns_add_args .end = arg_end (2 );
744
752
@@ -754,8 +762,10 @@ static void register_mdns_service_add(void)
754
762
}
755
763
756
764
static struct {
765
+ struct arg_str * instance ;
757
766
struct arg_str * service ;
758
767
struct arg_str * proto ;
768
+ struct arg_str * host ;
759
769
struct arg_end * end ;
760
770
} mdns_remove_args ;
761
771
@@ -772,15 +782,26 @@ static int cmd_mdns_service_remove(int argc, char **argv)
772
782
return 1 ;
773
783
}
774
784
775
- ESP_ERROR_CHECK ( mdns_service_remove (mdns_remove_args .service -> sval [0 ], mdns_remove_args .proto -> sval [0 ]) );
785
+ const char * instance = NULL ;
786
+ if (mdns_remove_args .instance -> count && mdns_remove_args .instance -> sval [0 ]) {
787
+ instance = mdns_remove_args .instance -> sval [0 ];
788
+ }
789
+ const char * host = NULL ;
790
+ if (mdns_remove_args .host -> count && mdns_remove_args .host -> sval [0 ]) {
791
+ host = mdns_remove_args .host -> sval [0 ];
792
+ }
793
+
794
+ ESP_ERROR_CHECK ( mdns_service_remove_for_host (instance , mdns_remove_args .service -> sval [0 ], mdns_remove_args .proto -> sval [0 ], host ) );
776
795
return 0 ;
777
796
}
778
797
779
798
static void register_mdns_service_remove (void )
780
799
{
781
800
mdns_remove_args .service = arg_str1 (NULL , NULL , "<service>" , "MDNS Service" );
782
801
mdns_remove_args .proto = arg_str1 (NULL , NULL , "<proto>" , "IP Protocol" );
783
- mdns_remove_args .end = arg_end (2 );
802
+ mdns_remove_args .host = arg_str0 ("h" , "host" , "<hostname>" , "Service for this (delegated) host" );
803
+ mdns_remove_args .instance = arg_str0 ("i" , "instance" , "<instance>" , "Instance name" );
804
+ mdns_remove_args .end = arg_end (4 );
784
805
785
806
const esp_console_cmd_t cmd_remove = {
786
807
.command = "mdns_service_remove" ,
0 commit comments