dnssd 1.1.0 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
data/.autotest CHANGED
@@ -1,15 +1,14 @@
1
- require 'autotest/restart'
2
-
3
- Autotest.add_hook :initialize do |at|
4
- at.testlib = 'minitest/unit'
1
+ begin
2
+ require 'autotest/fsevent'
3
+ rescue LoadError
4
+ end
5
5
 
6
- def at.path_to_classname(s)
7
- sep = File::SEPARATOR
8
- f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
9
- f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
10
- f = f.map { |path| path =~ /^Test/ ? path : "Test#{path}" }
11
- f.join('::').sub 'Dnssd', 'DNSSD'
6
+ Autotest.add_hook :run_command do |at|
7
+ at.unit_diff = 'cat'
8
+ if ENV['ONENINE']
9
+ system "rake1.9 compile"
10
+ else
11
+ system "rake compile"
12
12
  end
13
-
14
13
  end
15
14
 
@@ -1,13 +1,38 @@
1
+ === 1.2.0 / 2009-08-11
2
+
3
+ * 3 major enhancements
4
+ * DNSSD::Service is now directly instantiable
5
+ * DNSSD.announce which registers a server socket you've created
6
+ * DNSSD::Reply.connect which connects to a browsed service
7
+ * Fix asynchronous service shutdown crash
8
+
9
+ * 3 minor enhancements
10
+ * DNSSD.resolve now optionally accepts a DNSSD::Reply from DNSSD.browse
11
+ * Use rb_thread_wait_fd instead of custom rb_thread_select code
12
+ * DNSSD::Reply#protocol and DNSSD::Reply#service_name
13
+ * Added missing error classes
14
+ * Added missing InterfaceUnicast constant
15
+ * Improved Documentation
16
+ * Use C constants in ext/dnssd/errors.c
17
+ * Reduced C code in ext/dnssd/service.c for greater control. See
18
+ DNSSD::Service
19
+
20
+ * 4 bug fixes
21
+ * Don't invoke block on callback if none was provided
22
+ * Remove ext/dnssd/dns_sd.h so the correct header is used
23
+ * DNSSD::NoMemoryError is now raised instead of NoMemError
24
+ * DNSSD::ReferenceUsedError is now correctly named DNSSD::RefusedError
25
+
1
26
  === 1.1.0 / 2009-08-10
2
27
 
3
- * 2 Major enhancements
28
+ * 2 major enhancements
4
29
  * Packaging files that need to be here
5
30
  * Increased the version number
6
31
 
7
- * 1 Minor enhancement
32
+ * 1 minor enhancement
8
33
  * Less C codes
9
34
 
10
- * 1 Bugfix
35
+ * 1 bug fix
11
36
  * Increased INTERNET!
12
37
 
13
38
  === 0.7.2 / 2009-08-05
@@ -3,7 +3,6 @@ History.txt
3
3
  Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
- ext/dnssd/dns_sd.h
7
6
  ext/dnssd/dnssd.c
8
7
  ext/dnssd/dnssd.h
9
8
  ext/dnssd/errors.c
@@ -16,11 +15,14 @@ lib/dnssd/reply.rb
16
15
  lib/dnssd/service.rb
17
16
  lib/dnssd/text_record.rb
18
17
  sample/browse.rb
18
+ sample/enumerate_domains.rb
19
19
  sample/growl.rb
20
- sample/highlevel_api.rb
21
20
  sample/register.rb
22
21
  sample/resolve.rb
23
22
  sample/resolve_ichat.rb
23
+ sample/server.rb
24
+ sample/socket.rb
25
+ test/test_dnssd.rb
24
26
  test/test_dnssd_flags.rb
25
27
  test/test_dnssd_reply.rb
26
28
  test/test_dnssd_text_record.rb
data/README.txt CHANGED
@@ -10,17 +10,19 @@ resolving, registration and domain enumeration.
10
10
 
11
11
  == FEATURES/PROBLEMS:
12
12
 
13
- * Too much C, too little ruby
13
+ * Needs more pie.
14
+ * Not all of the DNSSD API is implemented
15
+ * Sometimes tests fail
14
16
 
15
17
  == SYNOPSIS:
16
18
 
19
+ See the sample directory (Hint: gem contents --prefix dnssd)
20
+
17
21
  Registering a service:
