| 54 | | |
|---|
| | 54 | |
|---|
| | 55 | # Dissector for ARP |
|---|
| | 56 | class ARP<Layer |
|---|
| | 57 | Scruby.register_dissector(self) |
|---|
| | 58 | def method_missing(method, *args) |
|---|
| | 59 | return Scruby.field(method, *args) |
|---|
| | 60 | end |
|---|
| | 61 | |
|---|
| | 62 | attr_accessor :hw_type, :ptype, :hwlen, :plen, :op, :hwsrc, :psrc, :pdst, :hwdst, :pdst |
|---|
| | 63 | |
|---|
| | 64 | @@request = {"who-has"=>1, "is-at"=>2, "RARP-req"=>3, "RARP-rep"=>4, |
|---|
| | 65 | "Dyn-RARP-req"=>5, "Dyn-RAR-rep"=>6, "Dyn-RARP-err"=>7, |
|---|
| | 66 | "InARP-req"=>8, "InARP-rep"=>9} |
|---|
| | 67 | |
|---|
| | 68 | def init |
|---|
| | 69 | @protocol = 'ARP' |
|---|
| | 70 | @fields_desc = [ XShortField("hwtype", 0x0001), |
|---|
| | 71 | XShortEnumField("ptype", ETHERTYPE_IPv4, ETHERTYPE_ALL), |
|---|
| | 72 | ByteField("hwlen", 6), |
|---|
| | 73 | ByteField("plen", 4), |
|---|
| | 74 | ShortField("op", @@request["who-has"]), |
|---|
| | 75 | MACField("hwsrc", '00:00:00:00:00:00'), |
|---|
| | 76 | IPField("psrc", '127.0.0.1'), |
|---|
| | 77 | MACField("hwdst", '00:00:00:00:00:00'), |
|---|
| | 78 | IPField("pdst", '127.0.0.1') ] |
|---|
| | 79 | end |
|---|
| | 80 | |
|---|
| | 81 | def pre_send(underlayer, payload) |
|---|
| | 82 | if underlayer.is_a?(Ether) |
|---|
| | 83 | underlayer.type = ETHERTYPE_ARP |
|---|
| | 84 | end |
|---|
| | 85 | end |
|---|
| | 86 | end |
|---|
| | 87 | |
|---|
| | 88 | |
|---|