Spicy
port.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <vector>
6 
7 #include <hilti/ast/builder/type.h>
8 #include <hilti/ast/operators/common.h>
9 #include <hilti/ast/types/enum.h>
10 #include <hilti/ast/types/integer.h>
11 #include <hilti/ast/types/port.h>
12 
13 namespace hilti::operator_ {
14 
15 STANDARD_OPERATOR_2(port, Equal, type::Bool(), type::Port(), type::Port(), "Compares two port values.")
16 STANDARD_OPERATOR_2(port, Unequal, type::Bool(), type::Port(), type::Port(), "Compares two port values.")
17 
18 BEGIN_KEYWORD_CTOR(port, Ctor, "port", type::Port(), "Creates a port instance.")
19  std::vector<Operand> parameters() const {
20  return {{"port", hilti::type::UnsignedInteger(16)}, {"protocol", type::Enum(type::Wildcard())}};
21  }
22 END_KEYWORD_CTOR
23 
24 BEGIN_METHOD(port, Protocol)
25  const auto& signature() const {
26  static auto _signature = Signature{.self = type::Port(),
27  .result = builder::typeByID("hilti::Protocol"),
28  .id = "protocol",
29  .args = {},
30  .doc = R"(
31 Returns the protocol the port is using (such as UDP or TCP).
32 )"};
33  return _signature;
34  }
35 END_METHOD
36 
37 } // namespace hilti::operator_
Definition: optional.h:79
Definition: operator-registry.h:15
Definition: integer.h:53