use of org.onosproject.routing.fpm.protocol.FpmHeader in project onos by opennetworkinglab.
the class FpmManager method updateRoute.
private void updateRoute(IpAddress pdPushNextHop, boolean isAdd, IpPrefix prefix, Channel ch, int raLength, short addrFamily) {
try {
RouteAttributeDst raDst = RouteAttributeDst.builder().length(raLength).type(RouteAttribute.RTA_DST).dstAddress(prefix.address()).build();
RouteAttributeGateway raGateway = RouteAttributeGateway.builder().length(raLength).type(RouteAttribute.RTA_GATEWAY).gateway(pdPushNextHop).build();
// Build RtNetlink.
RtNetlink rtNetlink = RtNetlink.builder().addressFamily(addrFamily).dstLength(prefix.prefixLength()).routeAttribute(raDst).routeAttribute(raGateway).build();
// Build Netlink.
int messageLength = raDst.length() + raGateway.length() + RtNetlink.RT_NETLINK_LENGTH + Netlink.NETLINK_HEADER_LENGTH;
Netlink netLink = Netlink.builder().length(messageLength).type(isAdd ? NetlinkMessageType.RTM_NEWROUTE : NetlinkMessageType.RTM_DELROUTE).flags(Netlink.NETLINK_REQUEST | Netlink.NETLINK_CREATE).rtNetlink(rtNetlink).build();
// Build FpmHeader.
messageLength += FpmHeader.FPM_HEADER_LENGTH;
FpmHeader fpmMessage = FpmHeader.builder().version(FpmHeader.FPM_VERSION_1).type(FpmHeader.FPM_TYPE_NETLINK).length(messageLength).netlink(netLink).build();
// Encode message in a channel buffer and transmit.
ch.write(fpmMessage.encode());
log.debug("Fpm Message for updated route {}", fpmMessage.toString());
} catch (RuntimeException e) {
log.info("Route not sent over fpm connection.");
}
}
use of org.onosproject.routing.fpm.protocol.FpmHeader in project onos by opennetworkinglab.
the class FpmSessionHandler method messageReceived.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
FpmHeader fpmMessage = (FpmHeader) e.getMessage();
initConnection(ctx, fpmMessage);
fpmListener.fpmMessage(us, fpmMessage);
}
Aggregations