PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/racket/l2/ethernet.rb

https://bitbucket.org/jrossi/metasploit
Ruby | 62 lines | 26 code | 1 blank | 35 comment | 0 complexity | ff063e691a0325dfed5a4391542fd50a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause
  1. # $Id: ethernet.rb 14 2008-03-02 05:42:30Z warchild $
  2. #
  3. # Copyright (c) 2008, Jon Hart
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. # * Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # * Neither the name of the <organization> nor the
  14. # names of its contributors may be used to endorse or promote products
  15. # derived from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY Jon Hart ``AS IS'' AND ANY
  18. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. # DISCLAIMED. IN NO EVENT SHALL Jon Hart BE LIABLE FOR ANY
  21. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. module Racket
  29. module L2
  30. # Ethernet II (DIX v2.0)
  31. #
  32. # http://en.wikipedia.org/wiki/Ethernet_II_framing
  33. class Ethernet < RacketPart
  34. ETHERTYPE_IPV4 = 0x0800
  35. ETHERTYPE_ARP = 0x0806
  36. ETHERTYPE_RARP = 0x8035
  37. ETHERTYPE_APPLETALK = 0x809b
  38. ETHERTYPE_AARP = 0x80f3
  39. ETHERTYPE_8021Q = 0x8100
  40. ETHERTYPE_IPX = 0x8137
  41. ETHERTYPE_NOVELL = 0x8138
  42. ETHERTYPE_IPV6 = 0x86DD
  43. ETHERTYPE_MPLS_UNICAST = 0x8847
  44. ETHERTYPE_MPLS_MULTICAST = 0x8848
  45. ETHERTYPE_PPPOE_DISCOVERY = 0x8863
  46. ETHERTYPE_PPPOE_SESSION = 0x8864
  47. ETHERTYPE_8021X = 0x888E
  48. ETHERTYPE_ATAOE = 0x88A2
  49. ETHERTYPE_8021AE = 0x88E5
  50. # Destination MAC address
  51. hex_octets :dst_mac, 48
  52. # Source MAC address
  53. hex_octets :src_mac, 48
  54. # Protocol of payload send with this ethernet datagram. Defaults to IPV4
  55. unsigned :ethertype, 16, { :default => ETHERTYPE_IPV4 }
  56. # Payload
  57. rest :payload
  58. end
  59. end
  60. end
  61. #set ts=2 et sw=2: vim