aec92363150b6ef6976f1e240a6a96cb74307c14
[netvirt.git] / natservice / impl / src / main / java / org / opendaylight / netvirt / natservice / internal / NAPTEntryEvent.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.natservice.internal;
10
11 import javax.annotation.Nullable;
12 import org.opendaylight.netvirt.natservice.internal.NaptPacketInHandler.NatPacketProcessingState;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
14
15 public class NAPTEntryEvent {
16     private final String ipAddress;
17     private final int portNumber;
18     private final Long routerId;
19     private final Operation op;
20     private final Protocol protocol;
21     private final PacketReceived packetReceived;
22     private final boolean pktProcessed;
23     private final long objectCreationTime;
24     private final NatPacketProcessingState state;
25
26     NAPTEntryEvent(String ipAddress, int portNumber, Long routerId, Operation op, Protocol protocol,
27             @Nullable PacketReceived packetReceived, boolean pktProcessed, @Nullable NatPacketProcessingState state) {
28         this.ipAddress = ipAddress;
29         this.portNumber = portNumber;
30         this.routerId = routerId;
31         this.op = op;
32         this.protocol = protocol;
33         this.packetReceived = packetReceived;
34         this.pktProcessed = pktProcessed;
35         this.state = state;
36         this.objectCreationTime = System.currentTimeMillis();
37     }
38
39     NAPTEntryEvent(String ipAddress, int portNumber, Long routerId, Operation op, Protocol protocol) {
40         this.op = op;
41         this.ipAddress = ipAddress;
42         this.portNumber = portNumber;
43         this.routerId = routerId;
44         this.protocol = protocol;
45         this.packetReceived = null;
46         this.pktProcessed = false;
47         this.state = null;
48         this.objectCreationTime = System.currentTimeMillis();
49     }
50
51     public PacketReceived getPacketReceived() {
52         return packetReceived;
53     }
54
55     public boolean isPktProcessed() {
56         return pktProcessed;
57     }
58
59     public String getIpAddress() {
60         return ipAddress;
61     }
62
63     public int getPortNumber() {
64         return portNumber;
65     }
66
67     public Long getRouterId() {
68         return routerId;
69     }
70
71     public Operation getOperation() {
72         return op;
73     }
74
75     public Protocol getProtocol() {
76         return protocol;
77     }
78
79     public long getObjectCreationTime() {
80         return objectCreationTime;
81     }
82
83     public NatPacketProcessingState getState() {
84         return state;
85     }
86
87     public enum Operation {
88         ADD, DELETE
89     }
90
91     public enum Protocol {
92         TCP, UDP
93     }
94 }