hi everybody

"Marcos Garcia Marti" <[email protected]> Fri, 14 May 2004 10:08:22 +0100
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
Hi list, my name is Marcos Garcia
I'm working with IPv6 at univerity and I'm trying libnet-1.1.2.1 because I need an easy
way of sending customized IPv6 packets with extension headers included.
I have made an easy code to test it in my two machines. I missed a pair of functions: one
for creating an [struct libnet_in6_addr]. I had to make this hack:

u_int8_t aux [16] =3D { 0xFE, 0xC0, 0x00,0x06, 0x00,0x00, 0x00,0x00, \
0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00, 0xA1 };
memcpy(src_ip.__u6_addr.__u6_addr16,aux, sizeof (aux));

The other thing I miss is an utility to resolve MAC address of a IPv6 direction, so i
won't need to do this:

u_char dst[6]=3D{0x0,0xa0,0x24,0xac,0x8c,0xf0};
ethhdr =3D libnet_autobuild_ethernet(dst,IPV6_ETH_TYPE,l);


So I'll thank you a lot if you know an easy-and-automatic way to do this.
Anyway, the code goes fine ;) ethereal proves it!

See you :)

PD:The code:

#include
#include
#define IPV6_ETH_TYPE 0x86dd
#define IPV6_NO_NEXT_HEADER 59

int main()
{
libnet_t *l=3DNULL;
char errbuf[LIBNET_ERRBUF_SIZE];
char device[10];
char direccion[100];
struct libnet_in6_addr src_ip, dst_ip;
int i=3D0;
printf("Hello world\n");

strcpy(device,"eth1");
l=3Dlibnet_init (LIBNET_LINK, device,errbuf);
if (l=3D=3DNULL)
{
printf("\nlibnet_init breaks, %s", errbuf); exit (EXIT_FAILURE);
}

u_int8_t aux [16] =3D { 0xFE, 0xC0, 0x00,0x06, 0x00,0x00, 0x00,0x00, \
0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00, 0xA1 };
memcpy(src_ip.__u6_addr.__u6_addr16,aux, sizeof (aux));

u_int8_t aux2 [16] =3D { 0xFE, 0xC0, 0x00,0x06, 0x00,0x00, 0x00,0x00, \
0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00, 0xB0 };
memcpy(dst_ip.__u6_addr.__u6_addr16,aux2, sizeof (aux2));

/*libnet_ptag_t
libnet_build_ipv6(u_int8_t tc, u_int32_t fl, u_int16_t len, u_int8_t nh,
u_int8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
*/
libnet_ptag_t ip6hdr,ethhdr;
ip6hdr =3D libnet_build_ipv6(1,3,LIBNET_IPV6_H+strlen(device),IPV6_NO_NEXT_HEADER,\
64,src_ip,dst_ip,device,strlen(device),l,0);
u_char dst[6]=3D{0x0,0xa0,0x24,0xac,0x8c,0xf0};
u_char src[6]=3D{0x0,0x04,0x75,0xc9,0xd4,0xdd};

//ethhdr =3D libnet_build_ethernet(dst,src,IPV6_ETH_TYPE,NULL,0,l,0);
//resolve MAC via ioctl: http://linux.about.com/library/cmd/blcmdl7_netdevice.htm
ethhdr =3D libnet_autobuild_ethernet(dst,IPV6_ETH_TYPE,l);

i=3Dlibnet_write(l);
printf("write da %d\n",i);
if (i<0) printf("%s",libnet_geterror(l));
libnet_destroy(l);

return (0);
}

---------------------------------------------------------
Crea tus álbumes de fotos ¡ahora también puedes revelarlos! http://fotos.ya.com
Ya.com ADSL Router Wi-Fi: Sólo 29,90 €/mes + IVA*. Router + Antivirus y firewall ¡Gratis!
http://ir.ya.com/app/redir?o=is2&prefix=isp_ya_com_&tgt810&afiliado=fofooter