/*
 * This file is part of PowerDNS or dnsdist.
 * Copyright -- PowerDNS.COM B.V. and its contributors
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * In addition, for the avoidance of any doubt, permission is granted to
 * link this program with OpenSSL and to (re)distribute the binaries
 * produced as the result of such linking.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
syntax = "proto2";

message PBDNSMessage {
  enum Type {
    DNSQueryType = 1;
    DNSResponseType = 2;
  }
  enum SocketFamily {
    INET = 1;   // IPv4 (RFC 791)
    INET6 = 2;  // IPv6 (RFC 2460)
  }
  enum SocketProtocol {
    UDP = 1;    // User Datagram Protocol (RFC 768)
    TCP = 2;    // Transmission Control Protocol (RFC 793)
  }
  required Type type = 1;
  optional bytes messageId = 2;
  optional bytes serverIdentity = 3;
  optional SocketFamily socketFamily = 4;
  optional SocketProtocol socketProtocol = 5;
  optional bytes from = 6;
  optional bytes to = 7;
  optional uint64 inBytes = 8;
  optional uint32 timeSec = 9;
  optional uint32 timeUsec = 10;
  optional uint32 id = 11;

  message DNSQuestion {
    optional string qName = 1;
    optional uint32 qType = 2;
    optional uint32 qClass = 3;
  }
  optional DNSQuestion question = 12;

  message DNSResponse {
    message DNSRR {
      optional string name = 1;
      optional uint32 type = 2;
      optional uint32 class = 3;
      optional uint32 ttl = 4;
      optional bytes rdata = 5;
    }
    optional uint32 rcode = 1;
    repeated DNSRR rrs = 2;
    optional string appliedPolicy = 3;
    repeated string tags = 4;
    optional uint32 queryTimeSec = 5;
    optional uint32 queryTimeUsec = 6;
  }

  optional DNSResponse response = 13;
  optional bytes originalRequestorSubnet = 14;
}
