Class: OSPFv2::Options

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IE

#method_missing

Constructor Details

#initialize(arg = {}) ⇒ Options

Returns a new instance of Options.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ie/options.rb', line 122

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OSPFv2::IE

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



120
121
122
# File 'lib/ie/options.rb', line 120

def options
  @options
end

Instance Method Details

#dc?Boolean

Returns:

  • (Boolean)


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

def dc?     ; __isSet(6)    ; end

#e?Boolean

Returns:

  • (Boolean)


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

def e?      ; __isSet(2)    ; end

#encodeObject



315
316
317
# File 'lib/ie/options.rb', line 315

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

#l?Boolean

Returns:

  • (Boolean)


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

def l?      ; __isSet(5)    ; end

#mc?Boolean

Returns:

  • (Boolean)


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

def mc?     ; __isSet(3)    ; end

#n?Boolean

Returns:

  • (Boolean)


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

def n?      ; __isSet(4)    ; end

#o?Boolean

Returns:

  • (Boolean)


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

def o?      ; __isSet(7)    ; end

#p?Boolean

Returns:

  • (Boolean)


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

def p?      ; __isSet(4)    ; end

#set(arg) ⇒ Object



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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/ie/options.rb', line 137

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[:L].nil? and arg[:l].nil?
    _flag = arg[:L] ||= arg[:l]
    if _flag.is_a?(TrueClass)
      setL
    elsif _flag.is_a?(FalseClass)
      unsetL
    elsif _flag.is_a?(Fixnum)
      if _flag == 0
        unsetL
      else
        setL
      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



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

def setDC   ; __setBit(6)   ; end

#setEObject



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

def setE    ; __setBit(2)   ; end

#setLObject

A new L-bit (L stands for LLS) is introduced into the OSPF Options field (see Figures 2a and 2b). Routers set the L-bit in Hello and DD packets to indicate that the packet contains an LLS data block. In other words, the LLS data block is only examined if the L-bit is set.



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

def setL    ; __setBit(5)   ; end

#setMCObject



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

def setMC   ; __setBit(3)   ; end

#setNObject

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



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

def setN    ; __setBit(4)   ; end

#setNSSAObject



310
311
312
313
# File 'lib/ie/options.rb', line 310

def setNSSA
  setN
  unsetE
end

#setOObject



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

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.



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

def setP    ; __setBit(4)   ; end

#setV6Object



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

def setV6   ; __setBit(1)   ; end

#to_hashObject



359
360
361
# File 'lib/ie/options.rb', line 359

def to_hash
  to_i
end

#to_iObject



355
356
357
# File 'lib/ie/options.rb', line 355

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].


351
352
353
# File 'lib/ie/options.rb', line 351

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



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

def unsetDC ; __unsetBit(6) ; end

#unsetEObject



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

def unsetE  ; __unsetBit(2) ; end

#unsetLObject



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

def unsetL  ; __unsetBit(5) ; end

#unsetMCObject



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

def unsetMC ; __unsetBit(3) ; end

#unsetNObject



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

def unsetN  ; __unsetBit(4) ; end

#unsetOObject



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

def unsetO  ; __unsetBit(7) ; end

#unsetPObject



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

def unsetP  ; __unsetBit(4) ; end

#unsetV6Object



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

def unsetV6 ; __unsetBit(1) ; end

#v6?Boolean

Returns:

  • (Boolean)


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

def v6?     ; __isSet(1)    ; end