Class: Racket::L4::VRRP

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

Overview

Instance Attribute Summary

Attributes inherited from RacketPart

#autofix

Instance Method Summary collapse

Methods inherited from RacketPart

#autofix?, #pretty

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

Returns:

  • (Boolean)


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