in reply to How do I *add* a socket option ?

Fastolfe is right. But I can be more specific. The error "Your vendor has not defined..." means that the module knows about this option but that it wasn't defined when the module was compiled.

The IO::Socket and Socket modules are included in the standard distribution but you are probably using dynamic loading so that all you need to do is recompile and install the Socket module (which IO::Socket uses to get its constants from).

If you aren't using dynamic loading, then you'll need to recompile Perl. If you do that, you probably want to enable dynamic loading in the process.

If you have the source code for Perl lying about, just go to that directory and do:

% cd ext/Socket % perl Makefile.PL % make test % make install

If you don't, then go fetch it from CPAN. It looks like the separate Socket module on CPAN is 1.5 while Perl comes with 1.72 so I wouldn't just fetch the Socket module.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
RE: (tye)Re: How do I *add* a socket option ?
by Q-Bert (Novice) on Oct 12, 2000 at 18:47 UTC
    Yep, I did exactly that, I got the 1.5 Socket version from CPAN, and installed *that*.

    Yes, I know that I downgraded Socket because of that, but I was ready to take that chance.

    I added

    if (strEQ(name, "SO_ORIGINAL_DST")) #ifdef SO_ORIGINAL_DST return SO_ORIGINAL_DST; #else goto not_there; #endif
    in Socket.xs ,and also put the SO_ORIGINAL_DST tag in Socket.pm

    I compiled it and installed it. It installed it in /usr/lib/perl5/site_perl/5.005/i386-linux/auto/Socket/Socket.so

    Now, when I run:

    my $destination_address = $server_socket->sockopt(SO_ORIGINAL_DST); print STDERR "Error: $!\n"; print STDERR "Requested destination address: $destination_address\n";
    I get "Your vendor has not defined Socket macro SO_ORIGINAL_DST, used at ./proxy.pl line 14".

    So the error appears as soon as $server_socket->sockopt() gets called, because it doesn't even reach the "Error: " output.

      Then SO_ORIGINAL_DST must not be defined when you compile that code. Check which include file that is defined in and what files you are including in Socket.xs. There could be #ifdef's that prevent it from being defined.

      FYI, you should get that error when your use imports that symbol, not when you try to use the symbol. And you must be importing that symbol since you don't have () on the end of it.

              - tye (but my friends call me "Tye")
        OK, cool, that sorta works.

        I added

        #include <linux/netfilter_ipv4.h>
        in Socket.xs and re-installed it. Now, I get my original error, the same that I got if I did
        getsockopt($server_socket, SOL_SOCKET, 80); # 80 = SO_ORIGINAL_DST
        That error is "Protocol not available".

        I am back to square one. :-(