Class: Racket::L4::VRRP
- Inherits:
-
RacketPart
- Object
- BitStruct
- RacketPart
- Racket::L4::VRRP
- Defined in:
- lib/racket/l4/vrrp.rb
Overview
Instance Attribute Summary
Attributes inherited from RacketPart
Instance Method Summary collapse
-
#add_auth(authdata) ⇒ Object
Add authentication data.
-
#add_ip(ip) ⇒ Object
Add a new IP to this message.
-
#checksum! ⇒ Object
compute and set the checksum.
-
#checksum? ⇒ Boolean
Validate the checksum.
-
#fix! ⇒ Object
(really, just set the checksum).
-
#initialize(*args) ⇒ VRRP
constructor
A new instance of VRRP.
Methods inherited from RacketPart
Constructor Details
#initialize(*args) ⇒ VRRP
Returns a new instance of VRRP.
80 81 82 83 84 |
# File 'lib/racket/l4/vrrp.rb', line 80 def initialize(*args) @ips = [] @authdata = "" super end |
Instance Method Details
#add_auth(authdata) ⇒ Object
Add authentication data
59 60 61 |
# File 'lib/racket/l4/vrrp.rb', line 59 def add_auth(authdata) @authdata = authdata[0,8].ljust(32, "\x00") end |
#add_ip(ip) ⇒ Object
Add a new IP to this message
54 55 56 |
# File 'lib/racket/l4/vrrp.rb', line 54 def add_ip(ip) @ips << L3::Misc.ipv42long(ip) end |
#checksum! ⇒ Object
compute and set the checksum
69 70 71 |
# File 'lib/racket/l4/vrrp.rb', line 69 def checksum! self.checksum = compute_checksum end |
#checksum? ⇒ Boolean
Validate the checksum
64 65 66 |
# File 'lib/racket/l4/vrrp.rb', line 64 def checksum? self.checksum == compute_checksum end |
#fix! ⇒ Object
(really, just set the checksum)
74 75 76 77 78 |
# File 'lib/racket/l4/vrrp.rb', line 74 def fix! self.payload = [@ips, @authdata].flatten.pack("N#{@ips.size}a*") self.num_ips = @ips.size self.checksum! end |