File tree 2 files changed +23
-7
lines changed
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){
245
245
return result;
246
246
}
247
247
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
+
248
258
String MDNSResponder::hostname (int idx) {
249
259
mdns_result_t * result = _getResult (idx);
250
260
if (!result){
@@ -333,13 +343,17 @@ String MDNSResponder::txt(int idx, const char * key) {
333
343
}
334
344
335
345
String 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 ;
343
357
}
344
358
345
359
MDNSResponder MDNS;
Original file line number Diff line number Diff line change @@ -111,11 +111,13 @@ class MDNSResponder {
111
111
bool hasTxt (int idx, const char * key);
112
112
String txt (int idx, const char * key);
113
113
String txt (int idx, int txtIdx);
114
+ String txtKey (int idx, int txtIdx);
114
115
115
116
private:
116
117
String _hostname;
117
118
mdns_result_t * results;
118
119
mdns_result_t * _getResult (int idx);
120
+ mdns_txt_item_t * _getResultTxt (int idx, int txtIdx);
119
121
};
120
122
121
123
extern MDNSResponder MDNS;
You can’t perform that action at this time.
0 commit comments