/** * Converts a Message object to a raw DNS wire format byte array. * @param msg The message to convert. * @return A byte array representing the raw DNS wire format of the message. */ protected byte[] toBytes(Message msg) { return msg.toWire(); } }
dnsMsg.getHeader().setRcode(Rcode.NOERROR); dnsMsg.addRecord(NEGATIVE_CACHE_SOA_RECORD, Section.AUTHORITY); handleDnsResponse(parsedPacket, dnsMsg.toWire());
/** * Generates a TSIG record with a specific error for a message and adds it * to the message. * @param m The message * @param error The error * @param old If this message is a response, the TSIG from the request */ public void apply(Message m, int error, TSIGRecord old) { Record r = generate(m, m.toWire(), error, old); m.addRecord(r, Section.ADDITIONAL); m.tsigState = Message.TSIG_SIGNED; }
/** * Generates a TSIG record with a specific error for a message and adds it * to the message. * @param m The message * @param error The error * @param old If this message is a response, the TSIG from the request */ public void apply(Message m, int error, TSIGRecord old) { Record r = generate(m, m.toWire(), error, old); m.addRecord(r, Section.ADDITIONAL); m.tsigState = Message.TSIG_SIGNED; }
/** * Generates a TSIG record with a specific error for a message and adds it * to the message. * @param m The message * @param error The error * @param old If this message is a response, the TSIG from the request */ public void apply(Message m, int error, TSIGRecord old) { Record r = generate(m, m.toWire(), error, old); m.addRecord(r, Section.ADDITIONAL); m.tsigState = Message.TSIG_SIGNED; }
/** * Generates a TSIG record with a specific error for a message and adds it * to the message. * @param m The message * @param error The error * @param old If this message is a response, the TSIG from the request */ public void apply(Message m, int error, TSIGRecord old) { Record r = generate(m, m.toWire(), error, old); m.addRecord(r, Section.ADDITIONAL); m.tsigState = Message.TSIG_SIGNED; }
/** * Returns an array containing the wire format representation of the Message. */ public byte [] toWire() { DNSOutput out = new DNSOutput(); toWire(out); size = out.current(); return out.toByteArray(); }
/** * Returns an array containing the wire format representation of the Message. */ public byte [] toWire() { DNSOutput out = new DNSOutput(); toWire(out); size = out.current(); return out.toByteArray(); }
/** * Returns an array containing the wire format representation of the Message. */ public byte [] toWire() { DNSOutput out = new DNSOutput(); toWire(out); size = out.current(); return out.toByteArray(); }
/** * Returns an array containing the wire format representation of the Message. */ public byte [] toWire() { DNSOutput out = new DNSOutput(); toWire(out); size = out.current(); return out.toByteArray(); }
.payloadBuilder( new UnknownPacket.Builder() .rawData(message.toWire()) );
@Test public void testNoQueryDnsQuery() throws Exception { Message message = new Message(); UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder() .srcPort(UdpPort.DOMAIN) .dstPort(UdpPort.DOMAIN) .srcAddr(InetAddress.getByAddress(new byte[]{8, 8, 4, 4})) .dstAddr(InetAddress.getByAddress(new byte[]{8, 8, 8, 8})) .correctChecksumAtBuild(true) .correctLengthAtBuild(true) .payloadBuilder( new UnknownPacket.Builder() .rawData(message.toWire()) ); IpPacket ipOutPacket = new IpV4Packet.Builder() .version(IpVersion.IPV4) .tos(IpV4Rfc791Tos.newInstance((byte) 0)) .protocol(IpNumber.UDP) .srcAddr((Inet4Address) Inet4Address.getByAddress(new byte[]{8, 8, 4, 4})) .dstAddr((Inet4Address) Inet4Address.getByAddress(new byte[]{8, 8, 8, 8})) .correctChecksumAtBuild(true) .correctLengthAtBuild(true) .payloadBuilder(payLoadBuilder) .build(); dnsPacketProxy.handleDnsRequest(ipOutPacket.getRawData()); assertNull(mockEventLoop.lastResponse); assertNull(mockEventLoop.lastOutgoing); dnsPacketProxy.handleDnsRequest(ipOutPacket.getRawData()); }
byte[] buildErrorMessage(final Header header, final int rcode, final Record question) { final Message response = new Message(); response.setHeader(header); for (int i = 0; i < 4; i++) response.removeAllRecords(i); if (rcode == Rcode.SERVFAIL) response.addRecord(question, Section.QUESTION); header.setRcode(rcode); return response.toWire(); }
/** * Creates a byte array containing the concatenation of the fields of the * SIG(0) record and the message to be signed. This does not perform * a cryptographic digest. * @param sig The SIG record used to sign the rrset. * @param msg The message to be signed. * @param previous If this is a response, the signature from the query. * @return The data to be cryptographically signed. */ public static byte [] digestMessage(SIGRecord sig, Message msg, byte [] previous) { DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous); msg.toWire(out); return out.toByteArray(); }
byte [] buildErrorMessage(Header header, int rcode, Record question) { Message response = new Message(); response.setHeader(header); for (int i = 0; i < 4; i++) response.removeAllRecords(i); if (rcode == Rcode.SERVFAIL) response.addRecord(question, Section.QUESTION); header.setRcode(rcode); return response.toWire(); }
private byte[] buildErrorMessage(Header header, int rcode, Record question) { Message response = new Message(); response.setHeader(header); for (int i = 0; i < 4; i++) { response.removeAllRecords(i); } if (rcode == Rcode.SERVFAIL) { response.addRecord(question, Section.QUESTION); } header.setRcode(rcode); return response.toWire(); }
/** * Creates a byte array containing the concatenation of the fields of the * SIG(0) record and the message to be signed. This does not perform * a cryptographic digest. * @param sig The SIG record used to sign the rrset. * @param msg The message to be signed. * @param previous If this is a response, the signature from the query. * @return The data to be cryptographically signed. */ public static byte [] digestMessage(SIGRecord sig, Message msg, byte [] previous) { DNSOutput out = new DNSOutput(); digestSIG(out, sig); if (previous != null) out.writeByteArray(previous); msg.toWire(out); return out.toByteArray(); }
byte[] buildErrorMessage(Header header, int rcode, Record question) { final Message response = new Message(); response.setHeader(header); for (int i = 0; i < 4; i++) { response.removeAllRecords(i); } if (rcode == Rcode.SERVFAIL) { response.addRecord(question, Section.QUESTION); } header.setRcode(rcode); return response.toWire(); }
.payloadBuilder( new UnknownPacket.Builder() .rawData(message.toWire()) );
.payloadBuilder( new UnknownPacket.Builder() .rawData(message.toWire()) );