add TLS support

This patch supports TLS connection to encrypt OF channel.

Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: add arp constants

Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.2: fix some error constant typos

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
contrib/ovs: TypeError: bad operand type for unary -: 'NoneType'

This fixes the following exception:
When Stream.__scs_connecting doesn't change self.state, Stream.connect()
returns None as implicit return value. Thus, the following exception is raised.

conf_switch_set_handler 00003247b5e63145 ovsdb_addr tcp:172.17.60.198:6634
_ovsdb_update 00003247b5e63145 tcp:172.17.60.198:6634 172.17.60.198
_add_tunnel_ports <ryu.app.tunnel_port_updater.TunnelDP object at 0x14a5950> set([])
172.17.60.198 - - [2012-11-21 15:01:00] "PUT /v1.0/conf/switches/00003247b5e63145/ovsdb_addr HTTP/1.1" 201 120 0.267351
remote tcp:172.17.60.198:6634
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/app/tunnel_port_updater.py", line 289, in _serve_loop
    self._init()
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/app/tunnel_port_updater.py", line 125, in _init
    self.ovs_bridge.init()
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/bridge.py", line 103, in init
    self.br_name = self._get_bridge_name()
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/bridge.py", line 111, in _get_bridge_name
    self.run_command([command])
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/bridge.py", line 99, in run_command
    self.vsctl.run_command(commands, self.timeout, self.exception)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/vsctl.py", line 1006, in run_command
    self._run_command(commands)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/vsctl.py", line 999, in _run_command
    self._do_main(commands)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/vsctl.py", line 918, in _do_main
    self._init_schema_helper()
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/vsctl.py", line 805, in _init_schema_helper
    vswitch_idl.OVSREC_DB_NAME)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/lib/ovs/vsctl.py", line 793, in _rpc_get_schema_json
    error, reply = rpc.transact_block(request)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/contrib/ovs/jsonrpc.py", line 306, in transact_block
    error = self.send(request)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/contrib/ovs/jsonrpc.py", line 240, in send
    self.run()
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/contrib/ovs/jsonrpc.py", line 200, in run
    retval = self.stream.send(self.output)
  File "/home/yamahata/openvswitch/sp-lab/scarab/gre-tunnel/ryu-2/bin/ryu/contrib/ovs/stream.py", line 213, in send
    return -retval
TypeError: bad operand type for unary -: 'NoneType'
<Greenlet at 0x133fd10: <bound method TunnelDP._serve_loop of <ryu.app.tunnel_port_updater.TunnelDP object at 0x14a5950>>> failed with TypeError

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFP_OXM_EXPERIMENTER_HEADER_SIZE assert

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3.py", line 233, in <module>
  OFP_OXM_EXPERIMENTER_HEADER_SIZE) == OFP_OXM_EXPERIMENTER_HEADER_SIZE

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFP_TABLE_MOD_PACK_STR assert

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3.py", line 383, in <module>
  assert (calcsize(OFP_TABLE_MOD_PACK_STR + OFP_HEADER_SIZE) ==
TypeError: cannot concatenate 'str' and 'int' objects

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFP_METER_BAND_DSCP_REMARK_PACK_STR assert

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3.py", line 480, in <module>
  OFP_METER_BAND_DSCP_REMARK_SIZE)
AssertionError

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFP_DESC_PACK_STR

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3.py", line 533, in <module>
  DESC_STR_LEN + 'c'
TypeError: cannot concatenate 'str' and 'int' objects

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPMP_AGGREGATE

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 898, in <module>
  @_set_stats_type(ofproto_v1_3.OFPST_AGGREGATE, OFPAggregateStats)
AttributeError: 'module' object has no attribute 'OFPST_AGGREGATE'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPPortStatsReply

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 976, in <module>
  @_set_msg_type(ofproto_v1_3.OFPT_STATS_REPLY)
AttributeError: 'module' object has no attribute 'OFPT_STATS_REPLY'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPMeterConfigStatsReply

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 1246, in <module>
  @_set_stats_type(ofproto_v1_3.OFPMP_METER_CONFIG, OFPMeterCOnfigStats)
NameError: name 'OFPMeterCOnfigStats' is not defined

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPMeterFeaturesStatsRequest

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 1265, in <module>
  @_set_stats_type(ofproto_v1_3.OFPMP_METER_FEATUERS, OFPMeterFeaturesStats)
AttributeError: 'module' object has no attribute 'OFPMP_METER_FEATUERS'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPQueueProp

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 1398, in register_queue_property
  return _register_queue_property
NameError: global name '_register_queue_property' is not defined

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPSetAsyn

File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 1555, in <module>
  @_set_msg_type(ofproto_v1_3.OFPT_SET_ASYNC)
AttributeError: 'module' object has no attribute 'OFPT_SET_ASYNC'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPPacketQueue

  File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_3_parser.py", line 2649, in OFPPacketQueue
    @clasmethod
NameError: name 'clasmethod' is not defined

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Add workaround to switch_features_handler for OF1.3

hacky workaround, will be removed. OF1.3 doesn't have ports. An
application should not depend on them. But there might be such bad
applications so let's keep this workaround for while.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: support OFPMatch

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix OFPMP_FLOW

FlowStats works now.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
enable OF1.3 support

Ryu sucessfully connects to CPqD OF1.3 switch.

https://github.com/CPqD/ofsoftswitch13

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_0: update and clean up

- add ip match support
- add match_to_str() and actions_to_str() instead of action_to_str()

Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>