pio 0.15.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhito Takamiya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -439,6 +439,7 @@ files:
439
439
  - features/step_definitions/packet_data_steps.rb
440
440
  - features/step_definitions/pending_steps.rb
441
441
  - features/support/env.rb
442
+ - features/udp_read.feature
442
443
  - lib/pio.rb
443
444
  - lib/pio/arp.rb
444
445
  - lib/pio/arp/format.rb
@@ -453,7 +454,6 @@ files:
453
454
  - lib/pio/dhcp/boot_request_options.rb
454
455
  - lib/pio/dhcp/client_id.rb
455
456
  - lib/pio/dhcp/common_options.rb
456
- - lib/pio/dhcp/csum_util.rb
457
457
  - lib/pio/dhcp/dhcp_field.rb
458
458
  - lib/pio/dhcp/dhcp_tlv_options.rb
459
459
  - lib/pio/dhcp/discover.rb
@@ -466,6 +466,7 @@ files:
466
466
  - lib/pio/dhcp/request.rb
467
467
  - lib/pio/echo.rb
468
468
  - lib/pio/enqueue.rb
469
+ - lib/pio/ethernet_header.rb
469
470
  - lib/pio/exact_match.rb
470
471
  - lib/pio/features.rb
471
472
  - lib/pio/flow_mod.rb
@@ -477,6 +478,7 @@ files:
477
478
  - lib/pio/icmp/reply.rb
478
479
  - lib/pio/icmp/request.rb
479
480
  - lib/pio/ipv4_address.rb
481
+ - lib/pio/ipv4_header.rb
480
482
  - lib/pio/lldp.rb
481
483
  - lib/pio/lldp/chassis_id_tlv.rb
482
484
  - lib/pio/lldp/end_of_lldpdu_value.rb
@@ -507,6 +509,7 @@ files:
507
509
  - lib/pio/packet_in.rb
508
510
  - lib/pio/packet_out.rb
509
511
  - lib/pio/parse_error.rb
512
+ - lib/pio/payload.rb
510
513
  - lib/pio/pcap.rb
511
514
  - lib/pio/port_status.rb
512
515
  - lib/pio/send_out_port.rb
@@ -518,11 +521,10 @@ files:
518
521
  - lib/pio/set_vlan_priority.rb
519
522
  - lib/pio/set_vlan_vid.rb
520
523
  - lib/pio/strip_vlan_header.rb
521
- - lib/pio/type/ethernet_header.rb
522
524
  - lib/pio/type/ip_address.rb
523
- - lib/pio/type/ipv4_header.rb
524
525
  - lib/pio/type/mac_address.rb
525
- - lib/pio/type/udp_header.rb
526
+ - lib/pio/udp.rb
527
+ - lib/pio/udp_header.rb
526
528
  - lib/pio/version.rb
527
529
  - pio.gemspec
528
530
  - spec/pio/arp/reply/options_spec.rb
@@ -587,108 +589,109 @@ required_rubygems_version: !ruby/object:Gem::Requirement
587
589
  version: '0'
588
590
  requirements: []
589
591
  rubyforge_project:
590
- rubygems_version: 2.4.3
592
+ rubygems_version: 2.4.6
591
593
  signing_key:
592
594
  specification_version: 4
593
595
  summary: Packet parser and generator.
594
596
  test_files:
595
- - spec/pio/set_eth_src_addr_spec.rb
596
- - spec/pio/features/request_spec.rb
597
- - spec/pio/features/reply_spec.rb
598
- - spec/pio/set_vlan_vid_spec.rb
599
- - spec/pio/set_transport_dst_port_spec.rb
600
- - spec/pio/strip_vlan_header_spec.rb
601
- - spec/pio/ipv4_address_spec.rb
602
- - spec/pio/open_flow/type_spec.rb
603
- - spec/pio/open_flow/phy_port_spec.rb
604
- - spec/pio/enqueue_spec.rb
605
- - spec/pio/hello_spec.rb
606
- - spec/pio/set_ip_src_addr_spec.rb
607
- - spec/pio/dhcp/request_spec.rb
608
- - spec/pio/dhcp/offer_spec.rb
609
- - spec/pio/dhcp/ack_spec.rb
610
- - spec/pio/dhcp/discover_spec.rb
611
- - spec/pio/set_transport_src_port_spec.rb
612
- - spec/pio/arp/request_spec.rb
613
597
  - spec/pio/arp/reply/options_spec.rb
614
- - spec/pio/arp/request/options_spec.rb
615
598
  - spec/pio/arp/reply_spec.rb
