Search in sources :

Example 91 with IpAddress

use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.

the class VbngResource method privateIpDeleteNotification.

/**
 * Query virtual BNG map.
 *
 * @return IP Address map
 */
@GET
@Path("map")
@Produces(MediaType.APPLICATION_JSON)
public Response privateIpDeleteNotification() {
    log.info("Received vBNG IP address map request");
    VbngConfigurationService vbngConfigurationService = get(VbngConfigurationService.class);
    Map<IpAddress, IpAddress> map = vbngConfigurationService.getIpAddressMappings();
    ObjectNode result = new ObjectMapper().createObjectNode();
    result.set("map", new IpAddressMapEntryCodec().encode(map.entrySet(), this));
    return ok(result.toString()).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IpAddress(org.onlab.packet.IpAddress) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 92 with IpAddress

use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.

the class VbngResource method privateIpDeleteNotification.

/**
 * Delete a virtual BNG connection.
 *
 * @param privateIp IP Address for the BNG private network
 * @return 200 OK
 */
@DELETE
@Path("{privateip}")
public Response privateIpDeleteNotification(@PathParam("privateip") String privateIp) {
    String result;
    if (privateIp == null) {
        log.info("Private IP address to delete is null");
        result = "0";
    }
    log.info("Received a private IP address : {} to delete", privateIp);
    IpAddress privateIpAddress = IpAddress.valueOf(privateIp);
    VbngService vbngService = get(VbngService.class);
    IpAddress assignedPublicIpAddress = null;
    // Delete a virtual BNG
    assignedPublicIpAddress = vbngService.deleteVbng(privateIpAddress);
    if (assignedPublicIpAddress != null) {
        result = assignedPublicIpAddress.toString();
    } else {
        result = "0";
    }
    return Response.ok().entity(result).build();
}
Also used : IpAddress(org.onlab.packet.IpAddress) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 93 with IpAddress

use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.

the class CastorArpManager method updateMac.

/**
 * Updates the IP address to mac address map.
 *
 * @param context The message context.
 */
private void updateMac(MessageContext context) {
    if ((castorStore.getAddressMap()).containsKey(context.sender())) {
        return;
    }
    Ethernet eth = context.packet();
    MacAddress macAddress = eth.getSourceMAC();
    IpAddress ipAddress = context.sender();
    castorStore.setAddressMap(ipAddress, macAddress);
}
Also used : Ethernet(org.onlab.packet.Ethernet) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress)

Example 94 with IpAddress

use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.

the class CastorArpManager method forward.

/**
 * Forwards the ARP packet to the specified connect point via packet out.
 *
 * @param context The packet context
 */
private void forward(MessageContext context) {
    TrafficTreatment.Builder builder = null;
    Ethernet eth = context.packet();
    ByteBuffer buf = ByteBuffer.wrap(eth.serialize());
    IpAddress target = context.target();
    String value = getMatchingConnectPoint(target);
    if (value != null) {
        ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(value);
        builder = DefaultTrafficTreatment.builder();
        builder.setOutput(connectPoint.port());
        packetService.emit(new DefaultOutboundPacket(connectPoint.deviceId(), builder.build(), buf));
    }
}
Also used : Ethernet(org.onlab.packet.Ethernet) IpAddress(org.onlab.packet.IpAddress) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 95 with IpAddress

use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.

the class CastorArpManager method createArpContext.

/**
 * Extracts context information from ARP packets.
 *
 * @param eth input Ethernet frame that is thought to be ARP
 * @param inPort in port
 * @return MessageContext object if the packet was a valid ARP packet,
 * otherwise null
 */
private MessageContext createArpContext(Ethernet eth, ConnectPoint inPort) {
    if (eth.getEtherType() != Ethernet.TYPE_ARP) {
        return null;
    }
    ARP arp = (ARP) eth.getPayload();
    IpAddress target = Ip4Address.valueOf(arp.getTargetProtocolAddress());
    IpAddress sender = Ip4Address.valueOf(arp.getSenderProtocolAddress());
    MessageType type;
    if (arp.getOpCode() == ARP.OP_REQUEST) {
        type = MessageType.REQUEST;
    } else if (arp.getOpCode() == ARP.OP_REPLY) {
        type = MessageType.REPLY;
    } else {
        return null;
    }
    return new MessageContext(eth, inPort, Protocol.ARP, type, target, sender);
}
Also used : IpAddress(org.onlab.packet.IpAddress) ARP(org.onlab.packet.ARP) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP)

Aggregations

IpAddress (org.onlab.packet.IpAddress)288 MacAddress (org.onlab.packet.MacAddress)63 VlanId (org.onlab.packet.VlanId)52 ConnectPoint (org.onosproject.net.ConnectPoint)48 Set (java.util.Set)46 DeviceId (org.onosproject.net.DeviceId)44 Logger (org.slf4j.Logger)40 Test (org.junit.Test)37 Collectors (java.util.stream.Collectors)36 Ethernet (org.onlab.packet.Ethernet)36 IpPrefix (org.onlab.packet.IpPrefix)36 HostId (org.onosproject.net.HostId)33 Host (org.onosproject.net.Host)32 Optional (java.util.Optional)30 HostLocation (org.onosproject.net.HostLocation)30 LoggerFactory (org.slf4j.LoggerFactory)30 ApplicationId (org.onosproject.core.ApplicationId)29 CoreService (org.onosproject.core.CoreService)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)28