18
22
 
19
- registration = DNSSD.register 'my web service', '_http._tcp', nil, 80
20
-
21
- # ...
23
+ http = TCPServer.new nil, 80
22
24
 
23
- registration.stop # unregister when we're done
25
+ DNSSD.announce http, 'my awesome HTTP server'
24
26
 
25
27
  Browsing services:
26
28
 
@@ -32,12 +34,12 @@ Browsing services:
32
34
 
33
35
  == REQUIREMENTS:
34
36
 
35
- * The mdns library on OS X
36
- * The dns-sd library on other operating systems
37
+ * OS X
38
+ * The dns-sd library on other operating systems (or dns-sd shim)
37
39
 
38
40
  == INSTALL:
39
41
 
40
- * FIX (sudo gem install, anything else)
42
+ sudo gem install dnssd
41
43
 
42
44
  == LICENSE:
43
45
 
@@ -4,15 +4,92 @@ void Init_DNSSD_Errors(void);
4
4
  void Init_DNSSD_Flags(void);
5
5
  void Init_DNSSD_Service(void);
6
6
 
7
+ /*
8
+ * call-seq:
9
+ * DNSSD.getservbyport(port, proto = nil) => service_name
10
+ *
11
+ * Wrapper for getservbyport(3) - returns the service name for +port+.
12
+ *
13
+ * DNSSD.getservbyport 1025 # => 'blackjack'
14
+ */
15
+
16
+ static VALUE
17
+ dnssd_getservbyport(int argc, VALUE * argv, VALUE self) {
18
+ VALUE _port, _proto;
19
+ struct servent * result;
20
+ int port;
21
+ char * proto = NULL;
22
+
23
+ rb_scan_args(argc, argv, "11", &_port, &_proto);
24
+
25
+ port = htons(FIX2INT(_port));
26
+
27
+ if (RTEST(_proto))
28
+ proto = StringValueCStr(_proto);
29
+
30
+ result = getservbyport(port, proto);
31
+
32
+ if (result == NULL)
33
+ return Qnil;
34
+
35
+ return rb_str_new2(result->s_name);
36
+ }
37
+
38
+ /*
39
+ * call-seq:
40
+ * DNSSD.interface_name(interface_index) # => interface_name
41
+ *
42
+ * Returns the interface name for interface +interface_index+.
43
+ *
44
+ * DNSSD.interface_name 1 # => 'lo0'
45
+ */
46
+
47
+ static VALUE
48
+ dnssd_if_nametoindex(VALUE self, VALUE name) {
49
+ return UINT2NUM(if_nametoindex(StringValueCStr(name)));
50
+ }
51
+
52
+ /*
53
+ * call-seq:
54
+ * DNSSD.interface_index(interface_name) # => interface_index
55
+ *
56
+ * Returns the interface index for interface +interface_name+.
57
+ *
58
+ * DNSSD.interface_index 'lo0' # => 1
59
+ */
60
+
61
+ static VALUE
62
+ dnssd_if_indextoname(VALUE self, VALUE index) {
63
+ char buffer[IF_NAMESIZE];
64
+
65
+ if (if_indextoname(NUM2UINT(index), buffer))
66
+ return rb_str_new2(buffer);
67
+
68
+ rb_raise(rb_eArgError, "invalid interface %d", NUM2UINT(index));
69
+
70
+ return Qnil;
71
+ }
72
+
7
73
  void
