@Override public void serializeTlvBody(final Ipv6InterfaceIdentifier tlv, final ByteBuf body) { ByteBufWriteUtil.writeIpv6Address(tlv, body); }
@Override public void serializeTlvBody(final Ipv6InterfaceIdentifier tlv, final ByteBuf body) { ByteBufWriteUtil.writeIpv6Address(tlv, body); }
private static void serializeIpv6Case(final TeLspCase teLSP, final Ipv6Case ipv6Case, final ByteBuf buffer) { ByteBufWriteUtil.writeIpv6Address(ipv6Case.getIpv6TunnelSenderAddress(), buffer); serializeTunnelIdAndLspId(buffer, teLSP); ByteBufWriteUtil.writeIpv6Address(ipv6Case.getIpv6TunnelEndpointAddress(), buffer); }
public static void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof EndpointsObj, "Wrong instance of PCEPObject. Passed %s. Needed EndpointsObject.", object.getClass()); final EndpointsObj ePObj = (EndpointsObj) object; final AddressFamily afi = ePObj.getAddressFamily(); Preconditions.checkArgument(afi instanceof Ipv6Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv6", afi.getClass()); final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH); final Ipv6 ipv6 = ((Ipv6Case) afi).getIpv6(); Preconditions.checkArgument(ipv6.getSourceIpv6Address() != null, "SourceIpv6Address is mandatory."); writeIpv6Address(ipv6.getSourceIpv6Address(), body); Preconditions.checkArgument(ipv6.getDestinationIpv6Address() != null, "DestinationIpv6Address is mandatory."); writeIpv6Address(ipv6.getDestinationIpv6Address(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof PceId, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass()); final PceId pceId = (PceId) object; if (pceId.getIpAddress().getIpv4Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH); ByteBufWriteUtil.writeIpv4Address(pceId.getIpAddress().getIpv4Address(), body); ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } else if (pceId.getIpAddress().getIpv6Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH); ByteBufWriteUtil.writeIpv6Address(pceId.getIpAddress().getIpv6Address(), body); ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpNhExtendedCommunity, "The extended community %s is not RedirectIpNhExtendedCommunityCase type.", extendedCommunity); final RedirectIpNhExtendedCommunity redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpNhExtendedCommunity) extendedCommunity).getRedirectIpNhExtendedCommunity(); final IpAddress nextHopAddress = redirect.getNextHopAddress(); if (nextHopAddress.getIpv4Address() != null) { ByteBufWriteUtil.writeIpv4Address(nextHopAddress.getIpv4Address(), byteAggregator); } else { ByteBufWriteUtil.writeIpv6Address(nextHopAddress.getIpv6Address(), byteAggregator); } ByteBufWriteUtil.writeUnsignedShort((redirect.isCopy() == null || !redirect.isCopy()) ? 0 : 1, byteAggregator); }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof PccIdReq, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass()); final PccIdReq pccIdReq = (PccIdReq) object; if (pccIdReq.getIpAddress().getIpv4Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH); ByteBufWriteUtil.writeIpv4Address(pccIdReq.getIpAddress().getIpv4Address(), body); ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } else if (pccIdReq.getIpAddress().getIpv6Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH); ByteBufWriteUtil.writeIpv6Address(pccIdReq.getIpAddress().getIpv6Address(), body); ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } } }
@Override public void serializeTlv(final Tlv tlv, final ByteBuf buffer) { Preconditions.checkArgument(tlv instanceof RsvpErrorSpec, "RSVPErrorSpecTlv is mandatory."); final RsvpErrorSpec rsvpTlv = (RsvpErrorSpec) tlv; final RsvpError rsvp = rsvpTlv.getRsvpError(); final ByteBuf body = Unpooled.buffer(); final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE); final Flags f = rsvp.getFlags(); if (f.isInPlace() != null) { flags.set(IN_PLACE_FLAG_OFFSET, f.isInPlace()); } if (f.isNotGuilty() != null) { flags.set(NOT_GUILTY_FLAGS_OFFSET, f.isNotGuilty()); } final IpAddress node = rsvp.getNode(); Preconditions.checkArgument(node != null, "Node is mandatory."); if (node.getIpv4Address() != null) { writeIpv4Address(node.getIpv4Address(), body); } else { writeIpv6Address(node.getIpv6Address(), body); } writeBitSet(flags, FLAGS_F_LENGTH, body); Preconditions.checkArgument(rsvp.getCode() != null, "Code is mandatory."); writeUnsignedByte(rsvp.getCode(), body); Preconditions.checkArgument(rsvp.getValue() != null, "Value is mandatory."); writeUnsignedShort(rsvp.getValue(), body); TlvUtil.formatTlv(TYPE, body, buffer); } }
private static void serializeNai(final Nai nai, final SidType sidType, final ByteBuf buffer) { switch (sidType) { case Ipv4NodeId: writeIpv4Address(((IpNodeId) nai).getIpAddress().getIpv4Address(), buffer); break; case Ipv6NodeId: writeIpv6Address(((IpNodeId) nai).getIpAddress().getIpv6Address(), buffer); break; case Ipv4Adjacency: writeIpv4Address(((IpAdjacency) nai).getLocalIpAddress().getIpv4Address(), buffer); writeIpv4Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv4Address(), buffer); break; case Ipv6Adjacency: writeIpv6Address(((IpAdjacency) nai).getLocalIpAddress().getIpv6Address(), buffer); writeIpv6Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv6Address(), buffer); break; case Unnumbered: final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency) nai; ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalNodeId(), buffer); ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalInterfaceId(), buffer); ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteNodeId(), buffer); ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteInterfaceId(), buffer); break; default: break; } }