Class: CiscoAclIntp::ExtendedAce

Inherits:
StandardAce show all
Defined in:
lib/cisco_acl_intp/ace_extended.rb

Overview

ACE for extended access list

Constant Summary

Constants inherited from AceBase

AceBase::NO_SEQ_NUMBER

Constants inherited from AccessControlContainer

AccessControlContainer::TERM_COLOR_TABLE

Instance Attribute Summary collapse

Attributes inherited from StandardAce

#action, #log_spec, #src_spec

Attributes inherited from AceBase

#seq_number

Instance Method Summary collapse

Methods inherited from StandardAce

#define_action, #define_log_spec, #define_src_spec

Methods inherited from AceBase

#<=>, #seq_number?

Methods inherited from AccessControlContainer

#clean_acl_string, disable_color, #generate_tag_footer, #generate_tag_header, #generate_tagged_str, #method_missing

Constructor Details

#initialize(opts) ⇒ ExtendACE

Constructor

Parameters:

  • opts (Hash)

    Options

Options Hash (opts):

  • :protocol (String)

    L3/L4 protocol

  • :number (Integer)

    Protocol/Port number

  • :action (String)

    Action

  • :src (AceSrcDstSpec)

    Source spec object

  • :src (Hash)

    Source spec parmeters

  • :dst (AceSrcDstSpec)

    Destination spec object

  • :dst (Hash)

    Destination spec parmeters

  • :tcp_port_qualifier (AceTcpFlagList)

    TCP Flags object

Raises:



51
52
53
54
55
56
57
58
# File 'lib/cisco_acl_intp/ace_extended.rb', line 51

def initialize(opts)
  super
  @options = opts
  @protocol = define_protocol
  @dst_spec = define_dst_spec
  @tcp_flags = define_tcp_flags
  @tcp_other_qualifiers = nil # not yet.
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CiscoAclIntp::AccessControlContainer

Instance Attribute Details

#dst_specAceSrcDstSpec

Parameters:

Returns:



13
14
15
# File 'lib/cisco_acl_intp/ace_extended.rb', line 13

def dst_spec
  @dst_spec
end

#protocolAceIpProtoSpec

Parameters:

Returns:



9
10
11
# File 'lib/cisco_acl_intp/ace_extended.rb', line 9

def protocol
  @protocol
end

#tcp_flagsAceTcpFlagList

Parameters:

  • value (AceTcpFlagList)

    TCP flags (used when ‘@protocol’:tcp)

Returns:



18
19
20
# File 'lib/cisco_acl_intp/ace_extended.rb', line 18

def tcp_flags
  @tcp_flags
end

#tcp_other_qualifiersAceOtherQualifierList

Parameters:

Returns:



23
24
25
# File 'lib/cisco_acl_intp/ace_extended.rb', line 23

def tcp_other_qualifiers
  @tcp_other_qualifiers
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (ExtendACE)

    RHS object

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
# File 'lib/cisco_acl_intp/ace_extended.rb', line 62

def ==(other)
  @action == other.action &&
    @protocol == other.protocol &&
    @src_spec == other.src_spec &&
    @dst_spec == other.dst_spec &&
    @tcp_flags == other.tcp_flags
  ## does it need to compare? : tcp_other_qualifiers
end

#contains?(other) ⇒ Boolean

Search matched ACE

Parameters:

Returns:

  • (Boolean)

    Matched or not

See Also:

  • SingleAceBase#search_ace


89
90
91
92
93
# File 'lib/cisco_acl_intp/ace_extended.rb', line 89

def contains?(other)
  super(other) &&
    @protocol.contains?(other.protocol) &&
    @dst_spec.contains?(other.dst_spec)
end

#define_dst_specAceSrcDstSpec (private)

Set instance variables

Returns:

Raises:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cisco_acl_intp/ace_extended.rb', line 117

def define_dst_spec
  if @options.key?(:dst)
    dst = @options[:dst]
    case dst
    when Hash
      AceSrcDstSpec.new(dst)
    when AceSrcDstSpec
      dst
    else
      raise AclArgumentError, 'Dst spec: unknown class'
    end
  else
    raise AclArgumentError, 'Not specified dst spec'
  end
end

#define_protocolObject (private)

Set instance variables return [AceIpProtoSpec] IP protocol object raise [AclArgumentError]



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cisco_acl_intp/ace_extended.rb', line 100

def define_protocol
  if @options.key?(:protocol)
    protocol = @options[:protocol]
    case protocol
    when AceIpProtoSpec
      protocol
    else
      AceIpProtoSpec.new(protocol)
    end
  else
    raise AclArgumentError, 'Not specified IP protocol'
  end
end

#define_tcp_flagsAceOtherQualifierList (private)

Set instance variables



135
136
137
138
139
# File 'lib/cisco_acl_intp/ace_extended.rb', line 135

def define_tcp_flags
  return unless @protocol.name == 'tcp' &&
                @options.key?(:tcp_flags_qualifier)
  @options[:tcp_flags_qualifier]
end

#to_sString

Generate string for Cisco IOS access list

Returns:

  • (String)


73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cisco_acl_intp/ace_extended.rb', line 73

def to_s
  format(
    '%s %s %s %s %s %s',
    tag_action(@action.to_s),
    tag_protocol(@protocol.to_s),
    @src_spec,
    @dst_spec,
    @tcp_flags,
    @tcp_other_qualifiers
  )
end