Class: DNSSD::Flags
- Inherits:
-
Object
- Object
- DNSSD::Flags
- Defined in:
- lib/dnssd/flags.rb,
ext/dnssd/flags.c,
ext/dnssd/service.c
Overview
Flags used in DNSSD Ruby API.
Constant Summary collapse
- ALL_FLAGS =
Bitfield with all valid flags set
FLAGS.values.inject { |flag, all| flag | all }
- MoreComing =
MoreComing indicates that at least one more result is queued and will be delivered following immediately after this one.
Applications should not update their UI to display browse results when the MoreComing flag is set, because this would result in a great deal of ugly flickering on the screen. Applications should instead wait until MoreComing is not set, and then update their UI.
When MoreComing is not set, that doesn’t mean there will be no more answers EVER, just that there are no more answers immediately available right now at this instant. If more answers become available in the future they will be delivered as usual.
ULONG2NUM(kDNSServiceFlagsMoreComing)
- Add =
:Flags::Add flag NOT set indicates a DNSSD::Flags::Remove, i.e. the domain is no longer valid.
Applies only to enumeration. An enumeration callback with the DNSSD
- Default =
Applies only to enumeration and is only valid in conjunction with Add
ULONG2NUM(kDNSServiceFlagsDefault)
- NoAutoRename =
:Flags::NoAutoRename overrides this behavior - with this flag set, name conflicts will result in a callback. The NoAutoRename flag is only valid if a name is explicitly specified when registering a service (i.e. the default name is not used.)
Flag for specifying renaming behavior on name conflict when registering non-shared records. By default, name conflicts are automatically handled by renaming the service. DNSSD
ULONG2NUM(kDNSServiceFlagsShareConnection)
Flag for registering individual records on a connected DNSSD
- Unique =
:Flags::Unique indicates that the record’s name is to be unique on the network (e.g. SRV records).
(Not used currently by the Ruby API)
DNSSD
- BrowseDomains =
:Flags::BrowseDomains enumerates domains recommended for browsing
Specifies domain enumeration type. DNSSD
- RegistrationDomains =
:Flags::RegistrationDomains enumerates domains recommended for registration.
Specifies domain enumeration type. DNSSD
- LongLivedQuery =
Flag for creating a long-lived unicast query for DNSSD.query_record
(Not used by the Ruby API)
ULONG2NUM(kDNSServiceFlagsLongLivedQuery)
- AllowRemoteQuery =
Flag for creating a record for which we will answer remote queries (queries from hosts more than one hop away; hosts not directly connected to the local link).
ULONG2NUM(kDNSServiceFlagsAllowRemoteQuery)
- ForceMulticast =
Flag for signifying that a query or registration should be performed exclusively via multicast DNS, even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
ULONG2NUM(kDNSServiceFlagsForceMulticast)
- Force =
Flag for signifying a “stronger” variant of an operation. Currently defined only for DNSSD.reconfirm_record, where it forces a record to be removed from the cache immediately, instead of querying for a few seconds before concluding that the record is no longer valid and then removing it. This flag should be used with caution because if a service browsing PTR record is indeed still valid on the network, forcing its removal will result in a user-interface flap – the discovered service instance will disappear, and then re-appear moments later.
ULONG2NUM(kDNSServiceFlagsForce)
- NonBrowsable =
A service registered with the NonBrowsable flag set can be resolved using DNSServiceResolve(), but will not be discoverable using DNSServiceBrowse(). This is for cases where the name is actually a GUID; it is found by other means; there is no end-user benefit to browsing to find a long list of opaque GUIDs. Using the NonBrowsable flag creates SRV+TXT without the cost of also advertising an associated PTR record.
ULONG2NUM(kDNSServiceFlagsNonBrowsable)
- ReturnIntermediates =
Flag for returning intermediate results. For example, if a query results in an authoritative NXDomain (name does not exist) then that result is returned to the client. However the query is not implicitly cancelled – it remains active and if the answer subsequently changes (e.g. because a VPN tunnel is subsequently established) then that positive result will still be returned to the client. Similarly, if a query results in a CNAME record, then in addition to following the CNAME referral, the intermediate CNAME result is also returned to the client. When this flag is not set, NXDomain errors are not returned, and CNAME records are followed silently without informing the client of the intermediate steps.
ULONG2NUM(kDNSServiceFlagsReturnIntermediates)
- FLAGS =
Hash of flags => flag_name
flags_hash
Instance Method Summary collapse
-
#&(flags) ⇒ Object
Returns the intersection of flags in
self
andflags
. -
#==(other) ⇒ Object
self
is equal ifother
has the same flags. -
#clear_flag(flag) ⇒ Object
Clears
flag
. -
#initialize(*flags) ⇒ Flags
constructor
Returns a new set of flags.
-
#inspect ⇒ Object
:nodoc:.
-
#set_flag(flag) ⇒ Object
Sets
flag
. -
#to_a ⇒ Object
Returns an Array of flag names.
-
#to_i ⇒ Object
Flags as a bitfield.
-
#verify ⇒ Object
Trims the flag list down to valid flags.
-
#|(flags) ⇒ Object
Returns the union of flags in
self
andflags
. -
#~ ⇒ Object
Returns the complement of the flags in
self
.
Constructor Details
#initialize(*flags) ⇒ Flags
Returns a new set of flags
33 34 35 36 37 |
# File 'lib/dnssd/flags.rb', line 33 def initialize(*flags) @flags = flags.inject 0 do |flag, acc| flag | acc end verify end |
Instance Method Details
#&(flags) ⇒ Object
Returns the intersection of flags in self
and flags
.
42 43 44 |
# File 'lib/dnssd/flags.rb', line 42 def &(flags) self.class.new(to_i & flags.to_i) end |
#==(other) ⇒ Object
self
is equal if other
has the same flags
49 50 51 |
# File 'lib/dnssd/flags.rb', line 49 def ==(other) to_i == other.to_i end |
#clear_flag(flag) ⇒ Object
Clears flag
56 57 58 59 60 |
# File 'lib/dnssd/flags.rb', line 56 def clear_flag(flag) @flags &= ~flag verify end |
#inspect ⇒ Object
:nodoc:
62 63 64 65 66 |
# File 'lib/dnssd/flags.rb', line 62 def inspect # :nodoc: flags = to_a.sort.join ', ' flags[0, 0] = ' ' unless flags.empty? "#<#{self.class}#{flags}>" end |
#set_flag(flag) ⇒ Object
Sets flag
71 72 73 74 75 |
# File 'lib/dnssd/flags.rb', line 71 def set_flag(flag) @flags |= flag verify end |
#to_a ⇒ Object
Returns an Array of flag names
80 81 82 83 84 |
# File 'lib/dnssd/flags.rb', line 80 def to_a FLAGS.map do |name, value| (@flags & value == value) ? name : nil end.compact end |
#to_i ⇒ Object
Flags as a bitfield
89 90 91 |
# File 'lib/dnssd/flags.rb', line 89 def to_i @flags end |
#verify ⇒ Object
Trims the flag list down to valid flags
96 97 98 99 100 |
# File 'lib/dnssd/flags.rb', line 96 def verify @flags &= ALL_FLAGS self end |
#|(flags) ⇒ Object
Returns the union of flags in self
and flags
105 106 107 |
# File 'lib/dnssd/flags.rb', line 105 def |(flags) self.class.new(to_i | flags.to_i) end |
#~ ⇒ Object
Returns the complement of the flags in self
112 113 114 |
# File 'lib/dnssd/flags.rb', line 112 def ~ self.class.new ~to_i end |