599
+ - spec/pio/arp/request/options_spec.rb
600
+ - spec/pio/arp/request_spec.rb
601
+ - spec/pio/arp_spec.rb
602
+ - spec/pio/dhcp/ack_spec.rb
603
+ - spec/pio/dhcp/discover_spec.rb
604
+ - spec/pio/dhcp/offer_spec.rb
605
+ - spec/pio/dhcp/request_spec.rb
606
+ - spec/pio/dhcp_spec.rb
607
+ - spec/pio/echo/reply_spec.rb
608
+ - spec/pio/echo/request_spec.rb
609
+ - spec/pio/enqueue_spec.rb
610
+ - spec/pio/features/reply_spec.rb
611
+ - spec/pio/features/request_spec.rb
616
612
  - spec/pio/flow_mod_spec.rb
617
- - spec/pio/lldp/options_spec.rb
618
- - spec/pio/set_vlan_priority_spec.rb
619
- - spec/pio/set_ip_dst_addr_spec.rb
620
- - spec/pio/mac_spec.rb
621
- - spec/pio/icmp/request_spec.rb
613
+ - spec/pio/hello_spec.rb
622
614
  - spec/pio/icmp/reply_spec.rb
615
+ - spec/pio/icmp/request_spec.rb
623
616
  - spec/pio/icmp_spec.rb
624
- - spec/pio/wildcards_spec.rb
625
- - spec/pio/dhcp_spec.rb
626
- - spec/pio/set_ip_tos_spec.rb
627
- - spec/pio/send_out_port_spec.rb
628
- - spec/pio/packet_in_spec.rb
617
+ - spec/pio/ipv4_address_spec.rb
618
+ - spec/pio/lldp/options_spec.rb
629
619
  - spec/pio/lldp_spec.rb
630
- - spec/pio/arp_spec.rb
631
- - spec/pio/echo/request_spec.rb
632
- - spec/pio/echo/reply_spec.rb
633
- - spec/pio/set_eth_dst_addr_spec.rb
620
+ - spec/pio/mac_spec.rb
634
621
  - spec/pio/match_spec.rb
622
+ - spec/pio/open_flow/phy_port_spec.rb
623
+ - spec/pio/open_flow/type_spec.rb
624
+ - spec/pio/packet_in_spec.rb
635
625
  - spec/pio/packet_out_spec.rb
626
+ - spec/pio/send_out_port_spec.rb
627
+ - spec/pio/set_eth_dst_addr_spec.rb
628
+ - spec/pio/set_eth_src_addr_spec.rb
629
+ - spec/pio/set_ip_dst_addr_spec.rb
630
+ - spec/pio/set_ip_src_addr_spec.rb
631
+ - spec/pio/set_ip_tos_spec.rb
632
+ - spec/pio/set_transport_dst_port_spec.rb
633
+ - spec/pio/set_transport_src_port_spec.rb
634
+ - spec/pio/set_vlan_priority_spec.rb
635
+ - spec/pio/set_vlan_vid_spec.rb
636
+ - spec/pio/strip_vlan_header_spec.rb
637
+ - spec/pio/wildcards_spec.rb
636
638
  - spec/spec_helper.rb
639
+ - features/arp_read.feature
640
+ - features/dhcp_read.feature
641
+ - features/echo_read.feature
642
+ - features/exact_match.feature
643
+ - features/features_read.feature
644
+ - features/flow_mod_read.feature
637
645
  - features/hello_read.feature
638
- - features/support/env.rb
646
+ - features/icmp_read.feature
647
+ - features/lldp_read.feature
648
+ - features/packet_data/aggregate_stats_reply.raw
649
+ - features/packet_data/aggregate_stats_request.raw
650
+ - features/packet_data/arp-storm.pcap
651
+ - features/packet_data/arp.pcap
652
+ - features/packet_data/barrier_reply.raw
653
+ - features/packet_data/barrier_request.raw
639
654
  - features/packet_data/desc_stats_reply.raw
655
+ - features/packet_data/desc_stats_request.raw
640
656
  - features/packet_data/dhcp.pcap
641
657
  - features/packet_data/echo_reply.raw
642
- - features/packet_data/flow_mod_modify_strict.raw
643
- - features/packet_data/flow_mod_add.raw
658
+ - features/packet_data/echo_request.raw
659
+ - features/packet_data/error.raw
644
660
  - features/packet_data/features_reply.raw
645
- - features/packet_data/aggregate_stats_reply.raw
646
- - features/packet_data/queue_get_config_reply.raw
647
- - features/packet_data/arp.pcap
648
661
  - features/packet_data/features_request.raw
