• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Question about adding search domains using kSCPropNetDNSSearchDomains
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about adding search domains using kSCPropNetDNSSearchDomains


  • Subject: Question about adding search domains using kSCPropNetDNSSearchDomains
  • From: "Abhishek Singh (abhsing2)" <email@hidden>
  • Date: Wed, 8 Oct 2008 16:42:29 +0530
  • Thread-topic: Question about adding search domains using kSCPropNetDNSSearchDomains

Title: Question about adding search domains using kSCPropNetDNSSearchDomains

Hi all,

I have been struggling for the past 2-3 days to get my code to add search domains to the dynamic store.

Right now i am in a state where i am able to add a search domain successfully. But if i try to add multiple search domains like abc.com pqr.com and xyz.com to the search domains, they all get added in the same domain. i.e when i say ping test, the DNS query being sent is for "test.abc.com pqr.com xyz.com" instead of sending 3 separate queries for "test.abc.com", "test.pqr.com" and "test.xyz.com".

Upon analyzing the output of "scutil --dns" this is what i see

> DNS configuration
>
> resolver #1
>   domain : abc.com
>   search domain[0] : abc.com abc.com pqr.com xyz.com
>   search domain[1] : abc.com
>   nameserver[0] : 10.76.11.102
>   order   : 200000
>
> resolver #2
>   domain : local
>   options : mdns
> .
> .
> .
> .
> .

In the above output the source of the problem is very clear. The search domain[0] contains all the 3 search domains together. For it to work correctly abc.com must be domain[0], pqr.com must be domain[1] and xyz.com must be domain[2].

But no matter what i try, the search domains always get appended in the domain[0].

The code i am using to insert search domains is as follows

          if ( search != NULL && strlen( search ) > 0 )
                {
                    CFMutableArrayRef search_list= CFArrayCreateMutable(NULL, 0,
                                                &kCFTypeArrayCallBacks);


                    if ( search_list)
                    {

/********************************************************************/
                                                char temp_search[1024] = "";
                                                char *split_names = NULL;

                                                safe_strlcpy(temp_search, search, sizeof(temp_search));


                                                unsigned int i = strlen(temp_search);
                                                int tokens = 0;
                                                for( ; i > 0; i--)
                                                {
                                                        if(',' == temp_search[i] || ' ' == temp_search[i])
                                                        {
                                                                tokens++;
                                                        }
                                                }
                                                tokens++;

                                                i = strlen(temp_search);
                                                for( ; i > 0; i--)
                                                {
                                                        if(',' == temp_search[i] || ' ' == temp_search[i])
                                                        {
                                                                temp_search[i] = NULL;
                                                                split_names = &temp_search[i+1];
                                                                CFArrayInsertValueAtIndex(search_list, --tokens,
                                                                        CFStringCreateWithCString( NULL,
                                                                        split_names, kCFStringEncodingUTF8 )  );
                                                        }
                                                }

                                                split_names = temp_search;
                                                CFArrayInsertValueAtIndex(search_list, 0,
                                                        CFStringCreateWithCString( NULL,
                                                        split_names, kCFStringEncodingUTF8 )  );

                                                CFDictionarySetValue(dns_new,
                                                        kSCPropNetDNSSearchDomains, search_list);
/********************************************************************/

                        CFRelease(search_list);
                    }
                }



Can someone please let me know what is it that i am doing wrong here?

If finding the mistake in the above code is going to be difficult, it would be a great help if someone could provide me with a sample code showing how we can add multiple search domains on MAC.

Thanx in advance

Thanx and regards,
Abhishek Singh


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Question about adding search domains using kSCPropNetDNSSearchDomains
      • From: Allan Nathanson <email@hidden>
  • Prev by Date: TCP Push function in CFStream?
  • Next by Date: Re: Question about adding search domains using kSCPropNetDNSSearchDomains
  • Previous by thread: Re: TCP Push function in CFStream?
  • Next by thread: Re: Question about adding search domains using kSCPropNetDNSSearchDomains
  • Index(es):
    • Date
    • Thread