src/mk_mdns_client.c
static int mk_prepare_qu_msg(unsigned char *buf, char *qname)
{
   uint16_t *pU16 = NULL;
   int qnlen = 0;
   int txlen = 0;
   uint16_t val16 = 0;

   if ((!buf)||(!qname)) {
      MK_LOG(LOG_ERR,"%s() NULL parameters \n",__func__);
      return 0;
   }

   // Fill header
   memset(buf,0,MDNS_HDRSZ);
   pU16 = (uint16_t *)&buf[0];
   // pU16[0] = 0; //id
   // pU16[1] = 0; //flags
   pU16[2] = htons(1); //num queries 
   // pU16[3] = 0; //answer
   // pU16[4] = 0; //auth_rr
   // pU16[4] = 0; // add_rr
   txlen = MDNS_HDRSZ;

   // Fill formatted question txt: "a.bcde.xyz" to "1a4bcde3xyz"
   qnlen = mk_get_dotted_str_to_dns_name(qname,&buf[txlen]);
   if ( qnlen <= 0 ) {
      MK_LOG(LOG_ERR,"%s() mk_get_dotted_str_to_dns_name error \n",__func__);
      return -1;
   }

  txlen += qnlen;

  //Fill type
  pU16 = (uint16_t *)&buf[txlen];
  val16 = RRTYPE_PTR;
  pU16[0] = htons(val16);
  txlen += 2;

  //Fill class/QU
  val16 = 1; // 1 for class internet
  val16 |= (1 << 15); // for unicast
  pU16 = (uint16_t *)&buf[txlen];
  pU16[0] = htons(val16);
  txlen += 2;

  return txlen;
}
/**
 * @brief mk_prepare_qu_msg prepares a simple minimal mimik specific mdns query 
 *      
 * This function will prepare a very minimal mimik specific mdns query
 * used to identify mimik edge super node in a local network.
 *
 * @param[in]   buf       pointer to a msg buffer to store a prepared mdns query message.
 * @param[out]  buf       pointer to a msg buffer where prepared mdns query message will be stored.
 * @return                returns the length of prepared message filled into buffer.
 */
@brief mk_prepare_qu_msg prepares a simple minimal mimik specific mdns query

This function will prepare a very minimal mimik specific mdns query
used to identify mimik edge super node in a local network.

@param[in]   buf       pointer to a msg buffer to store a prepared mdns query message.
@param[out]  buf       pointer to a msg buffer where prepared mdns query message will be stored.
@return                returns the length of prepared message filled into buffer.
@brief mk_prepare_qu_msg prepares a simple minimal mimik specific mdns query This function will prepare a very minimal mimik specific mdns query used to identify mimik edge super node in a local network . @param [ in ] buf pointer to a msg buffer to store a prepared mdns query message . @param [ out ] buf pointer to a msg buffer where prepared mdns query message will be stored . @return returns the length of prepared message filled into buffer .
static int mk_prepare_qu_msg(unsigned char *buf, char *qname)
{
   uint16_t *pU16 = NULL;
   int qnlen = 0;
   int txlen = 0;
   uint16_t val16 = 0;
   if ((!buf)||(!qname)) {
      MK_LOG(LOG_ERR,"%s() NULL parameters \n",__func__);
      return 0;
   }
   memset(buf,0,MDNS_HDRSZ);
   pU16 = (uint16_t *)&buf[0];
   pU16[2] = htons(1); 
   txlen = MDNS_HDRSZ;
   qnlen = mk_get_dotted_str_to_dns_name(qname,&buf[txlen]);
   if ( qnlen <= 0 ) {
      MK_LOG(LOG_ERR,"%s() mk_get_dotted_str_to_dns_name error \n",__func__);
      return -1;
   }
  txlen += qnlen;
  pU16 = (uint16_t *)&buf[txlen];
  val16 = RRTYPE_PTR;
  pU16[0] = htons(val16);
  txlen += 2;
  val16 = 1; 
  val16 |= (1 << 15); 
  pU16 = (uint16_t *)&buf[txlen];
  pU16[0] = htons(val16);
  txlen += 2;
  return txlen;
}
static int mk_prepare_qu_msg ( unsigned char * buf , char * qname ) { uint16_t * pU16 = NULL ; int qnlen = 0 ; int txlen = 0 ; uint16_t val16 = 0 ; if ( ( ! buf ) || ( ! qname ) ) { MK_LOG ( LOG_ERR , " \n " , __func__ ) ; return 0 ; } memset ( buf , 0 , MDNS_HDRSZ ) ; pU16 = ( uint16_t * ) & buf [ 0 ] ; pU16 [ 2 ] = htons ( 1 ) ; txlen = MDNS_HDRSZ ; qnlen = mk_get_dotted_str_to_dns_name ( qname , & buf [ txlen ] ) ; if ( qnlen <= 0 ) { MK_LOG ( LOG_ERR , " \n " , __func__ ) ; return -1 ; } txlen += qnlen ; pU16 = ( uint16_t * ) & buf [ txlen ] ; val16 = RRTYPE_PTR ; pU16 [ 0 ] = htons ( val16 ) ; txlen += 2 ; val16 = 1 ; val16 |= ( 1 << 15 ) ; pU16 = ( uint16_t * ) & buf [ txlen ] ; pU16 [ 0 ] = htons ( val16 ) ; txlen += 2 ; return txlen ; }
@brief mk_prepare_qu_msg prepares a simple minimal mimik specific mdns query
@brief mk_prepare_qu_msg prepares a simple minimal mimik specific mdns query
// Fill header // pU16[0] = 0; //id // pU16[1] = 0; //flags //num queries  // pU16[3] = 0; //answer // pU16[4] = 0; //auth_rr // pU16[4] = 0; // add_rr // Fill formatted question txt: "a.bcde.xyz" to "1a4bcde3xyz" //Fill type //Fill class/QU // 1 for class internet // for unicast