Search in sources :

Example 1 with MacBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder in project lispflowmapping by opendaylight.

the class LispAddressUtil method toEid.

public static Eid toEid(MacAddress mac, InstanceIdType vni) {
    EidBuilder builder = new EidBuilder();
    builder.setAddressType(MacAfi.class);
    builder.setVirtualNetworkId(vni);
    builder.setAddress((Address) new MacBuilder().setMac(mac).build());
    return builder.build();
}
Also used : EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) MacBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)

Example 2 with MacBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder in project lispflowmapping by opendaylight.

the class MacSerializer method deserializeRlocData.

@Override
protected Rloc deserializeRlocData(ByteBuffer buffer) {
    RlocBuilder rb = new RlocBuilder();
    rb.setAddressType(MacAfi.class);
    rb.setVirtualNetworkId(null);
    rb.setAddress(new MacBuilder().setMac(deserializeData(buffer)).build());
    return rb.build();
}
Also used : RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) MacBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)

Example 3 with MacBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder in project lispflowmapping by opendaylight.

the class MapResolverTest method isEqualIpVersionTest.

/**
 * Tests {@link MapResolver#isEqualIpVersion} method.
 */
@Test
@Ignore
public void isEqualIpVersionTest() {
    // input mapping
    final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
    final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
    Mockito.when(subscriberSetMock.contains(Mockito.any(Subscriber.class))).thenReturn(false);
    // ----------------------
    // with sourceRloc = null
    List<ItrRloc> itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv4BinaryAfi.class, IPV4_ADDRESS));
    ArgumentCaptor<Subscriber> captor = ArgumentCaptor.forClass(Subscriber.class);
    mapResolver.handleMapRequest(mapRequestBuilder.setSourceRloc(null).setItrRloc(itrRlocList).build());
    Mockito.verify(subscriberSetMock).add(captor.capture());
    // Since mapRequest's sourceRloc is null, first ItrRloc from the itrRlocList must be used.
    assertEquals(MacAfi.class, captor.getValue().getSrcRloc().getAddressType());
    // ----------------------
    // with sourceRloc address = itrRloc address
    itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv4BinaryAfi.class, IPV4_ADDRESS));
    MapRequest mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_1).setItrRloc(itrRlocList).build();
    captor = ArgumentCaptor.forClass(Subscriber.class);
    mapResolver.handleMapRequest(mapRequest);
    Mockito.verify(subscriberSetMock, Mockito.times(2)).add(captor.capture());
    assertEquals(IPV4_ADDRESS, captor.getValue().getSrcRloc().getAddress());
    // ----------------------
    // with sourceRloc address Afi = itrRloc address Afi (for Ipv4)
    itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv6Afi.class, IPV6_ADDRESS), newItrRloc(Ipv4Afi.class, IPV4_ADDRESS));
    mapRequest = mapRequestBuilder.setSourceRloc(IPV6_ADDRESS_BINARY).setItrRloc(itrRlocList).build();
    captor = ArgumentCaptor.forClass(Subscriber.class);
    mapResolver.handleMapRequest(mapRequest);
    Mockito.verify(subscriberSetMock, Mockito.times(3)).add(captor.capture());
    assertEquals(IPV6_ADDRESS, captor.getValue().getSrcRloc().getAddress());
    // ----------------------
    // with sourceRloc address Afi = itrRloc address Afi (for Ipv6)
    itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv6Afi.class, IPV6_ADDRESS), newItrRloc(Ipv4Afi.class, IPV4_ADDRESS));
    mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_2).setItrRloc(itrRlocList).build();
    captor = ArgumentCaptor.forClass(Subscriber.class);
    mapResolver.handleMapRequest(mapRequest);
    Mockito.verify(subscriberSetMock, Mockito.times(4)).add(captor.capture());
    assertEquals(IPV4_ADDRESS, captor.getValue().getSrcRloc().getAddress());
    // ----------------------
    // with no common ip address nor Afi
    final Mac mac = new MacBuilder().setMac(new MacAddress("aa:bb:cc:dd:ee:ff")).build();
    itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, mac), newItrRloc(NoAddressAfi.class, Mockito.mock(NoAddress.class)));
    mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_1).setItrRloc(itrRlocList).build();
    captor = ArgumentCaptor.forClass(Subscriber.class);
    mapResolver.handleMapRequest(mapRequest);
    Mockito.verify(subscriberSetMock, Mockito.times(5)).add(captor.capture());
    assertEquals(mac, captor.getValue().getSrcRloc().getAddress());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) Ipv4BinaryAfi(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4BinaryAfi) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Mac(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MacBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder) MacAfi(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi) NoAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with MacBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder in project lispflowmapping by opendaylight.

the class MacSerializer method deserializeEidData.

@Override
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
    EidBuilder eb = new EidBuilder();
    eb.setAddressType(MacAfi.class);
    eb.setVirtualNetworkId(getVni(ctx));
    eb.setAddress(new MacBuilder().setMac(deserializeData(buffer)).build());
    return eb.build();
}
Also used : EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) MacBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)

Aggregations

MacBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)4 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)2 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)1 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)1 MacAfi (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi)1 Mac (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac)1 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 Ipv4BinaryAfi (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4BinaryAfi)1 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)1 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)1 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)1 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)1 RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)1