14b22b933Srs /* -*- Mode: C; tab-width: 4 -*-
24b22b933Srs *
3*3b436d06SToomas Soome * Copyright (c) 2004-2018 Apple Inc. All rights reserved.
44b22b933Srs *
55ffb0c9bSToomas Soome * Redistribution and use in source and binary forms, with or without
64b22b933Srs * modification, are permitted provided that the following conditions are met:
74b22b933Srs *
85ffb0c9bSToomas Soome * 1. Redistributions of source code must retain the above copyright notice,
95ffb0c9bSToomas Soome * this list of conditions and the following disclaimer.
105ffb0c9bSToomas Soome * 2. Redistributions in binary form must reproduce the above copyright notice,
115ffb0c9bSToomas Soome * this list of conditions and the following disclaimer in the documentation
125ffb0c9bSToomas Soome * and/or other materials provided with the distribution.
13cda73f64SToomas Soome * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
145ffb0c9bSToomas Soome * contributors may be used to endorse or promote products derived from this
155ffb0c9bSToomas Soome * software without specific prior written permission.
164b22b933Srs *
175ffb0c9bSToomas Soome * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
185ffb0c9bSToomas Soome * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
195ffb0c9bSToomas Soome * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
205ffb0c9bSToomas Soome * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
215ffb0c9bSToomas Soome * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
225ffb0c9bSToomas Soome * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
235ffb0c9bSToomas Soome * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
245ffb0c9bSToomas Soome * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255ffb0c9bSToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
264b22b933Srs * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274b22b933Srs */
284b22b933Srs
294b22b933Srs #include <stdlib.h>
304b22b933Srs #include <string.h>
314b22b933Srs
324b22b933Srs #include "dns_sd.h"
334b22b933Srs
344b22b933Srs #if defined(_WIN32)
354b22b933Srs // disable warning "conversion from <data> to uint16_t"
364b22b933Srs #pragma warning(disable:4244)
375ffb0c9bSToomas Soome #define strncasecmp _strnicmp
385ffb0c9bSToomas Soome #define strcasecmp _stricmp
394b22b933Srs #endif
404b22b933Srs
414b22b933Srs /*********************************************************************************************
425ffb0c9bSToomas Soome *
435ffb0c9bSToomas Soome * Supporting Functions
445ffb0c9bSToomas Soome *
455ffb0c9bSToomas Soome *********************************************************************************************/
464b22b933Srs
475ffb0c9bSToomas Soome #define mDNSIsDigit(X) ((X) >= '0' && (X) <= '9')
485ffb0c9bSToomas Soome
495ffb0c9bSToomas Soome // DomainEndsInDot returns 1 if name ends with a dot, 0 otherwise
505ffb0c9bSToomas Soome // (DNSServiceConstructFullName depends this returning 1 for true, rather than any non-zero value meaning true)
514b22b933Srs
DomainEndsInDot(const char * dom)524b22b933Srs static int DomainEndsInDot(const char *dom)
535ffb0c9bSToomas Soome {
545ffb0c9bSToomas Soome while (dom[0] && dom[1])
555ffb0c9bSToomas Soome {
565ffb0c9bSToomas Soome if (dom[0] == '\\') // advance past escaped byte sequence
575ffb0c9bSToomas Soome {
585ffb0c9bSToomas Soome if (mDNSIsDigit(dom[1]) && mDNSIsDigit(dom[2]) && mDNSIsDigit(dom[3]))
595ffb0c9bSToomas Soome dom += 4; // If "\ddd" then skip four
605ffb0c9bSToomas Soome else dom += 2; // else if "\x" then skip two
615ffb0c9bSToomas Soome }
625ffb0c9bSToomas Soome else dom++; // else goto next character
635ffb0c9bSToomas Soome }
645ffb0c9bSToomas Soome return (dom[0] == '.');
655ffb0c9bSToomas Soome }
664b22b933Srs
InternalTXTRecordSearch(uint16_t txtLen,const void * txtRecord,const char * key,unsigned long * keylen)674b22b933Srs static uint8_t *InternalTXTRecordSearch
685ffb0c9bSToomas Soome (
695ffb0c9bSToomas Soome uint16_t txtLen,
705ffb0c9bSToomas Soome const void *txtRecord,
715ffb0c9bSToomas Soome const char *key,
725ffb0c9bSToomas Soome unsigned long *keylen
735ffb0c9bSToomas Soome )
745ffb0c9bSToomas Soome {
755ffb0c9bSToomas Soome uint8_t *p = (uint8_t*)txtRecord;
765ffb0c9bSToomas Soome uint8_t *e = p + txtLen;
775ffb0c9bSToomas Soome *keylen = (unsigned long) strlen(key);
785ffb0c9bSToomas Soome while (p<e)
795ffb0c9bSToomas Soome {
805ffb0c9bSToomas Soome uint8_t *x = p;
815ffb0c9bSToomas Soome p += 1 + p[0];
825ffb0c9bSToomas Soome if (p <= e && *keylen <= x[0] && !strncasecmp(key, (char*)x+1, *keylen))
835ffb0c9bSToomas Soome if (*keylen == x[0] || x[1+*keylen] == '=') return(x);
845ffb0c9bSToomas Soome }
855ffb0c9bSToomas Soome return(NULL);
865ffb0c9bSToomas Soome }
874b22b933Srs
884b22b933Srs /*********************************************************************************************
895ffb0c9bSToomas Soome *
905ffb0c9bSToomas Soome * General Utility Functions
915ffb0c9bSToomas Soome *
925ffb0c9bSToomas Soome *********************************************************************************************/
935ffb0c9bSToomas Soome
945ffb0c9bSToomas Soome // Note: Need to make sure we don't write more than kDNSServiceMaxDomainName (1009) bytes to fullName
955ffb0c9bSToomas Soome // In earlier builds this constant was defined to be 1005, so to avoid buffer overruns on clients
965ffb0c9bSToomas Soome // compiled with that constant we'll actually limit the output to 1005 bytes.
975ffb0c9bSToomas Soome
DNSServiceConstructFullName(char * const fullName,const char * const service,const char * const regtype,const char * const domain)985ffb0c9bSToomas Soome DNSServiceErrorType DNSSD_API DNSServiceConstructFullName
995ffb0c9bSToomas Soome (
1005ffb0c9bSToomas Soome char *const fullName,
1015ffb0c9bSToomas Soome const char *const service, // May be NULL
1025ffb0c9bSToomas Soome const char *const regtype,
1035ffb0c9bSToomas Soome const char *const domain
1045ffb0c9bSToomas Soome )
1055ffb0c9bSToomas Soome {
1065ffb0c9bSToomas Soome const size_t len = !regtype ? 0 : strlen(regtype) - DomainEndsInDot(regtype);
1075ffb0c9bSToomas Soome char *fn = fullName;
1085ffb0c9bSToomas Soome char *const lim = fullName + 1005;
1095ffb0c9bSToomas Soome const char *s = service;
1105ffb0c9bSToomas Soome const char *r = regtype;
1115ffb0c9bSToomas Soome const char *d = domain;
1125ffb0c9bSToomas Soome
1135ffb0c9bSToomas Soome // regtype must be at least "x._udp" or "x._tcp"
1145ffb0c9bSToomas Soome if (len < 6 || !domain || !domain[0]) return kDNSServiceErr_BadParam;
1155ffb0c9bSToomas Soome if (strncasecmp((regtype + len - 4), "_tcp", 4) && strncasecmp((regtype + len - 4), "_udp", 4)) return kDNSServiceErr_BadParam;
1165ffb0c9bSToomas Soome
1175ffb0c9bSToomas Soome if (service && *service)
1185ffb0c9bSToomas Soome {
1195ffb0c9bSToomas Soome while (*s)
1205ffb0c9bSToomas Soome {
1215ffb0c9bSToomas Soome unsigned char c = *s++; // Needs to be unsigned, or values like 0xFF will be interpreted as < 32
1225ffb0c9bSToomas Soome if (c <= ' ') // Escape non-printable characters
1235ffb0c9bSToomas Soome {
1245ffb0c9bSToomas Soome if (fn+4 >= lim) goto fail;
1255ffb0c9bSToomas Soome *fn++ = '\\';
1265ffb0c9bSToomas Soome *fn++ = '0' + (c / 100);
1275ffb0c9bSToomas Soome *fn++ = '0' + (c / 10) % 10;
1285ffb0c9bSToomas Soome c = '0' + (c ) % 10;
1295ffb0c9bSToomas Soome }
1305ffb0c9bSToomas Soome else if (c == '.' || (c == '\\')) // Escape dot and backslash literals
1315ffb0c9bSToomas Soome {
1325ffb0c9bSToomas Soome if (fn+2 >= lim) goto fail;
1335ffb0c9bSToomas Soome *fn++ = '\\';
1345ffb0c9bSToomas Soome }
1355ffb0c9bSToomas Soome else
1365ffb0c9bSToomas Soome if (fn+1 >= lim) goto fail;
1375ffb0c9bSToomas Soome *fn++ = (char)c;
1385ffb0c9bSToomas Soome }
1395ffb0c9bSToomas Soome *fn++ = '.';
1405ffb0c9bSToomas Soome }
1415ffb0c9bSToomas Soome
1425ffb0c9bSToomas Soome while (*r) if (fn+1 >= lim) goto fail;else *fn++ = *r++;
1435ffb0c9bSToomas Soome if (!DomainEndsInDot(regtype)) { if (fn+1 >= lim) goto fail;else *fn++ = '.';}
1445ffb0c9bSToomas Soome
1455ffb0c9bSToomas Soome while (*d) if (fn+1 >= lim) goto fail;else *fn++ = *d++;
1465ffb0c9bSToomas Soome if (!DomainEndsInDot(domain)) { if (fn+1 >= lim) goto fail;else *fn++ = '.';}
1475ffb0c9bSToomas Soome
1485ffb0c9bSToomas Soome *fn = '\0';
1495ffb0c9bSToomas Soome return kDNSServiceErr_NoError;
1505ffb0c9bSToomas Soome
1515ffb0c9bSToomas Soome fail:
1525ffb0c9bSToomas Soome *fn = '\0';
1535ffb0c9bSToomas Soome return kDNSServiceErr_BadParam;
1545ffb0c9bSToomas Soome }
1554b22b933Srs
1564b22b933Srs /*********************************************************************************************
1575ffb0c9bSToomas Soome *
1585ffb0c9bSToomas Soome * TXT Record Construction Functions
1595ffb0c9bSToomas Soome *
1605ffb0c9bSToomas Soome *********************************************************************************************/
1614b22b933Srs
1624b22b933Srs typedef struct _TXTRecordRefRealType
1635ffb0c9bSToomas Soome {
1645ffb0c9bSToomas Soome uint8_t *buffer; // Pointer to data
1655ffb0c9bSToomas Soome uint16_t buflen; // Length of buffer
1665ffb0c9bSToomas Soome uint16_t datalen; // Length currently in use
1675ffb0c9bSToomas Soome uint16_t malloced; // Non-zero if buffer was allocated via malloc()
1685ffb0c9bSToomas Soome } TXTRecordRefRealType;
1694b22b933Srs
1704b22b933Srs #define txtRec ((TXTRecordRefRealType*)txtRecord)
1714b22b933Srs
1724b22b933Srs // The opaque storage defined in the public dns_sd.h header is 16 bytes;
1734b22b933Srs // make sure we don't exceed that.
1745ffb0c9bSToomas Soome struct CompileTimeAssertionCheck_dnssd_clientlib
1755ffb0c9bSToomas Soome {
1765ffb0c9bSToomas Soome char assert0[(sizeof(TXTRecordRefRealType) <= 16) ? 1 : -1];
1775ffb0c9bSToomas Soome };
1784b22b933Srs
TXTRecordCreate(TXTRecordRef * txtRecord,uint16_t bufferLen,void * buffer)1794b22b933Srs void DNSSD_API TXTRecordCreate
1805ffb0c9bSToomas Soome (
1815ffb0c9bSToomas Soome TXTRecordRef *txtRecord,
1825ffb0c9bSToomas Soome uint16_t bufferLen,
1835ffb0c9bSToomas Soome void *buffer
1845ffb0c9bSToomas Soome )
1855ffb0c9bSToomas Soome {
1865ffb0c9bSToomas Soome txtRec->buffer = buffer;
1875ffb0c9bSToomas Soome txtRec->buflen = buffer ? bufferLen : (uint16_t)0;
1885ffb0c9bSToomas Soome txtRec->datalen = 0;
1895ffb0c9bSToomas Soome txtRec->malloced = 0;
1905ffb0c9bSToomas Soome }
1914b22b933Srs
TXTRecordDeallocate(TXTRecordRef * txtRecord)1924b22b933Srs void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtRecord)
1935ffb0c9bSToomas Soome {
1945ffb0c9bSToomas Soome if (txtRec->malloced) free(txtRec->buffer);
1955ffb0c9bSToomas Soome }
1964b22b933Srs
TXTRecordSetValue(TXTRecordRef * txtRecord,const char * key,uint8_t valueSize,const void * value)1974b22b933Srs DNSServiceErrorType DNSSD_API TXTRecordSetValue
1985ffb0c9bSToomas Soome (
1995ffb0c9bSToomas Soome TXTRecordRef *txtRecord,
2005ffb0c9bSToomas Soome const char *key,
2015ffb0c9bSToomas Soome uint8_t valueSize,
2025ffb0c9bSToomas Soome const void *value
2035ffb0c9bSToomas Soome )
2045ffb0c9bSToomas Soome {
2055ffb0c9bSToomas Soome uint8_t *start, *p;
2065ffb0c9bSToomas Soome const char *k;
2075ffb0c9bSToomas Soome unsigned long keysize, keyvalsize;
2085ffb0c9bSToomas Soome
2095ffb0c9bSToomas Soome for (k = key; *k; k++) if (*k < 0x20 || *k > 0x7E || *k == '=') return(kDNSServiceErr_Invalid);
2105ffb0c9bSToomas Soome keysize = (unsigned long)(k - key);
2115ffb0c9bSToomas Soome keyvalsize = 1 + keysize + (value ? (1 + valueSize) : 0);
2125ffb0c9bSToomas Soome if (keysize < 1 || keyvalsize > 255) return(kDNSServiceErr_Invalid);
2135ffb0c9bSToomas Soome (void)TXTRecordRemoveValue(txtRecord, key);
2145ffb0c9bSToomas Soome if (txtRec->datalen + keyvalsize > txtRec->buflen)
2155ffb0c9bSToomas Soome {
2165ffb0c9bSToomas Soome unsigned char *newbuf;
2175ffb0c9bSToomas Soome unsigned long newlen = txtRec->datalen + keyvalsize;
2185ffb0c9bSToomas Soome if (newlen > 0xFFFF) return(kDNSServiceErr_Invalid);
2195ffb0c9bSToomas Soome newbuf = malloc((size_t)newlen);
2205ffb0c9bSToomas Soome if (!newbuf) return(kDNSServiceErr_NoMemory);
2215ffb0c9bSToomas Soome memcpy(newbuf, txtRec->buffer, txtRec->datalen);
2225ffb0c9bSToomas Soome if (txtRec->malloced) free(txtRec->buffer);
2235ffb0c9bSToomas Soome txtRec->buffer = newbuf;
2245ffb0c9bSToomas Soome txtRec->buflen = (uint16_t)(newlen);
2255ffb0c9bSToomas Soome txtRec->malloced = 1;
2265ffb0c9bSToomas Soome }
2275ffb0c9bSToomas Soome start = txtRec->buffer + txtRec->datalen;
2285ffb0c9bSToomas Soome p = start + 1;
2295ffb0c9bSToomas Soome memcpy(p, key, keysize);
2305ffb0c9bSToomas Soome p += keysize;
2315ffb0c9bSToomas Soome if (value)
2325ffb0c9bSToomas Soome {
2335ffb0c9bSToomas Soome *p++ = '=';
2345ffb0c9bSToomas Soome memcpy(p, value, valueSize);
2355ffb0c9bSToomas Soome p += valueSize;
2365ffb0c9bSToomas Soome }
2375ffb0c9bSToomas Soome *start = (uint8_t)(p - start - 1);
2385ffb0c9bSToomas Soome txtRec->datalen += p - start;
2395ffb0c9bSToomas Soome return(kDNSServiceErr_NoError);
2405ffb0c9bSToomas Soome }
2414b22b933Srs
TXTRecordRemoveValue(TXTRecordRef * txtRecord,const char * key)2424b22b933Srs DNSServiceErrorType DNSSD_API TXTRecordRemoveValue
2435ffb0c9bSToomas Soome (
2445ffb0c9bSToomas Soome TXTRecordRef *txtRecord,
2455ffb0c9bSToomas Soome const char *key
2465ffb0c9bSToomas Soome )
2475ffb0c9bSToomas Soome {
2485ffb0c9bSToomas Soome unsigned long keylen, itemlen, remainder;
2495ffb0c9bSToomas Soome uint8_t *item = InternalTXTRecordSearch(txtRec->datalen, txtRec->buffer, key, &keylen);
2505ffb0c9bSToomas Soome if (!item) return(kDNSServiceErr_NoSuchKey);
2515ffb0c9bSToomas Soome itemlen = (unsigned long)(1 + item[0]);
2525ffb0c9bSToomas Soome remainder = (unsigned long)((txtRec->buffer + txtRec->datalen) - (item + itemlen));
2535ffb0c9bSToomas Soome // Use memmove because memcpy behaviour is undefined for overlapping regions
2545ffb0c9bSToomas Soome memmove(item, item + itemlen, remainder);
2555ffb0c9bSToomas Soome txtRec->datalen -= itemlen;
2565ffb0c9bSToomas Soome return(kDNSServiceErr_NoError);
2575ffb0c9bSToomas Soome }
2584b22b933Srs
TXTRecordGetLength(const TXTRecordRef * txtRecord)2594b22b933Srs uint16_t DNSSD_API TXTRecordGetLength (const TXTRecordRef *txtRecord) { return(txtRec->datalen); }
TXTRecordGetBytesPtr(const TXTRecordRef * txtRecord)2604b22b933Srs const void * DNSSD_API TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) { return(txtRec->buffer); }
2614b22b933Srs
2624b22b933Srs /*********************************************************************************************
2635ffb0c9bSToomas Soome *
2645ffb0c9bSToomas Soome * TXT Record Parsing Functions
2655ffb0c9bSToomas Soome *
2665ffb0c9bSToomas Soome *********************************************************************************************/
2674b22b933Srs
TXTRecordContainsKey(uint16_t txtLen,const void * txtRecord,const char * key)2684b22b933Srs int DNSSD_API TXTRecordContainsKey
2695ffb0c9bSToomas Soome (
2705ffb0c9bSToomas Soome uint16_t txtLen,
2715ffb0c9bSToomas Soome const void *txtRecord,
2725ffb0c9bSToomas Soome const char *key
2735ffb0c9bSToomas Soome )
2745ffb0c9bSToomas Soome {
2755ffb0c9bSToomas Soome unsigned long keylen;
2765ffb0c9bSToomas Soome return (InternalTXTRecordSearch(txtLen, txtRecord, key, &keylen) ? 1 : 0);
2775ffb0c9bSToomas Soome }
2784b22b933Srs
TXTRecordGetValuePtr(uint16_t txtLen,const void * txtRecord,const char * key,uint8_t * valueLen)2794b22b933Srs const void * DNSSD_API TXTRecordGetValuePtr
2805ffb0c9bSToomas Soome (
2815ffb0c9bSToomas Soome uint16_t txtLen,
2825ffb0c9bSToomas Soome const void *txtRecord,
2835ffb0c9bSToomas Soome const char *key,
2845ffb0c9bSToomas Soome uint8_t *valueLen
2855ffb0c9bSToomas Soome )
2865ffb0c9bSToomas Soome {
2875ffb0c9bSToomas Soome unsigned long keylen;
2885ffb0c9bSToomas Soome uint8_t *item = InternalTXTRecordSearch(txtLen, txtRecord, key, &keylen);
2895ffb0c9bSToomas Soome if (!item || item[0] <= keylen) return(NULL); // If key not found, or found with no value, return NULL
2905ffb0c9bSToomas Soome *valueLen = (uint8_t)(item[0] - (keylen + 1));
2915ffb0c9bSToomas Soome return (item + 1 + keylen + 1);
2925ffb0c9bSToomas Soome }
2934b22b933Srs
TXTRecordGetCount(uint16_t txtLen,const void * txtRecord)2944b22b933Srs uint16_t DNSSD_API TXTRecordGetCount
2955ffb0c9bSToomas Soome (
2965ffb0c9bSToomas Soome uint16_t txtLen,
2975ffb0c9bSToomas Soome const void *txtRecord
2985ffb0c9bSToomas Soome )
2995ffb0c9bSToomas Soome {
3005ffb0c9bSToomas Soome uint16_t count = 0;
3015ffb0c9bSToomas Soome uint8_t *p = (uint8_t*)txtRecord;
3025ffb0c9bSToomas Soome uint8_t *e = p + txtLen;
3035ffb0c9bSToomas Soome while (p<e) { p += 1 + p[0]; count++; }
3045ffb0c9bSToomas Soome return((p>e) ? (uint16_t)0 : count);
3055ffb0c9bSToomas Soome }
3064b22b933Srs
TXTRecordGetItemAtIndex(uint16_t txtLen,const void * txtRecord,uint16_t itemIndex,uint16_t keyBufLen,char * key,uint8_t * valueLen,const void ** value)3074b22b933Srs DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
3085ffb0c9bSToomas Soome (
3095ffb0c9bSToomas Soome uint16_t txtLen,
3105ffb0c9bSToomas Soome const void *txtRecord,
3115ffb0c9bSToomas Soome uint16_t itemIndex,
3125ffb0c9bSToomas Soome uint16_t keyBufLen,
3135ffb0c9bSToomas Soome char *key,
3145ffb0c9bSToomas Soome uint8_t *valueLen,
3155ffb0c9bSToomas Soome const void **value
3165ffb0c9bSToomas Soome )
3175ffb0c9bSToomas Soome {
3185ffb0c9bSToomas Soome uint16_t count = 0;
3195ffb0c9bSToomas Soome uint8_t *p = (uint8_t*)txtRecord;
3205ffb0c9bSToomas Soome uint8_t *e = p + txtLen;
3215ffb0c9bSToomas Soome while (p<e && count<itemIndex) { p += 1 + p[0]; count++; } // Find requested item
3225ffb0c9bSToomas Soome if (p<e && p + 1 + p[0] <= e) // If valid
3235ffb0c9bSToomas Soome {
3245ffb0c9bSToomas Soome uint8_t *x = p+1;
3255ffb0c9bSToomas Soome unsigned long len = 0;
3265ffb0c9bSToomas Soome e = p + 1 + p[0];
3275ffb0c9bSToomas Soome while (x+len<e && x[len] != '=') len++;
3285ffb0c9bSToomas Soome if (len >= keyBufLen) return(kDNSServiceErr_NoMemory);
3295ffb0c9bSToomas Soome memcpy(key, x, len);
3305ffb0c9bSToomas Soome key[len] = 0;
3315ffb0c9bSToomas Soome if (x+len<e) // If we found '='
3325ffb0c9bSToomas Soome {
3335ffb0c9bSToomas Soome *value = x + len + 1;
3345ffb0c9bSToomas Soome *valueLen = (uint8_t)(p[0] - (len + 1));
3355ffb0c9bSToomas Soome }
3365ffb0c9bSToomas Soome else
3375ffb0c9bSToomas Soome {
3385ffb0c9bSToomas Soome *value = NULL;
3395ffb0c9bSToomas Soome *valueLen = 0;
3405ffb0c9bSToomas Soome }
3415ffb0c9bSToomas Soome return(kDNSServiceErr_NoError);
3425ffb0c9bSToomas Soome }
3435ffb0c9bSToomas Soome return(kDNSServiceErr_Invalid);
3445ffb0c9bSToomas Soome }
3455ffb0c9bSToomas Soome
3465ffb0c9bSToomas Soome /*********************************************************************************************
3475ffb0c9bSToomas Soome *
3485ffb0c9bSToomas Soome * SCCS-compatible version string
3495ffb0c9bSToomas Soome *
3505ffb0c9bSToomas Soome *********************************************************************************************/
3515ffb0c9bSToomas Soome
3525ffb0c9bSToomas Soome // For convenience when using the "strings" command, this is the last thing in the file
3535ffb0c9bSToomas Soome
3545ffb0c9bSToomas Soome // Note: The C preprocessor stringify operator ('#') makes a string from its argument, without macro expansion
3555ffb0c9bSToomas Soome // e.g. If "version" is #define'd to be "4", then STRINGIFY_AWE(version) will return the string "version", not "4"
3565ffb0c9bSToomas Soome // To expand "version" to its value before making the string, use STRINGIFY(version) instead
3575ffb0c9bSToomas Soome #define STRINGIFY_ARGUMENT_WITHOUT_EXPANSION(s) # s
3585ffb0c9bSToomas Soome #define STRINGIFY(s) STRINGIFY_ARGUMENT_WITHOUT_EXPANSION(s)
3595ffb0c9bSToomas Soome
360*3b436d06SToomas Soome // The "used" variable attribute prevents a non-exported variable from being stripped, even if its visibility is hidden,
361*3b436d06SToomas Soome // e.g., when compiling with -fvisibility=hidden.
362*3b436d06SToomas Soome #if defined(__GNUC__)
363*3b436d06SToomas Soome #define DNSSD_USED __attribute__((used))
364*3b436d06SToomas Soome #else
365*3b436d06SToomas Soome #define DNSSD_USED
366*3b436d06SToomas Soome #endif
367*3b436d06SToomas Soome
3685ffb0c9bSToomas Soome // NOT static -- otherwise the compiler may optimize it out
3695ffb0c9bSToomas Soome // The "@(#) " pattern is a special prefix the "what" command looks for
370c1de7575SRichard Lowe #ifndef MDNS_VERSIONSTR_NODTS
371*3b436d06SToomas Soome const char VersionString_SCCS_libdnssd[] DNSSD_USED = "@(#) libdns_sd " STRINGIFY(mDNSResponderVersion) " (" __DATE__ " " __TIME__ ")";
372c1de7575SRichard Lowe #else
373c1de7575SRichard Lowe const char VersionString_SCCS_libdnssd[] = "@(#) libdns_sd " STRINGIFY(mDNSResponderVersion);
374c1de7575SRichard Lowe #endif
375