Class: OSPFv2::Options

Inherits:
Object show all
Defined in:
lib/ie/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = {}) ⇒ Options

Returns a new instance of Options.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ie/options.rb', line 103

def initialize(arg={})
  @options=0
  if arg.is_a?(Hash) then
    set(arg)
  elsif arg.is_a?(String)
    _parse_(arg)
  elsif arg.is_a?(Fixnum) and (0..255) === arg
    @options = arg
  elsif arg.is_a?(self.class)
    set(arg.to_hash)
  else
    raise ArgumentError, "Invalid argument", caller
  end
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



101
102
103
# File 'lib/ie/options.rb', line 101

def options
  @options
end

Instance Method Details

#dc?Boolean

Returns:

  • (Boolean)


255
# File 'lib/ie/options.rb', line 255

def dc?     ; __isSet(6)    ; end

#e?Boolean

Returns:

  • (Boolean)


279
# File 'lib/ie/options.rb', line 279

def e?      ; __isSet(2)    ; end

#encodeObject



290
291
292
# File 'lib/ie/options.rb', line 290

def encode
  [@options].pack('C')
end

#mc?Boolean

Returns:

  • (Boolean)


275
# File 'lib/ie/options.rb', line 275

def mc?     ; __isSet(3)    ; end

#n?Boolean

Returns:

  • (Boolean)


265
# File 'lib/ie/options.rb', line 265

def n?      ; __isSet(4)    ; end

#o?Boolean

Returns:

  • (Boolean)


251
# File 'lib/ie/options.rb', line 251

def o?      ; __isSet(7)    ; end

#p?Boolean

Returns:

  • (Boolean)


271
# File 'lib/ie/options.rb', line 271

def p?      ; __isSet(4)    ; end

#r?Boolean

Returns:

  • (Boolean)


259
# File 'lib/ie/options.rb', line 259

def r?      ; __isSet(5)    ; end

#set(arg) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/ie/options.rb', line 118

def set(arg)
  return self unless arg.is_a?(Hash)
  
  unless arg[:O].nil? and arg[:o].nil?
    _flag = arg[:O] ||= arg[:o]
    if _flag.is_a?(TrueClass)
      setO
    elsif _flag.is_a?(FalseClass)
      unsetO
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetO
      else
        setO
      end
    end
  end
  unless arg[:DC].nil? and arg[:dc].nil?
    _flag = arg[:DC] ||= arg[:dc]
    if _flag.is_a?(TrueClass)
      setDC
    elsif _flag.is_a?(FalseClass)
      unsetDC
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetDC
      else
        setDC
      end
    end
  end
  unless arg[:R].nil? and arg[:r].nil?
    _flag = arg[:R] ||= arg[:r]
    if _flag.is_a?(TrueClass)
      setR
    elsif _flag.is_a?(FalseClass)
      unsetR
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetR
      else
        setR
      end
    end
  end
  unless arg[:N].nil? and arg[:n].nil?
    _flag = arg[:N] ||= arg[:n]
    if _flag.is_a?(TrueClass)
      setN
    elsif _flag.is_a?(FalseClass)
      unsetN
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetN
      else
        setN
      end
    end
  end
  unless arg[:P].nil? and arg[:p].nil?
    _flag = arg[:P] ||= arg[:p]
    if _flag.is_a?(TrueClass)
      setP
    elsif _flag.is_a?(FalseClass)
      unsetP
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetP
      else
        setP
      end
    end
  end
  unless arg[:MC].nil? and arg[:mc].nil?
      _flag = arg[:MC] ||= arg[:mc]
      if _flag.is_a?(TrueClass)
        setMC
      elsif _flag.is_a?(FalseClass)
        unsetMC
      elsif _flag.is_a?(Fixnum)
        if _flag == 0
          unsetMC
        else
          setMC
        end
      end
    end
  unless arg[:E].nil? and arg[:e].nil?
    _flag = arg[:E] ||= arg[:e]
    if _flag.is_a?(TrueClass)
      setE
    elsif _flag.is_a?(FalseClass)
      unsetE
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetE
      else
        setE
      end
    end
  end
  unless arg[:V6].nil? and arg[:v6].nil?
    _flag = arg[:V6] ||= arg[:v6]
    if _flag.is_a?(TrueClass)
      setV6
    elsif _flag.is_a?(FalseClass)
      unsetV6
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetV6
      else
        setV6
      end
    end
  end
  self
