Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: "adsl1 devil" <adsl1.devil@wanadoo.fr>
Subject: How to send an ARP packet using the Netrain interface ?
Date: Mon, 11 Feb 2002 15:09:49 +0100	[thread overview]
Message-ID: <a48j85$dll$1@wanadoo.fr> (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;

}





                 reply	other threads:[~2002-02-11 14:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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