Search in sources :

Example 1 with OFExpExtAdId

use of org.projectfloodlight.openflow.protocol.OFExpExtAdId in project onos by opennetworkinglab.

the class OplinkHandshakerUtil method getNeighbor.

private OplinkPortAdjacency getNeighbor(OFExpPortAdjacency ad) {
    // Check input parameter
    if (ad == null) {
        return null;
    }
    // Get adjacency properties
    for (OFExpPortAdjacencyId adid : ad.getProperties()) {
        List<OFExpExtAdId> otns = adid.getAdId();
        if (otns != null && otns.size() > 0) {
            OFExpPortAdidOtn otn = (OFExpPortAdidOtn) otns.get(0);
            // ITU-T G.7714 ETH MAC Format (in second 16 bytes of the following)
            // |---------------------------------------------------------------------------|
            // | Other format (16 bytes)                                                   |
            // |---------------------------------------------------------------------------|
            // | Header (2 bytes) | ID (4 BITS) | MAC (6 bytes) | Port (4 bytes) | Unused  |
            // |---------------------------------------------------------------------------|
            ByteBuf buffer = Unpooled.buffer(OPSPEC_BYTES);
            otn.getOpspec().write32Bytes(buffer);
            long mac = buffer.getLong(OPSPEC_MAC_POS) << OPSPEC_ID_BITS >>> OPSPEC_MAC_BIT_OFF;
            int port = (int) (buffer.getLong(OPSPEC_PORT_POS) << OPSPEC_ID_BITS >>> OPSPEC_PORT_BIT_OFF);
            // constructed from MAC address
            return new OplinkPortAdjacency(DeviceId.deviceId(Dpid.uri(new Dpid(mac))), PortNumber.portNumber(port));
        }
    }
    // Returns null if no properties found
    return null;
}
Also used : Dpid(org.onosproject.openflow.controller.Dpid) OFExpExtAdId(org.projectfloodlight.openflow.protocol.OFExpExtAdId) OFExpPortAdidOtn(org.projectfloodlight.openflow.protocol.OFExpPortAdidOtn) OFExpPortAdjacencyId(org.projectfloodlight.openflow.protocol.OFExpPortAdjacencyId) ByteBuf(io.netty.buffer.ByteBuf) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 Dpid (org.onosproject.openflow.controller.Dpid)1 OFExpExtAdId (org.projectfloodlight.openflow.protocol.OFExpExtAdId)1 OFExpPortAdidOtn (org.projectfloodlight.openflow.protocol.OFExpPortAdidOtn)1 OFExpPortAdjacencyId (org.projectfloodlight.openflow.protocol.OFExpPortAdjacencyId)1