chromium/chrome/services/ipp_parser/public/mojom/ipp_parser.mojom

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Defines a mojom representation for an IPP, Internet Printing Protocol,
// request, IppRequest, and an interface for parsing arbitrary requests into
// this format, IppParser.

module ipp_parser.mojom;

import "sandbox/policy/mojom/sandbox.mojom";

struct Resolution {
  int32 xres;
  int32 yres;
};

union IppAttributeValue {
  array<bool> bools;

  // Per the RFC1903 DateAndTime specification, date's are serialized as a
  // string of 11 octets.
  array<uint8> date;

  array<int32> ints;
  array<string> strings;
  array<array<uint8>> octets;
  array<Resolution> resolutions;
};

struct IppAttribute {
  string name;
  int64 group_tag;
  int64 value_tag;
  IppAttributeValue value;
};

struct IppMessage {
  int64 major_version;
  int64 minor_version;
  int64 operation_id;
  int64 request_id;
  array<IppAttribute> attributes;
};

struct IppRequest {
  string method;
  string endpoint;
  string http_version;
  map<string, string> headers;
  IppMessage ipp;
  array<uint8> data;
};


// Implemented by the CupsIppParserService; supports parsing arbitrary IPP
// requests.
[ServiceSandbox=sandbox.mojom.Sandbox.kService]
interface IppParser {
  // Treats |to_parse| as an IPP request and attempts to parse into IppRequest
  // format. Returns empty IppRequest on failure.
  ParseIpp(array<uint8> to_parse) => (IppRequest? request);
};