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();
}
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();
}
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);
}
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));
}
}
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);
}
Aggregations