module arch.node.types.transport;

import arch.node.types.basics open;
import arch.node.types.crypto open;
import arch.node.types.identities open;

syntax alias IPv4Address := Nat;
syntax alias IPv6Address := Nat;

IPAddress : Type := Either IPv4Address IPv6Address;

type TransportProtocol :=
  | QUIC
  | TLS
  | WebTransport
  | WebSocket
  | TCP
  | UDP;

type TLSAddress :=
  mkTLSAddress@{
    ip : IPAddress;
    port : Nat;
    cert_issuer : String;
  };

type TransportAddress :=
  | QUICAddr TLSAddress
  | TLSAddr TLSAddress
  | IPAddr IPAddress;

type TransportOrderingPrefs :=
  | TransportOrdered
  | TransportUnordered;

type TransportReliabilityPrefs :=
  | TransportReliable
  | TransportUnreliable;

type TransportSecurityPrefs := | TransportDirect;

type TransportPrefs :=
  mkTransportPrefs@{
    ordering : TransportOrderingPrefs;
    reliability : TransportReliabilityPrefs;
    security : TransportSecurityPrefs;
  };

type SerializedMsg := | BARE ByteString;

type EncryptedMsg := | EncryptedMsgNull ByteString;