use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.
the class DefaultNeighbourMessageActionsTest method reply.
@Test
public void reply() throws Exception {
Ethernet request = NeighbourTestUtils.createArpRequest(IP1);
Ip4Address ip4Address = INTF1.ipAddressesList().get(0).ipAddress().getIp4Address();
Ethernet response = ARP.buildArpReply(ip4Address, MAC2, request);
packetService.emit(outbound(response, CP1));
expectLastCall().once();
replay(packetService);
actions.reply(createContext(request, CP1, null), MAC2);
verify(packetService);
}
use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.
the class OspfPseudonode method read.
/**
* Reads the channel buffer and returns object of OSPFPseudonode.
*
* @param cb ChannelBuffer
* @return object of OSPFPseudonode
*/
public static OspfPseudonode read(ChannelBuffer cb) {
int routerID = cb.readInt();
Ip4Address drInterface = Ip4Address.valueOf(cb.readInt());
return OspfPseudonode.of(routerID, drInterface);
}
use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.
the class BgpAttrRouterIdV4 method read.
/**
* Reads the IPv4 Router-ID.
*
* @param cb ChannelBuffer
* @param sType tag type
* @return object of BgpAttrRouterIdV4
* @throws BgpParseException while parsing BgpAttrRouterIdV4
*/
public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType) throws BgpParseException {
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, lsAttrLength);
}
byte[] ipBytes = new byte[lsAttrLength];
cb.readBytes(ipBytes, 0, lsAttrLength);
Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes);
return BgpAttrRouterIdV4.of(ip4RouterId, sType);
}
use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.
the class IPv4AddressTlv method read.
/**
* Reads the channel buffer and returns object of IPv4AddressTlv.
*
* @param cb channelBuffer
* @param type address type
* @return object of IPv4AddressTlv
* @throws BgpParseException while parsing IPv4AddressTlv
*/
public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
if (ipAddress.isMulticastAddress()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
Ip4Address address = Ip4Address.valueOf(ipAddress);
return IPv4AddressTlv.of(address, type);
}
use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.
the class BgpRouteEntryTest method testGetFields.
/**
* Tests getting the fields of a BGP route entry.
*/
@Test
public void testGetFields() {
// Create the fields to compare against
Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
byte pathSegmentType1 = (byte) BgpConstants.Update.AsPath.AS_SEQUENCE;
ArrayList<Long> segmentAsNumbers1 = new ArrayList<>();
segmentAsNumbers1.add(1L);
segmentAsNumbers1.add(2L);
segmentAsNumbers1.add(3L);
BgpRouteEntry.PathSegment pathSegment1 = new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1);
pathSegments.add(pathSegment1);
//
byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET;
ArrayList<Long> segmentAsNumbers2 = new ArrayList<>();
segmentAsNumbers2.add(4L);
segmentAsNumbers2.add(5L);
segmentAsNumbers2.add(6L);
BgpRouteEntry.PathSegment pathSegment2 = new BgpRouteEntry.PathSegment(pathSegmentType2, segmentAsNumbers2);
pathSegments.add(pathSegment2);
//
BgpRouteEntry.AsPath asPath = new BgpRouteEntry.AsPath(pathSegments);
//
long localPref = 100;
long multiExitDisc = 20;
// Generate the entry to test
BgpRouteEntry bgpRouteEntry = generateBgpRouteEntry();
assertThat(bgpRouteEntry.prefix(), is(prefix));
assertThat(bgpRouteEntry.nextHop(), is(nextHop));
assertThat(bgpRouteEntry.getBgpSession(), is(bgpSession));
assertThat(bgpRouteEntry.getOrigin(), is(origin));
assertThat(bgpRouteEntry.getAsPath(), is(asPath));
assertThat(bgpRouteEntry.getLocalPref(), is(localPref));
assertThat(bgpRouteEntry.getMultiExitDisc(), is(multiExitDisc));
}
Aggregations