//
// Copyright (C) 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-es v2.2.2 with parameter "target=ts"
// @generated from file protos/perfetto/trace/android/network_trace.proto (package perfetto.protos, syntax proto2)
/* eslint-disable */

import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv1";
import type { Message } from "@bufbuild/protobuf";

/**
 * Describes the file protos/perfetto/trace/android/network_trace.proto.
 */
export const file_protos_perfetto_trace_android_network_trace: GenFile = /*@__PURE__*/
  fileDesc("CjFwcm90b3MvcGVyZmV0dG8vdHJhY2UvYW5kcm9pZC9uZXR3b3JrX3RyYWNlLnByb3RvEg9wZXJmZXR0by5wcm90b3Mi+wEKEk5ldHdvcmtQYWNrZXRFdmVudBI0CglkaXJlY3Rpb24YASABKA4yIS5wZXJmZXR0by5wcm90b3MuVHJhZmZpY0RpcmVjdGlvbhIRCglpbnRlcmZhY2UYAiABKAkSDgoGbGVuZ3RoGAMgASgNEgsKA3VpZBgEIAEoDRILCgN0YWcYBSABKA0SEAoIaXBfcHJvdG8YBiABKA0SEQoJdGNwX2ZsYWdzGAcgASgNEhIKCmxvY2FsX3BvcnQYCCABKA0SEwoLcmVtb3RlX3BvcnQYCSABKA0SEQoJaWNtcF90eXBlGAogASgNEhEKCWljbXBfY29kZRgLIAEoDSLqAQoTTmV0d29ya1BhY2tldEJ1bmRsZRINCgNpaWQYASABKARIABIyCgNjdHgYAiABKAsyIy5wZXJmZXR0by5wcm90b3MuTmV0d29ya1BhY2tldEV2ZW50SAASHQoRcGFja2V0X3RpbWVzdGFtcHMYAyADKARCAhABEhoKDnBhY2tldF9sZW5ndGhzGAQgAygNQgIQARIVCg10b3RhbF9wYWNrZXRzGAUgASgNEhYKDnRvdGFsX2R1cmF0aW9uGAYgASgEEhQKDHRvdGFsX2xlbmd0aBgHIAEoBEIQCg5wYWNrZXRfY29udGV4dCJVChROZXR3b3JrUGFja2V0Q29udGV4dBILCgNpaWQYASABKAQSMAoDY3R4GAIgASgLMiMucGVyZmV0dG8ucHJvdG9zLk5ldHdvcmtQYWNrZXRFdmVudCpIChBUcmFmZmljRGlyZWN0aW9uEhMKD0RJUl9VTlNQRUNJRklFRBAAEg8KC0RJUl9JTkdSRVNTEAESDgoKRElSX0VHUkVTUxAC");

/**
 * NetworkPacketEvent records the details of a single packet sent or received
 * on the network (in Linux kernel terminology, one sk_buff struct).
 *
 * @generated from message perfetto.protos.NetworkPacketEvent
 */
export type NetworkPacketEvent = Message<"perfetto.protos.NetworkPacketEvent"> & {
  /**
   * The direction traffic is flowing for this event.
   *
   * @generated from field: optional perfetto.protos.TrafficDirection direction = 1;
   */
  direction: TrafficDirection;

  /**
   * The name of the interface if available (e.g. 'rmnet0').
   *
   * @generated from field: optional string interface = 2;
   */
  interface: string;

  /**
   * The length of the packet in bytes (wire_size - L2_header_size). Ignored
   * when using NetworkPacketEvent as the ctx in either NetworkPacketBundle or
   * NetworkPacketContext.
   *
   * @generated from field: optional uint32 length = 3;
   */
  length: number;

  /**
   * The Linux user id associated with the packet's socket.
   *
   * @generated from field: optional uint32 uid = 4;
   */
  uid: number;

  /**
   * The Android network tag associated with the packet's socket.
   *
   * @generated from field: optional uint32 tag = 5;
   */
  tag: number;

  /**
   * The packet's IP protocol (TCP=6, UDP=17, etc).
   *
   * @generated from field: optional uint32 ip_proto = 6;
   */
  ipProto: number;

  /**
   * The packet's TCP flags as a bitmask (FIN=0x1, SYN=0x2, RST=0x4, etc).
   *
   * @generated from field: optional uint32 tcp_flags = 7;
   */
  tcpFlags: number;

  /**
   * The local udp/tcp port of the packet.
   *
   * @generated from field: optional uint32 local_port = 8;
   */
  localPort: number;

  /**
   * The remote udp/tcp port of the packet.
   *
   * @generated from field: optional uint32 remote_port = 9;
   */
  remotePort: number;

  /**
   * The 1-byte ICMP type identifier.
   *
   * @generated from field: optional uint32 icmp_type = 10;
   */
  icmpType: number;

  /**
   * The 1-byte ICMP code identifier.
   *
   * @generated from field: optional uint32 icmp_code = 11;
   */
  icmpCode: number;
};

