File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,16 @@ mdns_result_t * MDNSResponder::_getResult(int idx){
245245 return result;
246246}
247247
248+ mdns_txt_item_t * MDNSResponder::_getResultTxt (int idx, int txtIdx){
249+ mdns_result_t * result = _getResult (idx);
250+ if (!result){
251+ log_e (" Result %d not found" , idx);
252+ return NULL ;
253+ }
254+ if (txtIdx >= result->txt_count ) return NULL ;
255+ return &result->txt [txtIdx];
256+ }
257+
248258String MDNSResponder::hostname (int idx) {
249259 mdns_result_t * result = _getResult (idx);
250260 if (!result){
@@ -333,13 +343,17 @@ String MDNSResponder::txt(int idx, const char * key) {
333343}
334344
335345String MDNSResponder::txt (int idx, int txtIdx) {
336- mdns_result_t * result = _getResult (idx);
337- if (!result){
338- log_e (" Result %d not found" , idx);
339- return " " ;
340- }
341- if (txtIdx >= result->txt_count ) return " " ;
342- return result->txt [txtIdx].value ;
346+ mdns_txt_item_t * resultTxt = _getResultTxt (idx, txtIdx);
347+ return !resultTxt
348+ ? " "
349+ : resultTxt->value ;
350+ }
351+
352+ String MDNSResponder::txtKey (int idx, int txtIdx) {
353+ mdns_txt_item_t * resultTxt = _getResultTxt (idx, txtIdx);
354+ return !resultTxt
355+ ? " "
356+ : resultTxt->key ;
343357}
344358
345359MDNSResponder MDNS;
Original file line number Diff line number Diff line change @@ -111,11 +111,13 @@ class MDNSResponder {
111111 bool hasTxt (int idx, const char * key);
112112 String txt (int idx, const char * key);
113113 String txt (int idx, int txtIdx);
114+ String txtKey (int idx, int txtIdx);
114115
115116private:
116117 String _hostname;
117118 mdns_result_t * results;
118119 mdns_result_t * _getResult (int idx);
120+ mdns_txt_item_t * _getResultTxt (int idx, int txtIdx);
119121};
120122
121123extern MDNSResponder MDNS;
You can’t perform that action at this time.
0 commit comments