649
- - features/packet_data/flow_stats_request.raw
650
- - features/packet_data/packet_in_arp_request.raw
651
- - features/packet_data/port_stats_request.raw
662
+ - features/packet_data/flow_mod_add.raw
663
+ - features/packet_data/flow_mod_delete.raw
652
664
  - features/packet_data/flow_mod_delete_strict.raw
653
- - features/packet_data/barrier_reply.raw
654
- - features/packet_data/get_config_request.raw
655
- - features/packet_data/vendor.raw
656
- - features/packet_data/port_mod.raw
665
+ - features/packet_data/flow_mod_modify.raw
666
+ - features/packet_data/flow_mod_modify_strict.raw
667
+ - features/packet_data/flow_removed.raw
668
+ - features/packet_data/flow_stats_reply.raw
669
+ - features/packet_data/flow_stats_request.raw
657
670
  - features/packet_data/get_config_reply.raw
658
- - features/packet_data/lldp.minimal.pcap
671
+ - features/packet_data/get_config_request.raw
659
672
  - features/packet_data/hello.raw
660
- - features/packet_data/flow_removed.raw
661
- - features/packet_data/set_config.raw
662
- - features/packet_data/port_stats_reply.raw
663
- - features/packet_data/packet_out.raw
664
- - features/packet_data/table_stats_reply.raw
673
+ - features/packet_data/icmp.pcap
674
+ - features/packet_data/lldp.detailed.pcap
675
+ - features/packet_data/lldp.minimal.pcap
676
+ - features/packet_data/packet_in_arp_request.raw
665
677
  - features/packet_data/packet_in_cbench.raw
678
+ - features/packet_data/packet_out.raw
679
+ - features/packet_data/port_mod.raw
680
+ - features/packet_data/port_stats_reply.raw
681
+ - features/packet_data/port_stats_request.raw
682
+ - features/packet_data/port_status.raw
683
+ - features/packet_data/queue_get_config_reply.raw
666
684
  - features/packet_data/queue_get_config_request.raw
667
- - features/packet_data/error.raw
668
- - features/packet_data/vendor_stats_request.raw
669
- - features/packet_data/icmp.pcap
670
- - features/packet_data/arp-storm.pcap
671
- - features/packet_data/flow_stats_reply.raw
672
- - features/packet_data/desc_stats_request.raw
673
- - features/packet_data/barrier_request.raw
685
+ - features/packet_data/set_config.raw
686
+ - features/packet_data/table_stats_reply.raw
674
687
  - features/packet_data/table_stats_request.raw
675
- - features/packet_data/port_status.raw
676
- - features/packet_data/flow_mod_modify.raw
677
- - features/packet_data/flow_mod_delete.raw
678
- - features/packet_data/lldp.detailed.pcap
679
- - features/packet_data/aggregate_stats_request.raw
680
- - features/packet_data/echo_request.raw
681
- - features/exact_match.feature
682
- - features/icmp_read.feature
688
+ - features/packet_data/vendor.raw
689
+ - features/packet_data/vendor_stats_request.raw
690
+ - features/packet_in_read.feature
691
+ - features/packet_out_read.feature
683
692
  - features/port_status_read.feature
684
- - features/arp_read.feature
685
- - features/step_definitions/pending_steps.rb
686
693
  - features/step_definitions/packet_data_steps.rb
687
- - features/flow_mod_read.feature
688
- - features/lldp_read.feature
689
- - features/dhcp_read.feature
690
- - features/features_read.feature
691
- - features/packet_out_read.feature
692
- - features/packet_in_read.feature
693
- - features/echo_read.feature
694
+ - features/step_definitions/pending_steps.rb
695
+ - features/support/env.rb
696
+ - features/udp_read.feature
694
697
  has_rdoc:
