packet lib: improve readability of json

this patch makes some json members of several packet libraries human-readable.

ex) ethernet.ethernet

before applying this patch:

    {'ethernet': {'ethertype': 2048, 'dst': 'ZmY6ZmY6ZmY6ZmY6ZmY6ZmY=', 'src': 'MDA6MDA6MDA6MDA6MDA6MDA='}}

after applying this patch:

    {'ethernet': {'ethertype': 2048, 'dst': u'ff:ff:ff:ff:ff:ff', 'src': u'00:00:00:00:00:00'}}

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
lib: ofctl: support the specified max_len of flow_mod

this patch makes the max_len of flow_mod message more flexible.

before applying this patch:

    ofctl_v1_0: 128 bytes for packet_in (fixed size) and none for others (fixed)
    ofctl_v1_2: 128 bytes for packet_in (fixed size) and 0 for others (fixed size)
    ofctl_v1_3: 0 for all by default (flexible)

    ofctl_v1_3 will send 0 byte length data in a packet_in message if max_len is not specified.

after applying this patch:

    all version: MAX_LEN for all by default (flexible)
    NOTE: MAX_LEN is 65535 for OF1.0, and is OFPCML_MAX for OF1.2/1.3.

    max_len is omissible by every ofctl.

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
rest_firewall: use the explicit max_len of flow_mod

rest_firewall had used the max_len value of flow_mod message which ofctl_v1_x specified.
in response to change ofctl_v1_x, rest_firewall gets to use the specified max_len explicitly.

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet.ospf: workaround a bytearray vs buffer problem

feeding bytearray to struct.unpack() crashes on some environment.
(depends on the interpreter versions?  i'm not sure.)

this fixes the following crash in the unit test.
the crash was seen on travis-ci, too.
https://travis-ci.org/osrg/ryu/jobs/15578909
https://s3.amazonaws.com/archive.travis-ci.org/jobs/15578909/log.txt

======================================================================
ERROR: test_hello (packet.test_ospf.Test_ospf)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/yamamoto/git/ryu/ryu/tests/unit/packet/test_ospf.py", line 68, in test_hello
    msg2, cls, rest = ospf.OSPFMessage.parser(binmsg)
  File "/Users/yamamoto/git/ryu/ryu/lib/packet/ospf.py", line 443, in parser
    kwargs = subcls.parser(binmsg)
  File "/Users/yamamoto/git/ryu/ryu/lib/packet/ospf.py", line 501, in parser
    n = addrconv.ipv4.bin_to_text(n)
  File "/Users/yamamoto/git/ryu/ryu/lib/addrconv.py", line 30, in bin_to_text
    return str(self._addr(self._strat.packed_to_int(bin),
  File "/Users/yamamoto/git/ryu/.venv/lib/python2.7/site-packages/netaddr/strategy/ipv4.py", line 196, in packed_to_int
    return _struct.unpack('>I', packed_int)[0]
error: unpack requires a string argument of length 4

----------------------------------------------------------------------

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
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>