2 * Copyright (c) 2017 Cisco Systems. All rights reserved.
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
8 package org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.states;
10 import org.apache.commons.lang3.mutable.MutableLong;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
13 public class VrfState {
14 private SubnetHolder subnetHolder;
15 private String protocolName;
16 private MutableLong nextRouteId;
18 public VrfState(String routingProtocolName) {
19 this.subnetHolder = new SubnetHolder();
20 this.protocolName = routingProtocolName;
21 this.nextRouteId = new MutableLong(1L);
24 public SubnetHolder getSubnetHolder() {
28 public String getProtocolName() {
32 public long getNextRouteId() {
33 return nextRouteId.getValue();
36 public void addNewPortIpInVrf(String portSubnetUuid, Ipv4Address portIp) {
37 subnetHolder.getSubnetState(portSubnetUuid).addNewIp(portIp);
38 nextRouteId.increment();
41 public void removePortIpFromVrf(String portSubnetUuid, Ipv4Address portIp) {
42 if (subnetHolder.subnetStateContains(portSubnetUuid)) {
43 subnetHolder.getSubnetState(portSubnetUuid).removeIp(portIp);
47 public int subnetCount() {
48 return subnetHolder.subnetHolderCount();
51 @Override public String toString() {
52 return "VrfState{" + "subnetHolder=" + subnetHolder + ", protocolName='" + protocolName + '\''
53 + ", nextRouteId=" + nextRouteId + '}';