@@ -1,81 +0,0 @@
1
- module Pio
2
- class Dhcp
3
- # Checksum Calculate Utility.
4
- module CsumUtil
5
- private
6
-
7
- def ip_csum
8
- ipv4_header_2bytewise_slices.reduce(:+)
9
- end
10
-
11
- def udp_csum
12
- udp_header_2bytewise_slices.reduce(:+)
13
- end
14
-
15
- def ipv4_header_2bytewise_slices
16
- [
17
- ipversion_ipheaderlength_iptypeofservice, ip_total_length,
18
- ip_identifier, ipflag_ipfragment,
19
- ipttl_ipproto,
20
- ip_source_address_upper,
21
- ip_source_address_lower,
22
- ip_destination_address_upper,
23
- ip_destination_address_lower
24
- ]
25
- end
26
-
27
- def ip_source_address_upper
28
- ip_source_address.get.to_i >> 16
29
- end
30
-
31
- def ip_source_address_lower
32
- ip_source_address.get.to_i & 0xffff
33
- end
34
-
35
- def ip_destination_address_upper
36
- ip_destination_address.get.to_i >> 16
37
- end
38
-
39
- def ip_destination_address_lower
40
- ip_destination_address.get.to_i & 0xffff
41
- end
42
-
43
- def ipversion_ipheaderlength_iptypeofservice
44
- ip_version << 12 | ip_header_length << 8 | ip_type_of_service
45
- end
46
-
47
- def ipflag_ipfragment
48
- ip_flag << 13 | ip_fragment
49
- end
50
-
51
- def ipttl_ipproto
52
- ip_ttl << 8 | ip_protocol
53
- end
54
-
55
- def udp_header_2bytewise_slices
56
- [
57
- pseudo_header_2bytewise_slices,
58
- udp_src_port,
59
- udp_dst_port,
60
- udp_len,
61
- payload_2bytewise_slices
62
- ]
63
- end
64
-
65
- def payload_2bytewise_slices
66
- (dhcp.to_binary_s + trail_data).unpack('n*').reduce(:+)
67
- end
68
-
69
- def pseudo_header_2bytewise_slices
70
- [
71
- ip_source_address_upper,
72
- ip_source_address_lower,
73
- ip_destination_address_upper,
74
- ip_destination_address_lower,
75
- ip_protocol,
76
- udp_len
77
- ].pack('n*').unpack('n*').reduce(:+)
78
- end
79
- end
80
- end
81
- end
@@ -1,43 +0,0 @@
1
- require 'pio/type/mac_address'
2
-
3
- module Pio
4
- module Type
5
- # Adds ethernet_header macro.
6
- module EthernetHeader
7
- # rubocop:disable MethodLength
8
- # rubocop:disable AbcSize
9
- def ethernet_header(options = { ether_type: 0x0800 })
10
- class_eval do
11
- mac_address :destination_mac
12
- mac_address :source_mac
13
- uint16 :ether_type_internal, initial_value: options[:ether_type]
14
-
15
- bit3 :vlan_pcp_internal, onlyif: -> { vlan? }
16
- bit1 :vlan_cfi, onlyif: -> { vlan? }
17
- bit12 :vlan_vid_internal, onlyif: -> { vlan? }
18
-
19
- uint16 :ether_type_vlan, onlyif: -> { vlan? },
20
- initial_value: options[:ether_type]
21
-
22
- def ether_type
23
- ether_type_internal
24
- end
25
-
26
- def vlan_vid
27
- vlan? ? vlan_vid_internal : 0xffff
28
- end
29
-
30
- def vlan_pcp
31
- vlan? ? vlan_pcp_internal : 0
32
- end
33
-
34
- def vlan?
35
- ether_type == 0x8100
36
- end
37
- end
38
- end
39
- # rubocop:enable MethodLength
40
- # rubocop:enable AbcSize
41
- end
42
- end
43
- end
@@ -1,33 +0,0 @@
1
- require 'pio/type/ip_address'
2
-
3
- module Pio
4
- module Type
5
- # IP Version 4 Header Format
6
- module IPv4Header
7
- # This method smells of :reek:TooManyStatements
8
- # rubocop:disable MethodLength
9
- # rubocop:disable AbcSize
10
- def ipv4_header(options = {})
11
- class_eval do
12
- bit4 :ip_version, initial_value: 0x4
13
- bit4 :ip_header_length, initial_value: 0x5
14
- uint8 :ip_type_of_service, initial_value: 0
15
- uint16be :ip_total_length,
16
- initial_value: options[:ip_total_length] || 0
17
- uint16be :ip_identifier, initial_value: 0
18
- bit3 :ip_flag, initial_value: 0
19
- bit13 :ip_fragment, initial_value: 0
20
- uint8 :ip_ttl, initial_value: 128
21
- uint8 :ip_protocol, initial_value: options[:ip_protocol] || 0
22
- uint16be :ip_header_checksum,
23
- initial_value: options[:ip_header_checksum] || 0
24
- ip_address :ip_source_address
25
- ip_address :ip_destination_address
26
- string :option, read_length: -> { 20 - ip_header_length * 4 }
27
- end
28
- end
29
- # rubocop:enable AbcSize
30
- # rubocop:enable MethodLength
31
- end
32
- end
33
- end
@@ -1,15 +0,0 @@
1
- module Pio
2
- module Type
3
- # UDP Header Format.
4
- module UdpHeader
5
- def udp_header(options)
6
- class_eval do
7
- uint16be :udp_src_port
8
- uint16be :udp_dst_port
9
- uint16be :udp_length, initial_value: options[:udp_length]
10
- uint16be :udp_checksum, initial_value: options[:udp_checksum]
11
- end
12
- end
13
- end
14
- end
15
- end