Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create OFP1.3 match fields. #12

Open
nickkaranatsios opened this issue Jan 21, 2013 · 2 comments
Open

create OFP1.3 match fields. #12

nickkaranatsios opened this issue Jan 21, 2013 · 2 comments
Assignees

Comments

@nickkaranatsios
Copy link
Member

A packet can be matched against the following fields:

  • InPort - input port
  • InPhyPort - input physical port
  • Metadata - any 64-bit data
  • EthDst - ethernet destination address
  • EthSrc - ethernet source address
  • EthType - ethernet type
  • VlanVid - VLAN VID
  • VlanPriority - VLAN priority
  • IpDscp - Diffserv code point
  • IpEcn - refers to IP ECN value
  • IPProto - IP proto field
  • IPv4SrcAddr - IPv4 source address
  • IPv4DstAddr - IPv4 destination address
  • TcpSrcPort - Source port for TCP and ICMP
  • TcpDstPort - Destination port for TCP and ICMP
  • UdpSrcPort - UDP source port
  • UdpDstPort - UDP destination port
  • SctpSrcPort - SCTP source port
  • SctpDstPort - SCTP destination port
  • Icmpv4Type - ICMPv4 type
  • Icmpv4Code - ICMPv4 code
  • ArpOp - ARP opcode
  • ArpSpa - ARP source protocol address
  • ArpTpa - ARP target protocol address
  • ArpSha - ARP source hardware (MAC) address
  • ArpTha - ARP target hardware (MAC) address
  • Ipv6Src - IPv6 source address
  • Ipv6Dst - IPv6 destination address
  • IPv6FlowLabel - IPv6 flow label
  • ICMPv6Type - ICMPv6 type
  • ICMPv6Code - ICMPv6 code
  • IPv6NdTarget - IPv6 neighbor target address
  • IPv6NdSll - IPv6 neighbor source link layer address
  • IPv6NdTll - IPv6 neighbor target link layer address
  • MplsLabel - Mpls Label
  • MplsBos - MPLS Bottom of Stack( 1 bit )
  • TunnelId - Tunnel-id
  • IPv6ExtHdr - IPv6 extension header

Define a class for each action set using ruby and can append those actions to openflow_actions by calling append_action_set_field_xxx. Where xxx would be the instance variable of each action, For example append_action_set_field_in_port. This results into a long else if statement to check for the type of action set to set.

@ghost ghost assigned nickkaranatsios Jan 21, 2013
@yasuhito
Copy link
Member

👍

@nickkaranatsios
Copy link
Member Author

Declare a class for each match field.

require "trema/action"


module Trema
  #
  # Creates an match field that matches the input port.
  #
  class MatchInPort < Action
    include MatchSet


    def initialize in_port
      validate_create :in_port, :presence => true, :validate_with => "check_unsigned_int", :value => in_port
    end


    def append_match actions
      append_match_in_port actions, @in_port
    end
  end
end

The MatchSet included module enables us to append the match field into actions and is implemented in c. It also loads (requires) each match field object at initialization. The method append_match_in_port is found in match-set.c and is basically a single line of code that appends this match field. (append_action_set_field_in_port( openflow_actions_ptr( r_actions ), NUM2UINT( in_port ) ); Have to think what else can refactor from above class.
Hide the include MatchSet statement. The current version of match-in-port looks like the following:

require "trema/match-field"


module Trema
  #
  # Creates an match field that matches the input port.
  #
  class MatchInPort < MatchField
    def initialize in_port
      validate_create :in_port, :presence => true, :validate_with => "check_unsigned_int", :value => in_port
    end


    def append_match actions
      append_match_in_port actions, @in_port
    end
  end
end

Basically a match in-port is kind of a match field that exposes the methods implemented by modules MatchSet and ActionHelper

Further refactor above match field class. Move the append_match actions method to MatchField class and dynamically create and call the append_match_xxx method. The above class now looks like:

require "trema/match-field"


module Trema
  #
  # A match field to match an input port
  #
  class MatchInPort < MatchField
    def initialize in_port
      validate_create :in_port, :presence => true, :validate_with => "check_unsigned_int", :value => in_port
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants