build.backends.of_parser.process_packet_in()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 16
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 16
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
crap 2
1
"""
2
    Module to transparently process OpenFlow requests,
3
"""
4
5
6 1
import napps.amlight.sdntrace.backends.openflow13 as openflow13
7 1
from kytos.core import log
8
9
10 1
def process_packet_in(event):
11
    """
12
13
    Args:
14
        event
15
    Return:
16
        ethernet: frame
17
        in_port: incoming port
18
        switch: incoming switch
19
    """
20 1
    of_version = event.content['message'].header.version
21 1
    if of_version.value == 4:
22 1
        return openflow13.packet_in(event, event.content['message'])
23
24 1
    log.error("Invalid OpenFlow version")
25 1
    return 0, 0, 0
26
27
28 1
def send_packet_out(controller, switch, port, data):
29
    """ Just prepare and send a PacketOut used by
30
    the Tracer.
31
32
    Args:
33
        controller: Kytos controller
34
        switch: OpenFlow datapath
35
        port: in_port
36
        data: Ethernet frame
37
    """
38
39 1
    of_version = switch.features.header.version
40
41 1
    if of_version.value == 4:
42 1
        openflow13.send_packet_out(controller, switch, port, data)
43
    else:
44 1
        log.error("Invalid OpenFlow version")
45
        return
46