end

#setDCObject



253
# File 'lib/ie/options.rb', line 253

def setDC   ; __setBit(6)   ; end

#setEObject



277
# File 'lib/ie/options.rb', line 277

def setE    ; __setBit(2)   ; end

#setMCObject



273
# File 'lib/ie/options.rb', line 273

def setMC   ; __setBit(3)   ; end

#setNObject

N-bit is used in Hello packets only. It signals the area is an NSSA area.



263
# File 'lib/ie/options.rb', line 263

def setN    ; __setBit(4)   ; end

#setNSSAObject



285
286
287
288
# File 'lib/ie/options.rb', line 285

def setNSSA
  setN
  unsetE
end

#setOObject



249
# File 'lib/ie/options.rb', line 249

def setO    ; __setBit(7)   ; end

#setPObject

P-bit is used in Type-7 LSA Header It signals the NSSA border to translate the Type-7 into Type-5.



269
# File 'lib/ie/options.rb', line 269

def setP    ; __setBit(4)   ; end

#setRObject



257
# File 'lib/ie/options.rb', line 257

def setR    ; __setBit(5)   ; end

#setV6Object



281
# File 'lib/ie/options.rb', line 281

def setV6   ; __setBit(1)   ; end

#to_hashObject



334
335
336
# File 'lib/ie/options.rb', line 334

def to_hash
  to_i
end

#to_iObject



330
331
332
# File 'lib/ie/options.rb', line 330

def to_i
  @options
end

#to_sObject

V6-bit

If this bit is clear, the router/link should be excluded from IPv6
routing calculations. See Section 3.8 of this memo.

E-bit

This bit describes the way AS-external-LSAs are flooded, as
described in Sections 3.6, 9.5, 10.8 and 12.1.2 of [Ref1].

MC-bit

This bit describes whether IP multicast datagrams are forwarded
according to the specifications in [Ref7].

N-bit

This bit describes the handling of Type-7 LSAs, as specified in
[Ref8].

R-bit

This bit (the `Router' bit) indicates whether the originator is an
active router.  If the router bit is clear routes which transit the
advertising node cannot be computed. Clearing the router bit would
be appropriate for a multi-homed host that wants to participate in
routing, but does not want to forward non-locally addressed
packets.

DC-bit

This bit describes the router's handling of demand circuits, as
specified in [Ref10].


326
327
328
# File 'lib/ie/options.rb', line 326

def to_s
  self.class.to_s.split('::').last + ": " + format(' 0x%x  [%s]', to_i, _to_s_)   #[@options].pack('C').unpack('B8')[0][1..7]
end

#unsetDCObject



254
# File 'lib/ie/options.rb', line 254

def unsetDC ; __unsetBit(6) ; end

#unsetEObject



278
# File 'lib/ie/options.rb', line 278

def unsetE  ; __unsetBit(2) ; end

#unsetMCObject



274
# File 'lib/ie/options.rb', line 274

def unsetMC ; __unsetBit(3) ; end

#unsetNObject



264
# File 'lib/ie/options.rb', line 264

def unsetN  ; __unsetBit(4) ; end

#unsetOObject



250
# File 'lib/ie/options.rb', line 250

def unsetO  ; __unsetBit(7) ; end

#unsetPObject



270
# File 'lib/ie/options.rb', line 270

def unsetP  ; __unsetBit(4) ; end

#unsetRObject



258
# File 'lib/ie/options.rb', line 258

def unsetR  ; __unsetBit(5) ; end

#unsetV6Object



282
# File 'lib/ie/options.rb', line 282

def unsetV6 ; __unsetBit(1) ; end

#v6?Boolean

Returns:

  • (Boolean)


283
# File 'lib/ie/options.rb', line 283

def v6?     ; __isSet(1)    ; end