Yeah, that's it! Now for the relavent bits:

XS(XS_Net__LibnetRaw_libnet_do_checksum) [...] u_char buf = (u_char)SvUV(ST(0)); [...] RETVAL = libnet_do_checksum(&buf, protocol, len); sv_setuv(ST(0), (UV)buf); SvSETMAGIC(ST(0));
The above is exactly what you want. You need to make the other functions handle buf the same way this one does. You also got it correct for Net__LibnetRaw_libnet_build_ip and Net__LibnetRaw_libnet_build_tcp.
XS(XS_Net__LibnetRaw_libnet_destroy_packet) [...] u_char * buf = (u_char *)SvPV(ST(0),PL_na); RETVAL = libnet_destroy_packet(&buf);
You want to add some code here that destroys the buf object. Probably just:
OUTPUT: buf sv_setsv(ST(0),&PL_sv_undef);
Now for the source of your problem (I think):
XS(XS_Net__LibnetRaw_libnet_init_packet) [...] u_char * buf = (u_char *)SvPV(ST(1),PL_na); [...] RETVAL = libnet_init_packet(p_size, &buf); sv_setpv((SV*)ST(1), buf);
This function seems to have used a different typemap for buf which is trying to extract the '\0'-terminated string that it is supposed to point to. I think all you need to do is fix this typemap to be like the other functions.

I'm going to check some other things I noticed and I'll reply separately if I detect any problems.

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

In reply to (tye)Re3: XS question: typemap for a pointer to a pointer? by tye
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.