Ok. Here's what I tried, but libnet_build_ip() is still crapping. I understand what you said about making all the functions accept the same type at the end of your Re4. Some where accepting the buf itself and others a pointer to it even when my calls were using passing simply $buf each time. This is how I changed the XS file to fix this (I think) for the two functions in question:

int libnet_init_packet(p_size, buf) size_t p_size u_char & buf CODE: u_char * buf_temp; buf_temp = &buf; RETVAL = libnet_init_packet(p_size, &buf_temp); OUTPUT: RETVAL buf int libnet_destroy_packet(buf) u_char & buf CODE: u_char * buf_temp; buf_temp = &buf; RETVAL = libnet_destroy_packet(&buf_temp); OUTPUT: RETVAL buf sv_setsv(ST(0),&PL_sv_undef);
The resultant C code appears to hold the proper type for the passed in $buf now...
XS(XS_Net__LibnetRaw_libnet_init_packet) { dXSARGS; if (items != 2) Perl_croak(aTHX_ "Usage: Net::LibnetRaw::libnet_init_packet(p_ +size, buf)"); { size_t p_size = (size_t)SvIV(ST(0)); u_char buf = (u_char)SvUV(ST(1)); int RETVAL; dXSTARG; #line 39 "LibnetRaw.xs" u_char * buf_temp; buf_temp = &buf; RETVAL = libnet_init_packet(p_size, &buf_temp); #line 106 "LibnetRaw.c" sv_setuv(ST(1), (UV)buf); SvSETMAGIC(ST(1)); XSprePUSH; PUSHi((IV)RETVAL); } XSRETURN(1); } XS(XS_Net__LibnetRaw_libnet_destroy_packet) { dXSARGS; if (items != 1) Perl_croak(aTHX_ "Usage: Net::LibnetRaw::libnet_destroy_packet +(buf)"); { u_char buf = (u_char)SvUV(ST(0)); int RETVAL; dXSTARG; #line 50 "LibnetRaw.xs" u_char * buf_temp; buf_temp = &buf; RETVAL = libnet_destroy_packet(&buf_temp); #line 127 "LibnetRaw.c" sv_setsv(ST(0),&PL_sv_undef); SvSETMAGIC(ST(0)); XSprePUSH; PUSHi((IV)RETVAL); } XSRETURN(1); }
So now, the type for buf passed in is u_char just like the other calls. I just noticed some other value vs. pointer to value mistakes I've made (It seems * and & are not quite as similar as I thought). That aside, I still think the error I am getting does not make sense.

In reply to Re: (tye)Re4: XS question: typemap for a pointer to a pointer? by Big Willy
in thread XS question: typemap for a pointer to a pointer? by Big Willy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.