Class: Dap::Filter::FilterDecodePortmapperReply
- Inherits:
-
Object
- Object
- Dap::Filter::FilterDecodePortmapperReply
- Includes:
- BaseDecoder
- Defined in:
- lib/dap/filter/udp.rb
Constant Summary collapse
- ID_TO_PROTOCOL =
{ 0=>"ip", 1=>"icmp", 2=>"igmp", 3=>"ggp", 4=>"ipencap", 5=>"st", 6=>"tcp", 8=>"egp", 9=>"igp", 12=>"pup", 17=>"udp", 20=>"hmp", 22=>"xns-idp", 27=>"rdp", 29=>"iso-tp4", 33=>"dccp", 36=>"xtp", 37=>"ddp", 38=>"idpr-cmtp", 41=>"ipv6", 43=>"ipv6-route", 44=>"ipv6-frag", 45=>"idrp", 46=>"rsvp", 47=>"gre", 50=>"esp", 51=>"ah", 57=>"skip", 58=>"ipv6-icmp", 59=>"ipv6-nonxt", 60=>"ipv6-opts", 73=>"rspf", 81=>"vmtp", 88=>"eigrp", 89=>"ospf", 93=>"ax.25", 94=>"ipip", 97=>"etherip", 98=>"encap", 103=>"pim", 108=>"ipcomp", 112=>"vrrp", 115=>"l2tp", 124=>"isis", 132=>"sctp", 133=>"fc", 135=>"mobility-header", 136=>"udplite", 137=>"mpls-in-ip", 138=>"manet", 139=>"hip", 140=>"shim6", 141=>"wesp", 142=>"rohc" }
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #decode(data) ⇒ Object
-
#parse_data(data) ⇒ Object
returns array of program-version-protocol-port strings for each rpc service.
Methods included from BaseDecoder
Methods included from Base
Instance Method Details
#decode(data) ⇒ Object
635 636 637 |
# File 'lib/dap/filter/udp.rb', line 635 def decode(data) { 'rpc_services'=>parse_data(data) } end |
#parse_data(data) ⇒ Object
returns array of program-version-protocol-port strings for each rpc service
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/dap/filter/udp.rb', line 611 def parse_data(data) ret = [] # Skip past header that contains no rpc services stripped = data[8..-1] curr_pos = 0 has_next = ( !stripped.nil? && stripped.length >= 8 ? stripped[curr_pos,8].to_i(16) : 0 ) curr_pos +=8 while has_next > 0 # See if enough data present for next set of reads. if data.length > curr_pos+40 prog_id = stripped[curr_pos,8].to_i(16); curr_pos+=8 version = stripped[curr_pos,8].to_i(16); curr_pos += 8 proto_id = stripped[curr_pos,8].to_i(16); curr_pos+=8 protocol = ID_TO_PROTOCOL[ proto_id ] || "proto-#{proto_id}" port = stripped[curr_pos,8].to_i(16); curr_pos += 8 ret << "#{prog_id}-v#{version}-#{protocol}-#{port}" if prog_id > 0 has_next = stripped[curr_pos,8].to_i(16); curr_pos += 8 else break end end ret end |