in reply to Re^6: Help with Lorcon XS library
in thread Help with Lorcon XS library

print Net::Lorcon2::lorcon_create("wlo1", $driver); #where $driver c +an be madwifing or other it says: Net::Lorcon2::lorcon_create: driver is not a reference at -e line 3.


Yes - you should not do that.
As the error message says $driver is not a reference.

print Net::Lorcon2::lorcon_create("wlo1", \$driver); #where $driver + can be madwifing or other it says segmentation error (core dump created)


Yes - you should not do that either. At least, this time you have passed something that is a reference.
But it's not a reference to the right thing, and therefore causes a segfault.

As I said in my first post, the correct thing to do would be:
my $driver = "madwifing"; my $if = "wlo1"; my $drv = lorcon_find_driver($driver); if (! $drv) { print STDERR "[-] Unable to find DRV for [$driver]\n"; exit 1; } my $lorcon = lorcon_create($if, $drv); if (! $lorcon) { print STDERR "[-] lorcon_create failed\n"; exit 1; }
What happens if you do that ?
In view of what marto dug up, it may not work either - but it's at least worth a try.

Cheers,
Rob

Replies are listed 'Best First'.
Re^8: Help with Lorcon XS library
by Bpl (Scribe) on Jul 21, 2020 at 12:47 UTC
    Hi! Many thanks, now it works, It is pretty strange but I think that the problem was related to the string passed as $driver and not to the XS code, WOW i am so happy, would you like to be thanked in the page of metacpan? under the voice HERO of the module. still many thanks, Regards Edoardo M

      If PerlMonks helped you by bringing you into contact with knowledgeable people, please consider showing your gratitude by stopping by the Offering Plate on your way out. :)


      Give a man a fish:  <%-{-{-{-<

        Hi again, yes, I am considering the idea of donating something,I have good memories linked to Perl, since the start of this summer I started writing some articles for the perl.com, I am still waiting the publication, hope soon. I am writing again because the "enemy" strickes back, while I was testing the lorcon_create I tried to put everything into the "new" subroutine for the function initialization, the code is as follows:
        sub new { my (undef, undef, $interface, undef, $driver) = @_; my $self = shift->SUPER::new( driver => $driver, interface => $interface, @_, ); my $drv = lorcon_find_driver($self->driver); if (! $drv) { die "[*] new: lorcon_find_driver: failed\n"; return; } $self->driver( $drv ); my $context = lorcon_create($self->interface, $drv); #_drv if (! $context) { die "[*] new: lorcon_create: failed\n"; return; } $self->_context($context) or die $!; return $self; }
        the only big problem stands when I tried to call the setInjectMode it produces a core dump (again). the code is:
        sub setInjectMode { my $self = shift; my $r = lorcon_open_inject($self->_context);#->_context); if ($r == -1) { die "[*] setInjectMode: lorcon_open_inject: " . lorcon_get_error +( $self->_context ) . "\n"; return; } return 1; }
        I think that there is something wrong in the $self->_context variable, perhaps I haven't understood the use of "_context" **update** dumping the Lorcon initialization variable the result was:
        $VAR1 = bless( [ \152150320, 'wlo1', undef, \152168944 ], 'Net::Lorcon2' );
        I think that the "undef" is referred to the _drv, the \152150320 is the $driver. the \152150320 changes to 'madwifing' modifyng those 2 lines
        # $self->driver( $drv ) ; my $context = lorcon_create($self->interface, $drv); #_drv
        regards Edoardo M.