Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* How to send an ARP packet using the Netrain interface ?
@ 2002-02-11 14:09 adsl1 devil
  0 siblings, 0 replies; only message in thread
From: adsl1 devil @ 2002-02-11 14:09 UTC (permalink / raw)


Hi,

I'm trying to send an ARP packet to a specific target. But, my program
(which includes the piece of the following code) gives a "Bind error :
permission denied" message. This program is executed with the root account.

So, my question is :

Is it possible to use DLI with a netrain interface in order to program arp
packet ? And if the answer is yes, how do I use this API for netrain ?

Thanks,

Stephane.



/*

* Build an Ethernet frame

*/

int

open_ethernet(char *device, struct sockaddr_dl *sdl,

u_char *src, u_char *target, u_short dli_proto)

{

int fd;

int ch;

bzero(sdl, sizeof(*sdl));

if (sscanf(device, "%[a-z]%hd%c", sdl->dli_device.dli_devname,

&(sdl->dli_device.dli_devnumber), &ch) != 2) {

fprintf(stderr, "%s : invalid device name\n", device);

exit(EXIT_FAILURE);

}

sdl->dli_family = AF_DLI;

sdl->dli_substructype = DLI_ETHERNET;

sdl->choose_addr.dli_eaddr.dli_ioctlflg = DLI_NORMAL;

sdl->choose_addr.dli_eaddr.dli_protype = dli_proto;

if (sdl->choose_addr.dli_eaddr.dli_target)

bcopy(target, sdl->choose_addr.dli_eaddr.dli_target, DLI_EADDRSIZE);

/* if (sdl.choose_addr.dli_eaddr.dli_dest)

bcopy(src, sdl->choose_addr.dli_eaddr.dli_dest, DLI_EADDRSIZE); */

if ((fd = socket(AF_DLI, SOCK_DGRAM, DLPROTO_DLI)) < 0) {

fprintf(stderr, "DLI open failed: %s\n", strerror(errno));

exit(EXIT_FAILURE);

}

if (bind(fd, (struct sockaddr*) sdl, sizeof(*sdl)) < 0) {

fprintf(stderr, "DLI bind failed : %s\n", strerror(errno));

exit(EXIT_FAILURE);

}

return fd;

}





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-02-11 14:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-11 14:09 How to send an ARP packet using the Netrain interface ? adsl1 devil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox