Class: Racket::L4::IGRP

Inherits:
RacketPart show all
Defined in:
lib/racket/l4/igrp.rb

Overview

uchar hopcount; /* hop count */

Constant Summary collapse

IGRP_UPDATE =
1
IGRP_REQUEST =
2

Instance Attribute Summary

Attributes inherited from RacketPart

#autofix

Instance Method Summary collapse

Methods inherited from RacketPart

#autofix?, #pretty

Constructor Details

#initialize(*args) ⇒ IGRP

Returns a new instance of IGRP.



67
68
69
70
71
72
# File 'lib/racket/l4/igrp.rb', line 67

def initialize(*args)
  @interior_routes = []
  @system_routes = []
  @exterior_routes = []
  super
end

Instance Method Details

#add_exterior(ip, delay, bw, mtu, rel, load, hop) ⇒ Object

Add an exterior route to this IGRP packet



87
88
89
90
# File 'lib/racket/l4/igrp.rb', line 87

def add_exterior(ip, delay, bw, mtu, rel, load, hop)
  @exterior_routes << add_entry(ip, delay, bw, mtu, rel, load, hop)
  self.nexterior += 1
end

#add_interior(ip, delay, bw, mtu, rel, load, hop) ⇒ Object

Add an interior route to this IGRP packet



81
82
83
84
# File 'lib/racket/l4/igrp.rb', line 81

def add_interior(ip, delay, bw, mtu, rel, load, hop)
  @interior_routes << add_entry(ip, delay, bw, mtu, rel, load, hop)
  self.ninterior += 1
end

#add_system(ip, delay, bw, mtu, rel, load, hop) ⇒ Object

Add a system route to this IGRP packet



75
76
77
78
# File 'lib/racket/l4/igrp.rb', line 75

def add_system(ip, delay, bw, mtu, rel, load, hop)
  @system_routes << add_entry(ip, delay, bw, mtu, rel, load, hop)
  self.nsystem += 1
end

#checksum!Object

Compute and set the checksum of this IGRP packet



93
94
95
# File 'lib/racket/l4/igrp.rb', line 93

def checksum! 
  self.checksum = compute_checksum
end

#checksum?Boolean

Is the checksum correct?

Returns:

  • (Boolean)


98
99
100
# File 'lib/racket/l4/igrp.rb', line 98

def checksum?
  self.checksum == compute_checksum
end

#fix!Object

Fix everything up in preparation for sending.



103
104
105
106
107
108
# File 'lib/racket/l4/igrp.rb', line 103

def fix!
  [@interior_routes, @system_routes, @exterior_routes].flatten.each do |r|
    self.payload += r
  end
  checksum!
end