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() {
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,
118 final ProtocolId protocolId) {
119 final LinkAttributesBuilder builder = new LinkAttributesBuilder();
120 final List<SrAdjIds> srAdjIds = new ArrayList<>();
121 final List<SrLanAdjIds> srLanAdjIds = new ArrayList<>();
122 final List<PeerSetSids> peerSetSids = new ArrayList<>();
123 for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
124 LOG.trace("Link attribute TLV {}", entry.getKey());
125 final int key = entry.getKey();
126 final ByteBuf value = entry.getValue();
128 case TlvUtil.LOCAL_IPV4_ROUTER_ID:
129 builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
130 LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
132 case TlvUtil.LOCAL_IPV6_ROUTER_ID:
133 builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
134 LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
136 case REMOTE_IPV4_ROUTER_ID:
137 builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
138 LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
140 case REMOTE_IPV6_ROUTER_ID:
141 builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
142 LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
145 builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
146 LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
149 builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
150 LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
152 case MAX_RESERVABLE_BANDWIDTH:
153 builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
154 LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
156 case UNRESERVED_BANDWIDTH:
157 parseUnreservedBandwidth(value, builder);
160 builder.setTeMetric(new TeMetric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
161 LOG.debug("Parsed Metric {}", builder.getTeMetric());
163 case LINK_PROTECTION_TYPE:
164 builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
165 LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
168 final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
169 builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
170 LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
173 // length can 3, 2 or 1
174 builder.setMetric(new Metric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
175 LOG.debug("Parsed Metric {}", builder.getMetric());
177 case SHARED_RISK_LINK_GROUP:
178 parseSrlg(value, builder);
181 LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
184 builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
185 LOG.debug("Parsed Link Name : {}", builder.getLinkName());
188 srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
189 LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
192 srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
193 LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
195 case PEER_NODE_SID_CODE:
196 builder.setPeerNodeSid(new PeerNodeSidBuilder(
197 SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
198 LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
200 case PEER_ADJ_SID_CODE:
201 builder.setPeerAdjSid(new PeerAdjSidBuilder(
202 SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
203 LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
205 case PEER_SET_SID_CODE:
206 peerSetSids.add(new PeerSetSidsBuilder(
207 SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
208 LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
210 // Performance Metrics
212 builder.setLinkDelay(new Delay(value.readUnsignedInt()));
213 LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
215 case LINK_MIN_MAX_DELAY:
216 builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder()
217 .setMinDelay(new Delay(value.readUnsignedInt()))
218 .setMaxDelay(new Delay(value.readUnsignedInt())).build());
219 LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
221 case DELAY_VARIATION:
222 builder.setDelayVariation(new Delay(value.readUnsignedInt()));
223 LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
226 builder.setLinkLoss(new Loss(value.readUnsignedInt()));
227 LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
229 case RESIDUAL_BANDWIDTH:
230 builder.setResidualBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
231 LOG.debug("Parsed Residual Bandwidth {}", builder.getResidualBandwidth());
233 case AVAILABLE_BANDWIDTH:
234 builder.setAvailableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
235 LOG.debug("Parsed Available Bandwidth {}", builder.getAvailableBandwidth());
237 case UTILIZED_BANDWIDTH:
238 builder.setUtilizedBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
239 LOG.debug("Parsed Utilized Bandwidth {}", builder.getUtilizedBandwidth());
242 LOG.warn("TLV {} is not a valid link attribute, ignoring it", key);
245 if (!srAdjIds.isEmpty()) {
246 builder.setSrAdjIds(srAdjIds);
248 if (!srLanAdjIds.isEmpty()) {
249 builder.setSrLanAdjIds(srLanAdjIds);
251 if (!peerSetSids.isEmpty()) {
252 builder.setPeerSetSids(peerSetSids);
254 LOG.trace("Finished parsing Link Attributes.");
255 return new LinkAttributesCaseBuilder().setLinkAttributes(builder.build()).build();
258 private static void parseUnreservedBandwidth(final ByteBuf value, final LinkAttributesBuilder builder) {
259 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate
260 .attribute.UnreservedBandwidth> unreservedBandwidth = new ArrayList<>(UNRESERVED_BW_COUNT);
261 for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
262 final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
263 unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(
264 new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
266 builder.setUnreservedBandwidth(unreservedBandwidth);
267 LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
270 private static void parseSrlg(final ByteBuf value, final LinkAttributesBuilder builder) {
271 final List<SrlgId> sharedRiskLinkGroups = new ArrayList<>();
272 while (value.isReadable()) {
273 sharedRiskLinkGroups.add(new SrlgId(value.readUnsignedInt()));
275 builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
276 LOG.debug("Parsed Shared Risk Link Groups {}", builder.getSharedRiskLinkGroups());
279 private static void ifPresentApply(final Object tlv, final SerializerInterface serializer) {
281 serializer.check(tlv);
286 static void serializeLinkAttributes(final LinkAttributesCase linkAttributesCase, final ByteBuf output) {
287 final LinkAttributes linkAttributes = linkAttributesCase.getLinkAttributes();
288 LOG.trace("Started serializing Link Attributes");
289 ifPresentApply(linkAttributes.getLocalIpv4RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID,
290 Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
291 ifPresentApply(linkAttributes.getLocalIpv6RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID,
292 Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
293 ifPresentApply(linkAttributes.getRemoteIpv4RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV4_ROUTER_ID,
294 Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
295 ifPresentApply(linkAttributes.getRemoteIpv6RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV6_ROUTER_ID,
296 Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
297 ifPresentApply(linkAttributes.getAdminGroup(), value -> TlvUtil.writeTLV(ADMIN_GROUP,
298 Unpooled.copyInt(((AdministrativeGroup) value).getValue().intValue()), output));
299 ifPresentApply(linkAttributes.getMaxLinkBandwidth(), value -> TlvUtil.writeTLV(MAX_BANDWIDTH,
300 Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
301 ifPresentApply(linkAttributes.getMaxReservableBandwidth(), value -> TlvUtil.writeTLV(MAX_RESERVABLE_BANDWIDTH,
302 Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
303 serializeUnreservedBw(linkAttributes.getUnreservedBandwidth(), output);
304 ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC,
305 Unpooled.copyLong(((TeMetric) value).getValue()), output));
306 ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE,
307 Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
308 serializeMplsProtocolMask(linkAttributes.getMplsProtocol(), output);
309 ifPresentApply(linkAttributes.getMetric(), value -> TlvUtil.writeTLV(METRIC,
310 Unpooled.copyMedium(((Metric) value).getValue().intValue()), output));
311 serializeSrlg(linkAttributes.getSharedRiskLinkGroups(), output);
312 ifPresentApply(linkAttributes.getLinkName(), value -> TlvUtil.writeTLV(LINK_NAME,
313 Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode((String) value)), output));
314 ifPresentApply(linkAttributes.getSrAdjIds(),
315 value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<SrAdjIds>) value, SR_ADJ_ID,
317 ifPresentApply(linkAttributes.getSrLanAdjIds(),
318 value -> SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifiers((List<SrLanAdjIds>) value, output));
319 ifPresentApply(linkAttributes.getPeerNodeSid(), value -> TlvUtil.writeTLV(PEER_NODE_SID_CODE,
320 SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerNodeSid) value), output));
321 ifPresentApply(linkAttributes.getPeerAdjSid(), value -> TlvUtil.writeTLV(PEER_ADJ_SID_CODE,
322 SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerAdjSid) value), output));
323 ifPresentApply(linkAttributes.getPeerSetSids(),
324 value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<PeerSetSids>) value,
325 PEER_SET_SID_CODE, output));
326 // Performance Metrics
327 ifPresentApply(linkAttributes.getLinkDelay(), value -> TlvUtil.writeTLV(LINK_DELAY,
328 Unpooled.copyInt(((Delay) value).getValue().intValue()), output));
329 serializeLinkMinMaxDelay(linkAttributes.getLinkMinMaxDelay(), output);
330 ifPresentApply(linkAttributes.getDelayVariation(), value -> TlvUtil.writeTLV(DELAY_VARIATION,
331 Unpooled.copyInt(((Delay) value).getValue().intValue()), output));
332 ifPresentApply(linkAttributes.getLinkLoss(), value -> TlvUtil.writeTLV(LINK_LOSS,
333 Unpooled.copyInt(((Loss) value).getValue().intValue()), output));
334 ifPresentApply(linkAttributes.getResidualBandwidth(), value -> TlvUtil.writeTLV(RESIDUAL_BANDWIDTH,
335 Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
336 ifPresentApply(linkAttributes.getAvailableBandwidth(), value -> TlvUtil.writeTLV(AVAILABLE_BANDWIDTH,
337 Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
338 ifPresentApply(linkAttributes.getUtilizedBandwidth(), value -> TlvUtil.writeTLV(UTILIZED_BANDWIDTH,
339 Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
340 LOG.trace("Finished serializing Link Attributes");
343 private static void serializeUnreservedBw(final List<UnreservedBandwidth> ubList, final ByteBuf byteAggregator) {
344 // this sub-TLV contains eight 32-bit IEEE floating point numbers
345 if (ubList != null) {
346 final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
347 for (final UnreservedBandwidth unreservedBandwidth : ubList) {
348 unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
350 TlvUtil.writeTLV(UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
354 private static void serializeSrlg(final List<SrlgId> srlgList, final ByteBuf byteAggregator) {
355 if (srlgList != null) {
356 final ByteBuf sharedRLGBuf = Unpooled.buffer();
357 for (final SrlgId srlgId : srlgList) {
358 sharedRLGBuf.writeInt(srlgId.getValue().intValue());
360 TlvUtil.writeTLV(SHARED_RISK_LINK_GROUP, sharedRLGBuf, byteAggregator);
364 private static void serializeMplsProtocolMask(final MplsProtocolMask mplsProtocolMask,
365 final ByteBuf byteAggregator) {
366 if (mplsProtocolMask != null) {
367 final ByteBuf mplsProtocolMaskBuf = Unpooled.buffer(1);
368 final BitArray mask = new BitArray(FLAGS_SIZE);
369 mask.set(LDP_BIT, mplsProtocolMask.isLdp());
370 mask.set(RSVP_BIT, mplsProtocolMask.isRsvpte());
371 mask.toByteBuf(mplsProtocolMaskBuf);
372 TlvUtil.writeTLV(MPLS_PROTOCOL, mplsProtocolMaskBuf, byteAggregator);
376 private static void serializeLinkMinMaxDelay(final LinkMinMaxDelay linkMinMaxDelay, final ByteBuf byteAggregator) {
377 if (linkMinMaxDelay != null) {
378 final ByteBuf linkMinMaxDelayBuf = Unpooled.buffer();
379 linkMinMaxDelayBuf.writeInt(linkMinMaxDelay.getMinDelay().getValue().intValue());
380 linkMinMaxDelayBuf.writeInt(linkMinMaxDelay.getMaxDelay().getValue().intValue());
381 TlvUtil.writeTLV(LINK_MIN_MAX_DELAY, linkMinMaxDelayBuf, byteAggregator);