ofctl_v1_3: support metadata

Support metadata in FlowMod instructions and match.

both a decimal number and a hexadecimal number are able to use in 'metadata' and 'metadata_mask'.
all the following examples express the same flow entry.

flow = {'match': {'metadata': '12345/4095'},
        'actions': [{'type': 'WRITE_METADATA',
                     'metadata': '12345',
                     'metadata_mask': '4095'}]}

flow = {'match': {'metadata': '12345/4095'},
        'actions': [{'type': 'WRITE_METADATA',
                     'metadata': 12345,
                     'metadata_mask': 4095}]}

flow = {'match': {'metadata': '0x3039/0xfff'},
        'actions': [{'type': 'WRITE_METADATA',
                     'metadata': '0x3039',
                     'metadata_mask': '0xfff'}]}

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_3: support meter

Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.

see following examples.

FlowMod with the meter instruction:

    flow = {'match': {},
            'actions': [{'type': 'METER',
                         'meter_id': 1}]
    curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add

MeterMod:

    meter = {'meter_id': 1,
             'flags': 'KBPS',
             'bands': [{'type': 'DROP',
                        'rate': 1000}]}
    curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add

    NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
          type: 'DROP', 'REMARK', 'EXPERIMENTER'

MeterStats:

    curl http://localhost:8080/stats/meter/1

MetetFeatures:

    curl http://localhost:8080/stats/meterfeatures/1

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
topology: add of13 support

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_3: correct MeterStats and MeterFeatures

- add the insufficient handlers
- correct the using instance

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_3: fix match for metadata

also use the default priority for FlowMod.

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_3: support OFPMeterConfigStats

Changes v2 -> v3:

- correct the following description

this patch implements a REST API for OFPMeterConfigStats.

e.g., when you send a MeterMod message as:

    curl -X POST -d '{"dpid": 1,
                      "meter_id": 1,
                      "flags": "KBPS",
                      "bands": [{"type": "DROP", "rate": 1000},
                                {"type": "REMARK", "rate": 2000},
                                {"type": "EXPERIMENTER", "rate": 3000}
                      ]}' http://localhost:8080/stats/meterentry/add

and you do the following command:

    curl http://localhost:8080/stats/meterconfig/1

then you will get the configuration as:

    {"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
                      {"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
                      {"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
            "flags": "KBPS",
            "meter_id": 1}]}

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
oxm_fields: make a crash less cryptic

when oxm length is not what we expect, explicitly raise an exception
with descriptive message like the following.

    Exception: Unexpected OXM payload length 3 for ipv6_flabel (expected 4)

This often happens if you are using LINC and IPv6.
https://github.com/FlowForwarding/of_protocol/pull/57

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
requires lxml

will be used for OF-Config stuff.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
add some convenient OF-Config classes

some python classes for a set of OF-Config 1.1.1 types.

the goal is to allow programmers use OF-Config without direct
XML manipulations.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config.capable_switch: api tweak

tweak method to take of_config.classes classes instead of xml.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
tests.integrated.test_of_config: update after capable_switch api change

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config.capable_switch: add delete_config and copy_config

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
a simple of-config client command

the placement (ryu/tests/bin) was suggested by FUJITA Tomonori.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config_cli: add delete_config and copy_config

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config_cli: add add_queue command

totally untested as i have no access to switches which support
the operation.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config: allows both of of-config element names and python style names

for convenience of api consumers, allows both of of-config style
element names (eg. logical-switches) and python style attribute
names (eg. logical_switches).

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of_config_cli: remove no longer necessary "_pythonify" stuff

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_rest: support OpenFlow1.2

this patch makes ofctl_rest enable use of OpenFlow1.2.

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
ofctl_v1_2/3: support OXM field names

this patch gets match field names to support OXM field names.

NOTE: OpenFlow1.0 does not support OXM field names.

the compatibility is as follows:

  dl_src    eth_src
  dl_dst    eth_dst
  dl_type   eth_type
  dl_vlan   vlan_vid
  nw_src    ipv4_src
  nw_dst    ipv4_dst
  nw_proto  ip_proto
  tp_src    tcp_src or udp_src
  tp_dst    tcp_dst or udp_dst

for example, the following commands for ofctl_rest install the same flow entry.

curl -X POST -d '{"dpid": 1,
                  "match": {"dl_type": 2048,
                            "nw_src": "192.168.1.1"},
                  "actions": [{"type": "OUTPUT",
                               "port": 2}]}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{"dpid": 1,
                  "match": {"eth_type": 2048,
                            "ipv4_src": 192.168.1.1"},
                  "actions": [{"type": "OUTPUT",
                               "port": 2}]}' http://localhost:8080/stats/flowentry/add

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
ofctl_v1_2/3: support IPv6

this patch implements the match conditions using IPv6.

NOTE: OpenFlow1.0 does not support IPv6.

e.g. using ofctl_rest)

curl -X POST -d '{"dpid": 1,
                  "match": {"eth_type": 34525,
                            "ipv6_src": "fe08:2001::/64",
                            "ipv6_dst": "ff02::1"},
                  "actions": [{"type": "OUTPUT",
                               "port": 2}]}' http://localhost:8080/stats/flowentry/add

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>