src/MsChapV2Packet.php
public static function fromString($packet)
    {
        if (strlen($packet) < 5) {
            return false;
        }

        $p = new self();
        $p->opcode    = ord($packet[0]);
        $p->msChapId  = ord($packet[1]);
        $temp         = unpack('n', substr($packet, 2, 2));
        $p->msLength  = array_shift($temp);
        $p->valueSize = ord($packet[4]);

        switch($p->opcode) {
            case 1: // challenge
                $p->challenge = substr($packet, 5, 16);
                $p->name      = substr($packet, -($p->msLength + 5 - $p->valueSize - 10));
                break;

            case 2: // response
                break;

            case 3: // success
                break;

            case 4: // failure
                $p->response = substr($packet, 4);
                break;
        }

        return $p;
    }
public static function fromString($packet)
    {
        if (strlen($packet) < 5) {
            return false;
        }

        $p = new self();
        $p->opcode    = ord($packet[0]);
        $p->msChapId  = ord($packet[1]);
        $temp         = unpack('n', substr($packet, 2, 2));
        $p->msLength  = array_shift($temp);
        $p->valueSize = ord($packet[4]);

        switch($p->opcode) {
            case 1: // challenge
                $p->challenge = substr($packet, 5, 16);
                $p->name      = substr($packet, -($p->msLength + 5 - $p->valueSize - 10));
                break;

            case 2: // response
                break;

            case 3: // success
                break;

            case 4: // failure
                $p->response = substr($packet, 4);
                break;
        }

        return $p;
    }
public static function fromString ( $ packet ) { if ( strlen ( $ packet ) < 5 ) { return false ; } $ p = new self ( ) ; $ p -> opcode = ord ( $ packet [ 0 ] ) ; $ p -> msChapId = ord ( $ packet [ 1 ] ) ; $ temp = unpack ( 'n' , substr ( $ packet , 2 , 2 ) ) ; $ p -> msLength = array_shift ( $ temp ) ; $ p -> valueSize = ord ( $ packet [ 4 ] ) ; switch ( $ p -> opcode ) { case 1 : // challenge $ p -> challenge = substr ( $ packet , 5 , 16 ) ; $ p -> name = substr ( $ packet , - ( $ p -> msLength + 5 - $ p -> valueSize - 10 ) ) ; break ; case 2 : // response break ; case 3 : // success break ; case 4 : // failure $ p -> response = substr ( $ packet , 4 ) ; break ; } return $ p ; }
Parse an MSCHAP v2 packet into a structure

@param string $packet Raw MSCHAP v2 packet string
@return \Dapphp\Radius\MsChapV2Packet The parsed packet structure
Parse an MSCHAP v2 packet into a structure