8
74
  Init_dnssd(void) {
9
75
  VALUE mDNSSD = rb_define_module("DNSSD");
10
76
 
11
- /* Specifies all interfaces. */
12
- rb_define_const(mDNSSD, "InterfaceAny", ULONG2NUM(kDNSServiceInterfaceIndexAny));
77
+ /* All interfaces */
78
+ rb_define_const(mDNSSD, "InterfaceAny",
79
+ ULONG2NUM(kDNSServiceInterfaceIndexAny));
80
+
81
+ /* Local interfaces, for services running only on the same machine */
82
+ rb_define_const(mDNSSD, "InterfaceLocalOnly",
83
+ ULONG2NUM(kDNSServiceInterfaceIndexLocalOnly));
84
+
85
+ /* Unicast interfaces */
86
+ rb_define_const(mDNSSD, "InterfaceUnicast",
87
+ ULONG2NUM(kDNSServiceInterfaceIndexUnicast));
88
+
89
+ rb_define_singleton_method(mDNSSD, "getservbyport", dnssd_getservbyport, -1);
13
90
 
14
- /* Specifies local interfaces only. */
15
- rb_define_const(mDNSSD, "InterfaceLocalOnly", ULONG2NUM(kDNSServiceInterfaceIndexLocalOnly));
91
+ rb_define_singleton_method(mDNSSD, "interface_index", dnssd_if_nametoindex, 1);
92
+ rb_define_singleton_method(mDNSSD, "interface_name", dnssd_if_indextoname, 1);
16
93
 
17
94
  Init_DNSSD_Errors();
18
95
  Init_DNSSD_Flags();
@@ -23,11 +23,13 @@
23
23
  #ifdef HAVE_SYS_IF_H
24
24
  #include <sys/if.h>
25
25
  #endif
26
+ #ifdef HAVE_NETDB_H
27
+ #include <netdb.h>
28
+ #endif
26
29
 
27
30
  extern VALUE eDNSSDError;
28
31
 
29
32
  void dnssd_check_error_code(DNSServiceErrorType e);
30
- void dnssd_instantiation_error(const char *what);
31
33
 
32
34
  #endif /* RDNSSD_INCLUDED */
33
35
 
@@ -4,39 +4,30 @@
4
4
  VALUE eDNSSDError;
5
5
  static VALUE eDNSSDUnknownError;
6
6
 
7
- #define DNSSD_ERROR_START (-65556)
8
- #define DNSSD_ERROR_END (-65536)
7
+ #define DNSSD_ERROR_START (DNSServiceErrorType)(-65792) /* 0xFFFE FF00 */
8
+ #define DNSSD_ERROR_END (DNSServiceErrorType)(-65537) /* 0xFFFE FFFF */
9
9
 
10
10
  static VALUE dnssd_errors[DNSSD_ERROR_END - DNSSD_ERROR_START];
11
11
 
12
12
  static void
13
- dnssd_errors_store(VALUE error, int num) {
14
- assert(DNSSD_ERROR_START <= num && num < DNSSD_ERROR_END);
15
- dnssd_errors[num - DNSSD_ERROR_START] = error;
13
+ dnssd_errors_store(VALUE error, DNSServiceErrorType err) {
14
+ assert(DNSSD_ERROR_START <= err && err <= DNSSD_ERROR_END);
15
+ dnssd_errors[err - DNSSD_ERROR_START] = error;
16
16
  }
17
17
 
18
18
  void
19
- dnssd_check_error_code(DNSServiceErrorType e) {
20
- int num = (int)e;
21
- if (num) {
22
- if(DNSSD_ERROR_START <= num && num < DNSSD_ERROR_END) {
23
- rb_raise(dnssd_errors[num - DNSSD_ERROR_START],
24
- "DNSSD operation failed with error code: %d", num);
19
+ dnssd_check_error_code(DNSServiceErrorType err) {
20
+ if (err) {
21
+ if(DNSSD_ERROR_START <= err && err < DNSSD_ERROR_END) {
22
+ rb_raise(dnssd_errors[err - DNSSD_ERROR_START],
23
+ "DNSSD operation failed with error code: %d", err);
25
24
  } else {
26
25
  rb_raise(eDNSSDUnknownError,
27
- "DNSSD operation failed with unrecognized error code: %d", num);
26
+ "DNSSD operation failed with unrecognized error code: %d", err);
28
27
  }
29
28
  }
30
29
  }
31
30
 
32
- void
33
- dnssd_instantiation_error(const char *what) {
34
- rb_raise(rb_eRuntimeError,
35
- "cannot instantiate %s, use DNSSD "
36
- "enumerate_domains(), browse(), resolve() or register() instead",
37
- what);
38
- }
39
-
40
31
  /* Document-class: DNSSD::Error
41
32
  *
42
33
  * Base class of all DNS Service Discovery related errors.
@@ -51,55 +42,86 @@ Init_DNSSD_Errors(void) {
51
42
  eDNSSDError = rb_define_class_under(mDNSSD, "Error", rb_eStandardError);
52
43
 
53
44
  eDNSSDUnknownError = rb_define_class_under(mDNSSD, "UnknownError", eDNSSDError);
54
- dnssd_errors_store(eDNSSDUnknownError, -65537);
45
+ dnssd_errors_store(eDNSSDUnknownError, kDNSServiceErr_Unknown);
55
46
 
56
47
  error_class = rb_define_class_under(mDNSSD, "NoSuchNameError", eDNSSDError);
57
- dnssd_errors_store(error_class, -65538);
48
+ dnssd_errors_store(error_class, kDNSServiceErr_NoSuchName);
58
49
 
59
- dnssd_errors_store(rb_eNoMemError, -65539);
50
+ error_class = rb_define_class_under(mDNSSD, "NoMemoryError", eDNSSDError);
51
+ dnssd_errors_store(error_class, kDNSServiceErr_NoMemory);
60
52
 
61
53
  error_class = rb_define_class_under(mDNSSD, "BadParamError", eDNSSDError);
62
- dnssd_errors_store(error_class, -65540);
54
+ dnssd_errors_store(error_class, kDNSServiceErr_BadParam);
63
55
 
64
56
  error_class = rb_define_class_under(mDNSSD, "BadReferenceError", eDNSSDError);
65
- dnssd_errors_store(error_class, -65541);
57
+ dnssd_errors_store(error_class, kDNSServiceErr_BadReference);
66
58
 
67
59
  error_class = rb_define_class_under(mDNSSD, "BadStateError", eDNSSDError);
68
- dnssd_errors_store(error_class, -65542);
60
+ dnssd_errors_store(error_class, kDNSServiceErr_BadState);
69
61
 
70
62
  error_class = rb_define_class_under(mDNSSD, "BadFlagsError", eDNSSDError);
71
- dnssd_errors_store(error_class, -65543);
63
+ dnssd_errors_store(error_class, kDNSServiceErr_BadFlags);
72
64
 
73
65
  error_class = rb_define_class_under(mDNSSD, "UnsupportedError", eDNSSDError);
74
- dnssd_errors_store(error_class, -65544);
66
+ dnssd_errors_store(error_class, kDNSServiceErr_Unsupported);
75
67
 
76
68
  error_class = rb_define_class_under(mDNSSD, "NotInitializedError", eDNSSDError);
77
- dnssd_errors_store(error_class, -65545);
69
+ dnssd_errors_store(error_class, kDNSServiceErr_NotInitialized);
78
70
 
79
71
  error_class = rb_define_class_under(mDNSSD, "AlreadyRegisteredError", eDNSSDError);
80
- dnssd_errors_store(error_class, -65547);
72
+ dnssd_errors_store(error_class, kDNSServiceErr_AlreadyRegistered);
81
73
 
82
74
  error_class = rb_define_class_under(mDNSSD, "NameConflictError", eDNSSDError);
83
- dnssd_errors_store(error_class, -65548);
75
+ dnssd_errors_store(error_class, kDNSServiceErr_NameConflict);
84
76
 
85
77
  error_class = rb_define_class_under(mDNSSD, "InvalidError", eDNSSDError);
86
- dnssd_errors_store(error_class, -65549);
78
+ dnssd_errors_store(error_class, kDNSServiceErr_Invalid);
79
+
80
+ error_class = rb_define_class_under(mDNSSD, "FirewallError", eDNSSDError);
81
+ dnssd_errors_store(error_class, kDNSServiceErr_Firewall);
87
82
 
88
83
  error_class = rb_define_class_under(mDNSSD, "ClientIncompatibleError", eDNSSDError);
89
- dnssd_errors_store(error_class, -65551);
84
+ dnssd_errors_store(error_class, kDNSServiceErr_Incompatible);
90
85
 
91
86
  error_class = rb_define_class_under(mDNSSD, "BadInterfaceIndexError", eDNSSDError);
92
- dnssd_errors_store(error_class, -65552);
87
+ dnssd_errors_store(error_class, kDNSServiceErr_BadInterfaceIndex);
93
88
 
94
- error_class = rb_define_class_under(mDNSSD, "ReferenceUsedError", eDNSSDError);
95
- dnssd_errors_store(error_class, -65553);
89
+ error_class = rb_define_class_under(mDNSSD, "RefusedError", eDNSSDError);
90
+ dnssd_errors_store(error_class, kDNSServiceErr_Refused);
96
91
 
97
92
  error_class = rb_define_class_under(mDNSSD, "NoSuchRecordError", eDNSSDError);
98
- dnssd_errors_store(error_class, -65554);
93
+ dnssd_errors_store(error_class, kDNSServiceErr_NoSuchRecord);
99
94
 
100
95
  error_class = rb_define_class_under(mDNSSD, "NoAuthenticationError", eDNSSDError);
101
- dnssd_errors_store(error_class, -65555);
96
+ dnssd_errors_store(error_class, kDNSServiceErr_NoAuth);
102
97
 
103
98
  error_class = rb_define_class_under(mDNSSD, "NoSuchKeyError", eDNSSDError);
104
- dnssd_errors_store(error_class, -65556);
99
+ dnssd_errors_store(error_class, kDNSServiceErr_NoSuchKey);
100
+
101
+ error_class = rb_define_class_under(mDNSSD, "NATTraversalError", eDNSSDError);
102
+ dnssd_errors_store(error_class, kDNSServiceErr_NATTraversal);
103
+
104
+ error_class = rb_define_class_under(mDNSSD, "DoubleNATError", eDNSSDError);
105
+ dnssd_errors_store(error_class, kDNSServiceErr_DoubleNAT);
106
+
107
+ error_class = rb_define_class_under(mDNSSD, "BadTimeError", eDNSSDError);
108
+ dnssd_errors_store(error_class, kDNSServiceErr_BadTime);
109
+
110
+ error_class = rb_define_class_under(mDNSSD, "BadSigError", eDNSSDError);
111
+ dnssd_errors_store(error_class, kDNSServiceErr_BadSig);
112
+
113
+ error_class = rb_define_class_under(mDNSSD, "BadKeyError", eDNSSDError);
114
+ dnssd_errors_store(error_class, kDNSServiceErr_BadKey);
115
+
116
+ error_class = rb_define_class_under(mDNSSD, "TransientError", eDNSSDError);
117
+ dnssd_errors_store(error_class, kDNSServiceErr_Transient);
118
+
119
+ error_class = rb_define_class_under(mDNSSD, "ServiceNotRunningError", eDNSSDError);
120
+ dnssd_errors_store(error_class, kDNSServiceErr_ServiceNotRunning);
121
+
122
+ error_class = rb_define_class_under(mDNSSD, "NATPortMappingUnsupported", eDNSSDError);
123
+ dnssd_errors_store(error_class, kDNSServiceErr_NATPortMappingUnsupported);
124
+
125
+ error_class = rb_define_class_under(mDNSSD, "NATPortMappingDisabled", eDNSSDError);
126
+ dnssd_errors_store(error_class, kDNSServiceErr_NATPortMappingDisabled);
105
127
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # :nodoc: all
2
+ # :stopdoc:
3
3
  #
4
4
  # Extension configuration script for DNS_SD C Extension.
5
5
 
@@ -38,6 +38,7 @@ have_header "sys/param.h"
38
38
  have_header "sys/if.h"
39
39
  have_header "net/if.h"
40
40
  have_header "arpa/inet.h"
41
+ have_header "netdb.h"
41
42
 
42
43
  abort "need function #{f}" unless have_macro("htons") || have_func("htons")
43
44
  abort "need function #{f}" unless have_macro("ntohs") || have_func("ntohs")
@@ -54,3 +55,5 @@ s1 >= s2 or abort("sizeof(void*) < sizeof(DNSServiceFlags) please contact the au
54
55
 
55
56
  create_makefile "dnssd"
56
57
 
58
+ # :startdoc:
59
+
@@ -1,7 +1,7 @@
1
1
  #include "dnssd.h"
2
2
 
3
- /* dns sd flags, flag ID's, flag names */
4
- #define DNSSD_MAX_FLAGS 9
3
+ /* dnssd flags, flag IDs, flag names */
4
+ #define DNSSD_MAX_FLAGS 13
5
5
 
6
6
  static const DNSServiceFlags dnssd_flag[DNSSD_MAX_FLAGS] = {
7
7
  kDNSServiceFlagsMoreComing,
@@ -17,7 +17,15 @@ static const DNSServiceFlags dnssd_flag[DNSSD_MAX_FLAGS] = {
17
17
  kDNSServiceFlagsBrowseDomains,
18
18
  kDNSServiceFlagsRegistrationDomains,
19
19
 
20
- kDNSServiceFlagsLongLivedQuery
20
+ kDNSServiceFlagsLongLivedQuery,
21
+
22
+ kDNSServiceFlagsAllowRemoteQuery,
23
+
24
+ kDNSServiceFlagsForceMulticast,
25
+
26
+ kDNSServiceFlagsForce,
27
+
28
+ kDNSServiceFlagsReturnIntermediates
21
29
  };
22
30
 
23
31
  static const char *dnssd_flag_name[DNSSD_MAX_FLAGS] = {
@@ -29,7 +37,11 @@ static const char *dnssd_flag_name[DNSSD_MAX_FLAGS] = {
29
37
  "unique",
30
38
  "browse_domains",
31
39
  "registration_domains",
32
- "long_lived_query"
40
+ "long_lived_query",
41
+ "allow_remote_query",
42
+ "force_multicast",
43
+ "force",
44
+ "return_intermediates"
33
45
  };
34
46
 
35
47
  void
@@ -42,7 +54,7 @@ Init_DNSSD_Flags(void) {
42
54
  cDNSSDFlags = rb_define_class_under(mDNSSD, "Flags", rb_cObject);
43
55
 
44
56
  /* flag constants */
45
- #if DNSSD_MAX_FLAGS != 9
57
+ #if DNSSD_MAX_FLAGS != 13
46
58
  #error The code below needs to be updated.
47
59
  #endif
48
60
 
@@ -60,7 +72,7 @@ Init_DNSSD_Flags(void) {
60
72
  * they will be delivered as usual.
61
73
  */
62
74
  rb_define_const(cDNSSDFlags, "MoreComing",
63
- ULONG2NUM(kDNSServiceFlagsMoreComing));
75
+ ULONG2NUM(kDNSServiceFlagsMoreComing));
64
76
 
65
77
  /* Applies only to enumeration. An enumeration callback with the
66
78
  * DNSSD::Flags::Add flag NOT set indicates a DNSSD::Flags::Remove, i.e. the
@@ -79,46 +91,96 @@ Init_DNSSD_Flags(void) {
79
91
  * service. DNSSD::Flags::NoAutoRename overrides this behavior - with this
80
92
  * flag set, name conflicts will result in a callback. The NoAutoRename flag
81
93
  * is only valid if a name is explicitly specified when registering a service
82
- * (ie the default name is not used.)
94
+ * (i.e. the default name is not used.)
83
95
  */
84
96
  rb_define_const(cDNSSDFlags, "NoAutoRename",
85
- ULONG2NUM(kDNSServiceFlagsNoAutoRename));
97
+ ULONG2NUM(kDNSServiceFlagsNoAutoRename));
86
98
 
87
- /* Flag for registering individual records on a connected DNSServiceRef.
99
+ /* Flag for registering individual records on a connected DNSSD::Service.
88
100
  *
89
101
  * DNSSD::Flags::Shared indicates that there may be multiple records with
90
- * this name on the network (e.g. PTR records). DNSSD::Flags::Unique
91
- * indicates that the record's name is to be unique on the network (e.g. SRV
92
- * records). (DNSSD::Flags::Shared and DNSSD::Flags::Unique are currently
93
- * not used by the Ruby API.)
102
+ * this name on the network (e.g. PTR records).
103
+ *
104
+ * (Not used currently by the Ruby API)
94
105
  */
95
106
  rb_define_const(cDNSSDFlags, "Shared", ULONG2NUM(kDNSServiceFlagsShared));
107
+
108
+ /* DNSSD::Flags::Unique indicates that the record's name is to be unique on
109
+ * the network (e.g. SRV records).
110
+ *
111
+ * (Not used currently by the Ruby API)
112
+ */
96
113
  rb_define_const(cDNSSDFlags, "Unique", ULONG2NUM(kDNSServiceFlagsUnique));
97
114
 
98
- /* DNSSD::Flags::BrowseDomains enumerates domains recommended for browsing
115
+ /* Specifies domain enumeration type.
116
+ *
117
+ * DNSSD::Flags::BrowseDomains enumerates domains recommended for browsing
99
118
  */
100
119
  rb_define_const(cDNSSDFlags, "BrowseDomains",
101
- ULONG2NUM(kDNSServiceFlagsBrowseDomains));
120
+ ULONG2NUM(kDNSServiceFlagsBrowseDomains));
102
121
 
103
- /* DNSSD::Flags::RegistrationDomains enumerates domains recommended for
122
+ /* Specifies domain enumeration type.
123
+ *
124
+ * DNSSD::Flags::RegistrationDomains enumerates domains recommended for
104
125
  * registration.
105
126
  */
106
-
107
127
  rb_define_const(cDNSSDFlags, "RegistrationDomains",
108
- ULONG2NUM(kDNSServiceFlagsRegistrationDomains));
128
+ ULONG2NUM(kDNSServiceFlagsRegistrationDomains));
109
129
 
110
- /* Flag for creating a long-lived unicast query for the DNSDS.query_record()
111
- * (currently not part of the Ruby API). */
130
+ /* Flag for creating a long-lived unicast query for DNSSD.query_record
131
+ *
132
+ * (Not used by the Ruby API)
133
+ */
112
134
  rb_define_const(cDNSSDFlags, "LongLivedQuery",
113
- ULONG2NUM(kDNSServiceFlagsLongLivedQuery));
135
+ ULONG2NUM(kDNSServiceFlagsLongLivedQuery));
136
+
137
+ /* Flag for creating a record for which we will answer remote queries
138
+ * (queries from hosts more than one hop away; hosts not directly connected
139
+ * to the local link).
140
+ */
141
+ rb_define_const(cDNSSDFlags, "AllowRemoteQuery",
142
+ ULONG2NUM(kDNSServiceFlagsAllowRemoteQuery));
143
+
144
+ /* Flag for signifying that a query or registration should be performed
145
+ * exclusively via multicast DNS, even for a name in a domain (e.g.
146
+ * foo.apple.com.) that would normally imply unicast DNS.
147
+ */
148
+ rb_define_const(cDNSSDFlags, "ForceMulticast",
149
+ ULONG2NUM(kDNSServiceFlagsForceMulticast));
150
+
151
+ /* Flag for signifying a "stronger" variant of an operation. Currently
152
+ * defined only for DNSSD.reconfirm_record, where it forces a record to
153
+ * be removed from the cache immediately, instead of querying for a few
154
+ * seconds before concluding that the record is no longer valid and then
155
+ * removing it. This flag should be used with caution because if a service
156
+ * browsing PTR record is indeed still valid on the network, forcing its
157
+ * removal will result in a user-interface flap -- the discovered service
158
+ * instance will disappear, and then re-appear moments later.
159
+ */
160
+ rb_define_const(cDNSSDFlags, "Force", ULONG2NUM(kDNSServiceFlagsForce));
161
+
162
+ /* Flag for returning intermediate results. For example, if a query results
163
+ * in an authoritative NXDomain (name does not exist) then that result is
164
+ * returned to the client. However the query is not implicitly cancelled --
165
+ * it remains active and if the answer subsequently changes (e.g. because a
166
+ * VPN tunnel is subsequently established) then that positive result will
167
+ * still be returned to the client. Similarly, if a query results in a CNAME
168
+ * record, then in addition to following the CNAME referral, the intermediate
169
+ * CNAME result is also returned to the client. When this flag is not set,
170
+ * NXDomain errors are not returned, and CNAME records are followed silently
171
+ * without informing the client of the intermediate steps.
172
+ */
173
+ rb_define_const(cDNSSDFlags, "ReturnIntermediates",
174
+ ULONG2NUM(kDNSServiceFlagsReturnIntermediates));
114
175
 
115
176
  flags_hash = rb_hash_new();
116
177
 
117
178
  for (i = 0; i < DNSSD_MAX_FLAGS; i++) {
118
179
  rb_hash_aset(flags_hash, rb_str_new2(dnssd_flag_name[i]),
119
- ULONG2NUM(dnssd_flag[i]));
180
+ ULONG2NUM(dnssd_flag[i]));
120
181
  }
121
182
 
183
+ /* Hash of flags => flag_name */
122
184
  rb_define_const(cDNSSDFlags, "FLAGS", flags_hash);
123
185
  }
124
186