51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-
+
|
{
return [[[self alloc] initWithResourceRecord: resourceRecord
handle: handle] autorelease];
}
- init
{
Class c = isa;
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPriority: (uint16_t)priority_
weight: (uint16_t)weight_
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
-
+
|
priority = ntohs(rdata[0]);
weight = ntohs(rdata[1]);
port = ntohs(rdata[2]);
if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
(uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
exceptionWithClass: [self class]];
target = [[OFString alloc]
initWithCString: buffer
encoding: OF_STRING_ENCODING_NATIVE];
} @catch (id e) {
[self release];
@throw e;
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
-
-
+
+
-
-
+
|
[target release];
[super dealloc];
}
- (OFString*)description
{
return [OFString stringWithFormat: @"<%@ priority: %" PRIu16
@", weight: %" PRIu16
return [OFString stringWithFormat:
@"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%"
@", target: %@:%" PRIu16 @">",
isa, priority, weight, target, port];
PRIu16 @">", [self class], priority, weight, target, port];
}
- (uint16_t)priority
{
return priority;
}
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
-
+
-
+
-
+
|
@try {
int answerLen, resourceRecordCount, i;
ns_rr resourceRecord;
ns_msg handle;
if (res_ninit(&resState))
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
exceptionWithClass: [self class]
socket: nil
host: domain];
answer = [self allocMemoryWithSize: of_pagesize];
answerLen = res_nsearch(&resState, [request cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer,
(int)of_pagesize);
if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
(h_errno == NO_DATA)))
return;
if (answerLen < 1 || answerLen > of_pagesize) {
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
exceptionWithClass: [self class]
socket: nil
host: domain];
}
if (ns_initparse(answer, answerLen, &handle))
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
exceptionWithClass: [self class]
socket: nil
host: domain];
resourceRecordCount = ns_msg_count(handle, ns_s_an);
for (i = 0; i < resourceRecordCount; i++) {
if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
continue;
|