/**
 * Describes the message perfetto.protos.NetworkPacketEvent.
 * Use `create(NetworkPacketEventSchema)` to create a new message.
 */
export const NetworkPacketEventSchema: GenMessage<NetworkPacketEvent> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_trace_android_network_trace, 0);

/**
 * NetworkPacketBundle bundles one or more packets sharing the same attributes.
 *
 * @generated from message perfetto.protos.NetworkPacketBundle
 */
export type NetworkPacketBundle = Message<"perfetto.protos.NetworkPacketBundle"> & {
  /**
   * @generated from oneof perfetto.protos.NetworkPacketBundle.packet_context
   */
  packetContext: {
    /**
     * The intern id for looking up the associated packet context.
     *
     * @generated from field: uint64 iid = 1;
     */
    value: bigint;
    case: "iid";
  } | {
    /**
     * The inlined context for events in this bundle.
     *
     * @generated from field: perfetto.protos.NetworkPacketEvent ctx = 2;
     */
    value: NetworkPacketEvent;
    case: "ctx";
  } | { case: undefined; value?: undefined };

  /**
   * The timestamp of the i-th packet encoded as the nanoseconds since the
   * enclosing TracePacket's timestamp.
   *
   * @generated from field: repeated uint64 packet_timestamps = 3 [packed = true];
   */
  packetTimestamps: bigint[];

  /**
   * The length of the i-th packet in bytes (wire_size - L2_header_size).
   *
   * @generated from field: repeated uint32 packet_lengths = 4 [packed = true];
   */
  packetLengths: number[];

  /**
   * Total number of packets in the bundle (when above aggregation_threshold).
   *
   * @generated from field: optional uint32 total_packets = 5;
   */
  totalPackets: number;

  /**
   * Duration between first and last packet (when above aggregation_threshold).
   *
   * @generated from field: optional uint64 total_duration = 6;
   */
  totalDuration: bigint;

  /**
   * Total packet length in bytes (when above aggregation_threshold).
   *
   * @generated from field: optional uint64 total_length = 7;
   */
  totalLength: bigint;
};

/**
 * Describes the message perfetto.protos.NetworkPacketBundle.
 * Use `create(NetworkPacketBundleSchema)` to create a new message.
 */
export const NetworkPacketBundleSchema: GenMessage<NetworkPacketBundle> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_trace_android_network_trace, 1);

/**
 * An internable packet context.
 *
 * @generated from message perfetto.protos.NetworkPacketContext
 */
export type NetworkPacketContext = Message<"perfetto.protos.NetworkPacketContext"> & {
  /**
   * @generated from field: optional uint64 iid = 1;
   */
  iid: bigint;

  /**
   * @generated from field: optional perfetto.protos.NetworkPacketEvent ctx = 2;
   */
  ctx?: NetworkPacketEvent;
};

/**
 * Describes the message perfetto.protos.NetworkPacketContext.
 * Use `create(NetworkPacketContextSchema)` to create a new message.
 */
export const NetworkPacketContextSchema: GenMessage<NetworkPacketContext> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_trace_android_network_trace, 2);

/**
 * @generated from enum perfetto.protos.TrafficDirection
 */
export enum TrafficDirection {
  /**
   * @generated from enum value: DIR_UNSPECIFIED = 0;
   */
  DIR_UNSPECIFIED = 0,

  /**
   * @generated from enum value: DIR_INGRESS = 1;
   */
  DIR_INGRESS = 1,

  /**
   * @generated from enum value: DIR_EGRESS = 2;
   */
  DIR_EGRESS = 2,
}

/**
 * Describes the enum perfetto.protos.TrafficDirection.
 */
export const TrafficDirectionSchema: GenEnum<TrafficDirection> = /*@__PURE__*/
  enumDesc(file_protos_perfetto_trace_android_network_trace, 0);

