ArduinoMDNS icon indicating copy to clipboard operation
ArduinoMDNS copied to clipboard

Include latest TrippyLighting fixes?

Open toqduj opened this issue 8 years ago • 3 comments

Hello dear developers,

I see that the trippylighting branch has a few additional commits/fixes (june-august 2017) since the last one here (april 2017). Would it be possible/necessary to include these in the arduino-libraries fork?

See: https://github.com/TrippyLighting/EthernetBonjour/commits/master

Cheers,

Brian.

toqduj avatar Jan 08 '18 14:01 toqduj

@toqduj would you be able to open a pull request for this?

sandeepmistry avatar Apr 25 '19 14:04 sandeepmistry

the diff was huge because of differences in formatting but it looks like the only function that changed was:

int MDNS::addServiceRecord(const char* name, uint16_t port,
             MDNSServiceProtocol_t proto, const char* textContent)
{
  int i, status = 0;
  MDNSServiceRecord_t* record = NULL;

  if (NULL != name && 0 != port) {
    for (i=0; i < NumMDNSServiceRecords; i++) {
      if (NULL == this->_serviceRecords[i]) {
        record = (MDNSServiceRecord_t*)my_malloc(sizeof(MDNSServiceRecord_t));
        if (NULL != record) {
          record->name = record->textContent = NULL;

          record->name = (uint8_t*)my_malloc(strlen((char*)name)+1);
          memset(record->name, 0, strlen((char*)name)+1);
          if (NULL == record->name)
            goto errorReturn;

          if (NULL != textContent) {
            record->textContent = (uint8_t*)my_malloc(strlen((char*)textContent)+1);
            memset(record->textContent, 0, strlen((char*)textContent)+1);
            if (NULL == record->textContent)
              goto errorReturn;

            strcpy((char*)record->textContent, textContent);
          }

          record->port = port;
          record->proto = proto;
          strcpy((char*)record->name, name);

          uint8_t* s = this->_findFirstDotFromRight(record->name);
          record->servName = (uint8_t*)my_malloc(strlen((char*)s)+13);
          memset(record->servName, 0, strlen((char*)s)+13);
          if (record->servName) {
            strcpy((char*)record->servName, (const char*)s);

            const uint8_t* srv_type = this->_postfixForProtocol(proto);
            if (srv_type)
              strcat((char*)record->servName, (const char*)srv_type);
          }

          this->_serviceRecords[i] = record;

          status = (MDNSSuccess ==
               this->_sendMDNSMessage(0, 0, (int)MDNSPacketTypeServiceRecord, i));

          break;
        }
      }
    }
  }

I will test this and see if it breaks anything...

gigaj0ule avatar Feb 23 '23 00:02 gigaj0ule

It doesn't break anything :-)

gigaj0ule avatar Feb 23 '23 00:02 gigaj0ule