PageRenderTime 36ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/ipv6

https://github.com/bahoom/racket
Ruby | 35 lines | 23 code | 7 blank | 5 comment | 1 complexity | f68f3259ebd90381795999fe1725bd05 MD5 | raw file
  1. #!/usr/bin/env ruby
  2. #
  3. # $Id$
  4. #
  5. require 'rubygems'
  6. require 'racket'
  7. include Racket
  8. unless (ARGV.size == 2)
  9. puts "Usage: #{$0} <srcip> <dstip>"
  10. exit
  11. end
  12. n = Racket::Racket.new
  13. n.iface = "eth0"
  14. n.l2 = L2::Ethernet.new(Misc.randstring(14))
  15. n.l2.ethertype = 0x86DD
  16. n.l3 = L3::IPv6.new
  17. n.l3.src_ip = L3::Misc.ipv62long(ARGV[0])
  18. n.l3.dst_ip = L3::Misc.ipv62long(ARGV[1])
  19. n.l3.nhead = 17
  20. n.l4 = L4::UDP.new
  21. n.l4.src_port = 12345
  22. n.l4.dst_port = 123
  23. n.l4.fix!(n.l3.src_ip, n.l3.dst_ip)
  24. f = n.sendpacket
  25. n.layers.compact.each do |l|
  26. puts l.pretty
  27. end
  28. #puts "Sent #{f}"