| Class | Racket::L4::ICMPv6Generic |
| In: |
lib/racket/l4/icmpv6.rb
(CVS)
|
| Parent: | RacketPart |
| ICMPv6_TYPE_ECHO_REPLY | = | 129 |
| ICMPv6_TYPE_DESTINATION_UNREACHABLE | = | 1 |
| ICMPv6_TYPE_PACKET_TOO_BIG | = | 2 |
| ICMPv6_TYPE_ECHO_REQUEST | = | 128 |
| ICMPv6_TYPE_TIME_EXCEEDED | = | 3 |
| ICMPv6_TYPE_PARAMETER_PROBLEM | = | 4 |
| ICMPv6_TYPE_MLD_QUERY | = | 130 |
| ICMPv6_TYPE_MLD_REPORT | = | 131 |
| ICMPv6_TYPE_MLD_DONE | = | 132 |
| ICMPv6_TYPE_ROUTER_SOLICITATION | = | 133 |
| ICMPv6_TYPE_ROUTER_ADVERTISEMENT | = | 134 |
| ICMPv6_TYPE_NEIGHBOR_SOLICITATION | = | 135 |
| ICMPv6_TYPE_NEIGHBOR_ADVERTISEMENT | = | 136 |
| ICMPv6_TYPE_REDIRECT | = | 137 |
| ICMPv6_TYPE_INFORMATION_REQUEST | = | 139 |
| ICMPv6_TYPE_INFORMATION_REPLY | = | 140 |
| checksum | Checksum | |
| code | Code | |
| message | ||
| type | Type |
Add an ICMPv6 option. RFC claims that the value should be padded (with what?) to land on a 64-bit boundary, however that doesn‘t always appear to be the case. so, yeah, try to pad on your own or pick strings that are multiples of 8 characters
# File lib/racket/l4/icmpv6.rb, line 74 def add_option(type, value) t = Racket::Misc::TLV.new(1,1) t.type = type t.length = (value.length + 2) / 8 just = value.length + 2 + (8 - ((value.length + 2) % 8)) t.value = (value.length + 2) % 8 == 0 ? value : value.ljust(just, "\x00") self.payload = t.encode + self.payload end
ignorantly assume the first parts of the payload contain ICMPv6 options and find a return an array of Racket::Misc::TLV representing the options
# File lib/racket/l4/icmpv6.rb, line 85 def get_options p = self.payload options = [] until ((o = Racket::Misc::TLV.new(1,1,8,true).decode(p)).nil?) options << o[0..2] p = o[3] end options end
get the source link layer address of this message, if found
# File lib/racket/l4/icmpv6.rb, line 107 def slla addr = nil self.get_options.each do |o| type, length, value, rest = o.flatten if (type == 1) addr = L2::Misc.string2mac(value) end end addr end
set the source link layer address of this message. expects addr in de:ad:ba:dc:af:e0 form
# File lib/racket/l4/icmpv6.rb, line 120 def slla=(addr) self.add_option(1, L2::Misc.mac2string(addr)) end
get the target link layer address of this message, if found
# File lib/racket/l4/icmpv6.rb, line 125 def tlla addr = nil self.get_options.each do |o| type, length, value, rest = o.flatten if (type == 2) addr = L2::Misc.string2mac(value) end end addr end