Search in sources :

Example 1 with EAPOL

use of org.onlab.packet.EAPOL in project aaa by opencord.

the class AaaTestBase method constructSupplicantLogoffPacket.

/**
 * Constructs an Ethernet packet containing a EAPOL_LOGOFF Payload.
 *
 * @return Ethernet packet
 */
Ethernet constructSupplicantLogoffPacket() {
    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(clientMac.toBytes());
    eth.setSourceMACAddress(serverMac.toBytes());
    eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
    eth.setVlanID((short) 2);
    EAP eap = new EAP(EAPOL.EAPOL_LOGOFF, (byte) 2, EAPOL.EAPOL_LOGOFF, null);
    // eapol header
    EAPOL eapol = new EAPOL();
    eapol.setEapolType(EAPOL.EAPOL_LOGOFF);
    eapol.setPacketLength(eap.getLength());
    // eap part
    eapol.setPayload(eap);
    eth.setPayload(eapol);
    eth.setPad(true);
    return eth;
}
Also used : EAP(org.onlab.packet.EAP) Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL)

Example 2 with EAPOL

use of org.onlab.packet.EAPOL in project aaa by opencord.

the class AaaTestBase method constructSupplicantAsfPacket.

/**
 * Constructs an Ethernet packet containing a EAPOL_ASF Payload.
 *
 * @return Ethernet packet
 */
Ethernet constructSupplicantAsfPacket() {
    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(clientMac.toBytes());
    eth.setSourceMACAddress(serverMac.toBytes());
    eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
    eth.setVlanID((short) 2);
    EAP eap = new EAP(EAPOL.EAPOL_START, (byte) 3, EAPOL.EAPOL_START, null);
    // eapol header
    EAPOL eapol = new EAPOL();
    eapol.setEapolType(EAPOL.EAPOL_ASF);
    eapol.setPacketLength(eap.getLength());
    // eap part
    eapol.setPayload(eap);
    eth.setPayload(eapol);
    eth.setPad(true);
    return eth;
}
Also used : EAP(org.onlab.packet.EAP) Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL)

Example 3 with EAPOL

use of org.onlab.packet.EAPOL in project aaa by opencord.

the class AaaManager method sendPacketToSupplicant.

/**
 * Send the ethernet packet to the supplicant.
 *
 * @param ethernetPkt  the ethernet packet
 * @param connectPoint the connect point to send out
 */
private void sendPacketToSupplicant(Ethernet ethernetPkt, ConnectPoint connectPoint, boolean isChallengeResponse) {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();
    OutboundPacket packet = new DefaultOutboundPacket(connectPoint.deviceId(), treatment, ByteBuffer.wrap(ethernetPkt.serialize()));
    EAPOL eap = ((EAPOL) ethernetPkt.getPayload());
    if (log.isTraceEnabled()) {
        log.trace("Sending eapol payload {} to supplicant at {} with MacAddress {}", eap, connectPoint, ethernetPkt.getDestinationMAC());
    }
    packetService.emit(packet);
    if (isChallengeResponse) {
        aaaStatisticsManager.getAaaStats().incrementEapPktTxauthEap();
    }
    aaaStatisticsManager.getAaaStats().incrementEapolFramesTx();
    aaaStatisticsManager.getAaaStats().countReqEapFramesTx();
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) EAPOL(org.onlab.packet.EAPOL) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Example 4 with EAPOL

use of org.onlab.packet.EAPOL in project aaa by opencord.

the class AaaIntegrationTest method testAuthentication.

/**
 * Tests the authentication path through the AAA application by sending
 * packets to the RADIUS server and checking the state machine
 * transitions.
 *
 * @throws Exception when an unhandled error occurs
 */
@Test
public void testAuthentication() throws Exception {
    // (1) Supplicant start up
    Ethernet startPacket = constructSupplicantStartPacket();
    sendPacket(startPacket);
    Ethernet responsePacket = fetchPacket(0);
    assertThat(responsePacket, notNullValue());
    checkRadiusPacket(aaa, responsePacket, EAP.REQUEST);
    // (2) Supplicant identify
    Ethernet identifyPacket = constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null);
    sendPacket(identifyPacket);
    // State machine should have been created by now
    StateMachine stateMachine = aaa.getStateMachine(SESSION_ID);
    assertThat(stateMachine, notNullValue());
    assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING));
    // (3) RADIUS MD5 challenge
    Ethernet radiusChallengeMD5Packet = fetchPacket(1);
    assertThat(radiusChallengeMD5Packet, notNullValue());
    checkRadiusPacket(aaa, radiusChallengeMD5Packet, EAP.REQUEST);
    // (4) Supplicant MD5 response
    Ethernet md5RadiusPacket = constructSupplicantIdentifyPacket(stateMachine, EAP.ATTR_MD5, stateMachine.challengeIdentifier(), radiusChallengeMD5Packet);
    sendPacket(md5RadiusPacket);
    // (5) RADIUS Success
    Ethernet successRadiusPacket = fetchPacket(2);
    assertThat(successRadiusPacket, notNullValue());
    EAPOL successEapol = (EAPOL) successRadiusPacket.getPayload();
    EAP successEap = (EAP) successEapol.getPayload();
    assertThat(successEap.getCode(), is(EAP.SUCCESS));
    // State machine should be in authorized state
    assertThat(stateMachine, notNullValue());
    assertThat(stateMachine.state(), is(StateMachine.STATE_AUTHORIZED));
}
Also used : EAP(org.onlab.packet.EAP) Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL) Test(org.junit.Test)

Example 5 with EAPOL

use of org.onlab.packet.EAPOL in project aaa by opencord.

the class AaaManager method buildEapolResponse.

/**
 * Builds an EAPOL packet based on the given parameters.
 *
 * @param dstMac    destination MAC address
 * @param srcMac    source MAC address
 * @param vlan      vlan identifier
 * @param eapolType EAPOL type
 * @param eap       EAP payload
 * @return Ethernet frame
 */
private static Ethernet buildEapolResponse(MacAddress dstMac, MacAddress srcMac, short vlan, byte eapolType, EAP eap, byte priorityCode) {
    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(dstMac.toBytes());
    eth.setSourceMACAddress(srcMac.toBytes());
    eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
    if (vlan != Ethernet.VLAN_UNTAGGED) {
        eth.setVlanID(vlan);
        eth.setPriorityCode(priorityCode);
    }
    // eapol header
    EAPOL eapol = new EAPOL();
    eapol.setEapolType(eapolType);
    eapol.setPacketLength(eap.getLength());
    // eap part
    eapol.setPayload(eap);
    eth.setPayload(eapol);
    eth.setPad(true);
    return eth;
}
Also used : Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL)

Aggregations

EAPOL (org.onlab.packet.EAPOL)8 EAP (org.onlab.packet.EAP)6 Ethernet (org.onlab.packet.Ethernet)6 MessageDigest (java.security.MessageDigest)1 Test (org.junit.Test)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)1 OutboundPacket (org.onosproject.net.packet.OutboundPacket)1