Search in sources :

Example 1 with FpmHeader

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.");
    }
}
Also used : Netlink(org.onosproject.routing.fpm.protocol.Netlink) RtNetlink(org.onosproject.routing.fpm.protocol.RtNetlink) RouteAttributeDst(org.onosproject.routing.fpm.protocol.RouteAttributeDst) RouteAttributeGateway(org.onosproject.routing.fpm.protocol.RouteAttributeGateway) FpmHeader(org.onosproject.routing.fpm.protocol.FpmHeader) RtNetlink(org.onosproject.routing.fpm.protocol.RtNetlink)

Example 2 with FpmHeader

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);
}
Also used : FpmHeader(org.onosproject.routing.fpm.protocol.FpmHeader)

Aggregations

FpmHeader (org.onosproject.routing.fpm.protocol.FpmHeader)2 Netlink (org.onosproject.routing.fpm.protocol.Netlink)1 RouteAttributeDst (org.onosproject.routing.fpm.protocol.RouteAttributeDst)1 RouteAttributeGateway (org.onosproject.routing.fpm.protocol.RouteAttributeGateway)1 RtNetlink (org.onosproject.routing.fpm.protocol.RtNetlink)1