Re: libnet_write

"Mustafa Abu Sedera" <[email protected]> Sun, 20 Jun 2004 13:35:48 +0000
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
libnet_adv_write_raw() should work for IP6 and IP4.
Check the code...

int
libnet_adv_write_raw(libnet_t *l, u_int8_t *packet, u_int32_t len)
{
    u_int c;

    if (l == NULL)
    {
        return (-1);
    }

    /* assume error */
    c = -1;

    switch (l->injection_type)
    {
        case LIBNET_RAW4_ADV:
            if (len > LIBNET_MAX_PACKET)
            {
                snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                        "%s(): packet is too large %d\n", __func__, len);
                return (c);
            }
            c = libnet_write_raw_ipv4(l, packet, len);   
/*************--IPv4--****************/
            break;

        case LIBNET_RAW6_ADV:
            c = libnet_write_raw_ipv6(l, packet, len);  
/**************--IPv6--***************/
            break;

        default:
            snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): advanced raw mode not enabled\n", __func__);
            return (-1);
    }

    /* do statistics */
    if (c == len)
    {
        l->stats.packets_sent++;
        l->stats.bytes_written += c;
    }
    else
    {
        l->stats.packet_errors++;
        /*
         *  XXX - we probably should have a way to retrieve the number of
         *  bytes actually written (since we might have written something).
         */
        if (c > 0)
        {
            l->stats.bytes_written += c;
        }
    }

    return (c);
}

>From: [email protected]
>To: [email protected]
>Subject: Re: libnet_write
>Date: Tue, 8 Jun 2004 21:53:06 +0530
>
>
>
>
>
>Hi Mike,
>
>  Your talking about libnet_adv_write_raw() or libnet_write_raw_ipv4() ?
>
>thanks
>Amit
>

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail