2 * Copyright (c) 2014 Cisco Systems, Inc. and others. 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.protocol.bgp.linkstate.impl.attribute;
10 import com.google.common.annotations.VisibleForTesting;
11 import com.google.common.collect.Multimap;
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.ByteBufUtil;
14 import io.netty.buffer.Unpooled;
15 import java.nio.charset.StandardCharsets;
16 import java.util.ArrayList;
17 import java.util.List;
18 import java.util.Map.Entry;
19 import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrLinkAttributesParser;
20 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
21 import org.opendaylight.protocol.util.BitArray;
22 import org.opendaylight.protocol.util.ByteArray;
23 import org.opendaylight.protocol.util.Ipv4Util;
24 import org.opendaylight.protocol.util.Ipv6Util;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.AdministrativeGroup;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Delay;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Ipv4RouterIdentifier;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Ipv6RouterIdentifier;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkProtectionType;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Loss;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.MplsProtocolMask;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.LinkMinMaxDelay;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.LinkMinMaxDelayBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerAdjSid;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerAdjSidBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerNodeSid;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerNodeSidBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerSetSids;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.PeerSetSidsBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.SrAdjIds;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.SrLanAdjIds;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.UnreservedBandwidth;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.UnreservedBandwidthBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.LinkStateAttribute;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.link.state.attribute.LinkAttributesCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.link.state.attribute.LinkAttributesCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributesBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Metric;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.TeMetric;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
60 public final class LinkAttributesParser {
62 public static final int SR_LAN_ADJ_ID = 1100;
63 private static final Logger LOG = LoggerFactory.getLogger(LinkAttributesParser.class);
64 private static final int UNRESERVED_BW_COUNT = 8;
66 private static final int BANDWIDTH_LENGTH = 4;
68 // MPLS protection mask bits
69 private static final int FLAGS_SIZE = 8;
71 private static final int LDP_BIT = 0;
72 private static final int RSVP_BIT = 1;
74 /* Link Attribute TLVs */
75 private static final int REMOTE_IPV4_ROUTER_ID = 1030;
76 private static final int REMOTE_IPV6_ROUTER_ID = 1031;
77 private static final int ADMIN_GROUP = 1088;
78 private static final int MAX_BANDWIDTH = 1089;
79 private static final int MAX_RESERVABLE_BANDWIDTH = 1090;
80 private static final int UNRESERVED_BANDWIDTH = 1091;
81 private static final int TE_METRIC = 1092;
82 private static final int LINK_PROTECTION_TYPE = 1093;
83 private static final int MPLS_PROTOCOL = 1094;
84 private static final int METRIC = 1095;
85 private static final int SHARED_RISK_LINK_GROUP = 1096;
86 private static final int LINK_OPAQUE = 1097;
87 private static final int LINK_NAME = 1098;
88 private static final int SR_ADJ_ID = 1099;
89 private static final int PEER_NODE_SID_CODE = 1101;
90 private static final int PEER_ADJ_SID_CODE = 1102;
91 private static final int PEER_SET_SID_CODE = 1103;
92 // Performance Metrics
93 private static final int LINK_DELAY = 1114;
94 private static final int LINK_MIN_MAX_DELAY = 1115;
95 private static final int DELAY_VARIATION = 1116;
96 private static final int LINK_LOSS = 1117;
97 private static final int RESIDUAL_BANDWIDTH = 1118;
98 private static final int AVAILABLE_BANDWIDTH = 1119;
99 private static final int UTILIZED_BANDWIDTH = 1120;
101 private LinkAttributesParser() {
102 throw new UnsupportedOperationException();
106 private interface SerializerInterface {
107 void check(Object cont);
111 * Parse Link Attributes.
113 * @param attributes key is the tlv type and value is the value of the tlv
114 * @param protocolId to differentiate parsing methods
115 * @return {@link LinkStateAttribute}
117 static LinkStateAttribute parseLinkAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
118 final LinkAttributesBuilder builder = new LinkAttributesBuilder();
119 final List<SrAdjIds> srAdjIds = new ArrayList<>();
120 final List<SrLanAdjIds> srLanAdjIds = new ArrayList<>();
121 final List<PeerSetSids> peerSetSids = new ArrayList<>();
122 for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
123 LOG.trace("Link attribute TLV {}", entry.getKey());
124 final int key = entry.getKey();
125 final ByteBuf value = entry.getValue();
127 case TlvUtil.LOCAL_IPV4_ROUTER_ID:
128 builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
129 LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
131 case TlvUtil.LOCAL_IPV6_ROUTER_ID:
132 builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
133 LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
135 case REMOTE_IPV4_ROUTER_ID:
136 builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
137 LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
139 case REMOTE_IPV6_ROUTER_ID:
140 builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
141 LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
144 builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
145 LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
148 builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
149 LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
151 case MAX_RESERVABLE_BANDWIDTH:
152 builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
153 LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
155 case UNRESERVED_BANDWIDTH:
156 parseUnreservedBandwidth(value, builder);
159 builder.setTeMetric(new TeMetric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
160 LOG.debug("Parsed Metric {}", builder.getTeMetric());
162 case LINK_PROTECTION_TYPE:
163 builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
164 LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
167 final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
168 builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
169 LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
172 // length can 3, 2 or 1
173 builder.setMetric(new Metric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
174 LOG.debug("Parsed Metric {}", builder.getMetric());
176 case SHARED_RISK_LINK_GROUP:
177 parseSrlg(value, builder);
180 LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
183 builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
184 LOG.debug("Parsed Link Name : {}", builder.getLinkName());
187 srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
188 LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
191 srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
192 LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
194 case PEER_NODE_SID_CODE:
195 builder.setPeerNodeSid(new PeerNodeSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
196 LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
198 case PEER_ADJ_SID_CODE:
199 builder.setPeerAdjSid(new PeerAdjSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
200 LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
202 case PEER_SET_SID_CODE:
203 peerSetSids.add(new PeerSetSidsBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
204 LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
206 // Performance Metrics
208 builder.setLinkDelay(new Delay(value.readUnsignedInt()));
209 LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
211 case LINK_MIN_MAX_DELAY:
212 builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder().setMinDelay(new Delay(value.readUnsignedInt()))
213 .setMaxDelay(new Delay(value.readUnsignedInt())).build());
214 LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
216 case DELAY_VARIATION:
217 builder.setDelayVariation(new Delay(value.readUnsignedInt()));
218 LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
221 builder.setLinkLoss(new Loss(value.readUnsignedInt()));
222 LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
224 case RESIDUAL_BANDWIDTH:
225 builder.setResidualBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
226 LOG.debug("Parsed Residual Bandwidth {}", builder.getResidualBandwidth());
228 case AVAILABLE_BANDWIDTH:
229 builder.setAvailableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
230 LOG.debug("Parsed Available Bandwidth {}", builder.getAvailableBandwidth());
232 case UTILIZED_BANDWIDTH:
233 builder.setUtilizedBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
234 LOG.debug("Parsed Utilized Bandwidth {}", builder.getUtilizedBandwidth());
237 LOG.warn("TLV {} is not a valid link attribute, ignoring it", key);
240 if (!srAdjIds.isEmpty()) {
241 builder.setSrAdjIds(srAdjIds);
243 if (!srLanAdjIds.isEmpty()) {
244 builder.setSrLanAdjIds(srLanAdjIds);
246 if (!peerSetSids.isEmpty()) {
247 builder.setPeerSetSids(peerSetSids);
249 LOG.trace("Finished parsing Link Attributes.");
250 return new LinkAttributesCaseBuilder().setLinkAttributes(builder.build()).build();
253 private static void parseUnreservedBandwidth(final ByteBuf value, final LinkAttributesBuilder builder) {
254 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.UnreservedBandwidth> unreservedBandwidth = new ArrayList<>(UNRESERVED_BW_COUNT);
255 for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
256 final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
257 unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
259 builder.setUnreservedBandwidth(unreservedBandwidth);
260 LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
263 private static void parseSrlg(final ByteBuf value, final LinkAttributesBuilder builder) {
264 final List<SrlgId> sharedRiskLinkGroups = new ArrayList<>();
265 while (value.isReadable()) {
266 sharedRiskLinkGroups.add(new SrlgId(value.readUnsignedInt()));
268 builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
269 LOG.debug("Parsed Shared Risk Link Groups {}", builder.getSharedRiskLinkGroups());
272 private static void ifPresentApply(final Object tlv, final SerializerInterface serializer) {
274 serializer.check(tlv);
279 static void serializeLinkAttributes(final LinkAttributesCase linkAttributesCase, final ByteBuf output) {
280 final LinkAttributes linkAttributes = linkAttributesCase.getLinkAttributes();
281 LOG.trace("Started serializing Link Attributes");
282 ifPresentApply(linkAttributes.getLocalIpv4RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
283 ifPresentApply(linkAttributes.getLocalIpv6RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
284 ifPresentApply(linkAttributes.getRemoteIpv4RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
285 ifPresentApply(linkAttributes.getRemoteIpv6RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
286 ifPresentApply(linkAttributes.getAdminGroup(), value -> TlvUtil.writeTLV(ADMIN_GROUP, Unpooled.copyInt((((AdministrativeGroup) value).getValue()).intValue()), output));
287 ifPresentApply(linkAttributes.getMaxLinkBandwidth(), value -> TlvUtil.writeTLV(MAX_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
288 ifPresentApply(linkAttributes.getMaxReservableBandwidth(), value -> TlvUtil.writeTLV(MAX_RESERVABLE_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
289 serializeUnreservedBw(linkAttributes.getUnreservedBandwidth(), output);
290 ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC, Unpooled.copyLong(((TeMetric) value).getValue()), output));
291 ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE, Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
292 serializeMplsProtocolMask(linkAttributes.getMplsProtocol(), output);
293 ifPresentApply(linkAttributes.getMetric(), value -> TlvUtil.writeTLV(METRIC, Unpooled.copyMedium(((Metric) value).getValue().intValue()), output));
294 serializeSrlg(linkAttributes.getSharedRiskLinkGroups(), output);
295 ifPresentApply(linkAttributes.getLinkName(), value -> TlvUtil.writeTLV(LINK_NAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode((String) value)), output));
296 ifPresentApply(linkAttributes.getSrAdjIds(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<SrAdjIds>) value, SR_ADJ_ID, output));
297 ifPresentApply(linkAttributes.getSrLanAdjIds(), value -> SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifiers((List<SrLanAdjIds>) value, output));
298 ifPresentApply(linkAttributes.getPeerNodeSid(), value -> TlvUtil.writeTLV(PEER_NODE_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerNodeSid) value), output));
299 ifPresentApply(linkAttributes.getPeerAdjSid(), value -> TlvUtil.writeTLV(PEER_ADJ_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerAdjSid) value), output));
300 ifPresentApply(linkAttributes.getPeerSetSids(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<PeerSetSids>) value, PEER_SET_SID_CODE, output));
301 // Performance Metrics
302 ifPresentApply(linkAttributes.getLinkDelay(), value -> TlvUtil.writeTLV(LINK_DELAY, Unpooled.copyInt((((Delay) value).getValue()).intValue()), output));
303 serializeLinkMinMaxDelay(linkAttributes.getLinkMinMaxDelay(), output);
304 ifPresentApply(linkAttributes.getDelayVariation(), value -> TlvUtil.writeTLV(DELAY_VARIATION, Unpooled.copyInt((((Delay) value).getValue()).intValue()), output));
305 ifPresentApply(linkAttributes.getLinkLoss(), value -> TlvUtil.writeTLV(LINK_LOSS, Unpooled.copyInt((((Loss) value).getValue()).intValue()), output));
306 ifPresentApply(linkAttributes.getResidualBandwidth(), value -> TlvUtil.writeTLV(RESIDUAL_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
307 ifPresentApply(linkAttributes.getAvailableBandwidth(), value -> TlvUtil.writeTLV(AVAILABLE_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
308 ifPresentApply(linkAttributes.getUtilizedBandwidth(), value -> TlvUtil.writeTLV(UTILIZED_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
309 LOG.trace("Finished serializing Link Attributes");
312 private static void serializeUnreservedBw(final List<UnreservedBandwidth> ubList, final ByteBuf byteAggregator) {
313 // this sub-TLV contains eight 32-bit IEEE floating point numbers
314 if (ubList != null) {
315 final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
316 for (final UnreservedBandwidth unreservedBandwidth : ubList) {
317 unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
319 TlvUtil.writeTLV(UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
323 private static void serializeSrlg(final List<SrlgId> srlgList, final ByteBuf byteAggregator) {
324 if (srlgList != null) {
325 final ByteBuf sharedRLGBuf = Unpooled.buffer();
326 for (final SrlgId srlgId : srlgList) {
327 sharedRLGBuf.writeInt(srlgId.getValue().intValue());
329 TlvUtil.writeTLV(SHARED_RISK_LINK_GROUP, sharedRLGBuf, byteAggregator);
333 private static void serializeMplsProtocolMask(final MplsProtocolMask mplsProtocolMask, final ByteBuf byteAggregator) {
334 if (mplsProtocolMask != null) {
335 final ByteBuf mplsProtocolMaskBuf = Unpooled.buffer(1);
336 final BitArray mask = new BitArray(FLAGS_SIZE);
337 mask.set(LDP_BIT, mplsProtocolMask.isLdp());
338 mask.set(RSVP_BIT, mplsProtocolMask.isRsvpte());
339 mask.toByteBuf(mplsProtocolMaskBuf);
340 TlvUtil.writeTLV(MPLS_PROTOCOL, mplsProtocolMaskBuf, byteAggregator);
344 private static void serializeLinkMinMaxDelay(final LinkMinMaxDelay linkMinMaxDelay, final ByteBuf byteAggregator) {
345 if (linkMinMaxDelay != null) {
346 final ByteBuf linkMinMaxDelayBuf = Unpooled.buffer();
347 linkMinMaxDelayBuf.writeInt(linkMinMaxDelay.getMinDelay().getValue().intValue());
348 linkMinMaxDelayBuf.writeInt(linkMinMaxDelay.getMaxDelay().getValue().intValue());
349 TlvUtil.writeTLV(LINK_MIN_MAX_DELAY, linkMinMaxDelayBuf, byteAggregator);