@Override public NshEntry build() { return new NshEntryImpl(this); }
public NshEntryBuilder setLength(final Short value) { if (value != null) { checkLengthRange(value); } this._length = value; return this; }
public NshEntryBuilder setNsi(final Short value) { if (value != null) { checkNsiRange(value); } this._nsi = value; return this; } private static void checkNspRange(final long value) {
public NshEntryBuilder(NshEntry base) { if (base.key() == null) { this.key = new NshEntryKey( base.getName() ); this._name = base.getName(); } else { this.key = base.key(); this._name = key.getName(); } this._length = base.getLength(); this._mdType = base.getMdType(); this._nextProtocol = base.getNextProtocol(); this._nsi = base.getNsi(); this._nsp = base.getNsp(); this._version = base.getVersion(); if (base instanceof NshEntryImpl) { NshEntryImpl impl = (NshEntryImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<NshEntry> casted =(AugmentationHolder<NshEntry>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
if (!Objects.equals(_length, other.getLength())) { return false; if (!Objects.equals(_mdType, other.getMdType())) { return false; if (!Objects.equals(_name, other.getName())) { return false; if (!Objects.equals(_nextProtocol, other.getNextProtocol())) { return false; if (!Objects.equals(_nsi, other.getNsi())) { return false; if (!Objects.equals(_nsp, other.getNsp())) { return false; if (!Objects.equals(_version, other.getVersion())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
private NshEntryImpl(NshEntryBuilder base) { if (base.key() == null) { this.key = new NshEntryKey( base.getName() ); this._name = base.getName(); } else { this.key = base.key(); this._name = key.getName(); } this._length = base.getLength(); this._mdType = base.getMdType(); this._nextProtocol = base.getNextProtocol(); this._nsi = base.getNsi(); this._nsp = base.getNsp(); this._version = base.getVersion(); this.augmentation = ImmutableMap.copyOf(base.augmentation); }
request.isAdd = booleanToByte(isAdd); request.verOC = (byte) entry.getVersion().shortValue(); request.length = (byte) entry.getLength().intValue(); if (entry.getNextProtocol() == Ipv4.class) { request.nextProtocol = 1; } else if (entry.getNextProtocol() == Ipv6.class) { request.nextProtocol = 2; } else if (entry.getNextProtocol() == Ethernet.class) { request.nextProtocol = 3; } else { if (entry.getMdType() == MdType1.class) { request.mdType = 1; getNshEntryMdType1Request(entry, request); } else if (entry.getMdType() == MdType2.class) { request.mdType = 2; getNshEntryMdType2Request(entry, request); request.nspNsi = (entry.getNsp().intValue() << 8) | entry.getNsi();
@Override public Initialized<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev170315.vpp.nsh.nsh.entries.NshEntry> init( @Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry readValue, @Nonnull final ReadContext ctx) { return Initialized.create( InstanceIdentifier.create(VppNsh.class).child( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev170315.vpp.nsh.NshEntries.class).child( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev170315.vpp.nsh.nsh.entries.NshEntry.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev170315.vpp.nsh.nsh.entries.NshEntryKey(id.firstKeyOf(NshEntry.class).getName())), new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev170315.vpp.nsh.nsh.entries.NshEntryBuilder(readValue) .setName(readValue.getName()) .build()); } }
private void getNshEntryMdType2Request(@Nonnull final NshEntry entry, @Nonnull NshAddDelEntry request) { final List<Md2Data> md2Datas = entry.augmentation(NshMdType2Augment.class).getMd2Data(); final byte md2_len = (byte) (entry.getLength() * 4 - 8); byte cur_len = 0; byte option_len; LOG.debug("wr: md2_len={}", md2_len); request.tlv = new byte[md2_len]; for (Md2Data md2data : md2Datas) { option_len = (byte) md2data.getLen().shortValue(); LOG.debug("wr: option_len={}", option_len); if ((cur_len + option_len + 4) <= md2_len) { request.tlv[cur_len] = (byte) (md2data.getMd2Class().shortValue() >> 8); request.tlv[cur_len + 1] = (byte) (md2data.getMd2Class().shortValue() & 0xF); request.tlv[cur_len + 2] = (byte) md2data.getType().shortValue(); request.tlv[cur_len + 3] = option_len; /* convert string to hex digits */ LOG.debug("wr: md2data.getMetadata()={}", md2data.getMetadata()); int length = md2data.getMetadata().length(); for (int i = 0; i < length / 2; ++i) { request.tlv[(cur_len+4)+i] = (byte)(Integer.parseInt (md2data.getMetadata().substring(i*2, i*2+2), 16) & 0xff); } cur_len += (option_len + 4); } } request.tlvLength = cur_len; }
@Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Creating nsh entry: iid={} dataAfter={}", id, dataAfter); final int newEntryIndex = nshAddDelEntry(true, id, dataAfter); // Add nsh entry name <-> vpp index mapping to the naming context: nshEntryContext.addName(newEntryIndex, dataAfter.getName(), writeContext.getMappingContext()); LOG.debug("Successfully created nsh entry(id={]): iid={} dataAfter={}", newEntryIndex, id, dataAfter); }
private void getNshEntryMdType1Request(@Nonnull final NshEntry entry, @Nonnull NshAddDelEntry request) { final NshMdType1Augment nshMdType1Augment = entry.augmentation(NshMdType1Augment.class); if (nshMdType1Augment != null) { request.c1 = (int) nshMdType1Augment.getC1().longValue(); request.c2 = (int) nshMdType1Augment.getC2().longValue(); request.c3 = (int) nshMdType1Augment.getC3().longValue(); request.c4 = (int) nshMdType1Augment.getC4().longValue(); } }
public NshEntryBuilder setVersion(final Short value) { if (value != null) { checkVersionRange(value); } this._version = value; return this; }
public NshEntryBuilder setNsp(final Long value) { if (value != null) { checkNspRange(value); } this._nsp = value; return this; } private static void checkVersionRange(final short value) {
public NshEntryBuilder addAugmentation(Class<? extends Augmentation<NshEntry>> augmentationType, Augmentation<NshEntry> augmentationValue) { if (augmentationValue == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentationValue); return this; }
@Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing nsh entry: iid={} dataBefore={}", id, dataBefore); final String entryName = dataBefore.getName(); checkState(nshEntryContext.containsIndex(entryName, writeContext.getMappingContext()), "Removing nsh entry {}, but index could not be found in the nsh entry context", entryName); final int entryIndex = nshEntryContext.getIndex(entryName, writeContext.getMappingContext()); nshAddDelEntry(false, id, dataBefore); // Remove deleted interface from interface context: nshEntryContext.removeName(dataBefore.getName(), writeContext.getMappingContext()); LOG.debug("Successfully removed nsh entry(id={]): iid={} dataAfter={}", entryIndex, id, dataBefore); }