55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
-
+
+
|
handle: handle] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException newWithClass: c
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPriority: (uint16_t)priority_
weight: (uint16_t)weight_
port: (uint16_t)port_
target: (OFString*)target_
{
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
-
+
|
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
newWithClass: isa];
exceptionWithClass: isa];
target = [[OFString alloc]
initWithCString: buffer
encoding: OF_STRING_ENCODING_NATIVE];
} @catch (id e) {
[self release];
@throw e;
|
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
241
242
243
244
|
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
241
242
243
244
|
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
|
@try {
int answerLen, resourceRecordCount, i;
ns_rr resourceRecord;
ns_msg handle;
if (res_ninit(&resState))
@throw [OFAddressTranslationFailedException
newWithClass: isa
socket: nil
host: domain];
exceptionWithClass: isa
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
newWithClass: isa
socket: nil
host: domain];
exceptionWithClass: isa
socket: nil
host: domain];
}
if (ns_initparse(answer, answerLen, &handle))
@throw [OFAddressTranslationFailedException
newWithClass: isa
socket: nil
host: domain];
exceptionWithClass: isa
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;
if (ns_rr_type(resourceRecord) != ns_t_srv ||
|