ObjFW
OFDNSResourceRecord.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 #import "OFString.h"
18 
19 #import "socket.h"
20 
21 OF_ASSUME_NONNULL_BEGIN
22 
25 @class OFArray OF_GENERIC(ObjectType);
26 @class OFData;
27 
31 typedef enum {
37 
41 typedef enum {
67 
74 {
75  OFString *_name;
76  of_dns_class_t _DNSClass;
77  of_dns_record_type_t _recordType;
78  uint32_t _TTL;
79  OF_RESERVE_IVARS(OFDNSResourceRecord, 4)
80 }
81 
85 @property (readonly, nonatomic) OFString *name;
86 
90 @property (readonly, nonatomic) of_dns_class_t DNSClass;
91 
95 @property (readonly, nonatomic) of_dns_record_type_t recordType;
96 
101 @property (readonly, nonatomic) uint32_t TTL;
102 
113 - (instancetype)initWithName: (OFString *)name
114  DNSClass: (of_dns_class_t)DNSClass
115  recordType: (of_dns_record_type_t)recordType
116  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
117 @end
118 
124 OF_SUBCLASSING_RESTRICTED
126 {
127  of_socket_address_t _address;
128 }
129 
133 @property (readonly, nonatomic) const of_socket_address_t *address;
134 
135 - (instancetype)initWithName: (OFString *)name
136  DNSClass: (of_dns_class_t)DNSClass
137  recordType: (of_dns_record_type_t)recordType
138  TTL: (uint32_t)TTL OF_UNAVAILABLE;
139 
149 - (instancetype)initWithName: (OFString *)name
150  address: (const of_socket_address_t *)address
151  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
152 @end
153 
160 OF_SUBCLASSING_RESTRICTED
162 {
163  of_socket_address_t _address;
164 }
165 
169 @property (readonly, nonatomic) const of_socket_address_t *address;
170 
171 - (instancetype)initWithName: (OFString *)name
172  DNSClass: (of_dns_class_t)DNSClass
173  recordType: (of_dns_record_type_t)recordType
174  TTL: (uint32_t)TTL OF_UNAVAILABLE;
175 
185 - (instancetype)initWithName: (OFString *)name
186  address: (const of_socket_address_t *)address
187  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
188 @end
189 
196 OF_SUBCLASSING_RESTRICTED
198 {
199  OFString *_alias;
200 }
201 
205 @property (readonly, nonatomic) OFString *alias;
206 
207 - (instancetype)initWithName: (OFString *)name
208  DNSClass: (of_dns_class_t)DNSClass
209  recordType: (of_dns_record_type_t)recordType
210  TTL: (uint32_t)TTL OF_UNAVAILABLE;
211 
222 - (instancetype)initWithName: (OFString *)name
223  DNSClass: (of_dns_class_t)DNSClass
224  alias: (OFString *)alias
225  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
226 @end
227 
234 OF_SUBCLASSING_RESTRICTED
236 {
237  OFString *_CPU, *_OS;
238 }
239 
243 @property (readonly, nonatomic) OFString *CPU;
244 
248 @property (readonly, nonatomic) OFString *OS;
249 
250 - (instancetype)initWithName: (OFString *)name
251  DNSClass: (of_dns_class_t)DNSClass
252  recordType: (of_dns_record_type_t)recordType
253  TTL: (uint32_t)TTL OF_UNAVAILABLE;
254 
266 - (instancetype)initWithName: (OFString *)name
267  DNSClass: (of_dns_class_t)DNSClass
268  CPU: (OFString *)CPU
269  OS: (OFString *)OS
270  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
271 @end
272 
279 OF_SUBCLASSING_RESTRICTED
281 {
282  uint16_t _preference;
283  OFString *_mailExchange;
284 }
285 
289 @property (readonly, nonatomic) uint16_t preference;
290 
294 @property (readonly, nonatomic) OFString *mailExchange;
295 
296 - (instancetype)initWithName: (OFString *)name
297  DNSClass: (of_dns_class_t)DNSClass
298  recordType: (of_dns_record_type_t)recordType
299  TTL: (uint32_t)TTL OF_UNAVAILABLE;
300 
312 - (instancetype)initWithName: (OFString *)name
313  DNSClass: (of_dns_class_t)DNSClass
314  preference: (uint16_t)preference
315  mailExchange: (OFString *)mailExchange
316  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
317 @end
318 
325 OF_SUBCLASSING_RESTRICTED
327 {
328  OFString *_authoritativeHost;
329 }
330 
334 @property (readonly, nonatomic) OFString *authoritativeHost;
335 
336 - (instancetype)initWithName: (OFString *)name
337  DNSClass: (of_dns_class_t)DNSClass
338  recordType: (of_dns_record_type_t)recordType
339  TTL: (uint32_t)TTL OF_UNAVAILABLE;
340 
351 - (instancetype)initWithName: (OFString *)name
352  DNSClass: (of_dns_class_t)DNSClass
353  authoritativeHost: (OFString *)authoritativeHost
354  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
355 @end
356 
363 OF_SUBCLASSING_RESTRICTED
365 {
366  OFString *_domainName;
367 }
368 
372 @property (readonly, nonatomic) OFString *domainName;
373 
374 - (instancetype)initWithName: (OFString *)name
375  DNSClass: (of_dns_class_t)DNSClass
376  recordType: (of_dns_record_type_t)recordType
377  TTL: (uint32_t)TTL OF_UNAVAILABLE;
378 
389 - (instancetype)initWithName: (OFString *)name
390  DNSClass: (of_dns_class_t)DNSClass
391  domainName: (OFString *)domainName
392  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
393 @end
394 
401 OF_SUBCLASSING_RESTRICTED
402 @interface OFRPDNSResourceRecord: OFDNSResourceRecord
403 {
404  OFString *_mailbox, *_TXTDomainName;
405 }
406 
410 @property (readonly, nonatomic) OFString *mailbox;
411 
416 @property (readonly, nonatomic) OFString *TXTDomainName;
417 
418 - (instancetype)initWithName: (OFString *)name
419  DNSClass: (of_dns_class_t)DNSClass
420  recordType: (of_dns_record_type_t)recordType
421  TTL: (uint32_t)TTL OF_UNAVAILABLE;
422 
435 - (instancetype)initWithName: (OFString *)name
436  DNSClass: (of_dns_class_t)DNSClass
437  mailbox: (OFString *)mailbox
438  TXTDomainName: (OFString *)TXTDomainName
439  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
440 @end
441 
448 OF_SUBCLASSING_RESTRICTED
450 {
451  OFString *_primaryNameServer, *_responsiblePerson;
452  uint32_t _serialNumber, _refreshInterval, _retryInterval;
453  uint32_t _expirationInterval, _minTTL;
454 }
455 
459 @property (readonly, nonatomic) OFString *primaryNameServer;
460 
464 @property (readonly, nonatomic) OFString *responsiblePerson;
465 
469 @property (readonly, nonatomic) uint32_t serialNumber;
470 
474 @property (readonly, nonatomic) uint32_t refreshInterval;
475 
479 @property (readonly, nonatomic) uint32_t retryInterval;
480 
484 @property (readonly, nonatomic) uint32_t expirationInterval;
485 
489 @property (readonly, nonatomic) uint32_t minTTL;
490 
491 - (instancetype)initWithName: (OFString *)name
492  DNSClass: (of_dns_class_t)DNSClass
493  recordType: (of_dns_record_type_t)recordType
494  TTL: (uint32_t)TTL OF_UNAVAILABLE;
495 
512 - (instancetype)initWithName: (OFString *)name
513  DNSClass: (of_dns_class_t)DNSClass
514  primaryNameServer: (OFString *)primaryNameServer
515  responsiblePerson: (OFString *)responsiblePerson
516  serialNumber: (uint32_t)serialNumber
517  refreshInterval: (uint32_t)refreshInterval
518  retryInterval: (uint32_t)retryInterval
519  expirationInterval: (uint32_t)expirationInterval
520  minTTL: (uint32_t)minTTL
521  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
522 @end
523 
530 OF_SUBCLASSING_RESTRICTED
532 {
533  uint16_t _priority, _weight;
534  OFString *_target;
535  uint16_t _port;
536 }
537 
541 @property (readonly, nonatomic) uint16_t priority;
542 
546 @property (readonly, nonatomic) uint16_t weight;
547 
551 @property (readonly, nonatomic) OFString *target;
552 
556 @property (readonly, nonatomic) uint16_t port;
557 
558 - (instancetype)initWithName: (OFString *)name
559  DNSClass: (of_dns_class_t)DNSClass
560  recordType: (of_dns_record_type_t)recordType
561  TTL: (uint32_t)TTL OF_UNAVAILABLE;
562 
575 - (instancetype)initWithName: (OFString *)name
576  priority: (uint16_t)priority
577  weight: (uint16_t)weight
578  target: (OFString *)target
579  port: (uint16_t)port
580  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
581 @end
582 
589 OF_SUBCLASSING_RESTRICTED
591 {
592  OFArray OF_GENERIC(OFData *) *_textStrings;
593 }
594 
598 @property (readonly, nonatomic) OFArray OF_GENERIC(OFData *) *textStrings;
599 
600 - (instancetype)initWithName: (OFString *)name
601  DNSClass: (of_dns_class_t)DNSClass
602  recordType: (of_dns_record_type_t)recordType
603  TTL: (uint32_t)TTL OF_UNAVAILABLE;
604 
615 - (instancetype)initWithName: (OFString *)name
616  DNSClass: (of_dns_class_t)DNSClass
617  textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings
618  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
619 @end
620 
621 #ifdef __cplusplus
622 extern "C" {
623 #endif
624 extern OFString *_Nonnull of_dns_class_to_string(of_dns_class_t DNSClass);
625 extern OFString *_Nonnull of_dns_record_type_to_string(
626  of_dns_record_type_t recordType);
627 extern of_dns_class_t of_dns_class_parse(OFString *_Nonnull string);
628 extern of_dns_record_type_t of_dns_record_type_parse(OFString *_Nonnull string);
629 #ifdef __cplusplus
630 }
631 #endif
632 
633 OF_ASSUME_NONNULL_END
of_dns_record_type_t
The type of a DNS resource record.
Definition: OFDNSResourceRecord.h:41
@ OF_DNS_RECORD_TYPE_HINFO
Definition: OFDNSResourceRecord.h:53
@ OF_DNS_RECORD_TYPE_PTR
Definition: OFDNSResourceRecord.h:51
@ OF_DNS_RECORD_TYPE_MX
Definition: OFDNSResourceRecord.h:55
@ OF_DNS_RECORD_TYPE_RP
Definition: OFDNSResourceRecord.h:59
@ OF_DNS_RECORD_TYPE_SOA
Definition: OFDNSResourceRecord.h:49
@ OF_DNS_RECORD_TYPE_CNAME
Definition: OFDNSResourceRecord.h:47
@ OF_DNS_RECORD_TYPE_NS
Definition: OFDNSResourceRecord.h:45
@ OF_DNS_RECORD_TYPE_TXT
Definition: OFDNSResourceRecord.h:57
@ OF_DNS_RECORD_TYPE_ALL
Definition: OFDNSResourceRecord.h:65
@ OF_DNS_RECORD_TYPE_A
Definition: OFDNSResourceRecord.h:43
@ OF_DNS_RECORD_TYPE_SRV
Definition: OFDNSResourceRecord.h:63
@ OF_DNS_RECORD_TYPE_AAAA
Definition: OFDNSResourceRecord.h:61
of_dns_class_t
The DNS class.
Definition: OFDNSResourceRecord.h:31
@ OF_DNS_CLASS_IN
Definition: OFDNSResourceRecord.h:33
@ OF_DNS_CLASS_ANY
Definition: OFDNSResourceRecord.h:35
A class represenging a DNS resource record.
Definition: OFDNSResourceRecord.h:163
A class representing an A DNS resource record.
Definition: OFDNSResourceRecord.h:127
An abstract class for storing objects in an array.
Definition: OFArray.h:92
A class representing a CNAME DNS resource record.
Definition: OFDNSResourceRecord.h:199
A class representing a DNS resource record.
Definition: OFDNSResourceRecord.h:75
A class for storing arbitrary data in an array.
Definition: OFData.h:40
A class representing an HINFO DNS resource record.
Definition: OFDNSResourceRecord.h:237
A class representing an MX DNS resource record.
Definition: OFDNSResourceRecord.h:282
A class representing an NS DNS resource record.
Definition: OFDNSResourceRecord.h:328
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class representing a PTR DNS resource record.
Definition: OFDNSResourceRecord.h:366
A class representing an SOA DNS resource record.
Definition: OFDNSResourceRecord.h:451
A class representing an SRV DNS resource record.
Definition: OFDNSResourceRecord.h:533
A class for handling strings.
Definition: OFString.h:132
A class representing a TXT DNS resource record.
Definition: OFDNSResourceRecord.h:592
A protocol for the creation of copies.
Definition: OFObject.h:1187
A struct which represents a host / port pair for a socket.
Definition: socket.h:136