ObjFW
OFDNSResourceRecord.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2024 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 "OFSocket.h"
18 #import "OFString.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
24 @class OFArray OF_GENERIC(ObjectType);
25 @class OFData;
26 
30 typedef enum {
35 } OFDNSClass;
36 
40 typedef enum {
66 
73 {
74  OFString *_name;
75  OFDNSClass _DNSClass;
76  OFDNSRecordType _recordType;
77  uint32_t _TTL;
78  OF_RESERVE_IVARS(OFDNSResourceRecord, 4)
79 }
80 
84 @property (readonly, nonatomic) OFString *name;
85 
89 @property (readonly, nonatomic) OFDNSClass DNSClass;
90 
94 @property (readonly, nonatomic) OFDNSRecordType recordType;
95 
100 @property (readonly, nonatomic) uint32_t TTL;
112 - (instancetype)initWithName: (OFString *)name
113  DNSClass: (OFDNSClass)DNSClass
114  recordType: (OFDNSRecordType)recordType
115  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
116 @end
117 
123 OF_SUBCLASSING_RESTRICTED
125 {
126  OFSocketAddress _address;
127 }
128 
132 @property (readonly, nonatomic) const OFSocketAddress *address;
134 - (instancetype)initWithName: (OFString *)name
135  DNSClass: (OFDNSClass)DNSClass
136  recordType: (OFDNSRecordType)recordType
137  TTL: (uint32_t)TTL OF_UNAVAILABLE;
138 
148 - (instancetype)initWithName: (OFString *)name
149  address: (const OFSocketAddress *)address
150  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
151 @end
152 
159 OF_SUBCLASSING_RESTRICTED
161 {
162  OFSocketAddress _address;
163 }
164 
168 @property (readonly, nonatomic) const OFSocketAddress *address;
170 - (instancetype)initWithName: (OFString *)name
171  DNSClass: (OFDNSClass)DNSClass
172  recordType: (OFDNSRecordType)recordType
173  TTL: (uint32_t)TTL OF_UNAVAILABLE;
174 
184 - (instancetype)initWithName: (OFString *)name
185  address: (const OFSocketAddress *)address
186  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
187 @end
188 
195 OF_SUBCLASSING_RESTRICTED
197 {
198  OFString *_alias;
199 }
200 
204 @property (readonly, nonatomic) OFString *alias;
206 - (instancetype)initWithName: (OFString *)name
207  DNSClass: (OFDNSClass)DNSClass
208  recordType: (OFDNSRecordType)recordType
209  TTL: (uint32_t)TTL OF_UNAVAILABLE;
210 
221 - (instancetype)initWithName: (OFString *)name
222  DNSClass: (OFDNSClass)DNSClass
223  alias: (OFString *)alias
224  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
225 @end
226 
233 OF_SUBCLASSING_RESTRICTED
235 {
236  OFString *_CPU, *_OS;
237 }
238 
242 @property (readonly, nonatomic) OFString *CPU;
247 @property (readonly, nonatomic) OFString *OS;
249 - (instancetype)initWithName: (OFString *)name
250  DNSClass: (OFDNSClass)DNSClass
251  recordType: (OFDNSRecordType)recordType
252  TTL: (uint32_t)TTL OF_UNAVAILABLE;
253 
265 - (instancetype)initWithName: (OFString *)name
266  DNSClass: (OFDNSClass)DNSClass
267  CPU: (OFString *)CPU
268  OS: (OFString *)OS
269  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
270 @end
271 
278 OF_SUBCLASSING_RESTRICTED
280 {
281  uint16_t _preference;
282  OFString *_mailExchange;
283 }
284 
288 @property (readonly, nonatomic) uint16_t preference;
293 @property (readonly, nonatomic) OFString *mailExchange;
295 - (instancetype)initWithName: (OFString *)name
296  DNSClass: (OFDNSClass)DNSClass
297  recordType: (OFDNSRecordType)recordType
298  TTL: (uint32_t)TTL OF_UNAVAILABLE;
299 
311 - (instancetype)initWithName: (OFString *)name
312  DNSClass: (OFDNSClass)DNSClass
313  preference: (uint16_t)preference
314  mailExchange: (OFString *)mailExchange
315  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
316 @end
317 
324 OF_SUBCLASSING_RESTRICTED
326 {
327  OFString *_authoritativeHost;
328 }
329 
333 @property (readonly, nonatomic) OFString *authoritativeHost;
335 - (instancetype)initWithName: (OFString *)name
336  DNSClass: (OFDNSClass)DNSClass
337  recordType: (OFDNSRecordType)recordType
338  TTL: (uint32_t)TTL OF_UNAVAILABLE;
339 
350 - (instancetype)initWithName: (OFString *)name
351  DNSClass: (OFDNSClass)DNSClass
352  authoritativeHost: (OFString *)authoritativeHost
353  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
354 @end
355 
362 OF_SUBCLASSING_RESTRICTED
364 {
365  OFString *_domainName;
366 }
367 
371 @property (readonly, nonatomic) OFString *domainName;
373 - (instancetype)initWithName: (OFString *)name
374  DNSClass: (OFDNSClass)DNSClass
375  recordType: (OFDNSRecordType)recordType
376  TTL: (uint32_t)TTL OF_UNAVAILABLE;
377 
388 - (instancetype)initWithName: (OFString *)name
389  DNSClass: (OFDNSClass)DNSClass
390  domainName: (OFString *)domainName
391  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
392 @end
393 
400 OF_SUBCLASSING_RESTRICTED
402 {
403  OFString *_mailbox, *_TXTDomainName;
404 }
405 
409 @property (readonly, nonatomic) OFString *mailbox;
415 @property (readonly, nonatomic) OFString *TXTDomainName;
417 - (instancetype)initWithName: (OFString *)name
418  DNSClass: (OFDNSClass)DNSClass
419  recordType: (OFDNSRecordType)recordType
420  TTL: (uint32_t)TTL OF_UNAVAILABLE;
421 
434 - (instancetype)initWithName: (OFString *)name
435  DNSClass: (OFDNSClass)DNSClass
436  mailbox: (OFString *)mailbox
437  TXTDomainName: (OFString *)TXTDomainName
438  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
439 @end
440 
447 OF_SUBCLASSING_RESTRICTED
449 {
450  OFString *_primaryNameServer, *_responsiblePerson;
451  uint32_t _serialNumber, _refreshInterval, _retryInterval;
452  uint32_t _expirationInterval, _minTTL;
453 }
454 
458 @property (readonly, nonatomic) OFString *primaryNameServer;
463 @property (readonly, nonatomic) OFString *responsiblePerson;
468 @property (readonly, nonatomic) uint32_t serialNumber;
473 @property (readonly, nonatomic) uint32_t refreshInterval;
478 @property (readonly, nonatomic) uint32_t retryInterval;
483 @property (readonly, nonatomic) uint32_t expirationInterval;
488 @property (readonly, nonatomic) uint32_t minTTL;
490 - (instancetype)initWithName: (OFString *)name
491  DNSClass: (OFDNSClass)DNSClass
492  recordType: (OFDNSRecordType)recordType
493  TTL: (uint32_t)TTL OF_UNAVAILABLE;
494 
511 - (instancetype)initWithName: (OFString *)name
512  DNSClass: (OFDNSClass)DNSClass
513  primaryNameServer: (OFString *)primaryNameServer
514  responsiblePerson: (OFString *)responsiblePerson
515  serialNumber: (uint32_t)serialNumber
516  refreshInterval: (uint32_t)refreshInterval
517  retryInterval: (uint32_t)retryInterval
518  expirationInterval: (uint32_t)expirationInterval
519  minTTL: (uint32_t)minTTL
520  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
521 @end
522 
529 OF_SUBCLASSING_RESTRICTED
531 {
532  uint16_t _priority, _weight;
533  OFString *_target;
534  uint16_t _port;
535 }
536 
540 @property (readonly, nonatomic) uint16_t priority;
545 @property (readonly, nonatomic) uint16_t weight;
550 @property (readonly, nonatomic) OFString *target;
555 @property (readonly, nonatomic) uint16_t port;
557 - (instancetype)initWithName: (OFString *)name
558  DNSClass: (OFDNSClass)DNSClass
559  recordType: (OFDNSRecordType)recordType
560  TTL: (uint32_t)TTL OF_UNAVAILABLE;
561 
574 - (instancetype)initWithName: (OFString *)name
575  priority: (uint16_t)priority
576  weight: (uint16_t)weight
577  target: (OFString *)target
578  port: (uint16_t)port
579  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
580 @end
581 
588 OF_SUBCLASSING_RESTRICTED
590 {
591  OFArray OF_GENERIC(OFData *) *_textStrings;
592 }
593 
597 @property (readonly, nonatomic) OFArray OF_GENERIC(OFData *) *textStrings;
599 - (instancetype)initWithName: (OFString *)name
600  DNSClass: (OFDNSClass)DNSClass
601  recordType: (OFDNSRecordType)recordType
602  TTL: (uint32_t)TTL OF_UNAVAILABLE;
603 
614 - (instancetype)initWithName: (OFString *)name
615  DNSClass: (OFDNSClass)DNSClass
616  textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings
617  TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
618 @end
619 
620 #ifdef __cplusplus
621 extern "C" {
622 #endif
623 
629 extern OFString *_Nonnull OFDNSClassName(OFDNSClass DNSClass);
630 
637 extern OFString *_Nonnull OFDNSRecordTypeName(OFDNSRecordType recordType);
638 
646 extern OFDNSClass OFDNSClassParseName(OFString *_Nonnull string);
647 
655 extern OFDNSRecordType OFDNSRecordTypeParseName(OFString *_Nonnull string);
656 #ifdef __cplusplus
657 }
658 #endif
659 
660 OF_ASSUME_NONNULL_END
Definition: OFDNSResourceRecord.h:56
An abstract class for storing objects in an array.
Definition: OFArray.h:103
A class representing an RP DNS resource record.
Definition: OFDNSResourceRecord.h:402
Definition: OFDNSResourceRecord.h:32
Definition: OFDNSResourceRecord.h:44
Definition: OFDNSResourceRecord.h:46
OFDNSClass
The DNS class.
Definition: OFDNSResourceRecord.h:30
Definition: OFDNSResourceRecord.h:48
A class representing a DNS resource record.
Definition: OFDNSResourceRecord.h:72
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
Definition: OFDNSResourceRecord.h:58
A class representing a DNS resource record.
Definition: OFDNSResourceRecord.h:161
Definition: OFDNSResourceRecord.h:60
Definition: OFDNSResourceRecord.h:62
A class representing an SOA DNS resource record.
Definition: OFDNSResourceRecord.h:449
A struct which represents a host / port pair for a socket.
Definition: OFSocket.h:182
A class for handling strings.
Definition: OFString.h:134
A class representing a CNAME DNS resource record.
Definition: OFDNSResourceRecord.h:197
OFString * OFDNSClassName(OFDNSClass DNSClass)
Returns the name for the specified OFDNSClass.
Definition: OFDNSResourceRecord.m:25
A class representing a PTR DNS resource record.
Definition: OFDNSResourceRecord.h:364
Definition: OFDNSResourceRecord.h:42
A class representing a TXT DNS resource record.
Definition: OFDNSResourceRecord.h:590
A class representing an SRV DNS resource record.
Definition: OFDNSResourceRecord.h:531
A class representing an HINFO DNS resource record.
Definition: OFDNSResourceRecord.h:235
A class representing an A DNS resource record.
Definition: OFDNSResourceRecord.h:125
Definition: OFDNSResourceRecord.h:34
OFDNSRecordType
The type of a DNS resource record.
Definition: OFDNSResourceRecord.h:40
Definition: OFDNSResourceRecord.h:52
A class representing an NS DNS resource record.
Definition: OFDNSResourceRecord.h:326
A protocol for the creation of copies.
Definition: OFObject.h:1346
A class for storing arbitrary data in an array.
Definition: OFData.h:41
A class representing an MX DNS resource record.
Definition: OFDNSResourceRecord.h:280
OFDNSClass OFDNSClassParseName(OFString *string)
Parses the specified string as an OFDNSClass.
Definition: OFDNSResourceRecord.m:71
Definition: OFDNSResourceRecord.h:50
Definition: OFDNSResourceRecord.h:64
Definition: OFDNSResourceRecord.h:54
OFDNSRecordType OFDNSRecordTypeParseName(OFString *string)
Parses the specified string as an OFDNSRecordType.
Definition: OFDNSResourceRecord.m:91
OFString * OFDNSRecordTypeName(OFDNSRecordType recordType)
Returns the name for the specified OFDNSRecordType.
Definition: OFDNSResourceRecord.m:38