Re: char * to struct ether_addr *

Christian Ehlen <[email protected]>
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
> is there any function in libnet to pass from a char * in format
> xx:xx:xx:xx:xx:xx to a struct ether_addr* ?

yes - there is. check libnet-functions.h.

libnet 1.1.0

u_char * libnet_hex_aton(char *s, int *len);

libnet 1.1.1

u_int8_t * libnet_hex_aton(int8_t *s, int *len);

if you use a GNU/Linux system and you want to do it libnet 
independent - look in '/usr/include/netinet/ether.h' for a
function called ether_aton.

example (not plattform independent...)

#include <netinet/ether.h>
 
struct ether_addr *ea;

if ((ea = ether_aton(spoofed_mac)) == NULL){
	printf("ether_aton error: invalid mac addr\n");
}

now you've got a valid network byte order mac.

hope this helps ...

> I want to take an argument from command line (ff:ff:ff:ff:ff:ff  in for
> example) and use it for ARP packet creation.
> is there any function to make that? 
> 
> Thank you very much.
> Sergio.
-- 
GnuPG signed + encrypted messages welcome
Key fingerprint = BFBE 3FD4 0C8B AA45 F6B6  6962 2FE7 A299 4675 1715
Public key can be found on keyservers (e.g. wwwkeys.de.pgp.net - 
keyID = 46751715)
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBAHnFxL+eimUZ1FxURAkCrAKCdnR1nNiJieO0P5XEdQ3+tVdaTvgCeKknI
7LgqawSzcJpdGWgUQJu1G1E=
=ItG/
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.