File: CWDNSManager.h

package info (click to toggle)
pantomime 1.3.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 2,332 kB
  • sloc: objc: 22,026; makefile: 11; sh: 4
file content (122 lines) | stat: -rw-r--r-- 3,590 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
**  CWDNSManager.h
**
**  Copyright (c) 2004-2007 Ludovic Marcotte
**  Copyright (C) 2013 The GNUstep team
**
**  Author: Ludovic Marcotte <ludovic@Sophos.ca>
**          Riccardo Mottola
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**  
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
**  Lesser General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _Pantomime_H_CWDNSManager
#define _Pantomime_H_CWDNSManager

#include <Pantomime/CWConnection.h>

#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSTimer.h>

#ifdef MACOSX
#import <Foundation/NSMapTable.h>
#include <CoreFoundation/CoreFoundation.h>
#endif

#if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
#ifndef NSUInteger
#define NSUInteger unsigned int
#endif
#ifndef NSInteger
#define NSInteger int
#endif
#endif

/*!
  @const PantomimeDNSResolutionCompleted
  @discussion This notification is automatically posted when 
              the DNS resolution has completed successfully.
*/
extern NSString* PantomimeDNSResolutionCompleted;

/*!
  @const PantomimeDNSResolutionFailed
  @discussion This notification is automatically posted when
              the DNS resolution has failed.
*/
extern NSString* PantomimeDNSResolutionFailed;

#ifdef MACOSX
typedef enum {ET_RDESC, ET_WDESC, ET_EDESC} RunLoopEventType;
/*!
  @class CWDNSManager
  @discussion This class is used in Pantomime to perform DNS resolution.
              Currently, it does not do asynchronous lookups but implements
	      a simple cache to speedup repetitive requets.
*/
@interface CWDNSManager : NSObject
#else
@interface CWDNSManager : NSObject <RunLoopEvents>
#endif
{
  @private
    NSMutableArray *_servers, *_queue;
    NSMutableDictionary *_cache;
    NSTimer *_timer;

#ifdef MACOSX
    CFRunLoopSourceRef _runLoopSource;
    CFSocketContext *_context;
    CFSocketRef _cf_socket;
#endif

    unsigned short _packet_id;
    BOOL _is_asynchronous;
    NSInteger _socket;
}

/*!
  @method addressesForName:background:
  @discussion This method is used to obtain an array of IP
              addresses from a fully qualified domain name.
  @param theName The fully qualified domain name.
  @param theBOOL If YES, the call is non-blocking and returns nil.
                 Otherwise, the call is block and returns an
		 array of addresses, if any.
  @result The array of addresses encoded as NSData instances.
*/
- (NSArray *) addressesForName: (NSString *) theName
                    background: (BOOL) theBOOL;
/*!
  @method singleInstance
  @discussion This method is used to obtain the shared
              CWDNSManager instance for DNS resolution.
  @result The shared instance.
*/
+ (id) singleInstance;

#ifdef MACOSX
- (void) receivedEvent: (void *) theData
                  type: (RunLoopEventType) theType
                 extra: (void *) theExtra
               forMode: (NSString *) theMode;
#endif

@end

#endif // _Pantomime_H_CWDNSManager