1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
|
# File 'lib/net/dns/resolv.rb', line 1215
def encode
return MessageEncoder.new {|msg|
msg.put_pack('nnnnnn',
@id,
(@qr & 1) << 15 |
(@opcode & 15) << 11 |
(@aa & 1) << 10 |
(@tc & 1) << 9 |
(@rd & 1) << 8 |
(@ra & 1) << 7 |
(@rcode & 15),
@question.length,
@answer.length,
@authority.length,
@additional.length)
@question.each {|q|
name, typeclass, unicast = q
hibit = unicast ? (1<<15) : 0x00
msg.put_name(name)
msg.put_pack('nn', typeclass::TypeValue, typeclass::ClassValue|hibit)
}
[@answer, @authority, @additional].each {|rr|
rr.each {|r|
name, ttl, data, cacheflush = r
hibit = cacheflush ? (1<<15) : 0x00
msg.put_name(name)
msg.put_pack('nnN', data.class::TypeValue, data.class::ClassValue|hibit, ttl)
msg.put_length16 {data.encode_rdata(msg)}
}
}
}.to_s
end
|