src/EAPPacket.php
public static function fromString($packet)
    {
        // TODO: validate incoming packet better

        $p = new self();
        $p->code = ord($packet[0]);
        $p->id   = ord($packet[1]);
        $temp    = unpack('n', substr($packet, 2, 2));
        $length  = array_shift($temp);

        if (strlen($packet) != $length) {
            return false;
        }

        $p->type = ord(substr($packet, 4, 1));
        $p->data = substr($packet, 5);

        return $p;
    }
public static function fromString($packet)
    {
        // TODO: validate incoming packet better

        $p = new self();
        $p->code = ord($packet[0]);
        $p->id   = ord($packet[1]);
        $temp    = unpack('n', substr($packet, 2, 2));
        $length  = array_shift($temp);

        if (strlen($packet) != $length) {
            return false;
        }

        $p->type = ord(substr($packet, 4, 1));
        $p->data = substr($packet, 5);

        return $p;
    }
public static function fromString ( $ packet ) { // TODO: validate incoming packet better $ p = new self ( ) ; $ p -> code = ord ( $ packet [ 0 ] ) ; $ p -> id = ord ( $ packet [ 1 ] ) ; $ temp = unpack ( 'n' , substr ( $ packet , 2 , 2 ) ) ; $ length = array_shift ( $ temp ) ; if ( strlen ( $ packet ) != $ length ) { return false ; } $ p -> type = ord ( substr ( $ packet , 4 , 1 ) ) ; $ p -> data = substr ( $ packet , 5 ) ; return $ p ; }
Convert a raw EAP packet into a structure

@param string $packet The EAP packet
@return \Dapphp\Radius\EAPPacket  The parsed packet structure
Convert a raw EAP packet into a structure