-1

I would like to find device lost of connection during communication. Bonjour keeps device entry in local cache with long TTL so if I find lost of communication with device than I want to call DNSServiceReconfirmRecord to verify device is till in network.

DNSSD_API DNSServiceReconfirmRecord(
DNSServiceFlags flags,
uint32_t        interfaceIndex,
const char      *fullname,
uint16_t        rrtype,
uint16_t        rrclass,
uint16_t        rdlen,
const void      *rdata
);

How can I get rdata values? can anyone guide me how to use DNSServiceReconfirmRecord? I have all required information except rdata on above function.

Jonas
  • 6,915
  • 8
  • 35
  • 53
NoWorries
  • 1
  • 1
  • 1
    Please [edit] your question to show [what you have tried so far](http://whathaveyoutried.com). You should include a [mcve] of the code that you are having problems with, then we can try to help with the specific problem. You should also read [ask]. – Toby Speight Feb 24 '17 at 12:54

1 Answers1

1

You should consider at the rrtype and then provide rdata appropriately. Wiki has list of DNS record types. The pointer rdata should point to the raw data of the resource record, i.e., either create it your self or find a library that can.

Example:

If rrtype == kDNSServiceType_PTR (kDNSServiceType_PTR = 12), then rdata must point to a "Pointer record" defined in RFC 1035.

Community
  • 1
  • 1
Jonas
  • 6,915
  • 8
  • 35
  • 53
  • Thanks. How can i create rdata my self on above example? I cant find anything in library. I am working on windows I can access to dnn-sd.h only. – NoWorries Feb 24 '17 at 12:59
  • You should follow the RFC linked to, or another definition if: `rrtype != kDNSServiceType_PTR` – Jonas Feb 24 '17 at 13:01
  • I setup rdata as a NULL RDATA format. I can see function didn't succeeded and return error -65541. I check with wirehshark trace. there is no packet transmission during this function called. DNSServiceReconfirmRecord(kDNSServiceFlagsForce, 0,"xyz._xxx._udp.local", kDNSServiceType_PTR, kDNSServiceClass_IN,27, bigNULL); – NoWorries Feb 24 '17 at 14:27
  • Why is rdlen = 27, when you provide zero bytes (by passing NULL pointer)? – Jonas Feb 24 '17 at 14:30
  • What is your rrtype? And why? – Jonas Feb 24 '17 at 14:34
  • rrtype: kDNSServiceType_PTR , I put 27 from wireshark packet trace during discovery process. For a setup I am just using one device so i can see all information from response packet received on query reply – NoWorries Feb 24 '17 at 14:44
  • Did you read the documentation? It says: rdlen The length, in bytes, of the resource record rdata. – Jonas Feb 24 '17 at 14:47
  • I think i dont understood properly rdata format. I gone through RFC 1035 as per your link...is there any example .... – NoWorries Feb 24 '17 at 14:47
  • What is the argument for using kDNSServiceType_PTR? – Jonas Feb 24 '17 at 14:50
  • ohh ya, that was my mistake, type: SRV.. I looked wrong trace with google cast....I am not so expert in network.. – NoWorries Feb 24 '17 at 15:01
  • For rrtype = SRV = kDNSServiceType_SRV = 33, you should follow: https://tools.ietf.org/html/rfc2782 – Jonas Feb 24 '17 at 15:24
  • As per the wiki link – Jonas Feb 24 '17 at 15:25
  • @bbt Did you succeed? – Jonas Feb 27 '17 at 13:26
  • I was on holidays last couple of days. I will check today and update you. meanwhile i have workaround this issues. main aim is behind this work is to remove lost device entries from local cache so what i did ,simple loop which keep polling after 1 s to identify lost of device and update GUI. bonjour provides details of device and second loop code identify lost of device instead of bonjour api. – NoWorries Mar 01 '17 at 10:28